Index: webserver/example/freeRTOSexample/Source/EnergyMeters/Meters_ISRs.c =================================================================== --- webserver/example/freeRTOSexample/Source/EnergyMeters/Meters_ISRs.c (revision 19) +++ webserver/example/freeRTOSexample/Source/EnergyMeters/Meters_ISRs.c (revision 22) @@ -2,7 +2,10 @@ #include "semphr.h" #include "task.h" +#include "MetersIncludes.h" -extern basementGasReading; extern xMetersSemaphore; +extern xTickCount; /* millisecond tick counter */ + +void handleGasMeterTick(void); /* The interrupt entry point. */ @@ -19,5 +22,5 @@ if ((IO2_INT_STAT_R & (1 << 10)) != 0) /* P2.10 interrupt triggered */ { - basementGasReading++; + handleGasMeterTick(); } // else if ((IO2_INT_STAT_R & (1 << n)) != 0) /* some other interrupt triggered */ @@ -56,5 +59,10 @@ } +void handleGasMeterTick(void) +{ + meterItems[METER_INDEX_GAS].timeBeforeLastTick = meterItems[METER_INDEX_GAS].timeLastTick; /* when did the tick before the last tick occur? */ + meterItems[METER_INDEX_GAS].timeLastTick = getEpochTimeWithMs(); /* when did the last tick occur? epoch (seconds) */ + meterItems[METER_INDEX_GAS].valueLastTick = 0; /* what value did we have at the last tick? */ + meterItems[METER_INDEX_GAS].valueBeforeLastTick = 1; /* what value did we have at the tick before the last tick? */ +} - -