aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-08-05 20:35:21 -0600
committerSelene ToyKeeper2020-08-05 20:35:21 -0600
commit50ced6ed2852e66a86a607f117f6f772865fccf5 (patch)
tree5ba02d751239e689d96640bbf018afdaaaf7c2a0 /spaghetti-monster
parentfixed bug: main LEDs stayed on while setting aux LED color in lockout mode (diff)
downloadanduril-50ced6ed2852e66a86a607f117f6f772865fccf5.tar.gz
anduril-50ced6ed2852e66a86a607f117f6f772865fccf5.tar.bz2
anduril-50ced6ed2852e66a86a607f117f6f772865fccf5.zip
reduced ROM 10 bytes by cleaning up blink_confirm() calls
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/beacon-mode.c2
-rw-r--r--spaghetti-monster/anduril/lockout-mode.c6
-rw-r--r--spaghetti-monster/anduril/misc.c14
-rw-r--r--spaghetti-monster/anduril/misc.h1
-rw-r--r--spaghetti-monster/anduril/off-mode.c8
-rw-r--r--spaghetti-monster/anduril/sunset-timer.c9
6 files changed, 21 insertions, 19 deletions
diff --git a/spaghetti-monster/anduril/beacon-mode.c b/spaghetti-monster/anduril/beacon-mode.c
index 28ff0bd..e6ac64c 100644
--- a/spaghetti-monster/anduril/beacon-mode.c
+++ b/spaghetti-monster/anduril/beacon-mode.c
@@ -54,7 +54,7 @@ uint8_t beacon_state(Event event, uint16_t arg) {
// hold: configure beacon timing
else if (event == EV_click1_hold) {
if (0 == (arg % TICKS_PER_SECOND)) {
- blink_confirm(1);
+ blink_once();
}
return MISCHIEF_MANAGED;
}
diff --git a/spaghetti-monster/anduril/lockout-mode.c b/spaghetti-monster/anduril/lockout-mode.c
index 66392d9..943114d 100644
--- a/spaghetti-monster/anduril/lockout-mode.c
+++ b/spaghetti-monster/anduril/lockout-mode.c
@@ -92,13 +92,13 @@ uint8_t lockout_state(Event event, uint16_t arg) {
#endif
// 4 clicks: exit and turn on
else if (event == EV_4clicks) {
- blink_confirm(1);
+ blink_once();
set_state(steady_state, memorized_level);
return MISCHIEF_MANAGED;
}
// 4 clicks, but hold last: exit and start at floor
else if (event == EV_click4_hold) {
- blink_confirm(1);
+ blink_once();
// reset button sequence to avoid activating anything in ramp mode
current_event = 0;
// ... and back to ramp mode
@@ -158,7 +158,7 @@ uint8_t lockout_state(Event event, uint16_t arg) {
rgb_led_lockout_mode = (mode << 4) | (rgb_led_lockout_mode & 0x0f);
rgb_led_update(rgb_led_lockout_mode, 0);
save_config();
- blink_confirm(1);
+ blink_once();
return MISCHIEF_MANAGED;
}
// 7H: change RGB aux LED color
diff --git a/spaghetti-monster/anduril/misc.c b/spaghetti-monster/anduril/misc.c
index a03225c..182c7e5 100644
--- a/spaghetti-monster/anduril/misc.c
+++ b/spaghetti-monster/anduril/misc.c
@@ -23,15 +23,21 @@
#include "misc.h"
void blink_confirm(uint8_t num) {
+ uint8_t brightness = actual_level;
+ uint8_t bump = actual_level + (MAX_LEVEL/4);
+ if (bump > MAX_LEVEL) bump = 0;
for (; num>0; num--) {
- set_level(MAX_LEVEL/4);
+ set_level(bump);
delay_4ms(10/4);
- set_level(0);
- // TODO: only do this delay if num > 1
- delay_4ms(100/4);
+ set_level(brightness);
+ if (num > 1) { delay_4ms(100/4); }
}
}
+void blink_once() {
+ blink_confirm(1);
+}
+
// Just go dark for a moment to indicate to user that something happened
void blip() {
uint8_t temp = actual_level;
diff --git a/spaghetti-monster/anduril/misc.h b/spaghetti-monster/anduril/misc.h
index e582a71..548cc23 100644
--- a/spaghetti-monster/anduril/misc.h
+++ b/spaghetti-monster/anduril/misc.h
@@ -21,6 +21,7 @@
#define MISC_H
void blink_confirm(uint8_t num);
+void blink_once();
void blip();
diff --git a/spaghetti-monster/anduril/off-mode.c b/spaghetti-monster/anduril/off-mode.c
index 07331f1..50d1dcf 100644
--- a/spaghetti-monster/anduril/off-mode.c
+++ b/spaghetti-monster/anduril/off-mode.c
@@ -185,7 +185,7 @@ uint8_t off_state(Event event, uint16_t arg) {
// 8 clicks, but hold last click: turn simple UI off (or configure it)
else if ((event == EV_click8_hold) && (!arg)) {
if (simple_ui_active) { // turn off simple UI
- blink_confirm(1);
+ blink_once();
simple_ui_active = 0;
save_config();
}
@@ -201,7 +201,7 @@ uint8_t off_state(Event event, uint16_t arg) {
}
// 8 clicks: enable simple UI
else if (event == EV_8clicks) {
- blink_confirm(1);
+ blink_once();
simple_ui_active = 1;
save_config();
return MISCHIEF_MANAGED;
@@ -223,7 +223,7 @@ uint8_t off_state(Event event, uint16_t arg) {
#ifdef USE_MOMENTARY_MODE
// 5 clicks: momentary mode
else if (event == EV_5clicks) {
- blink_confirm(1);
+ blink_once();
set_state(momentary_state, 0);
return MISCHIEF_MANAGED;
}
@@ -253,7 +253,7 @@ uint8_t off_state(Event event, uint16_t arg) {
rgb_led_off_mode = (mode << 4) | (rgb_led_off_mode & 0x0f);
rgb_led_update(rgb_led_off_mode, 0);
save_config();
- blink_confirm(1);
+ blink_once();
return MISCHIEF_MANAGED;
}
// 7 clicks (hold last): change RGB aux LED color
diff --git a/spaghetti-monster/anduril/sunset-timer.c b/spaghetti-monster/anduril/sunset-timer.c
index b083515..5a2ba18 100644
--- a/spaghetti-monster/anduril/sunset-timer.c
+++ b/spaghetti-monster/anduril/sunset-timer.c
@@ -51,13 +51,8 @@ uint8_t sunset_timer_state(Event event, uint16_t arg) {
sunset_timer += SUNSET_TIMER_UNIT;
sunset_timer_peak = sunset_timer; // reset ceiling
sunset_ticks = 0; // reset phase
- // blink to confirm
- uint8_t brightness = actual_level;
- uint8_t bump = actual_level + 32;
- if (bump > MAX_LEVEL) bump = 0;
- set_level(bump);
- delay_4ms(2);
- set_level(brightness);
+ // let the user know something happened
+ blink_once();
}
}
return MISCHIEF_MANAGED;
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.