From: Jan "Yenya" Kasprzak Date: Wed, 1 May 2013 22:09:32 +0000 (+0200) Subject: power off by default, power on/off with button X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=tinyboard.git;a=commitdiff_plain;h=3e9d94b2511bc76aab92b2af38aacadf2dbe4dab power off by default, power on/off with button --- diff --git a/projects/step-up/adc.c b/projects/step-up/adc.c index b8c253e..326588a 100644 --- a/projects/step-up/adc.c +++ b/projects/step-up/adc.c @@ -120,21 +120,12 @@ void init_adc() start_next_adc(); } -#if 0 void susp_adc() { ADCSRA = 0; DIDR0 = 0; } -static void adc1_gain20_adc(uint16_t adcsum) -{ - // running average - adc1_gain20_offset += adcsum - - (adc1_gain20_offset >> ADC1_GAIN20_OFFSET_SHIFT); -} -#endif - static void inline adc_based_timer() { static unsigned char count; diff --git a/projects/step-up/control.c b/projects/step-up/control.c index f627262..c8c38cd 100644 --- a/projects/step-up/control.c +++ b/projects/step-up/control.c @@ -77,8 +77,7 @@ void short_press() void long_press() { - e.shutdown_in_progress = 0; - pattern_reload(); + power_down(); } pattern_t *pwmled_pattern_select() diff --git a/projects/step-up/main.c b/projects/step-up/main.c index 383aa5e..69657a8 100644 --- a/projects/step-up/main.c +++ b/projects/step-up/main.c @@ -26,16 +26,14 @@ static void hw_setup() set_sleep_mode(SLEEP_MODE_IDLE); } -#if 0 static void hw_suspend() { susp_pwm(); susp_adc(); - susp_tmr(); - susp_gpio(); susp_buttons(); wdt_disable(); + power_all_disable(); } void power_down() @@ -60,7 +58,6 @@ void power_down() // ok, so I will wake up hw_setup(); } -#endif int main(void) { @@ -69,7 +66,7 @@ int main(void) log_set_state(3); hw_setup(); - // power_down(); - not while still debugging + power_down(); sei(); #if 1 diff --git a/projects/step-up/pwm.c b/projects/step-up/pwm.c index 18a1425..e3b477c 100644 --- a/projects/step-up/pwm.c +++ b/projects/step-up/pwm.c @@ -39,22 +39,16 @@ void init_pwm() PORTB &= ~_BV(PB4); // set to zero } -#if 0 void susp_pwm() { - unsigned char i; - - for (i = 0; i < N_PWMLEDS; i++) - pwm[i] = 0; - - DDRB &= ~(_BV( PB1 ) | _BV( PB3 ) | _BV( PB5 )); - TCCR1D = TCCR1C = TCCR1B = TCCR1A = 0; + DDRB &= ~(_BV( PB4 )); + PORTB &= ~(_BV( PB4 )); + TCCR1 = 0; TIMSK = 0; TIFR = 0; PLLCSR &= ~(_BV(PLLE) | _BV(PCKE)); } -#endif void pwm_off() {