Skip to content

Commit

Permalink
Commit temp calibration to eeprom
Browse files Browse the repository at this point in the history
  • Loading branch information
maniacbug committed Aug 22, 2013
1 parent 1092c6c commit 01ded76
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions examples/sensornet/nodeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ void nodeconfig_listen(void)
int8_t val = strtol(serialdata,NULL,16);
nextserialat = serialdata;

eeprom_info.temp_calibration = val * 0x10;
printf_P(PSTR("TEMP: %02x\n\r"),eeprom_info.temp_calibration);

eeprom_update_block(&eeprom_info,address_at_eeprom_location,sizeof(eeprom_info));
set_temp_calibration( val * 0x10 );

printf_P(PSTR("RESET NODE before changes take effect\r\n"));
if ( ! eeprom_info.isValid() )
printf_P(PSTR("Please assign an address\r\n"));
Expand All @@ -122,4 +120,12 @@ void nodeconfig_listen(void)
}
}
}

void set_temp_calibration(int16_t val)
{
eeprom_info.temp_calibration = val;
printf_P(PSTR("TEMP: %02x\n\r"),eeprom_info.temp_calibration);
eeprom_update_block(&eeprom_info,address_at_eeprom_location,sizeof(eeprom_info));
}

// vim:ai:cin:sts=2 sw=2 ft=cpp
1 change: 1 addition & 0 deletions examples/sensornet/nodeconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct eeprom_info_t

const eeprom_info_t& nodeconfig_read(void);
void nodeconfig_listen(void);
void set_temp_calibration(int16_t val);

#endif // __NODECONFIG_H__

Expand Down
1 change: 1 addition & 0 deletions examples/sensornet/sensornet.pde
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ void loop(void)
// Now apply the calibration
this_node.temp_calibration += calibration_data.result();
// And save it to eeprom...
set_temp_calibration( this_node.temp_calibration );
}

}
Expand Down

0 comments on commit 01ded76

Please sign in to comment.