aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-events.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-08-11 15:16:23 -0600
committerSelene ToyKeeper2019-08-11 15:16:23 -0600
commit89a86871aa6330218043586f0347c0c1e7c79dab (patch)
treee3a4cc2a4517e5563e91cdaaf86718170d4f0a37 /spaghetti-monster/fsm-events.c
parentAdded setup info for Fedora. (diff)
parentadded scripts to flash attiny1634, which were missing before (diff)
downloadanduril-89a86871aa6330218043586f0347c0c1e7c79dab.tar.gz
anduril-89a86871aa6330218043586f0347c0c1e7c79dab.tar.bz2
anduril-89a86871aa6330218043586f0347c0c1e7c79dab.zip
merged fsm to trunk... lots of updates:
+ attiny1634 support + Emisar D4v2 support + Mateminco MF01S / MT18 support + Fireflies E01 and E07v2 support + RGB aux LED support + added factory reset function + added manual / automatic memory toggle + added 2-level brightness during lockout + added Fireflies UI + made momentary mode also support strobe-group modes * thermal regulation rewritten, behaves mostly better now * strobe modes auto-reverse their ramp now * muggle mode fixes * UI diagram and manual updated * button timing adjusted, and compile-time options added for it * general refactoring
Diffstat (limited to 'spaghetti-monster/fsm-events.c')
-rw-r--r--spaghetti-monster/fsm-events.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/spaghetti-monster/fsm-events.c b/spaghetti-monster/fsm-events.c
index 72216ae..362a5cc 100644
--- a/spaghetti-monster/fsm-events.c
+++ b/spaghetti-monster/fsm-events.c
@@ -20,6 +20,7 @@
#ifndef FSM_EVENTS_C
#define FSM_EVENTS_C
+
void empty_event_sequence() {
current_event = EV_none;
// when the user completes an input sequence, interrupt any running timers
@@ -116,26 +117,26 @@ uint8_t nice_delay_ms(uint16_t ms) {
#ifdef USE_RAMPING
uint8_t level = actual_level; // volatile, avoid repeat access
if (level < QUARTERSPEED_LEVEL) {
- CLKPR = 1<<CLKPCE; CLKPR = 2;
+ clock_prescale_set(clock_div_4);
_delay_loop_2(BOGOMIPS*98/100/4);
}
//else if (level < HALFSPEED_LEVEL) {
- // CLKPR = 1<<CLKPCE; CLKPR = 1;
+ // clock_prescale_set(clock_div_2);
// _delay_loop_2(BOGOMIPS*98/100/2);
//}
else {
- CLKPR = 1<<CLKPCE; CLKPR = 0;
+ clock_prescale_set(clock_div_1);
_delay_loop_2(BOGOMIPS*98/100);
}
// restore regular clock speed
- CLKPR = 1<<CLKPCE; CLKPR = 0;
+ clock_prescale_set(clock_div_1);
#else
// underclock MCU to save power
- CLKPR = 1<<CLKPCE; CLKPR = 2;
+ clock_prescale_set(clock_div_4);
// wait
_delay_loop_2(BOGOMIPS*98/100/4);
// restore regular clock speed
- CLKPR = 1<<CLKPCE; CLKPR = 0;
+ clock_prescale_set(clock_div_1);
#endif // ifdef USE_RAMPING
#else
// wait
@@ -159,11 +160,18 @@ uint8_t nice_delay_ms(uint16_t ms) {
void delay_4ms(uint8_t ms) {
while(ms-- > 0) {
// underclock MCU to save power
- CLKPR = 1<<CLKPCE; CLKPR = 2;
+ clock_prescale_set(clock_div_4);
// wait
_delay_loop_2(BOGOMIPS*98/100);
// restore regular clock speed
- CLKPR = 1<<CLKPCE; CLKPR = 0;
+ clock_prescale_set(clock_div_1);
+ }
+}
+#else
+void delay_4ms(uint8_t ms) {
+ while(ms-- > 0) {
+ // wait
+ _delay_loop_2(BOGOMIPS*398/100);
}
}
#endif