# HG changeset patch # User ethanzonca@CL-ENS241-08.cedarville.edu # Date 2013-02-26 15:05:05 # Node ID 0405269c2f4cdcaad267351457e0c22e17ab7141 # Parent 5696a474fa0f99785fba10613d9d17bcb9de6c03 Added blackout mode for power-saving during actual launches diff --git a/master/master/config.h b/master/master/config.h --- a/master/master/config.h +++ b/master/master/config.h @@ -21,6 +21,8 @@ //#define DEBUG_OUTPUT +#define BLACKOUT_ENABLE + #define F_CPU 11059200 #define MODULE_ID '1' #define BOARDTEMP_ADDR 0x90 diff --git a/master/master/lib/led.c b/master/master/lib/led.c --- a/master/master/lib/led.c +++ b/master/master/lib/led.c @@ -16,6 +16,8 @@ #include #include "led.h" +bool blackout = false; + // Configure port direction and initial state of LEDs void led_setup() { @@ -26,19 +28,29 @@ void led_setup() } // Beep on startup - led_on(LED_POWER); + OCR0B = 30; // Power LED + led_on(LED_BUZZ); _delay_ms(1); led_off(LED_BUZZ); } +void led_power_toggle() +{ + OCR0B ^= 30; +} + // Turn the specified LED on void led_on(uint8_t led) { + if(blackout && led != LED_ERROR) + { + return; + } *(ledList[led].port) |= (1<= 240 && pulseUp) pulseUp = false; else if(OCR0B <= 12 && !pulseUp); diff --git a/master/master/lib/led.h b/master/master/lib/led.h --- a/master/master/lib/led.h +++ b/master/master/lib/led.h @@ -56,9 +56,11 @@ static led_t ledList[] = { #define NUM_LEDS 12 void led_setup(); +void led_power_toggle(); void led_on(uint8_t led); void led_off(uint8_t led); void led_toggle(uint8_t led); +void led_blackout(); void led_errorcode(uint8_t code); void led_spin(); void led_alert(); diff --git a/master/master/lib/looptime.c b/master/master/lib/looptime.c --- a/master/master/lib/looptime.c +++ b/master/master/lib/looptime.c @@ -23,9 +23,6 @@ void time_setup() // Generic microcontroller config options OCR0A = 173; // Approx 172.7969 ticks per ms with 64 prescaler - - OCR0B = 20; // Power LED - TCCR0A |= (1 << WGM01) | (1 << WGM00) | // Count until OCR0A, then overflow (wgm02 in the next line specifies this as well) (1<< COM0B1); // Non-inverting PWM on OC0B TCCR0B |= (1 << CS01) | (1 << CS00) | (1 << WGM02); // clock div by 64 diff --git a/master/master/master.c b/master/master/master.c --- a/master/master/master.c +++ b/master/master/master.c @@ -77,6 +77,7 @@ int main(void) // Periodic: LED execution indicator if(time_millis() - lastLedCycle > LEDCYCLE_RATE) { + led_power_toggle(); led_spin(); // Enable GPS serial interrupts if we aren't doing AFSK @@ -134,6 +135,10 @@ int main(void) // Periodic: APRS transmission if(time_millis() - lastAprsBroadcast > APRS_TRANSMIT_PERIOD) { + #ifdef BLACKOUT_ENABLE + led_blackout(); + #endif + // Ensure we aren't already transmitting while(afsk_busy());