From 1c1980a41a146a5994c8c1cfe67e96be4e63c213 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 25 Sep 2020 05:19:19 -0600 Subject: reduced ROM 4 bytes by rearranging thermal_config_save() logic a bit patch is from SammysHP: https://gist.github.com/SammysHP/48347a770995921444a6e91b187cb55b --- spaghetti-monster/anduril/tempcheck-mode.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/anduril/tempcheck-mode.c b/spaghetti-monster/anduril/tempcheck-mode.c index 34abeb0..e618480 100644 --- a/spaghetti-monster/anduril/tempcheck-mode.c +++ b/spaghetti-monster/anduril/tempcheck-mode.c @@ -44,21 +44,20 @@ uint8_t tempcheck_state(Event event, uint16_t arg) { } void thermal_config_save(uint8_t step, uint8_t value) { - // item 1: calibrate room temperature - if (step == 1) { - if (value) { + if (value) { + // item 1: calibrate room temperature + if (step == 1) { int8_t rawtemp = temperature - therm_cal_offset; therm_cal_offset = value - rawtemp; adc_reset = 2; // invalidate all recent temperature data } - } - // item 2: set maximum heat limit - else { - if (value) { + // item 2: set maximum heat limit + else { therm_ceil = 30 + value - 1; } } + if (therm_ceil > MAX_THERM_CEIL) therm_ceil = MAX_THERM_CEIL; } -- cgit v1.2.3