Index: webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c =================================================================== --- webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c (revision 46) +++ webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c (revision 47) @@ -139,10 +139,10 @@ // Init Example Button meter - meterItems[METER_INDEX_BUTTON].meterEnabled = 1; /* 0: item not used, 1: meter enabled */ - meterItems[METER_INDEX_BUTTON].timeLastTick = getEpochTimeWithMs(); /* when did the last tick occur? epoch (seconds) */ - meterItems[METER_INDEX_BUTTON].timeBeforeLastTick = getEpochTimeWithMs(); /* when did the tick before last tick occur? epoch (seconds) */ - meterItems[METER_INDEX_BUTTON].valueLastTick = 1; /* what value did we have at the last tick? */ - meterItems[METER_INDEX_BUTTON].currentValue = 1; /* same: start value of the meter */ - meterItems[METER_INDEX_BUTTON].valueBeforeLastTick = 0; /* what value did we have at the tick before the last tick? */ + meterItems[METER_INDEX_TST].meterEnabled = 1; /* 0: item not used, 1: meter enabled */ + meterItems[METER_INDEX_TST].timeLastTick = getEpochTimeWithMs(); /* when did the last tick occur? epoch (seconds) */ + meterItems[METER_INDEX_TST].timeBeforeLastTick = getEpochTimeWithMs(); /* when did the tick before last tick occur? epoch (seconds) */ + meterItems[METER_INDEX_TST].valueLastTick = 1; /* what value did we have at the last tick? */ + meterItems[METER_INDEX_TST].currentValue = 1; /* same: start value of the meter */ + meterItems[METER_INDEX_TST].valueBeforeLastTick = 0; /* what value did we have at the tick before the last tick? */ // Init Gas meter @@ -154,3 +154,21 @@ meterItems[METER_INDEX_GAS].valueBeforeLastTick = 0; /* what value did we have at the tick before the last tick? */ + // Init Electricity meter 1 + meterItems[METER_INDEX_EL1].meterEnabled = 1; /* 0: item not used, 1: meter enabled */ + meterItems[METER_INDEX_EL1].timeLastTick = getEpochTimeWithMs(); /* when did the last tick occur? epoch (seconds) */ + meterItems[METER_INDEX_EL1].timeBeforeLastTick = getEpochTimeWithMs(); /* when did the tick before last tick occur? epoch (seconds) */ + meterItems[METER_INDEX_EL1].valueLastTick = 1; /* what value did we have at the last tick? */ + meterItems[METER_INDEX_EL1].currentValue = 1; /* same: start value of the meter */ + meterItems[METER_INDEX_EL1].valueBeforeLastTick = 0; /* what value did we have at the tick before the last tick? */ + + // Init Electricity meter 2 + meterItems[METER_INDEX_EL2].meterEnabled = 1; /* 0: item not used, 1: meter enabled */ + meterItems[METER_INDEX_EL2].timeLastTick = getEpochTimeWithMs(); /* when did the last tick occur? epoch (seconds) */ + meterItems[METER_INDEX_EL2].timeBeforeLastTick = getEpochTimeWithMs(); /* when did the tick before last tick occur? epoch (seconds) */ + meterItems[METER_INDEX_EL2].valueLastTick = 1; /* what value did we have at the last tick? */ + meterItems[METER_INDEX_EL2].currentValue = 1; /* same: start value of the meter */ + meterItems[METER_INDEX_EL2].valueBeforeLastTick = 0; /* what value did we have at the tick before the last tick? */ + + + } Index: webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c =================================================================== --- webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c (revision 46) +++ webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c (revision 47) @@ -33,5 +33,5 @@ if ((IO2_INT_STAT_R & (1 << 10)) != 0) /* P2.10 interrupt triggered - SPI Load Switch */ { - handleMeterTick(METER_INDEX_BUTTON); + handleMeterTick(METER_INDEX_TST); IO2_INT_CLR |= (1<<10); } @@ -43,10 +43,10 @@ else if ((IO2_INT_STAT_R & (1 << 1)) != 0) /* P0.1 interrupt triggered - connector J4, Pin 1*/ { - handleMeterTick(1); + handleMeterTick(METER_INDEX_EL1); IO2_INT_CLR |= (1<<1); } else if ((IO2_INT_STAT_R & (1 << 2)) != 0) /* P0.2 interrupt triggered - connector J4, Pin 2*/ { - handleMeterTick(2); + handleMeterTick(METER_INDEX_EL2); IO2_INT_CLR |= (1<<2); } Index: webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h =================================================================== --- webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h (revision 46) +++ webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h (revision 47) @@ -5,7 +5,11 @@ #define NUMBER_OF_METERS 5 /* the number of meters we use */ -#define METER_INDEX_BUTTON 0 /* index of the button example meter data */ +#define METER_INDEX_TST 0 /* index of the button example meter data */ +#define METER_INDEX_GAS 1 /* index of the gas meter data */ +#define METER_INDEX_EL1 2 /* index of the Electricity 1 meter data */ +#define METER_INDEX_EL2 3 /* index of the Electricity 2 meter data */ -#define METER_INDEX_GAS 1 /* index of the gas meter data */ + + #define DEBOUNCE_TICK_THRESHOLD_MS 50 /* when two ticks are less than this time period apart, the second tick is ignored (debouncing) */