aboutsummaryrefslogtreecommitdiff
path: root/hw/hank/lume-x1/hwdef.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-09-22 17:15:47 -0600
committerSelene ToyKeeper2024-09-22 17:15:47 -0600
commit6be8fff532c4be83126517a6e3b7b725548761c2 (patch)
tree10865593112cc903c5558bdf0dc6b892367f3883 /hw/hank/lume-x1/hwdef.c
parentcherry-picked hank-lume-x1 code from https://github.com/loneoceans/anduril/co... (diff)
downloadanduril-6be8fff532c4be83126517a6e3b7b725548761c2.tar.gz
anduril-6be8fff532c4be83126517a6e3b7b725548761c2.tar.bz2
anduril-6be8fff532c4be83126517a6e3b7b725548761c2.zip
hank-lume-x1 cleanup and calibration, part 1:
- changed model number from 0281 to 0171 - cleaned up blink_negative and AUXLED_RGB_DIFFERENT_PORTS a little (but the latter needs a complete refactor, as soon as the hardware abstraction code can handle aux LEDs better) - cleaned up USE_LONG_BLINK_FOR_NEGATIVE_SIGN a little - removed USE_OTG_IN_MOMENTARY since it's not actually used - moved hw/loneoceans/lume-x1-avr32dd20/* files into hw/hank/lume-x1/ - superficial cleanup on hank/lume-x1/hwdef.* - removed some of the extra stuff from hank/lume-x1/anduril.h - adjusted calibration (especially ramp table) on hank-lume-x1 (ramp shape is pretty close to a D4K-boost now, but with more firefly modes) (calibration is based on a sample size of 1, further testing needed)
Diffstat (limited to '')
-rw-r--r--hw/hank/lume-x1/hwdef.c (renamed from hw/loneoceans/lume-x1-avr32dd20/hwdef.c)68
1 files changed, 27 insertions, 41 deletions
diff --git a/hw/loneoceans/lume-x1-avr32dd20/hwdef.c b/hw/hank/lume-x1/hwdef.c
index 275037b..3fe32f3 100644
--- a/hw/loneoceans/lume-x1-avr32dd20/hwdef.c
+++ b/hw/hank/lume-x1/hwdef.c
@@ -11,13 +11,12 @@
#include "fsm/chan-rgbaux.c"
// Declare variables and functions to support UDR multiple power paths
-uint8_t power_path_level = 0; // 0 = off, 1 = firefly, 2 = low, 3 = high
uint8_t is_boost_currently_on = 0; // for turn-on delay during first turn on
-void set_level_udr(uint8_t level);
-void set_power_path(uint8_t ramp_level);
void set_level_zero();
+void set_level_udr(uint8_t level);
bool gradual_tick_main(uint8_t gt);
+void set_power_path(uint8_t ramp_level);
Channel channels[] = {
{ // main LEDs
@@ -30,16 +29,15 @@ Channel channels[] = {
// turn off
void set_level_zero() {
- power_path_level = 0; // set power path level to 0
DAC_LVL = 0; // set DAC to 0
- DAC_VREF = V10; // set DAC Vref to lowest
+ DAC_VREF = V10; // set DAC Vref to lowest
- // turn off DC/DC converter and amplifier
+ // turn off DC/DC converter and amplifier
BST_ENABLE_PORT &= ~(1 << BST_ENABLE_PIN);
is_boost_currently_on = 0;
// turn off all UDR paths
- LED_PATH1_PORT &= ~LED_PATH1_PIN;
+ LED_PATH1_PORT &= ~LED_PATH1_PIN;
LED_PATH2_PORT &= ~LED_PATH2_PIN;
LED_PATH3_PORT &= ~LED_PATH3_PIN;
}
@@ -67,64 +65,52 @@ void set_level_udr(uint8_t level) {
set_power_path(level);
}
-// handles dynamic Vref used in the ramp tables
+// handles dynamic Vref used in the ramp tables
bool gradual_tick_main(uint8_t gt) {
// TODO overall smoothness can be improved due to gt using linear
// adjustments, but ramp table is non-linear.
- // if Vref is the same, make gradual adjustments.
+ // if Vref is the same, make gradual adjustments.
// else, jump to the next ramp level and use set_level() to handle power paths.
PWM2_DATATYPE vref_next = PWM2_GET(gt); // DAC ramp table Vref
// if different vref level, make a ramp level adjustment..
if (vref_next != DAC_VREF) return true; // use set_level() to handle normally
- // .. else, same vref, adjust level gradually.
+ // .. else, same vref, adjust level gradually.
PWM1_DATATYPE dac_next = PWM1_GET(gt); // DAC ramp table data
PWM1_DATATYPE dac_curr = DAC_LVL >> 6; // register is left-aligned
GRADUAL_ADJUST_SIMPLE(dac_next, dac_curr);
DAC_LVL = dac_curr << 6;
-
+
if (dac_next == dac_curr) return true; // done
return false;
}
-// handles dynamic power pathways based on threshold levels
+// handles dynamic power pathways based on threshold levels
void set_power_path(uint8_t ramp_level){
- ramp_level++; // convert to 1-based indexing
-
- // check if the ramp level corresponds to a new power path or not;
- // if it doesn't, no need to change anything.
- if (ramp_level>=LED_PATH3_PIN_LEVEL_MIN){
- if (power_path_level != 3){
- // high Mode
- LED_PATH1_PORT |= LED_PATH1_PIN;
- LED_PATH2_PORT |= LED_PATH2_PIN;
- LED_PATH3_PORT |= LED_PATH3_PIN;
- power_path_level = 3;
- }
+ ramp_level ++; // convert to 1-based indexing
+
+ if (ramp_level >= LED_PATH3_PIN_LEVEL_MIN) {
+ // high mode
+ LED_PATH1_PORT |= LED_PATH1_PIN;
+ LED_PATH2_PORT |= LED_PATH2_PIN;
+ LED_PATH3_PORT |= LED_PATH3_PIN;
}
- else if (ramp_level>=LED_PATH2_PIN_LEVEL_MIN){
- if (power_path_level != 2){
- // low Mode
- //LED_PATH1_PORT &= ~LED_PATH1_PIN;
- LED_PATH1_PORT |= LED_PATH1_PIN;
- LED_PATH2_PORT |= LED_PATH2_PIN;
- LED_PATH3_PORT &= ~LED_PATH3_PIN;
- power_path_level = 2;
- }
+ else if (ramp_level >= LED_PATH2_PIN_LEVEL_MIN) {
+ // low mode
+ LED_PATH1_PORT |= LED_PATH1_PIN;
+ LED_PATH2_PORT |= LED_PATH2_PIN;
+ LED_PATH3_PORT &= ~LED_PATH3_PIN;
}
- else if (ramp_level>=LED_PATH1_PIN_LEVEL_MIN){
- if (power_path_level != 1){
- // firefly mode
- LED_PATH1_PORT |= LED_PATH1_PIN;
- LED_PATH2_PORT &= ~LED_PATH2_PIN;
- LED_PATH3_PORT &= ~LED_PATH3_PIN;
- power_path_level = 1;
- }
+ else if (ramp_level >= LED_PATH1_PIN_LEVEL_MIN) {
+ // firefly mode
+ LED_PATH1_PORT |= LED_PATH1_PIN;
+ LED_PATH2_PORT &= ~LED_PATH2_PIN;
+ LED_PATH3_PORT &= ~LED_PATH3_PIN;
}
}