/* * main.c * * Created: 14.11.2016 07:26:13 * Author : Dennis * * Description: * This is the demo code for the "LED Cube Pendant" project on instructables.com: * instructables.com/tag/type-id/user-nqtronix/keyword-XG7D */ #define F_CPU 8000000UL #include #include #include #include #include "HAL/rtc.h" #include "HAL/cplex.h" #include "Data/img_rgb24b_4x4x4.h" uint8_t display_data[CPLEX_LEDS] = {0}; volatile uint8_t frameStart = 0; volatile uint8_t enable_sleep = 0; volatile uint8_t adc_release = 0; // Uncomment line to set B3 (D- line) whenever processor is in active mode //#define DEBUG_ON_TIME // Uncomment for long term power down //#define FORCE_OFF // Uncomment to display all white instead of color test pattern //#define DEBUG_LEDS_ALL_ON // Uncomment to enable test animation (overrides static image) //#define DEBUG_LEDS_CYCLE int main(void) { #ifdef FORCE_OFF set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_mode(); #endif // disable unused modules PRR0 = (1< ADC6/ PE2 ADCSRA = (0b111<= CPLEX_LEDS) { dbg_i = 0; } // turn on LED at fulll brightness display_data[dbg_i] = 0xFF; } #endif // load the next block of data cplex_nextFrame(display_data); // display each pixel after another uint8_t l_LEDs_left; do{ l_LEDs_left = cplex_nextLED(); }while (l_LEDs_left); frameStart = 0; } // Wait for the result of the ADC while (ADCSRA&(1< 200) { adc_release = 1; } // go into power-save if (adc_release && (ADCH < 10)) { // disable step-up + LED timer // disabling interrupt effectively disables LEDs TIMSK2 &= ~(1< PWR_SAVE mode reduces current consumption set_sleep_mode(SLEEP_MODE_PWR_SAVE); sleep_mode(); } } ISR(PCINT3_vect) { // my type of button does not bounce! (withing a 100 cycle experiment period) if (!(PINE&(1<