aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/fsm-events.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-events.c b/spaghetti-monster/fsm-events.c
index e965224..b8e9018 100644
--- a/spaghetti-monster/fsm-events.c
+++ b/spaghetti-monster/fsm-events.c
@@ -125,16 +125,34 @@ uint8_t nice_delay_ms(uint16_t ms) {
*/
while(ms-- > 0) {
#ifdef USE_DYNAMIC_UNDERCLOCKING
+ #ifdef USE_RAMPING
+ uint8_t level = actual_level; // volatile, avoid repeat access
+ if (level < QUARTERSPEED_LEVEL) {
+ CLKPR = 1<<CLKPCE; CLKPR = 2;
+ _delay_loop_2(BOGOMIPS*98/100/4);
+ }
+ //else if (level < HALFSPEED_LEVEL) {
+ // CLKPR = 1<<CLKPCE; CLKPR = 1;
+ // _delay_loop_2(BOGOMIPS*98/100/2);
+ //}
+ else {
+ CLKPR = 1<<CLKPCE; CLKPR = 0;
+ _delay_loop_2(BOGOMIPS*98/100);
+ }
+ // restore regular clock speed
+ CLKPR = 1<<CLKPCE; CLKPR = 0;
+ #else
// underclock MCU to save power
CLKPR = 1<<CLKPCE; CLKPR = 2;
// wait
_delay_loop_2(BOGOMIPS*98/100/4);
// restore regular clock speed
CLKPR = 1<<CLKPCE; CLKPR = 0;
+ #endif // ifdef USE_RAMPING
#else
// wait
_delay_loop_2(BOGOMIPS*98/100);
- #endif
+ #endif // ifdef USE_DYNAMIC_UNDERCLOCKING
process_emissions();
if ((nice_delay_interrupt) || (old_state != current_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.