Skip to content

Commit

Permalink
Merge pull request #214 from marcv81/comfort-fix
Browse files Browse the repository at this point in the history
Fixed is_comfort function
  • Loading branch information
atc1441 authored Sep 7, 2021
2 parents 0f83187 + 3fd875e commit c61e70e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ATC_Thermometer/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ RAM uint16_t comfort_y[] = {2000, 1980, 3200, 6000, 8200, 8600, 7700, 3800};

_attribute_ram_code_ bool is_comfort(int16_t t, uint16_t h) {
bool c = 0;
uint8_t npol = sizeof(comfort_x);
for (uint8_t i = 0, j = npol - 1; i < npol; j = i++)
uint8_t npol = sizeof(comfort_x) / sizeof(comfort_x[0]);
for (uint8_t i = 0, j = npol - 1; i < npol; j = i++)
{
if ((
(comfort_y[i] < comfort_y[j]) && (comfort_y[i] <= h) && (h <= comfort_y[j]) &&
(comfort_y[i] < comfort_y[j]) && (comfort_y[i] < h) && (h <= comfort_y[j]) &&
((comfort_y[j] - comfort_y[i]) * (t - comfort_x[i]) > (comfort_x[j] - comfort_x[i]) * (h - comfort_y[i]))
) || (
(comfort_y[i] > comfort_y[j]) && (comfort_y[j] <= h) && (h <= comfort_y[i]) &&
(comfort_y[i] > comfort_y[j]) && (comfort_y[j] < h) && (h <= comfort_y[i]) &&
((comfort_y[j] - comfort_y[i]) * (t - comfort_x[i]) < (comfort_x[j] - comfort_x[i]) * (h - comfort_y[i]))
))
c = !c;
Expand Down

0 comments on commit c61e70e

Please sign in to comment.