<commit_before>#include <WProgram.h>
#include <avr/eeprom.h>

#include "hmcore.h"

#ifdef HEATERMETER_NETWORKING
#include <WiServer.h>  
#endif

#if defined(DFLASH_LOGGING) || defined(DFLASH_SERVING)
#include <dataflash.h>
  #ifdef DFLASH_SERVING
  #include "flashfiles.h"
  #endif
#endif

#include "strings.h"

static TempProbe probe0(PIN_PIT,   &STEINHART[0]);
static TempProbe probe1(PIN_FOOD1, &STEINHART[0]);
static TempProbe probe2(PIN_FOOD2, &STEINHART[0]);
static TempProbe probe3(PIN_AMB,   &STEINHART[1]);
GrillPid pid(PIN_BLOWER);

ShiftRegLCD lcd(PIN_LCD_DATA, PIN_LCD_CLK, TWO_WIRE, 2); 

#ifdef HEATERMETER_NETWORKING
static boolean g_NetworkInitialized;
#endif /* HEATERMETER_NETWORKING */
#ifdef HEATERMETER_SERIAL
static char g_SerialBuff[40];  // should be 49 to support /set?pn0=(urlencoded 13 chars)
#endif /* HEATERMETER_SERIAL */

#define config_store_byte(eeprom_field, src) { eeprom_write_byte((uint8_t *)offsetof(__eeprom_data, eeprom_field), src); }
#define config_store_word(eeprom_field, src) { eeprom_write_word((uint16_t *)offsetof(__eeprom_data, eeprom_field), src); }

#define EEPROM_MAGIC 0xf00d8000
#define PROBE_NAME_SIZE 13

const struct PROGMEM __eeprom_data {
  long magic;
  int setPoint;
  char probeNames[TEMP_COUNT][PROBE_NAME_SIZE];
  char probeTempOffsets[TEMP_COUNT];
  unsigned char lidOpenOffset;
  unsigned int lidOpenDuration;
  float pidConstants[4]; // constants are stored Kb, Kp, Ki, Kd
  boolean manualMode;
  unsigned char maxFanSpeed;  // in percent
  struct {
    boolean henabled;
    boolean lenabled;
    int high;
    int low;
  } alarms[TEMP_COUNT];
} DEFAULT_CONFIG PROGMEM = { 
  EEPROM_MAGIC,  // magic
  225,  // setpoint
  { "Pit", "Food Probe1", "Food Probe2", "Ambient" },  // probe names
  { 0, 0, 0 },  // probe offsets
  15,  // lid open offset
  240, // lid open duration
  { 5.0f, 4.0f, 0.002f, 2.5f },
  false, // manual mode
  100,  // max fan speed
  { { false, false, 200, 100 }, { false, false, 200, 100 }, 
    { false, false, 200, 100 }, { false, false, 200, 100 } }
};

boolean storeProbeName(unsigned char probeIndex, const char *name)
{
  if (probeIndex >= TEMP_COUNT)
    return false;
    
  size_t ofs = offsetof(__eeprom_data, probeNames);
  ofs += probeIndex * (PROBE_NAME_SIZE * sizeof(char));
  eeprom_write_block(name, (void *)ofs, PROBE_NAME_SIZE);
  return true;
}
<commit_msg>Fix missing default probe offset for TEMP_AMB.  It still defaulted to 0 from what I can tell though, so no big deal.<commit_after>#include <WProgram.h>
#include <avr/eeprom.h>

#include "hmcore.h"

#ifdef HEATERMETER_NETWORKING
#include <WiServer.h>  
#endif

#if defined(DFLASH_LOGGING) || defined(DFLASH_SERVING)
#include <dataflash.h>
  #ifdef DFLASH_SERVING
  #include "flashfiles.h"
  #endif
#endif

#include "strings.h"

static TempProbe probe0(PIN_PIT,   &STEINHART[0]);
static TempProbe probe1(PIN_FOOD1, &STEINHART[0]);
static TempProbe probe2(PIN_FOOD2, &STEINHART[0]);
static TempProbe probe3(PIN_AMB,   &STEINHART[1]);
GrillPid pid(PIN_BLOWER);

ShiftRegLCD lcd(PIN_LCD_DATA, PIN_LCD_CLK, TWO_WIRE, 2); 

#ifdef HEATERMETER_NETWORKING
static boolean g_NetworkInitialized;
#endif /* HEATERMETER_NETWORKING */
#ifdef HEATERMETER_SERIAL
static char g_SerialBuff[40];  // should be 49 to support /set?pn0=(urlencoded 13 chars)
#endif /* HEATERMETER_SERIAL */

#define config_store_byte(eeprom_field, src) { eeprom_write_byte((uint8_t *)offsetof(__eeprom_data, eeprom_field), src); }
#define config_store_word(eeprom_field, src) { eeprom_write_word((uint16_t *)offsetof(__eeprom_data, eeprom_field), src); }

#define EEPROM_MAGIC 0xf00d8000
#define PROBE_NAME_SIZE 13

const struct PROGMEM __eeprom_data {
  long magic;
  int setPoint;
  char probeNames[TEMP_COUNT][PROBE_NAME_SIZE];
  char probeTempOffsets[TEMP_COUNT];
  unsigned char lidOpenOffset;
  unsigned int lidOpenDuration;
  float pidConstants[4]; // constants are stored Kb, Kp, Ki, Kd
  boolean manualMode;
  unsigned char maxFanSpeed;  // in percent
  struct {
    boolean henabled;
    boolean lenabled;
    int high;
    int low;
  } alarms[TEMP_COUNT];
} DEFAULT_CONFIG PROGMEM = { 
  EEPROM_MAGIC,  // magic
  225,  // setpoint
  { "Pit", "Food Probe1", "Food Probe2", "Ambient" },  // probe names
  { 0, 0, 0, 0 },  // probe offsets
  15,  // lid open offset
  240, // lid open duration
  { 5.0f, 4.0f, 0.002f, 2.5f },
  false, // manual mode
  100,  // max fan speed
  { { false, false, 200, 100 }, { false, false, 200, 100 }, 
    { false, false, 200, 100 }, { false, false, 200, 100 } }
};

boolean storeProbeName(unsigned char probeIndex, const char *name)
{
  if (probeIndex >= TEMP_COUNT)
    return false;
    
  size_t ofs = offsetof(__eeprom_data, probeNames);
  ofs += probeIndex * (PROBE_NAME_SIZE * sizeof(char));
  eeprom_write_block(name, (void *)ofs, PROBE_NAME_SIZE);
  return true;
}

{'fraction_non_alphanumeric': 0.11922442244224422, 'fraction_numerical': 0.03382838283828383, 'mean_word_length': 4.638372093023256, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4059645', 'n_tokens_mistral': 1992, 'n_tokens_neox': 1831, 'n_words': 448}