Skip to content

Commit

Permalink
Fix pressure trend
Browse files Browse the repository at this point in the history
  • Loading branch information
hexaedron committed Oct 9, 2024
1 parent 35488d8 commit a400816
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Binary file modified Firmware/firmware.bin
Binary file not shown.
9 changes: 8 additions & 1 deletion src/getPressureTrend.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <ch32v003fun.h>

#define PRESSURE_DELTA 128UL // ~0.5 mmHg
#define PRESSURE_DELTA 64UL // ~0.25 mmHg
#define PRESSURE_FULL_DELTA 256UL // 1 mmHg

int8_t getPressureTrend(uint32_t* pressureHistory, uint8_t pressureHistoryHours, uint32_t currentPressure)
{
Expand All @@ -19,8 +20,14 @@ int8_t getPressureTrend(uint32_t* pressureHistory, uint8_t pressureHistoryHours,
if(currentPressure > (max + PRESSURE_DELTA))
return 1;

if( (currentPressure > min) && ((currentPressure - min) > PRESSURE_FULL_DELTA) )
return 1;

if(currentPressure < (min - PRESSURE_DELTA))
return -1;

if( (currentPressure < max) && ((max - currentPressure) > PRESSURE_FULL_DELTA) )
return -1;

return 0;
}

0 comments on commit a400816

Please sign in to comment.