Changeset 43

Show
Ignore:
Timestamp:
02/01/10 22:24:48 (15 years ago)
Author:
phil
Message:

merge with other version (from laptop): changed handleGasMeterTick() changed to generic handleMeterTick()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c

    r42 r43  
    9292} 
    9393 
    94 void handleGasMeterTick(void
     94void handleMeterTick(portSHORT portNum
    9595{ 
    9696  unsigned long long currentTime = getEpochTimeWithMs(); /* current epoch time with ms in ms */ 
    97   if (  currentTime > (meterItems[METER_INDEX_GAS].timeLastTick + DEBOUNCE_TICK_THRESHOLD_MS) ) 
     97 
     98  globalValue++; 
     99    //   LCD_cls(); 
     100  //LCD_puts( ( signed portCHAR * ) "xyz" ); 
     101   
     102 
     103  if (  currentTime > (meterItems[portNum].timeLastTick + DEBOUNCE_TICK_THRESHOLD_MS) ) 
    98104  { 
    99105    /* we have a tick that is not a bounce */ 
    100     meterItems[METER_INDEX_GAS].currentValue++; /* one more tick. always increase the counter */ 
     106    meterItems[portNum].currentValue++; /* one more tick. always increase the counter */ 
     107 
    101108 
    102109    /* now check if we should accumulate the ticks for this time period so we leave the new data item available long 
    103110     * enough on the web page to be read by the server  
    104111     */ 
    105     if ( currentTime > ((unsigned long long)meterItems[METER_INDEX_GAS].timeBeforeLastTick + ((unsigned long long)ACCUMULATE_TICK_THRESHOLD_SEC * (unsigned long long)1000)) ) 
     112    if ( currentTime > ((unsigned long long)meterItems[portNum].timeBeforeLastTick + ((unsigned long long)ACCUMULATE_TICK_THRESHOLD_SEC * (unsigned long long)1000)) ) 
    106113    { 
     114 
     115 
     116  
     117 
    107118      /* if the last meter tick happened longer than DEBOUNCE_TICK_THRESHOLD_MS ago (i.e. the switch did not just bounce), 
    108119       * we create a new data item 
    109120       */ 
    110       meterItems[METER_INDEX_GAS].timeBeforeLastTick = meterItems[METER_INDEX_GAS].timeLastTick;     /* when did the tick before the last tick occur? (epoch in milliseconds) */ 
    111       meterItems[METER_INDEX_GAS].timeLastTick = currentTime; /* when did the last tick occur? (epoch in milliseconds) */ 
    112       meterItems[METER_INDEX_GAS].valueBeforeLastTick = meterItems[METER_INDEX_GAS].valueLastTick;   /* what value did we have at the tick before the last tick? */ 
    113       meterItems[METER_INDEX_GAS].valueLastTick = meterItems[METER_INDEX_GAS].currentValue;   /* what value did we have at the last tick? now one more! */ 
     121      meterItems[portNum].timeBeforeLastTick = meterItems[portNum].timeLastTick;     /* when did the tick before the last tick occur? (epoch in milliseconds) */ 
     122      meterItems[portNum].timeLastTick = currentTime; /* when did the last tick occur? (epoch in milliseconds) */ 
     123      meterItems[portNum].valueBeforeLastTick = meterItems[portNum].valueLastTick;   /* what value did we have at the tick before the last tick? */ 
     124      meterItems[portNum].valueLastTick = meterItems[portNum].currentValue;   /* what value did we have at the last tick? now one more! */ 
    114125      /* at present, valueLastTick and currentValue are the same. This might be different for future versions. */ 
    115126    } 
     
    117128    { 
    118129      /* do not create a new data item, but update the current "last" data item */ 
    119       meterItems[METER_INDEX_GAS].timeLastTick = currentTime; 
    120       meterItems[METER_INDEX_GAS].valueLastTick = meterItems[METER_INDEX_GAS].currentValue; 
     130      meterItems[portNum].timeLastTick = currentTime; 
     131      meterItems[portNum].valueLastTick = meterItems[portNum].currentValue; 
    121132    } 
    122133  }