~toykeeper/flashlight-firmware/fsm

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/anduril/tempcheck-mode.c

  • Committer: Selene ToyKeeper
  • Date: 2023-04-17 00:21:29 UTC
  • mto: (483.1.175 anduril2)
  • mto: This revision was merged to the branch mainline in revision 491.
  • Revision ID: bzr@toykeeper.net-20230417002129-32mnxi61ro64o29u
reduced ROM by ~600 bytes by moving all eeprom config values to a "cfg" struct
(this also made some parts of the code cleaner)

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    if (value) {
52
52
        // item 1: calibrate room temperature
53
53
        if (step == 1) {
54
 
            int8_t rawtemp = temperature - therm_cal_offset;
55
 
            therm_cal_offset = value - rawtemp;
 
54
            int8_t rawtemp = temperature - cfg.therm_cal_offset;
 
55
            cfg.therm_cal_offset = value - rawtemp;
56
56
            adc_reset = 2;  // invalidate all recent temperature data
57
57
        }
58
58
 
59
59
        // item 2: set maximum heat limit
60
60
        else {
61
 
            therm_ceil = 30 + value - 1;
 
61
            cfg.therm_ceil = 30 + value - 1;
62
62
        }
63
63
    }
64
64
 
65
 
    if (therm_ceil > MAX_THERM_CEIL) therm_ceil = MAX_THERM_CEIL;
 
65
    if (cfg.therm_ceil > MAX_THERM_CEIL) cfg.therm_ceil = MAX_THERM_CEIL;
66
66
}
67
67
 
68
68
uint8_t thermal_config_state(Event event, uint16_t arg) {