aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2018-09-13 03:44:23 -0600
committerSelene ToyKeeper2018-09-13 03:44:23 -0600
commit215a56b08586dcf4352b6eb2713f5238a4d5b360 (patch)
treeb9eb06ecc88e9941273a04470bad97a6f6078081 /spaghetti-monster
parentfixed bug: clicking MAX_CLICKS+1 times and holding the final click would hang... (diff)
downloadanduril-215a56b08586dcf4352b6eb2713f5238a4d5b360.tar.gz
anduril-215a56b08586dcf4352b6eb2713f5238a4d5b360.tar.bz2
anduril-215a56b08586dcf4352b6eb2713f5238a4d5b360.zip
Added tint ramping. Not tested yet. Also added BLF Lantern build target.
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/anduril.c43
-rwxr-xr-xspaghetti-monster/anduril/build-all.sh1
-rw-r--r--spaghetti-monster/fsm-ramping.c20
-rw-r--r--spaghetti-monster/fsm-ramping.h4
4 files changed, 67 insertions, 1 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index c8517af..07d51f5 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -75,6 +75,9 @@
#elif defined(FSM_BLF_GT_MINI_DRIVER)
#include "cfg-blf-gt-mini.h"
+#elif defined(FSM_BLF_LANTERN_DRIVER)
+#include "cfg-blf-lantern.h"
+
#elif defined(FSM_BLF_Q8_DRIVER)
#include "cfg-blf-q8.h"
@@ -204,6 +207,10 @@ uint8_t config_state_values[MAX_CONFIG_VALUES];
// ramping mode and its related config mode
uint8_t steady_state(EventPtr event, uint16_t arg);
uint8_t ramp_config_state(EventPtr event, uint16_t arg);
+#ifdef USE_TINT_RAMPING
+// not actually a mode, more of a fallback under other modes
+uint8_t tint_ramping_state(EventPtr event, uint16_t arg);
+#endif
// party and tactical strobes
#ifdef USE_STROBE_STATE
uint8_t strobe_state(EventPtr event, uint16_t arg);
@@ -784,6 +791,34 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
}
+#ifdef USE_TINT_RAMPING
+uint8_t tint_ramping_state(EventPtr event, uint16_t arg) {
+ static int8_t tint_ramp_direction = 1;
+
+ // click, click, hold: change the tint
+ if (event == EV_click3_hold) {
+ if ((arg & 1) == 0) { // ramp slower
+ if ((tint_ramp_direction > 0) && (tint < 255)) {
+ tint += 1;
+ }
+ else if ((tint_ramp_direction < 0) && (tint > 0)) {
+ tint -= 1;
+ }
+ }
+ return EVENT_HANDLED;
+ }
+
+ // click, click, hold, release: reverse direction for next ramp
+ else if (event == EV_click3_hold_release) {
+ tint_ramp_direction = -tint_ramp_direction;
+ return EVENT_HANDLED;
+ }
+
+ return EVENT_NOT_HANDLED;
+}
+#endif // ifdef USE_TINT_RAMPING
+
+
#ifdef USE_STROBE_STATE
uint8_t strobe_state(EventPtr event, uint16_t arg) {
// 'st' reduces ROM size by avoiding access to a volatile var
@@ -1786,14 +1821,20 @@ void setup() {
load_config();
+ #ifdef USE_TINT_RAMPING
+ // add tint ramping underneath every other state
+ push_state(tint_ramping_state, 0);
+
#ifdef USE_MUGGLE_MODE
if (muggle_mode_active)
push_state(muggle_state, (MUGGLE_FLOOR+MUGGLE_CEILING)/2);
else
#endif
push_state(off_state, 0);
- #endif
+ #endif // ifdef USE_TINT_RAMPING
+
+ #endif // ifdef START_AT_MEMORIZED_LEVEL
}
diff --git a/spaghetti-monster/anduril/build-all.sh b/spaghetti-monster/anduril/build-all.sh
index 794b285..98f95f5 100755
--- a/spaghetti-monster/anduril/build-all.sh
+++ b/spaghetti-monster/anduril/build-all.sh
@@ -5,6 +5,7 @@ UI=anduril
for TARGET in \
BLF_GT \
BLF_GT_MINI \
+ BLF_LANTERN \
BLF_Q8 \
EMISAR_D1 \
EMISAR_D1S \
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c
index 6cdf5e6..0492943 100644
--- a/spaghetti-monster/fsm-ramping.c
+++ b/spaghetti-monster/fsm-ramping.c
@@ -25,9 +25,20 @@
void set_level(uint8_t level) {
actual_level = level;
+
+ #ifdef USE_TINT_RAMPING
+ // calculate actual PWM levels based on a single-channel ramp
+ // and a global tint value
+ uint8_t brightness = pgm_read_byte(pwm1_levels + level);
+ uint8_t warm_PWM, cool_PWM;
+ cool_PWM = (uint16_t)tint * brightness / 255;
+ warm_PWM = brightness - cool_PWM;
+ #endif
+
#ifdef USE_SET_LEVEL_GRADUALLY
gradual_target = level;
#endif
+
#ifdef USE_INDICATOR_LED
#ifdef USE_INDICATOR_LED_WHILE_RAMPING
if (! go_to_standby)
@@ -40,6 +51,7 @@ void set_level(uint8_t level) {
indicator_led(0);
#endif
#endif
+
//TCCR0A = PHASE;
if (level == 0) {
#if PWM_CHANNELS >= 1
@@ -56,6 +68,12 @@ void set_level(uint8_t level) {
#endif
} else {
level --;
+
+ #ifdef USE_TINT_RAMPING
+ PWM1_LVL = warm_PWM;
+ PWM2_LVL = cool_PWM;
+ #else
+
#if PWM_CHANNELS >= 1
PWM1_LVL = pgm_read_byte(pwm1_levels + level);
#endif
@@ -68,6 +86,8 @@ void set_level(uint8_t level) {
#if PWM_CHANNELS >= 4
PWM4_LVL = pgm_read_byte(pwm4_levels + level);
#endif
+
+ #endif // ifdef USE_TINT_RAMPING
}
#ifdef USE_DYNAMIC_UNDERCLOCKING
auto_clock_speed();
diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h
index 14c8dae..9732b9c 100644
--- a/spaghetti-monster/fsm-ramping.h
+++ b/spaghetti-monster/fsm-ramping.h
@@ -26,6 +26,10 @@
// actual_level: last ramp level set by set_level()
volatile uint8_t actual_level = 0;
+#ifdef USE_TINT_RAMPING
+uint8_t tint = 0;
+#endif
+
#ifdef USE_SET_LEVEL_GRADUALLY
// adjust brightness very smoothly
volatile uint8_t gradual_target;
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.