aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-11-22 05:34:26 -0700
committerSelene ToyKeeper2023-11-22 05:34:26 -0700
commitbaaa035cf93340b8f2c626bdba47e8066cf40067 (patch)
tree10114a3fa02f301c41da8b07619e146a14186f28 /ui
parentgot ADC voltage+temp working on avrdd... but broke all other builds/MCUs (diff)
downloadanduril-baaa035cf93340b8f2c626bdba47e8066cf40067.tar.gz
anduril-baaa035cf93340b8f2c626bdba47e8066cf40067.tar.bz2
anduril-baaa035cf93340b8f2c626bdba47e8066cf40067.zip
ADC voltage: battcheck 3 digits, fixed t1616, switched back to 8-bit internal volt unit
Before this branch, `voltage` was 6 bits: Volts * 10 A couple patches ago, I upgraded it to 16 bits: 65535 * Volts / 10.24 That costs too much extra ROM on attiny85 though, for extra precision it doesn't even use... so I switched back to an 8-bit value. It's still more precise than before though: Volts * 40 ... and battcheck displays an extra digit now, on devices with ROM for it. ... and battcheck waits a second to get a more accurate measurement before displaying the first value. It has *much* less variation between first and later readings now. Also: - got t1616 builds working again (tested fc13 and thefreeman-boost-fwaa) - upgraded t1616 voltage and temp to 12-bit (10 bits + 4x oversampling) - removed expensive temp conversion from t1616 ADC interrupt - recalibrated t1616 bogomips again; runs faster after interrupt fix - increased t1616 internal VDD measurement resolution by 36% (1.5V Vref, not 1.1V) - fixed sloppy setting of Vref bits I still need to test / update other t1616 builds, and fix all the t85 + t1634 code and build targets.
Diffstat (limited to 'ui')
-rw-r--r--ui/anduril/anduril.c1
-rw-r--r--ui/anduril/aux-leds.c34
-rw-r--r--ui/anduril/config-default.h4
3 files changed, 22 insertions, 17 deletions
diff --git a/ui/anduril/anduril.c b/ui/anduril/anduril.c
index c434518..1cdb8d0 100644
--- a/ui/anduril/anduril.c
+++ b/ui/anduril/anduril.c
@@ -316,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 dce8d26..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
- 16, 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 cd25b52..1b34e8c 100644
--- a/ui/anduril/config-default.h
+++ b/ui/anduril/config-default.h
@@ -143,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)
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.