From 39b30b41f92978a3e05a8de0a416279fb35b35b1 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Fri, 25 Aug 2017 02:14:31 -0600
Subject: Added battcheck mode to ramping-ui. It's bigger than I had hoped.
:( Added fsm-misc.*, which currently only has interruptible blink functions
in it. (for blinking out numbers and such)
---
spaghetti-monster/fsm-misc.c | 91 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 91 insertions(+)
create mode 100644 spaghetti-monster/fsm-misc.c
(limited to 'spaghetti-monster/fsm-misc.c')
diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c
new file mode 100644
index 0000000..46325ef
--- /dev/null
+++ b/spaghetti-monster/fsm-misc.c
@@ -0,0 +1,91 @@
+/*
+ * fsm-misc.c: Miscellaneous function for SpaghettiMonster.
+ *
+ * Copyright (C) 2017 Selene ToyKeeper
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef FSM_MISC_C
+#define FSM_MISC_C
+
+#ifdef USE_BLINK_NUM
+uint8_t blink_digit(uint8_t num) {
+ //StatePtr old_state = current_state;
+
+ // "zero" digit gets a single short blink
+ uint8_t ontime = 200;
+ if (!num) { ontime = 8; num ++; }
+
+ for (; num>0; num--) {
+ set_level(BLINK_BRIGHTNESS);
+ if (! nice_delay_ms(ontime)) { set_level(0); return 0; }
+ set_level(0);
+ //if (current_state != old_state) return 0;
+ if (! nice_delay_ms(400)) return 0;
+ //if (current_state != old_state) return 0;
+ }
+ return nice_delay_ms(600);
+}
+
+uint8_t blink_num(uint8_t num) {
+ //StatePtr old_state = current_state;
+ #if 0
+ uint8_t hundreds = num / 100;
+ num = num % 100;
+ uint8_t tens = num / 10;
+ num = num % 10;
+ #else // 8 bytes smaller
+ uint8_t hundreds = 0;
+ uint8_t tens = 0;
+ for(; num >= 100; hundreds ++, num -= 100);
+ for(; num >= 10; tens ++, num -= 10);
+ #endif
+
+ #if 0
+ // wait a moment in the dark before starting
+ set_level(0);
+ if (! nice_delay_ms(200)) return 0;
+ #endif
+
+ #if 0
+ if (hundreds) {
+ if (! blink_digit(hundreds)) return 0;
+ if (! blink_digit(tens)) return 0;
+ }
+ else if (tens) {
+ if (! blink_digit(tens)) return 0;
+ }
+ if (! blink_digit(num)) return 0;
+ return nice_delay_ms(1000);
+ #else // same size :(
+ if (hundreds) if (! blink_digit(hundreds)) return 0;
+ if (hundreds || tens) if (! blink_digit(tens)) return 0;
+ if (! blink_digit(num)) return 0;
+ return nice_delay_ms(1000);
+ #endif
+
+ /*
+ uint8_t volts, tenths;
+ volts = voltage / 10;
+ tenths = voltage % 10;
+ if (! blink(volts)) return;
+ if (! nice_delay_ms(200)) return;
+ if (! blink(tenths)) return;
+ nice_delay_ms(200);
+ */
+}
+#endif
+
+#endif
--
cgit v1.2.3
From 4052efbf6d7993c6b846105e870b1fcbcdb761e7 Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Fri, 25 Aug 2017 02:32:43 -0600
Subject: Made 4bar and 8bar battcheck styles work. Added LVP handling for
other modes, including battcheck.
---
spaghetti-monster/fsm-misc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'spaghetti-monster/fsm-misc.c')
diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c
index 46325ef..7322a59 100644
--- a/spaghetti-monster/fsm-misc.c
+++ b/spaghetti-monster/fsm-misc.c
@@ -20,7 +20,7 @@
#ifndef FSM_MISC_C
#define FSM_MISC_C
-#ifdef USE_BLINK_NUM
+#if defined(USE_BLINK_NUM) || defined(USE_BLINK_DIGIT)
uint8_t blink_digit(uint8_t num) {
//StatePtr old_state = current_state;
@@ -38,7 +38,9 @@ uint8_t blink_digit(uint8_t num) {
}
return nice_delay_ms(600);
}
+#endif
+#ifdef USE_BLINK_NUM
uint8_t blink_num(uint8_t num) {
//StatePtr old_state = current_state;
#if 0
--
cgit v1.2.3
From a419850e536f00549120255a627137faffded47a Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Sun, 3 Sep 2017 14:58:22 -0600
Subject: Got the 4th PWM channel to work, ish. (channel 4 is inverted though)
Moved go_to_suspend thing into main() instead of making each UI handle that
during loop(). Made default_state() optional. Fixed bug where battcheck and
other number readouts could interfere with the state which interrupted them.
(they would sometimes turn the LED off after the new state had already
started) Updated darkhorse's moon levels to match new ramp on D4 hardware.
---
spaghetti-monster/fsm-misc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'spaghetti-monster/fsm-misc.c')
diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c
index 7322a59..5d28002 100644
--- a/spaghetti-monster/fsm-misc.c
+++ b/spaghetti-monster/fsm-misc.c
@@ -30,7 +30,7 @@ uint8_t blink_digit(uint8_t num) {
for (; num>0; num--) {
set_level(BLINK_BRIGHTNESS);
- if (! nice_delay_ms(ontime)) { set_level(0); return 0; }
+ if (! nice_delay_ms(ontime)) { return 0; }
set_level(0);
//if (current_state != old_state) return 0;
if (! nice_delay_ms(400)) return 0;
--
cgit v1.2.3
From 45e3a7758046536754f073c42ac27dc737e69fab Mon Sep 17 00:00:00 2001
From: Selene ToyKeeper
Date: Tue, 26 Sep 2017 16:47:44 -0600
Subject: Added dynamic underclocking to FSM, instead of doing it manually in
Anduril.
---
spaghetti-monster/fsm-misc.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
(limited to 'spaghetti-monster/fsm-misc.c')
diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c
index 5d28002..1b8f864 100644
--- a/spaghetti-monster/fsm-misc.c
+++ b/spaghetti-monster/fsm-misc.c
@@ -20,6 +20,25 @@
#ifndef FSM_MISC_C
#define FSM_MISC_C
+#ifdef USE_DYNAMIC_UNDERCLOCKING
+void auto_clock_speed() {
+ uint8_t level = actual_level; // volatile, avoid repeat access
+ if (level < QUARTERSPEED_LEVEL) {
+ // run at quarter speed
+ // note: this only works when executed as two consecutive instructions
+ // (don't try to combine them or put other stuff between)
+ CLKPR = 1< MAX_1x7135) indicator_led(2);
+ else if (actual_level > 0) indicator_led(1);
+ else indicator_led(0);
+}
+*/
+#endif // USE_INDICATOR_LED
+
+
#endif
--
cgit v1.2.3