aboutsummaryrefslogtreecommitdiff
path: root/fsm
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-08-19 13:10:04 -0600
committerSelene ToyKeeper2024-08-19 13:10:04 -0600
commit4c2bbf92194ff5f41a87baa95c5388b325a27d2d (patch)
tree2d2b51fc3ef800e55009bc5f01ef7119d4c32d6e /fsm
parentts25-boost: reduced visible PWM, made party strobe less blurry (diff)
parentremoved "Off -> 3H" strobe/mood mode access from Extended Simple UI (diff)
downloadanduril-4c2bbf92194ff5f41a87baa95c5388b325a27d2d.tar.gz
anduril-4c2bbf92194ff5f41a87baa95c5388b325a27d2d.tar.bz2
anduril-4c2bbf92194ff5f41a87baa95c5388b325a27d2d.zip
Merge branch 'trunk' into wurkkos-ts25-boost
# By Selene ToyKeeper (20) and others * trunk: (25 commits) removed "Off -> 3H" strobe/mood mode access from Extended Simple UI include hardware-specific readme files in the release .zip added change log for 2024-04-20 release Forgot to update model count after the last couple additions use low aux for chan-aux level 0 MODELS: added emisar-d3aa make-release.sh should use version-string.sh instead of duplicating code d3aa: fixed voltage calculation to use 0.02V units instead of 0.025V d3aa weak battery test: blink 3x instead of 2x, and omit number readout use smooth steps in lockout mode, if enabled fixed Tactical Mode's strobes when Momentary Mode not enabled increased voltage precision from 0.025V to 0.02V (so 0 to 255 now goes from 0.00V to 5.10V) weak battery detection: use different thresholds for AA and Li-Ion (also, fixed bug where a totally empty li-ion didn't get limited) d3aa: got weak battery detection actually working, and not letting the magic smoke out of updi adapters any more (probably) dammit, got alkaline detection half working and then my flashing adapter died (saving progress here so I can work on a different branch) fixed inaccurate comment (thanks to xikteny for spotting it) d3aa fine-tuning: - new ramp - production style config defaults (simple mode, Hank config) - candle tuning - fixed way-too-fast thermal regulation (might still be a bit fast, but it's a lot better) d3aa: fixed voltage measurement Allow manually running GitHub actions workflows Bugfix: Prevent switching channel modes when in tactical mode ... # Conflicts: # arch/attiny1616.c (fixed)
Diffstat (limited to 'fsm')
-rw-r--r--fsm/adc.c58
-rw-r--r--fsm/adc.h10
-rw-r--r--fsm/chan-aux.c2
-rw-r--r--fsm/chan-rgbaux.c14
-rw-r--r--fsm/ramping.c5
-rw-r--r--fsm/ramping.h3
6 files changed, 52 insertions, 40 deletions
diff --git a/fsm/adc.c b/fsm/adc.c
index fbe84a1..e0bacb6 100644
--- a/fsm/adc.c
+++ b/fsm/adc.c
@@ -209,8 +209,8 @@ static void ADC_voltage_handler() {
#endif
else measurement = adc_smooth[0];
- // convert raw ADC value to FSM voltage units: Volts * 40
- // 0 .. 200 = 0.0V .. 5.0V
+ // convert raw ADC value to FSM voltage units: Volts * 50
+ // 0 .. 250 = 0.0V .. 5.0V
voltage = voltage_raw2cooked(measurement)
+ (VOLTAGE_FUDGE_FACTOR << 1)
#ifdef USE_VOLTAGE_CORRECTION
@@ -392,46 +392,46 @@ static void ADC_temperature_handler() {
#ifdef USE_BATTCHECK
#ifdef BATTCHECK_4bars
PROGMEM const uint8_t voltage_blinks[] = {
- 4*30,
- 4*35,
- 4*38,
- 4*40,
- 4*42,
- 255,
+ 30*dV,
+ 35*dV,
+ 38*dV,
+ 40*dV,
+ 42*dV,
+ 255,
};
#endif
#ifdef BATTCHECK_6bars
PROGMEM const uint8_t voltage_blinks[] = {
- 4*30,
- 4*34,
- 4*36,
- 4*38,
- 4*40,
- 4*41,
- 4*43,
- 255,
+ 30*dV,
+ 34*dV,
+ 36*dV,
+ 38*dV,
+ 40*dV,
+ 41*dV,
+ 43*dV,
+ 255,
};
#endif
#ifdef BATTCHECK_8bars
PROGMEM const uint8_t voltage_blinks[] = {
- 4*30,
- 4*33,
- 4*35,
- 4*37,
- 4*38,
- 4*39,
- 4*40,
- 4*41,
- 4*42,
- 255,
+ 30*dV,
+ 33*dV,
+ 35*dV,
+ 37*dV,
+ 38*dV,
+ 39*dV,
+ 40*dV,
+ 41*dV,
+ 42*dV,
+ 255,
};
#endif
void battcheck() {
#ifdef BATTCHECK_VpT
- blink_num(voltage / 4);
+ blink_num(voltage / dV);
#ifdef USE_EXTRA_BATTCHECK_DIGIT
- // 0 1 2 3 --> 0 2 5 7, representing x.x00 x.x25 x.x50 x.x75
- blink_num(((voltage % 4)<<1) + ((voltage % 4)>>1));
+ // 0.02V precision, 0 1 2 3 4 remainder -> .00 .02 .04 .06 .08V
+ blink_num((voltage % dV) * (10/dV));
#endif
#else
uint8_t i;
diff --git a/fsm/adc.h b/fsm/adc.h
index 02e33f8..5dec6c5 100644
--- a/fsm/adc.h
+++ b/fsm/adc.h
@@ -4,6 +4,10 @@
#pragma once
+// voltage is 0.00V to 5.10V in 0.02V steps, from 0 to 255
+// so one deci-Volt is 5 steps
+#define dV 5
+
#if defined(USE_LVP) || defined(USE_THERMAL_REGULATION)
// use raw value instead of lowpassed value for the next N measurements
// (2 = 1 for voltage + 1 for temperature)
@@ -15,13 +19,13 @@ volatile uint8_t adc_reset = 2;
#ifndef VOLTAGE_WARNING_SECONDS
#define VOLTAGE_WARNING_SECONDS 5
#endif
-// low-battery threshold in volts * 10
+// low-battery threshold in volts * 50
#ifndef VOLTAGE_LOW
-#define VOLTAGE_LOW (4*29)
+#define VOLTAGE_LOW (29*dV)
#endif
// battery is low but not critical
#ifndef VOLTAGE_RED
-#define VOLTAGE_RED (4*33)
+#define VOLTAGE_RED (33*dV)
#endif
// MCU sees voltage 0.X volts lower than actual, add X/2 to readings
#ifndef VOLTAGE_FUDGE_FACTOR
diff --git a/fsm/chan-aux.c b/fsm/chan-aux.c
index e04e6a2..239316a 100644
--- a/fsm/chan-aux.c
+++ b/fsm/chan-aux.c
@@ -4,7 +4,7 @@
#pragma once
void set_level_aux(uint8_t level) {
- indicator_led(!(!(level)) << 1); // high (or off)
+ indicator_led((!(!(level)) << 1) + 1); // high (level > 0) or low
}
bool gradual_tick_null(uint8_t gt) { return true; } // do nothing
diff --git a/fsm/chan-rgbaux.c b/fsm/chan-rgbaux.c
index 19d18a6..a66c29e 100644
--- a/fsm/chan-rgbaux.c
+++ b/fsm/chan-rgbaux.c
@@ -4,31 +4,31 @@
#pragma once
void set_level_auxred(uint8_t level) {
- rgb_led_set(!(!(level)) * 0b000010); // red, high (or off)
+ rgb_led_set(0b000001 << !(!(level))); // red, high (level > 0) or low
}
void set_level_auxyel(uint8_t level) {
- rgb_led_set(!(!(level)) * 0b001010); // red+green, high (or off)
+ rgb_led_set(0b000101 << !(!(level))); // red+green, high (level > 0) or low
}
void set_level_auxgrn(uint8_t level) {
- rgb_led_set(!(!(level)) * 0b001000); // green, high (or off)
+ rgb_led_set(0b000100 << !(!(level))); // green, high (level > 0) or low
}
void set_level_auxcyn(uint8_t level) {
- rgb_led_set(!(!(level)) * 0b101000); // green+blue, high (or off)
+ rgb_led_set(0b010100 << !(!(level))); // green+blue, high (level > 0) or low
}
void set_level_auxblu(uint8_t level) {
- rgb_led_set(!(!(level)) * 0b100000); // blue, high (or off)
+ rgb_led_set(0b010000 << !(!(level))); // blue, high (level > 0) or low
}
void set_level_auxprp(uint8_t level) {
- rgb_led_set(!(!(level)) * 0b100010); // red+blue, high (or off)
+ rgb_led_set(0b010001 << !(!(level))); // red+blue, high (level > 0) or low
}
void set_level_auxwht(uint8_t level) {
- rgb_led_set(!(!(level)) * 0b101010); // red+green+blue, high (or off)
+ rgb_led_set(0b010101 << !(!(level))); // red+green+blue, high (level > 0) or low
}
bool gradual_tick_null(uint8_t gt) { return true; } // do nothing
diff --git a/fsm/ramping.c b/fsm/ramping.c
index adc8acb..743e619 100644
--- a/fsm/ramping.c
+++ b/fsm/ramping.c
@@ -57,6 +57,11 @@ inline void set_level_aux_rgb_leds(uint8_t level) {
void set_level(uint8_t level) {
+ #ifdef USE_RAMP_LEVEL_HARD_LIMIT
+ if (ramp_level_hard_limit && (level > ramp_level_hard_limit))
+ level = ramp_level_hard_limit;
+ #endif
+
#ifdef USE_JUMP_START
// maybe "jump start" the engine, if it's prone to slow starts
// (pulse the output high for a moment to wake up the power regulator)
diff --git a/fsm/ramping.h b/fsm/ramping.h
index c4b7d48..f542bd2 100644
--- a/fsm/ramping.h
+++ b/fsm/ramping.h
@@ -10,6 +10,9 @@
uint8_t actual_level = 0;
// the level used before actual
uint8_t prev_level = 0;
+#ifdef USE_RAMP_LEVEL_HARD_LIMIT
+uint8_t ramp_level_hard_limit = 0;
+#endif
void set_level(uint8_t level);
//void set_level_smooth(uint8_t level);