aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-11-30 09:19:45 -0700
committerSelene ToyKeeper2023-11-30 09:19:45 -0700
commitf745e12c3bc48d8fe544893871191086cf3cccc9 (patch)
tree0e7f6c2c5f362719ac4efad9d5c2365f3ed3c159 /ui
parentadded md5sum to build-all.sh output per target (diff)
parenteliminated direct CCP register access from arch/attiny1616 (diff)
downloadanduril-f745e12c3bc48d8fe544893871191086cf3cccc9.tar.gz
anduril-f745e12c3bc48d8fe544893871191086cf3cccc9.tar.bz2
anduril-f745e12c3bc48d8fe544893871191086cf3cccc9.zip
Merge branch 'avr32dd20-devkit' into trunk
Added support for AVR DD MCUs, particularly avr32dd20. Also did a bunch of refactoring for how MCU support works, cleaned up the ADC code, switched to consistent internal formats for voltage and temperature, fixed the FW3X, and some other little things. * avr32dd20-devkit: (28 commits) eliminated direct CCP register access from arch/attiny1616 made the avr32dd20 flashing script more universal added a build target for FW3X with manually-fixed RGB aux wiring prevent future issues like the FW3X had fixed FW3X thermal regulation fixed incorrect temperature history for a few seconds after waking fsm/adc: removed dead code FW3X: fixed external temperature sensor FW3X: multiple upgrades... fw3x: fixed swapped red+blue, fixed battery measurements, added police color strobe fixed ADC on sp10-pro fixed ADC on attiny85 and related builds fixed ADC on attiny1634 and related builds more ADC / DAC / MCU progress... avr32dd20-devkit: make the defaults a bit more dev friendly (realtime voltage colors, and no simple UI by default) ADC voltage: battcheck 3 digits, fixed t1616, switched back to 8-bit internal volt unit got ADC voltage+temp working on avrdd... but broke all other builds/MCUs 1.55V AA battery should not show as "white" voltage color, only purple started refactoring fsm/adc.*, but need a checkpoint before continuing added dac-scale.py: short script to calculate avrdd DAC+Vref values from level_calc.py ramp data ...
Diffstat (limited to '')
-rw-r--r--ui/anduril/anduril.c19
-rw-r--r--ui/anduril/aux-leds.c34
-rw-r--r--ui/anduril/config-default.h16
-rw-r--r--ui/anduril/ramp-mode.c2
-rw-r--r--ui/anduril/ramp-mode.h9
-rw-r--r--ui/anduril/version-check-mode.c5
6 files changed, 52 insertions, 33 deletions
diff --git a/ui/anduril/anduril.c b/ui/anduril/anduril.c
index e72c3b5..1cdb8d0 100644
--- a/ui/anduril/anduril.c
+++ b/ui/anduril/anduril.c
@@ -34,16 +34,19 @@
* as possible. These are mostly "USE" flags.
*/
+/********* load up MCU info, like ROM size and such *********/
+#include "arch/mcu.h"
+
/********* User-configurable options *********/
#include "anduril/config-default.h"
/********* specific settings for known driver types *********/
-// Anduril config file name (set it here or define it at the gcc command line)
-//#define CFG_H cfg-blf-q8.h
-#include "fsm/tk.h"
#include incfile(CFG_H)
+#ifdef HWDEF_H
+#include incfile(HWDEF_H)
+#endif
/********* Include headers which need to be before FSM *********/
@@ -77,11 +80,12 @@
#include "fsm/spaghetti-monster.h"
/********* does this build target have special code to include? *********/
-#ifdef HWDEF_C_FILE
-#include incfile(HWDEF_C_FILE)
+#ifdef CFG_C
+#include incfile(CFG_C)
#endif
-#ifdef CFG_C_FILE
-#include incfile(CFG_C_FILE)
+
+#ifdef HWDEF_C
+#include incfile(HWDEF_C)
#endif
@@ -312,6 +316,7 @@ void loop() {
#ifdef USE_BATTCHECK
else if (state == battcheck_state) {
+ nice_delay_ms(1000); // wait a moment for a more accurate reading
battcheck();
#ifdef USE_SIMPLE_UI
// in simple mode, turn off after one readout
diff --git a/ui/anduril/aux-leds.c b/ui/anduril/aux-leds.c
index 1b30d34..fd184fc 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
- 9, 1, // R
- 10, 2, // R+G
- 11, 3, // G
- 12, 4, // G+B
- 13, 5, // B
- 14, 6, // R + B
- 15, 7, // R+G+B
- 20, 0, // black
+ 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
#endif
// li-ion voltages
- 29, 1, // R
- 33, 2, // R+G
- 35, 3, // G
- 37, 4, // G+B
- 39, 5, // B
- 41, 6, // R + B
- 44, 7, // R+G+B // skip; looks too similar to G+B
- 255, 7, // R+G+B
+ 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
};
uint8_t volts = voltage;
//if (volts < VOLTAGE_LOW) return 0;
diff --git a/ui/anduril/config-default.h b/ui/anduril/config-default.h
index 899bc4a..1b34e8c 100644
--- a/ui/anduril/config-default.h
+++ b/ui/anduril/config-default.h
@@ -20,7 +20,7 @@
// overheat protection
#define USE_THERMAL_REGULATION
-#if (ATTINY==85) || (ATTINY==1634)
+#if (MCU==0x85) || (MCU==0x1634)
// sloppy temperature sensor needs bigger error margin
#define DEFAULT_THERM_CEIL 45 // try not to get hotter than this (in C)
#else
@@ -113,6 +113,12 @@
// timer is available in regular ramp mode and candle mode
#define USE_SUNSET_TIMER
+// optionally make gradual ticks happen faster
+// Affects: thermal regulation speed, sunset mode, maybe other features
+// (default is calibrated for 8-bit PWM,
+// but 10-bit should set this value to 4 instead of 1)
+#define GRADUAL_ADJUST_SPEED 1
+
///// What to do when power is connected /////
// factory reset function erases user's runtime configuration in eeprom
@@ -137,6 +143,10 @@
#define BATTCHECK_VpT
//#define BATTCHECK_8bars // FIXME: breaks build
//#define BATTCHECK_4bars // FIXME: breaks build
+#if ROM_SIZE > 10000
+ // battcheck displays 1.25V instead of 1.2V
+ #define USE_EXTRA_BATTCHECK_DIGIT
+#endif
// allow the user to calibrate the voltage readings?
// (adjust in 0.05V increments from -0.30V to +0.30V)
// (1 = -0.30V, 2 = -0.25V, ... 7 = 0V, ... 13 = +0.30V)
@@ -185,7 +195,7 @@
// if the aux LEDs oscillate between "full battery" and "empty battery"
// while in "voltage" mode, enable this to reduce the amplitude of
// those oscillations
-#if (ATTINY==1616) || (ATTINY==1634)
+#if (ROM_SIZE > 10000)
#define USE_LOWPASS_WHILE_ASLEEP
#endif
@@ -195,7 +205,7 @@
// Use "smooth steps" to soften on/off and step changes
// on MCUs with enough room for extra stuff like this
-#if (ATTINY==1616) || (ATTINY==1634)
+#if (ROM_SIZE > 10000)
#define USE_SMOOTH_STEPS
#endif
// 0 = none, 1 = smooth, 2+ = undefined
diff --git a/ui/anduril/ramp-mode.c b/ui/anduril/ramp-mode.c
index 9e19025..4c535b4 100644
--- a/ui/anduril/ramp-mode.c
+++ b/ui/anduril/ramp-mode.c
@@ -287,7 +287,7 @@ uint8_t steady_state(Event event, uint16_t arg) {
static uint16_t ticks_since_adjust = 0;
ticks_since_adjust++;
if (diff) {
- uint16_t ticks_per_adjust = 256;
+ uint16_t ticks_per_adjust = 256 / GRADUAL_ADJUST_SPEED;
if (diff < 0) {
//diff = -diff;
if (actual_level > THERM_FASTER_LEVEL) {
diff --git a/ui/anduril/ramp-mode.h b/ui/anduril/ramp-mode.h
index 59c8db0..1392981 100644
--- a/ui/anduril/ramp-mode.h
+++ b/ui/anduril/ramp-mode.h
@@ -4,14 +4,15 @@
#pragma once
-#ifndef RAMP_LENGTH
-#define RAMP_LENGTH 150 // default, if not overridden in a driver cfg file
+#ifndef RAMP_SIZE
+#define RAMP_SIZE 150 // default, if not overridden in a driver cfg file
#endif
+// TODO: Replace MAX_Xx7135 with MAX_CH1, MAX_CH2, MAX_REGULATED, etc
+
// thermal properties, if not defined per-driver
#ifndef MIN_THERM_STEPDOWN
-// TODO: Replace MAX_Xx7135 with MAX_CH1, MAX_CH2, MAX_REGULATED, etc
-#define MIN_THERM_STEPDOWN MAX_1x7135 // lowest value it'll step down to
+#define MIN_THERM_STEPDOWN (RAMP_SIZE/3) // lowest value it'll step down to
#endif
#ifndef THERM_FASTER_LEVEL
#ifdef MAX_Nx7135
diff --git a/ui/anduril/version-check-mode.c b/ui/anduril/version-check-mode.c
index eebe59b..1cd6968 100644
--- a/ui/anduril/version-check-mode.c
+++ b/ui/anduril/version-check-mode.c
@@ -15,7 +15,10 @@ uint8_t version_check_state(Event event, uint16_t arg) {
inline void version_check_iter() {
for (uint8_t i=0; i<sizeof(version_number)-1; i++) {
uint8_t digit = pgm_read_byte(version_number + i) - '0';
- if (digit < 10) blink_digit(digit);
+ // digits: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ // hex digits: 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ // 'model' file: 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
+ if (digit < 16) blink_digit(digit);
else { // "buzz" for non-numeric characters
for(uint8_t frame=0; frame<25; frame++) {
set_level((frame&1) << 5);