aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-11-14 18:28:52 -0700
committerSelene ToyKeeper2019-11-14 18:28:52 -0700
commit81ed77d88c999f9c2368718047d0969fef44e534 (patch)
tree9b1bc0b4e27241c61b6052c187e1e347d9ded2ed
parentfixed ADC code; measures and behaves correctly now, and is easier to read... (diff)
downloadanduril-81ed77d88c999f9c2368718047d0969fef44e534.tar.gz
anduril-81ed77d88c999f9c2368718047d0969fef44e534.tar.bz2
anduril-81ed77d88c999f9c2368718047d0969fef44e534.zip
fixed factory reset (wasn't running interrupt logic since it's deferred now)
(also fixed issue where nice_delay_ms() was aborted during setup()) (and adjusted the timing to make factory reset similar to the speed it was before this change)
-rw-r--r--spaghetti-monster/anduril/anduril.c10
-rw-r--r--spaghetti-monster/fsm-events.c12
-rw-r--r--spaghetti-monster/fsm-main.c1
3 files changed, 11 insertions, 12 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 48f4ac1..19d61b7 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -2356,7 +2356,7 @@ void rgb_led_update(uint8_t mode, uint8_t arg) {
void factory_reset() {
// display a warning for a few seconds before doing the actual reset,
// so the user has time to abort if they want
- #define SPLODEY_TIME 3000
+ #define SPLODEY_TIME 2500
#define SPLODEY_STEPS 64
#define SPLODEY_TIME_PER_STEP (SPLODEY_TIME/SPLODEY_STEPS)
uint8_t bright;
@@ -2364,9 +2364,9 @@ void factory_reset() {
// wind up to an explosion
for (bright=0; bright<SPLODEY_STEPS; bright++) {
set_level(bright);
- delay_4ms(SPLODEY_TIME_PER_STEP/2/4);
+ nice_delay_ms(SPLODEY_TIME_PER_STEP/2);
set_level(bright>>1);
- delay_4ms(SPLODEY_TIME_PER_STEP/2/4);
+ nice_delay_ms(SPLODEY_TIME_PER_STEP/2);
if (! button_is_pressed()) {
reset = 0;
break;
@@ -2387,14 +2387,14 @@ void factory_reset() {
bright = MAX_LEVEL;
for (; bright > 0; bright--) {
set_level(bright);
- delay_4ms(SPLODEY_TIME_PER_STEP/6/4);
+ nice_delay_ms(SPLODEY_TIME_PER_STEP/8);
}
}
// explosion cancelled, fade away
else {
for (; bright > 0; bright--) {
set_level(bright);
- delay_4ms(SPLODEY_TIME_PER_STEP/3/4);
+ nice_delay_ms(SPLODEY_TIME_PER_STEP/3);
}
}
}
diff --git a/spaghetti-monster/fsm-events.c b/spaghetti-monster/fsm-events.c
index e125e84..a1b013a 100644
--- a/spaghetti-monster/fsm-events.c
+++ b/spaghetti-monster/fsm-events.c
@@ -110,7 +110,7 @@ uint8_t nice_delay_ms(uint16_t ms) {
/* // delay_zero() implementation
if (ms == 0) {
CLKPR = 1<<CLKPCE; CLKPR = 0; // full speed
- _delay_loop_2(BOGOMIPS*98/100/3);
+ _delay_loop_2(BOGOMIPS*95/100/3);
return 1;
}
*/
@@ -120,15 +120,15 @@ uint8_t nice_delay_ms(uint16_t ms) {
uint8_t level = actual_level; // volatile, avoid repeat access
if (level < QUARTERSPEED_LEVEL) {
clock_prescale_set(clock_div_4);
- _delay_loop_2(BOGOMIPS*98/100/4);
+ _delay_loop_2(BOGOMIPS*95/100/4);
}
//else if (level < HALFSPEED_LEVEL) {
// clock_prescale_set(clock_div_2);
- // _delay_loop_2(BOGOMIPS*98/100/2);
+ // _delay_loop_2(BOGOMIPS*95/100/2);
//}
else {
clock_prescale_set(clock_div_1);
- _delay_loop_2(BOGOMIPS*98/100);
+ _delay_loop_2(BOGOMIPS*95/100);
}
// restore regular clock speed
clock_prescale_set(clock_div_1);
@@ -136,13 +136,13 @@ uint8_t nice_delay_ms(uint16_t ms) {
// underclock MCU to save power
clock_prescale_set(clock_div_4);
// wait
- _delay_loop_2(BOGOMIPS*98/100/4);
+ _delay_loop_2(BOGOMIPS*95/100/4);
// restore regular clock speed
clock_prescale_set(clock_div_1);
#endif // ifdef USE_RAMPING
#else
// wait
- _delay_loop_2(BOGOMIPS*98/100);
+ _delay_loop_2(BOGOMIPS*95/100);
#endif // ifdef USE_DYNAMIC_UNDERCLOCKING
// run pending system processes while we wait
diff --git a/spaghetti-monster/fsm-main.c b/spaghetti-monster/fsm-main.c
index a898f41..c9ab69b 100644
--- a/spaghetti-monster/fsm-main.c
+++ b/spaghetti-monster/fsm-main.c
@@ -123,7 +123,6 @@ int main() {
#else
delay_4ms(1);
#endif
- empty_event_sequence();
// fallback for handling a few things
#ifndef DONT_USE_DEFAULT_STATE
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.