From 01ded76e31890084d8b0f0d0c76b23d9434aabe3 Mon Sep 17 00:00:00 2001 From: maniacbug Date: Wed, 21 Aug 2013 21:04:36 -0700 Subject: [PATCH] Commit temp calibration to eeprom --- examples/sensornet/nodeconfig.cpp | 14 ++++++++++---- examples/sensornet/nodeconfig.h | 1 + examples/sensornet/sensornet.pde | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/sensornet/nodeconfig.cpp b/examples/sensornet/nodeconfig.cpp index d27b5ec1..ff2be35a 100644 --- a/examples/sensornet/nodeconfig.cpp +++ b/examples/sensornet/nodeconfig.cpp @@ -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")); @@ -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 diff --git a/examples/sensornet/nodeconfig.h b/examples/sensornet/nodeconfig.h index f08db90e..99b26ae7 100644 --- a/examples/sensornet/nodeconfig.h +++ b/examples/sensornet/nodeconfig.h @@ -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__ diff --git a/examples/sensornet/sensornet.pde b/examples/sensornet/sensornet.pde index 5a3dc660..df76dd59 100644 --- a/examples/sensornet/sensornet.pde +++ b/examples/sensornet/sensornet.pde @@ -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 ); } }