aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/attiny1616.c12
-rw-r--r--arch/attiny1616.h2
-rw-r--r--arch/attiny1634.c12
-rw-r--r--arch/attiny1634.h2
-rw-r--r--arch/attiny85.c10
-rw-r--r--arch/attiny85.h2
-rw-r--r--arch/avr32dd20.c6
-rw-r--r--arch/avr32dd20.h2
-rw-r--r--fsm/adc.c58
-rw-r--r--fsm/adc.h10
-rw-r--r--fsm/eeprom.c8
-rw-r--r--fsm/eeprom.h8
-rw-r--r--hw/sofirn/sp10-pro/hwdef.h4
-rw-r--r--hw/thefreeman/avr32dd20-devkit/hwdef.c6
-rw-r--r--hw/thefreeman/avr32dd20-devkit/hwdef.h5
-rw-r--r--hw/thefreeman/boost-fwaa-mp3432-hdr-dac-rgb/hwdef.h4
-rw-r--r--ui/anduril/anduril.c12
-rw-r--r--ui/anduril/aux-leds.c39
-rw-r--r--ui/anduril/strobe-modes.c2
-rw-r--r--ui/anduril/tactical-mode.c5
20 files changed, 113 insertions, 96 deletions
diff --git a/arch/attiny1616.c b/arch/attiny1616.c
index c5499dd..02e64b1 100644
--- a/arch/attiny1616.c
+++ b/arch/attiny1616.c
@@ -104,18 +104,18 @@ inline uint16_t mcu_adc_result_volts() {
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) {
// In : 65535 * 1.5 / Vbat
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// 1.5 = ADC Vref
#if 0
// 1024 = how much ADC resolution we're using (10 bits)
// (12 bits available, but it costs an extra 84 bytes of ROM to calculate)
- uint8_t vbat40 = (uint16_t)(40 * 1.5 * 1024) / (measurement >> 6);
+ uint8_t vbat = (uint16_t)(10 * dV * 1.5 * 1024) / (measurement >> 6);
#else
// ... spend the extra 84 bytes of ROM for better precision
// 4096 = how much ADC resolution we're using (12 bits)
- uint8_t vbat40 = (uint32_t)(40 * 1.5 * 4096) / (measurement >> 4);
+ uint8_t vbat = (uint32_t)(10 * dV * 1.5 * 4096) / (measurement >> 4);
#endif
- return vbat40;
+ return vbat;
}
#if 0 // fine voltage, 0 to 10.24V in 1/6400th V steps
@@ -130,12 +130,12 @@ inline uint16_t mcu_vdd_raw2fine(uint16_t measurement) {
#ifdef USE_VOLTAGE_DIVIDER
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement) {
// In : 4095 * Vdiv / 1.1V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// Vdiv = Vbat / 4.3 (typically)
// 1.1 = ADC Vref
const uint16_t adc_per_volt =
(((uint16_t)ADC_44 << 4) - ((uint16_t)ADC_22 << 4))
- / (4 * (44-22));
+ / (dV * (44-22));
uint8_t result = measurement / adc_per_volt;
return result;
}
diff --git a/arch/attiny1616.h b/arch/attiny1616.h
index 940973e..711452d 100644
--- a/arch/attiny1616.h
+++ b/arch/attiny1616.h
@@ -85,7 +85,7 @@ inline void mcu_adc_vect_clear();
inline uint16_t mcu_adc_result_temp();
inline uint16_t mcu_adc_result_volts();
-// return Volts * 40, range 0 to 6.375V
+// return Volts * 50, range 0 to 5.10V
#define voltage_raw2cooked mcu_vdd_raw2cooked
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement);
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement);
diff --git a/arch/attiny1634.c b/arch/attiny1634.c
index e29d1c3..314ca52 100644
--- a/arch/attiny1634.c
+++ b/arch/attiny1634.c
@@ -97,30 +97,30 @@ inline uint16_t mcu_adc_result() {
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) {
// In : 65535 * 1.1 / Vbat
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// 1.1 = ADC Vref
#if 0
// 1024 = how much ADC resolution we're using (10 bits)
// (12 bits available, but it costs an extra 84 bytes of ROM to calculate)
- uint8_t vbat40 = (uint16_t)(40 * 1.1 * 1024) / (measurement >> 6);
+ uint8_t vbat = (uint16_t)(10 * dV * 1.1 * 1024) / (measurement >> 6);
#else
// ... spend the extra 84 bytes of ROM for better precision
// 4096 = how much ADC resolution we're using (12 bits)
- uint8_t vbat40 = (uint32_t)(40 * 1.1 * 4096) / (measurement >> 4);
+ uint8_t vbat = (uint32_t)(10 * dV * 1.1 * 4096) / (measurement >> 4);
#endif
- return vbat40;
+ return vbat;
}
#ifdef USE_VOLTAGE_DIVIDER
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement) {
// In : 4095 * Vdiv / 1.1V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// Vdiv = Vbat / 4.3 (typically)
// 1.1 = ADC Vref
const uint16_t adc_per_volt =
(((uint16_t)ADC_44 << 4) - ((uint16_t)ADC_22 << 4))
- / (4 * (44-22));
+ / (dV * (44-22));
uint8_t result = measurement / adc_per_volt;
return result;
}
diff --git a/arch/attiny1634.h b/arch/attiny1634.h
index 559d04e..19920fe 100644
--- a/arch/attiny1634.h
+++ b/arch/attiny1634.h
@@ -66,7 +66,7 @@ inline void mcu_adc_off();
inline uint16_t mcu_adc_result();
-// return Volts * 40, range 0 to 6.375V
+// return Volts * 50, range 0 to 5.10V
#define voltage_raw2cooked mcu_vdd_raw2cooked
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement);
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement);
diff --git a/arch/attiny85.c b/arch/attiny85.c
index 9e298cc..4ca4b87 100644
--- a/arch/attiny85.c
+++ b/arch/attiny85.c
@@ -103,24 +103,24 @@ inline uint16_t mcu_adc_result() { return ADC; }
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) {
// In : 65535 * 1.1 / Vbat
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// 1.1 = ADC Vref
// 1024 = how much ADC resolution we're using (10 bits)
// (12 bits available, but it costs an extra 84 bytes of ROM to calculate)
- uint8_t vbat40 = (uint16_t)(40 * 1.1 * 1024) / (measurement >> 6);
- return vbat40;
+ uint8_t vbat = (uint16_t)(10 * dV * 1.1 * 1024) / (measurement >> 6);
+ return vbat;
}
#ifdef USE_VOLTAGE_DIVIDER
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement) {
// In : 4095 * Vdiv / 1.1V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// Vdiv = Vbat / 4.3 (typically)
// 1.1 = ADC Vref
const uint16_t adc_per_volt =
(((uint16_t)ADC_44 << 4) - ((uint16_t)ADC_22 << 4))
- / (4 * (44-22));
+ / (dV * (44-22));
uint8_t result = measurement / adc_per_volt;
return result;
}
diff --git a/arch/attiny85.h b/arch/attiny85.h
index 3f6ffcb..06a1061 100644
--- a/arch/attiny85.h
+++ b/arch/attiny85.h
@@ -53,7 +53,7 @@ inline void mcu_adc_off();
inline uint16_t mcu_adc_result();
-// return Volts * 40, range 0 to 6.375V
+// return Volts * 50, range 0 to 5.10V
#define voltage_raw2cooked mcu_vdd_raw2cooked
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement);
inline uint8_t mcu_vdivider_raw2cooked(uint16_t measurement);
diff --git a/arch/avr32dd20.c b/arch/avr32dd20.c
index 2ac3526..3ada2ee 100644
--- a/arch/avr32dd20.c
+++ b/arch/avr32dd20.c
@@ -141,10 +141,10 @@ inline uint16_t mcu_adc_result() {
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) {
// In : 65535 * (Vbat / 10) / 1.024V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// (add 80 to round up near a boundary)
- uint8_t vbat40 = (uint16_t)(measurement + 80) / 160;
- return vbat40;
+ uint8_t vbat50 = (uint16_t)(measurement + 64) / 128;
+ return vbat50;
}
#if 0
diff --git a/arch/avr32dd20.h b/arch/avr32dd20.h
index 09b4096..7d06863 100644
--- a/arch/avr32dd20.h
+++ b/arch/avr32dd20.h
@@ -71,7 +71,7 @@ inline uint16_t mcu_adc_result();
//inline uint16_t mcu_adc_result_temp();
//inline uint16_t mcu_adc_result_volts();
-// return Volts * 40, range 0 to 6.375V
+// return Volts * 50, range 0 to 5.10V
#define voltage_raw2cooked mcu_vdd_raw2cooked
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement);
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/eeprom.c b/fsm/eeprom.c
index 8f8bd67..436a736 100644
--- a/fsm/eeprom.c
+++ b/fsm/eeprom.c
@@ -14,7 +14,7 @@ uint8_t eeprom[EEPROM_BYTES];
#endif
uint8_t load_eeprom() {
- #if defined(LED_ENABLE_PIN) || defined(LED2_ENABLE_PIN)
+ #ifdef USE_EEP_DELAY
delay_4ms(2); // wait for power to stabilize
#endif
@@ -32,7 +32,7 @@ uint8_t load_eeprom() {
}
void save_eeprom() {
- #if defined(LED_ENABLE_PIN) || defined(LED2_ENABLE_PIN)
+ #ifdef USE_EEP_DELAY
delay_4ms(2); // wait for power to stabilize
#endif
@@ -54,7 +54,7 @@ uint8_t eeprom_wl[EEPROM_WL_BYTES];
uint8_t * eep_wl_prev_offset;
uint8_t load_eeprom_wl() {
- #if defined(LED_ENABLE_PIN) || defined(LED2_ENABLE_PIN)
+ #ifdef USE_EEP_DELAY
delay_4ms(2); // wait for power to stabilize
#endif
@@ -83,7 +83,7 @@ uint8_t load_eeprom_wl() {
}
void save_eeprom_wl() {
- #if defined(LED_ENABLE_PIN) || defined(LED2_ENABLE_PIN)
+ #ifdef USE_EEP_DELAY
delay_4ms(2); // wait for power to stabilize
#endif
diff --git a/fsm/eeprom.h b/fsm/eeprom.h
index 1e10fd2..d5f0363 100644
--- a/fsm/eeprom.h
+++ b/fsm/eeprom.h
@@ -55,3 +55,11 @@
// if this marker isn't found, the eeprom is assumed to be blank
#define EEP_MARKER 0b10100101
+// wait a few ms before eeprom operations, to wait for power to stabilize
+// (otherwise reads or writes can get corrupt data)
+// (not necessary on some hardware,
+// but enabled by default when there's space)
+#if defined(LED_ENABLE_PIN) || defined(LED2_ENABLE_PIN) || (ROM_SIZE > 10000)
+ #define USE_EEP_DELAY
+#endif
+
diff --git a/hw/sofirn/sp10-pro/hwdef.h b/hw/sofirn/sp10-pro/hwdef.h
index f220318..43da9d0 100644
--- a/hw/sofirn/sp10-pro/hwdef.h
+++ b/hw/sofirn/sp10-pro/hwdef.h
@@ -62,8 +62,8 @@ enum CHANNEL_MODES {
// Voltage divider battLVL
#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is regulated
-#define DUAL_VOLTAGE_FLOOR (4*21) // for AA/14500 boost drivers, don't indicate low voltage if below this level
-#define DUAL_VOLTAGE_LOW_LOW (4*7) // the lower voltage range's danger zone 0.7 volts (NiMH)
+#define DUAL_VOLTAGE_FLOOR (21*dV) // for AA/14500 boost drivers, don't indicate low voltage if below this level
+#define DUAL_VOLTAGE_LOW_LOW ( 7*dV) // the lower voltage range's danger zone 0.7 volts (NiMH)
#define ADMUX_VOLTAGE_DIVIDER ADC_MUXPOS_AIN9_gc // which ADC channel to read
#undef voltage_raw2cooked
diff --git a/hw/thefreeman/avr32dd20-devkit/hwdef.c b/hw/thefreeman/avr32dd20-devkit/hwdef.c
index 460082f..5b534d2 100644
--- a/hw/thefreeman/avr32dd20-devkit/hwdef.c
+++ b/hw/thefreeman/avr32dd20-devkit/hwdef.c
@@ -119,13 +119,13 @@ bool gradual_tick_main(uint8_t gt) {
uint8_t voltage_raw2cooked(uint16_t measurement) {
// In : 65535 * BATTLVL / 1.024V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// BATTLVL = Vbat * (100.0/(330+100)) = Vbat / 4.3
- // So, Out = In * 4.3 / 1600
+ // So, Out = In * 4.3 / 1280
// (plus a bit of fudging to fix the slope and offset,
// based on measuring actual hardware)
uint8_t result = (uint32_t)(measurement + (65535 * 4 / 1024))
- * 43 / 16128;
+ * 43 / 12880;
return result;
}
diff --git a/hw/thefreeman/avr32dd20-devkit/hwdef.h b/hw/thefreeman/avr32dd20-devkit/hwdef.h
index 231f74a..5015c24 100644
--- a/hw/thefreeman/avr32dd20-devkit/hwdef.h
+++ b/hw/thefreeman/avr32dd20-devkit/hwdef.h
@@ -109,8 +109,8 @@ enum CHANNEL_MODES {
// AVR datasheet table 3.1 I/O Multiplexing, PA6 ADC0 = AIN26
#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is regulated
#define ADMUX_VOLTAGE_DIVIDER ADC_MUXPOS_AIN26_gc
-#define DUAL_VOLTAGE_FLOOR (4*21) // for AA/14500 boost drivers, don't indicate low voltage if below this level
-#define DUAL_VOLTAGE_LOW_LOW (4*7) // the lower voltage range's danger zone 0.7 volts (NiMH)
+#define DUAL_VOLTAGE_FLOOR (21*dV) // for AA/14500 boost drivers, don't indicate low voltage if below this level
+#define DUAL_VOLTAGE_LOW_LOW ( 7*dV) // the lower voltage range's danger zone 0.7 volts (NiMH)
// don't use the default VDD converter
// convert BATT LVL pin readings to FSM volt units
#undef voltage_raw2cooked
@@ -155,6 +155,7 @@ inline void hwdef_setup() {
//PORTA.PIN2CTRL = PORT_PULLUPEN_bm; // B
#ifdef USE_BST_BYPASS
PORTA.PIN3CTRL = PORT_PULLUPEN_bm; // BBY
+ BST_BYPASS_PORT |= (1 << BST_BYPASS_PIN);
#endif
PORTA.PIN4CTRL = PORT_PULLUPEN_bm;
PORTA.PIN5CTRL = PORT_PULLUPEN_bm;
diff --git a/hw/thefreeman/boost-fwaa-mp3432-hdr-dac-rgb/hwdef.h b/hw/thefreeman/boost-fwaa-mp3432-hdr-dac-rgb/hwdef.h
index bc1d9a7..1c6e6be 100644
--- a/hw/thefreeman/boost-fwaa-mp3432-hdr-dac-rgb/hwdef.h
+++ b/hw/thefreeman/boost-fwaa-mp3432-hdr-dac-rgb/hwdef.h
@@ -94,8 +94,8 @@ enum CHANNEL_MODES {
// Voltage divider battLVL
#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is regulated
#define ADMUX_VOLTAGE_DIVIDER ADC_MUXPOS_AIN2_gc // which ADC channel to read
-#define DUAL_VOLTAGE_FLOOR (4*21) // for AA/14500 boost drivers, don't indicate low voltage if below this level
-#define DUAL_VOLTAGE_LOW_LOW (4*7) // the lower voltage range's danger zone 0.7 volts (NiMH)
+#define DUAL_VOLTAGE_FLOOR (21*dV) // for AA/14500 boost drivers, don't indicate low voltage if below this level
+#define DUAL_VOLTAGE_LOW_LOW ( 7*dV) // the lower voltage range's danger zone 0.7 volts (NiMH)
// don't use the default VDD converter
#undef voltage_raw2cooked
#define voltage_raw2cooked mcu_vdivider_raw2cooked
diff --git a/ui/anduril/anduril.c b/ui/anduril/anduril.c
index 1cdb8d0..4378816 100644
--- a/ui/anduril/anduril.c
+++ b/ui/anduril/anduril.c
@@ -121,7 +121,7 @@
#include "anduril/lockout-mode.h"
#endif
-#ifdef USE_MOMENTARY_MODE
+#if (defined(USE_MOMENTARY_MODE) || defined(USE_TACTICAL_MODE))
#include "anduril/momentary-mode.h"
#endif
@@ -189,7 +189,7 @@
#include "anduril/lockout-mode.c"
#endif
-#ifdef USE_MOMENTARY_MODE
+#if (defined(USE_MOMENTARY_MODE) || defined(USE_TACTICAL_MODE))
#include "anduril/momentary-mode.c"
#endif
@@ -293,10 +293,12 @@ void loop() {
#ifdef USE_STROBE_STATE
else if ((state == strobe_state)
- #ifdef USE_MOMENTARY_MODE
+ #if defined(USE_MOMENTARY_MODE) || defined(USE_TACTICAL_MODE)
// also handle momentary strobes
- || ((
- (state == momentary_state)
+ || ((0
+ #ifdef USE_MOMENTARY_MODE
+ || (state == momentary_state)
+ #endif
#ifdef USE_TACTICAL_MODE
|| (state == tactical_state)
#endif
diff --git a/ui/anduril/aux-leds.c b/ui/anduril/aux-leds.c
index fd184fc..7356666 100644
--- a/ui/anduril/aux-leds.c
+++ b/ui/anduril/aux-leds.c
@@ -58,27 +58,27 @@ void indicator_led_update(uint8_t mode, uint8_t tick) {
uint8_t voltage_to_rgb() {
static const uint8_t levels[] = {
// voltage, color
- 0, 0, // black
+ 0, 0, // black
#ifdef DUAL_VOLTAGE_FLOOR
// AA / NiMH voltages
- 4* 9, 1, // R
- 4*10, 2, // R+G
- 4*11, 3, // G
- 4*12, 4, // G+B
- 4*13, 5, // B
- 4*14, 6, // R + B
- 4*16, 7, // R+G+B
- 4*20, 0, // black
+ 9*dV, 1, // R
+ 10*dV, 2, // R+G
+ 11*dV, 3, // G
+ 12*dV, 4, // G+B
+ 13*dV, 5, // B
+ 14*dV, 6, // R + B
+ 16*dV, 7, // R+G+B
+ 20*dV, 0, // black
#endif
// li-ion voltages
- 4*29, 1, // R
- 4*33, 2, // R+G
- 4*35, 3, // G
- 4*37, 4, // G+B
- 4*39, 5, // B
- 4*41, 6, // R + B
- 4*44, 7, // R+G+B // skip; looks too similar to G+B
- 255, 7, // R+G+B
+ 29*dV, 1, // R
+ 33*dV, 2, // R+G
+ 35*dV, 3, // G
+ 37*dV, 4, // G+B
+ 39*dV, 5, // B
+ 41*dV, 6, // R + B
+ 44*dV, 7, // R+G+B // skip; looks too similar to G+B
+ 255, 7, // R+G+B
};
uint8_t volts = voltage;
//if (volts < VOLTAGE_LOW) return 0;
@@ -151,11 +151,8 @@ void rgb_led_update(uint8_t mode, uint16_t arg) {
else { // voltage
// show actual voltage while asleep...
if (go_to_standby) {
- actual_color = voltage_to_rgb();
// choose a color based on battery voltage
- //if (volts >= 38) actual_color = pgm_read_byte(colors + 4);
- //else if (volts >= 33) actual_color = pgm_read_byte(colors + 2);
- //else actual_color = pgm_read_byte(colors + 0);
+ actual_color = voltage_to_rgb();
}
// ... but during preview, cycle colors quickly
else {
diff --git a/ui/anduril/strobe-modes.c b/ui/anduril/strobe-modes.c
index ccc4aa0..38e4dca 100644
--- a/ui/anduril/strobe-modes.c
+++ b/ui/anduril/strobe-modes.c
@@ -13,7 +13,7 @@ uint8_t strobe_state(Event event, uint16_t arg) {
// 'st' reduces ROM size slightly
strobe_mode_te st = current_strobe_type;
- #ifdef USE_MOMENTARY_MODE
+ #if defined(USE_MOMENTARY_MODE) || defined(USE_TACTICAL_MODE)
momentary_mode = 1; // 0 = ramping, 1 = strobes
#endif
diff --git a/ui/anduril/tactical-mode.c b/ui/anduril/tactical-mode.c
index 5acd902..002f917 100644
--- a/ui/anduril/tactical-mode.c
+++ b/ui/anduril/tactical-mode.c
@@ -68,6 +68,11 @@ uint8_t tactical_state(Event event, uint16_t arg) {
return lockout_state(event, arg);
}
+ // handle 3C here to prevent changing channel modes unintentionally
+ if (event == EV_3clicks) {
+ return EVENT_HANDLED;
+ }
+
// 6 clicks: exit and turn off
else if (event == EV_6clicks) {
blink_once();