//* ************************************************************************************************ /// @fn measure_temp(enum sys_message msg) /// @brief Temperature display routine. Mesure and parse the temperature. /// @return none //* ************************************************************************************************ static void measure_temp(enum sys_message msg) { // Call the driver to measure the temperature temperature_measurement(); // Display new stuff on the screen display_temperature(); }
// ************************************************************************************************* // @fn display_temperature // @brief Common display routine for metric and English units. // @param u8 line LINE1 // u8 update DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_CLEAR // @return none // ************************************************************************************************* void display_temperature(u8 line, u8 update) { u8 *str; s16 temperature; // Redraw whole screen if (update == DISPLAY_LINE_UPDATE_FULL) { // Menu item is visible sTemp.state = MENU_ITEM_VISIBLE; // Perform one temperature measurement with disabled filter temperature_measurement(FILTER_OFF); // Display temperature display_temperature(LINE2, DISPLAY_LINE_UPDATE_PARTIAL); } else if (update == DISPLAY_LINE_UPDATE_PARTIAL) { // When using English units, convert °C to °F (temp*1.8+32) if (!sys.flag.use_metric_units) { temperature = convert_C_to_F(sTemp.degrees); } else { temperature = sTemp.degrees; } // Indicate temperature sign through arrow up/down icon if (temperature < 0) { // Convert negative to positive number temperature = ~temperature; temperature += 1; display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_ON); } else // Temperature is >= 0 { display_symbol(LCD_SYMB_ARROW_UP, SEG_ON); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); } // Limit min/max temperature to +/- 99.9 °C / °F if (temperature > 999) temperature = 999; // Display result in xx.x format str = int_to_array(temperature, 3, 1); display_chars(LCD_SEG_L2_3_0, str, SEG_ON); // Display °C / °F display_symbol(LCD_SEG_L2_DP, SEG_ON); // display_symbol(LCD_UNIT_L1_DEGREE, SEG_ON); if (sys.flag.use_metric_units) display_char(LCD_SEG_L2_0, 'C', SEG_ON); else display_char(LCD_SEG_L2_0, 'F', SEG_ON); } else if (update == DISPLAY_LINE_CLEAR) { // Menu item is not visible sTemp.state = MENU_ITEM_NOT_VISIBLE; // Clean up function-specific segments before leaving function display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); // display_symbol(LCD_UNIT_L1_DEGREE, SEG_OFF); display_symbol(LCD_SEG_L2_DP, SEG_OFF); } }
static void edit_offset_set(uint8_t pos, int8_t step) { temperature.offset += step; display_temperature(); }
static void measure_temp(enum sys_message msg) { temperature_measurement(); display_temperature(); }
// ************************************************************************************************* // @fn test_mode // @brief Manual test mode. Activated by holding buttons STAR and UP simultaneously. // Cancelled by any other button press. // @param none // @return none // ************************************************************************************************* void test_mode(void) { u8 test_step, start_next_test; u8 * str; u8 i; // Disable timer - no need for a clock tick Timer0_Stop(); // Disable LCD charge pump while in standby mode // This reduces current consumption by ca. 5?A to ca. 10?A LCDBVCTL = 0; // Show welcome screen display_chars(LCD_SEG_L1_3_0, (u8*)"0430", SEG_ON); display_chars(LCD_SEG_L2_4_0, (u8*)"CC430", SEG_ON); display_symbol(LCD_SEG_L1_COL, SEG_ON); display_symbol(LCD_ICON_HEART, SEG_ON); display_symbol(LCD_ICON_STOPWATCH, SEG_ON); display_symbol(LCD_ICON_RECORD, SEG_ON); display_symbol(LCD_ICON_ALARM, SEG_ON); display_symbol(LCD_ICON_BEEPER1, SEG_ON); display_symbol(LCD_ICON_BEEPER2, SEG_ON); display_symbol(LCD_ICON_BEEPER3, SEG_ON); display_symbol(LCD_SYMB_ARROW_UP, SEG_ON); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_ON); display_symbol(LCD_SYMB_AM, SEG_ON); // Hold watchdog WDTCTL = WDTPW + WDTHOLD; // Wait for button press _BIS_SR(LPM3_bits + GIE); __no_operation(); // Clear display display_all_off(); #ifdef USE_LCD_CHARGE_PUMP // Charge pump voltage generated internally, internal bias (V2-V4) generation // This ensures that the contrast and LCD control is constant for the whole battery lifetime LCDBVCTL = LCDCPEN | VLCD_2_72; #endif // Renenable timer Timer0_Start(); // Debounce button press Timer0_A4_Delay(CONV_MS_TO_TICKS(100)); while(1) { // Check button event if (BUTTON_STAR_IS_PRESSED && BUTTON_UP_IS_PRESSED) { // Start with test #0 test_step = 0; start_next_test = 1; while(1) { if (start_next_test) { // Clean up previous test display display_all_off(); start_next_test = 0; switch (test_step) { case 0: // All LCD segments on display_all_on(); // Wait until buttons are off while (BUTTON_STAR_IS_PRESSED && BUTTON_UP_IS_PRESSED); break; case 1: // Altitude measurement #ifdef CONFIG_ALTITUDE display_altitude(LINE1, DISPLAY_LINE_UPDATE_FULL); for (i=0; i<2; i++) { while((PS_INT_IN & PS_INT_PIN) == 0); do_altitude_measurement(FILTER_OFF); display_altitude(LINE1, DISPLAY_LINE_UPDATE_PARTIAL); } stop_altitude_measurement(); #endif break; case 2: // Temperature measurement display_temperature(LINE1, DISPLAY_LINE_UPDATE_FULL); for (i=0; i<4; i++) { Timer0_A4_Delay(CONV_MS_TO_TICKS(250)); temperature_measurement(FILTER_OFF); display_temperature(LINE1, DISPLAY_LINE_UPDATE_PARTIAL); } break; case 3: // Acceleration measurement as_start(); for (i=0; i<4; i++) { Timer0_A4_Delay(CONV_MS_TO_TICKS(250)); as_get_data(sAccel.xyz); str = itoa( sAccel.xyz[0], 3, 0); display_chars(LCD_SEG_L1_2_0, str, SEG_ON); str = itoa( sAccel.xyz[2], 3, 0); display_chars(LCD_SEG_L2_2_0, str, SEG_ON); } as_stop(); break; //pfs #ifndef ELIMINATE_BLUEROBIN case 4: // BlueRobin test button.flag.up = 1; sx_bluerobin(LINE1); Timer0_A4_Delay(CONV_MS_TO_TICKS(100)); get_bluerobin_data(); display_heartrate(LINE1, DISPLAY_LINE_UPDATE_FULL); stop_bluerobin(); break; #endif } // Debounce button Timer0_A4_Delay(CONV_MS_TO_TICKS(200)); } // Check button event if (BUTTON_STAR_IS_PRESSED) { test_step = 1; start_next_test = 1; } else if (BUTTON_NUM_IS_PRESSED) { test_step = 2; start_next_test = 1; } else if (BUTTON_UP_IS_PRESSED) { test_step = 3; start_next_test = 1; } else if (BUTTON_DOWN_IS_PRESSED) { test_step = 4; start_next_test = 1; } else if (BUTTON_BACKLIGHT_IS_PRESSED) { // Wait until button has been released (avoid restart) while (BUTTON_BACKLIGHT_IS_PRESSED); // Disable LCD and LCD charge pump LCDBCTL0 &= ~BIT0; LCDBVCTL = 0; // Debounce button press Timer0_A4_Delay(CONV_MS_TO_TICKS(500)); // Disable timer - no need for a clock tick Timer0_Stop(); // Hold watchdog WDTCTL = WDTPW + WDTHOLD; // Sleep until button is pressed (ca. 4?A current consumption) _BIS_SR(LPM4_bits + GIE); __no_operation(); // Force watchdog reset for a clean restart WDTCTL = 1; } #ifdef USE_WATCHDOG // Service watchdog WDTCTL = WDTPW + WDTIS__512K + WDTSSEL__ACLK + WDTCNTCL; #endif // To LPM3 _BIS_SR(LPM3_bits + GIE); __no_operation(); } } else { // Debounce button Timer0_A4_Delay(CONV_MS_TO_TICKS(100)); button.all_flags = 0; break; } } }
/*------------------------------------------------------------------------------------------------------------------------------------------- * main function *------------------------------------------------------------------------------------------------------------------------------------------- */ int main () { static uint_fast8_t last_ldr_value = 0xFF; struct tm tm; LISTENER_DATA lis; ESP8266_INFO * esp8266_infop; uint_fast8_t esp8266_is_up = 0; uint_fast8_t code; #if SAVE_RAM == 0 IRMP_DATA irmp_data; uint32_t stop_time; uint_fast8_t cmd; #endif uint_fast8_t status_led_cnt = 0; uint_fast8_t display_flag = DISPLAY_FLAG_UPDATE_ALL; uint_fast8_t show_temperature = 0; uint_fast8_t time_changed = 0; uint_fast8_t power_is_on = 1; uint_fast8_t night_power_is_on = 1; uint_fast8_t ldr_value; uint_fast8_t ap_mode = 0; SystemInit (); SystemCoreClockUpdate(); // needed for Nucleo board #if defined (STM32F103) // disable JTAG to get back PB3, PB4, PA13, PA14, PA15 RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); // turn on clock for the alternate function register GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); // disable the JTAG, enable the SWJ interface #endif log_init (); // initilize logger on uart #if SAVE_RAM == 0 irmp_init (); // initialize IRMP #endif timer2_init (); // initialize timer2 for IRMP, DCF77, EEPROM etc. delay_init (DELAY_RESOLUTION_1_US); // initialize delay functions with granularity of 1 us board_led_init (); // initialize GPIO for green LED on disco or nucleo board button_init (); // initialize GPIO for user button on disco or nucleo board rtc_init (); // initialize I2C RTC eeprom_init (); // initialize I2C EEPROM if (button_pressed ()) // set ESP8266 into flash mode { board_led_on (); esp8266_flash (); } log_msg ("\r\nWelcome to WordClock Logger!"); log_msg ("----------------------------"); log_str ("Version: "); log_msg (VERSION); if (rtc_is_up) { log_msg ("rtc is online"); } else { log_msg ("rtc is offline"); } if (eeprom_is_up) { log_msg ("eeprom is online"); read_version_from_eeprom (); log_printf ("current eeprom version: 0x%08x\r\n", eeprom_version); if ((eeprom_version & 0xFF0000FF) == 0x00000000) { // Upper and Lower Byte must be 0x00 if (eeprom_version >= EEPROM_VERSION_1_5_0) { #if SAVE_RAM == 0 log_msg ("reading ir codes from eeprom"); remote_ir_read_codes_from_eeprom (); #endif log_msg ("reading display configuration from eeprom"); display_read_config_from_eeprom (); log_msg ("reading timeserver data from eeprom"); timeserver_read_data_from_eeprom (); } if (eeprom_version >= EEPROM_VERSION_1_7_0) { log_msg ("reading night timers from eeprom"); night_read_data_from_eeprom (); } } } else { log_msg ("eeprom is offline"); } ldr_init (); // initialize LDR (ADC) display_init (); // initialize display dcf77_init (); // initialize DCF77 night_init (); // initialize night time routines short_isr = 1; temp_init (); // initialize DS18xx short_isr = 0; display_reset_led_states (); display_mode = display_get_display_mode (); animation_mode = display_get_animation_mode (); auto_brightness = display_get_automatic_brightness_control (); if (eeprom_is_up) { if (eeprom_version != EEPROM_VERSION) { log_printf ("updating EEPROM to version 0x%08x\r\n", EEPROM_VERSION); eeprom_version = EEPROM_VERSION; write_version_to_eeprom (); #if SAVE_RAM == 0 remote_ir_write_codes_to_eeprom (); #endif display_write_config_to_eeprom (); timeserver_write_data_to_eeprom (); night_write_data_to_eeprom (); eeprom_version = EEPROM_VERSION; } } ds3231_flag = 1; #if SAVE_RAM == 0 stop_time = uptime + 3; // wait 3 seconds for IR signal... display_set_status_led (1, 1, 1); // show white status LED while (uptime < stop_time) { if (irmp_get_data (&irmp_data)) // got IR signal? { display_set_status_led (1, 0, 0); // yes, show red status LED delay_sec (1); // and wait 1 second (void) irmp_get_data (&irmp_data); // flush input of IRMP now display_set_status_led (0, 0, 0); // and switch status LED off log_msg ("calling IR learn function"); if (remote_ir_learn ()) // learn IR commands { remote_ir_write_codes_to_eeprom (); // if successful, save them in EEPROM } break; // and break the loop } } #endif display_set_status_led (0, 0, 0); // switch off status LED esp8266_init (); esp8266_infop = esp8266_get_info (); while (1) { if (! ap_mode && esp8266_is_up && button_pressed ()) // if user pressed user button, set ESP8266 to AP mode { ap_mode = 1; log_msg ("user button pressed: configuring esp8266 as access point"); esp8266_is_online = 0; esp8266_infop->is_online = 0; esp8266_infop->ipaddress[0] = '\0'; esp8266_accesspoint ("wordclock", "1234567890"); } if (status_led_cnt) { status_led_cnt--; if (! status_led_cnt) { display_set_status_led (0, 0, 0); } } if ((code = listener (&lis)) != 0) { display_set_status_led (1, 0, 0); // got net command, light red status LED status_led_cnt = STATUS_LED_FLASH_TIME; switch (code) { case LISTENER_SET_COLOR_CODE: // set color { display_set_colors (&(lis.rgb)); log_printf ("command: set colors to %d %d %d\r\n", lis.rgb.red, lis.rgb.green, lis.rgb.blue); break; } case LISTENER_POWER_CODE: // power on/off { if (power_is_on != lis.power) { power_is_on = lis.power; display_flag = DISPLAY_FLAG_UPDATE_ALL; log_msg ("command: set power"); } break; } case LISTENER_DISPLAY_MODE_CODE: // set display mode { if (display_mode != lis.mode) { display_mode = display_set_display_mode (lis.mode); display_flag = DISPLAY_FLAG_UPDATE_ALL; log_printf ("command: set display mode to %d\r\n", display_mode); } break; } case LISTENER_ANIMATION_MODE_CODE: // set animation mode { if (animation_mode != lis.mode) { animation_mode = display_set_animation_mode (lis.mode); animation_flag = 0; display_flag = DISPLAY_FLAG_UPDATE_ALL; log_printf ("command: set animation mode to %d\r\n", animation_flag); } break; } case LISTENER_DISPLAY_TEMPERATURE_CODE: // set animation mode { show_temperature = 1; log_msg ("command: show temperature"); break; } case LISTENER_SET_BRIGHTNESS_CODE: // set brightness { if (auto_brightness) { auto_brightness = 0; last_ldr_value = 0xFF; display_set_automatic_brightness_control (auto_brightness); } display_set_brightness (lis.brightness); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; log_printf ("command: set brightness to %d, disable autmomatic brightness control per LDR\r\n", lis.brightness); break; } case LISTENER_SET_AUTOMATIC_BRIHGHTNESS_CODE: // automatic brightness control on/off { if (lis.automatic_brightness_control) { auto_brightness = 1; log_msg ("command: enable automatic brightness control"); } else { auto_brightness = 0; log_msg ("command: disable automatic brightness control"); } last_ldr_value = 0xFF; display_set_automatic_brightness_control (auto_brightness); break; } case LISTENER_TEST_DISPLAY_CODE: // test display { log_msg ("command: start display test"); display_test (); break; } case LISTENER_SET_DATE_TIME_CODE: // set date/time { if (rtc_is_up) { rtc_set_date_time (&(lis.tm)); } if (hour != (uint_fast8_t) lis.tm.tm_hour || minute != (uint_fast8_t) lis.tm.tm_min) { display_flag = DISPLAY_FLAG_UPDATE_ALL; } wday = lis.tm.tm_wday; hour = lis.tm.tm_hour; minute = lis.tm.tm_min; second = lis.tm.tm_sec; log_printf ("command: set time to %s %4d-%02d-%02d %02d:%02d:%02d\r\n", wdays_en[lis.tm.tm_wday], lis.tm.tm_year + 1900, lis.tm.tm_mon + 1, lis.tm.tm_mday, lis.tm.tm_hour, lis.tm.tm_min, lis.tm.tm_sec); break; } case LISTENER_GET_NET_TIME_CODE: // get net time { net_time_flag = 1; log_msg ("command: start net time request"); break; } case LISTENER_IR_LEARN_CODE: // IR learn { #if SAVE_RAM == 0 log_msg ("command: learn IR codes"); if (remote_ir_learn ()) { remote_ir_write_codes_to_eeprom (); } #endif break; } case LISTENER_SAVE_DISPLAY_CONFIGURATION: // save display configuration { display_write_config_to_eeprom (); log_msg ("command: save display settings"); break; } } } if (auto_brightness && ldr_poll_brightness (&ldr_value)) { if (ldr_value + 1 < last_ldr_value || ldr_value > last_ldr_value + 1) // difference greater than 2 { log_printf ("ldr: old brightnes: %d new brightness: %d\r\n", last_ldr_value, ldr_value); last_ldr_value = ldr_value; display_set_brightness (ldr_value); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; } } if (!esp8266_is_up) // esp8266 up yet? { if (esp8266_infop->is_up) { esp8266_is_up = 1; log_msg ("esp8266 now up"); } } else { // esp8266 is up... if (! esp8266_is_online) // but not online yet... { if (esp8266_infop->is_online) // now online? { char buf[32]; esp8266_is_online = 1; log_msg ("esp8266 now online"); sprintf (buf, " IP %s", esp8266_infop->ipaddress); display_banner (buf); display_flag = DISPLAY_FLAG_UPDATE_ALL; net_time_flag = 1; } } } if (dcf77_time(&tm)) { display_set_status_led (1, 1, 0); // got DCF77 time, light yellow = green + red LED status_led_cnt = 50; if (rtc_is_up) { rtc_set_date_time (&tm); } if (hour != (uint_fast8_t) tm.tm_hour || minute != (uint_fast8_t) tm.tm_min) { display_flag = DISPLAY_FLAG_UPDATE_ALL; } wday = tm.tm_wday; hour = tm.tm_hour; minute = tm.tm_min; second = tm.tm_sec; log_printf ("dcf77: %s %4d-%02d-%02d %02d:%02d:%02d\r\n", wdays_en[tm.tm_wday], tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); } if (ds3231_flag) { if (rtc_is_up && rtc_get_date_time (&tm)) { if (hour != (uint_fast8_t) tm.tm_hour || minute != (uint_fast8_t) tm.tm_min) { display_flag = DISPLAY_FLAG_UPDATE_ALL; } wday = tm.tm_wday; hour = tm.tm_hour; minute = tm.tm_min; second = tm.tm_sec; log_printf ("read rtc: %s %4d-%02d-%02d %02d:%02d:%02d\r\n", wdays_en[tm.tm_wday], tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); } ds3231_flag = 0; } if (auto_brightness && ldr_conversion_flag) { ldr_start_conversion (); ldr_conversion_flag = 0; } if (net_time_flag) { if (esp8266_infop->is_online) { display_set_status_led (0, 0, 1); // light blue status LED status_led_cnt = STATUS_LED_FLASH_TIME; timeserver_start_timeserver_request (); // start a timeserver request, answer follows... } net_time_flag = 0; net_time_countdown = 3800; // next net time after 3800 sec } if (show_time_flag) // set every full minute { #if WCLOCK24H == 1 display_flag = DISPLAY_FLAG_UPDATE_ALL; #else if (minute % 5) { display_flag = DISPLAY_FLAG_UPDATE_MINUTES; // only update minute LEDs } else { display_flag = DISPLAY_FLAG_UPDATE_ALL; } #endif show_time_flag = 0; } if (power_is_on == night_power_is_on && night_check_night_times (power_is_on, wday, hour * 60 + minute)) { power_is_on = ! power_is_on; night_power_is_on = ! night_power_is_on; display_flag = DISPLAY_FLAG_UPDATE_ALL; log_printf ("Found Timer: %s at %02d:%02d\r\n", power_is_on ? "on" : "off", hour, minute); } if (show_temperature) { uint_fast8_t temperature_index; show_temperature = 0; if (ds18xx_is_up) { short_isr = 1; temperature_index = temp_read_temp_index (); short_isr = 0; log_printf ("got temperature from DS18xxx: %d%s\r\n", temperature_index / 2, (temperature_index % 2) ? ".5" : ""); } else if (rtc_is_up) { temperature_index = rtc_get_temperature_index (); log_printf ("got temperature from RTC: %d%s\r\n", temperature_index / 2, (temperature_index % 2) ? ".5" : ""); } else { temperature_index = 0xFF; log_msg ("no temperature available"); } if (temperature_index != 0xFF) { display_temperature (power_is_on, temperature_index); #if WCLOCK24H == 1 // WC24H shows temperature with animation, WC12H rolls itself uint32_t stop_time; stop_time = uptime + 5; while (uptime < stop_time) { if (animation_flag) { animation_flag = 0; display_animation (); } } #endif display_flag = DISPLAY_FLAG_UPDATE_ALL; // force update } } if (display_flag) // refresh display (time/mode changed) { log_msg ("update display"); #if WCLOCK24H == 1 if (display_mode == MODES_COUNT - 1) // temperature { uint_fast8_t temperature_index; if (ds18xx_is_up) { short_isr = 1; temperature_index = temp_read_temp_index (); short_isr = 0; log_printf ("got temperature from DS18xxx: %d%s\r\n", temperature_index / 2, (temperature_index % 2) ? ".5" : ""); } else if (rtc_is_up) { temperature_index = rtc_get_temperature_index (); log_printf ("got temperature from RTC: %d%s\r\n", temperature_index / 2, (temperature_index % 2) ? ".5" : ""); } else { temperature_index = 0x00; log_msg ("no temperature available"); } display_clock (power_is_on, 0, temperature_index - 20, display_flag); // show new time } else { display_clock (power_is_on, hour, minute, display_flag); // show new time } #else display_clock (power_is_on, hour, minute, display_flag); // show new time #endif display_flag = DISPLAY_FLAG_NONE; } if (animation_flag) { animation_flag = 0; display_animation (); } if (dcf77_flag) { dcf77_flag = 0; dcf77_tick (); } #if SAVE_RAM == 0 cmd = remote_ir_get_cmd (); // get IR command if (cmd != REMOTE_IR_CMD_INVALID) // got IR command, light green LED { display_set_status_led (1, 0, 0); status_led_cnt = STATUS_LED_FLASH_TIME; } if (cmd != REMOTE_IR_CMD_INVALID) // if command valid, log command code { switch (cmd) { case REMOTE_IR_CMD_POWER: log_msg ("IRMP: POWER key"); break; case REMOTE_IR_CMD_OK: log_msg ("IRMP: OK key"); break; case REMOTE_IR_CMD_DECREMENT_DISPLAY_MODE: log_msg ("IRMP: decrement display mode"); break; case REMOTE_IR_CMD_INCREMENT_DISPLAY_MODE: log_msg ("IRMP: increment display mode"); break; case REMOTE_IR_CMD_DECREMENT_ANIMATION_MODE: log_msg ("IRMP: decrement animation mode"); break; case REMOTE_IR_CMD_INCREMENT_ANIMATION_MODE: log_msg ("IRMP: increment animation mode"); break; case REMOTE_IR_CMD_DECREMENT_HOUR: log_msg ("IRMP: decrement hour"); break; case REMOTE_IR_CMD_INCREMENT_HOUR: log_msg ("IRMP: increment hour"); break; case REMOTE_IR_CMD_DECREMENT_MINUTE: log_msg ("IRMP: decrement minute"); break; case REMOTE_IR_CMD_INCREMENT_MINUTE: log_msg ("IRMP: increment minute"); break; case REMOTE_IR_CMD_DECREMENT_BRIGHTNESS_RED: log_msg ("IRMP: decrement red brightness"); break; case REMOTE_IR_CMD_INCREMENT_BRIGHTNESS_RED: log_msg ("IRMP: increment red brightness"); break; case REMOTE_IR_CMD_DECREMENT_BRIGHTNESS_GREEN: log_msg ("IRMP: decrement green brightness"); break; case REMOTE_IR_CMD_INCREMENT_BRIGHTNESS_GREEN: log_msg ("IRMP: increment green brightness"); break; case REMOTE_IR_CMD_DECREMENT_BRIGHTNESS_BLUE: log_msg ("IRMP: decrement blue brightness"); break; case REMOTE_IR_CMD_INCREMENT_BRIGHTNESS_BLUE: log_msg ("IRMP: increment blue brightness"); break; case REMOTE_IR_CMD_DECREMENT_BRIGHTNESS: log_msg ("IRMP: decrement brightness"); break; case REMOTE_IR_CMD_INCREMENT_BRIGHTNESS: log_msg ("IRMP: increment brightness"); break; case REMOTE_IR_CMD_GET_TEMPERATURE: log_msg ("IRMP: get temperature"); break; } } switch (cmd) { case REMOTE_IR_CMD_POWER: { power_is_on = ! power_is_on; display_flag = DISPLAY_FLAG_UPDATE_ALL; break; } case REMOTE_IR_CMD_OK: { display_write_config_to_eeprom (); break; } case REMOTE_IR_CMD_DECREMENT_DISPLAY_MODE: // decrement display mode { display_mode = display_decrement_display_mode (); display_flag = DISPLAY_FLAG_UPDATE_ALL; break; } case REMOTE_IR_CMD_INCREMENT_DISPLAY_MODE: // increment display mode { display_mode = display_increment_display_mode (); display_flag = DISPLAY_FLAG_UPDATE_ALL; break; } case REMOTE_IR_CMD_DECREMENT_ANIMATION_MODE: // decrement display mode { animation_mode = display_decrement_animation_mode (); display_flag = DISPLAY_FLAG_UPDATE_ALL; break; } case REMOTE_IR_CMD_INCREMENT_ANIMATION_MODE: // increment display mode { animation_mode = display_increment_animation_mode (); display_flag = DISPLAY_FLAG_UPDATE_ALL; break; } case REMOTE_IR_CMD_DECREMENT_HOUR: // decrement hour { if (hour > 0) { hour--; } else { hour = 23; } second = 0; display_flag = DISPLAY_FLAG_UPDATE_ALL; time_changed = 1; break; } case REMOTE_IR_CMD_INCREMENT_HOUR: // increment hour { if (hour < 23) { hour++; } else { hour = 0; } second = 0; display_flag = DISPLAY_FLAG_UPDATE_ALL; time_changed = 1; break; } case REMOTE_IR_CMD_DECREMENT_MINUTE: // decrement minute { if (minute > 0) { minute--; } else { minute = 59; } second = 0; display_flag = DISPLAY_FLAG_UPDATE_ALL; time_changed = 1; break; } case REMOTE_IR_CMD_INCREMENT_MINUTE: // increment minute { if (minute < 59) { minute++; } else { minute = 0; } second = 0; display_flag = DISPLAY_FLAG_UPDATE_ALL; time_changed = 1; break; } case REMOTE_IR_CMD_DECREMENT_BRIGHTNESS_RED: // decrement red brightness { display_decrement_color_red (); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; break; } case REMOTE_IR_CMD_INCREMENT_BRIGHTNESS_RED: // increment red brightness { display_increment_color_red (); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; break; } case REMOTE_IR_CMD_DECREMENT_BRIGHTNESS_GREEN: // decrement green brightness { display_decrement_color_green (); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; break; } case REMOTE_IR_CMD_INCREMENT_BRIGHTNESS_GREEN: // increment green brightness { display_increment_color_green (); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; break; } case REMOTE_IR_CMD_DECREMENT_BRIGHTNESS_BLUE: // decrement blue brightness { display_decrement_color_blue (); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; break; } case REMOTE_IR_CMD_INCREMENT_BRIGHTNESS_BLUE: // increment blue brightness { display_increment_color_blue (); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; break; } case REMOTE_IR_CMD_AUTO_BRIGHTNESS_CONTROL: // toggle auto brightness { auto_brightness = ! auto_brightness; last_ldr_value = 0xFF; display_set_automatic_brightness_control (auto_brightness); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; break; } case REMOTE_IR_CMD_DECREMENT_BRIGHTNESS: // decrement brightness { if (auto_brightness) { auto_brightness = 0; last_ldr_value = 0xFF; display_set_automatic_brightness_control (auto_brightness); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; } display_decrement_brightness (); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; break; } case REMOTE_IR_CMD_INCREMENT_BRIGHTNESS: // increment brightness { if (auto_brightness) { auto_brightness = 0; last_ldr_value = 0xFF; display_set_automatic_brightness_control (auto_brightness); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; } display_increment_brightness (); display_flag = DISPLAY_FLAG_UPDATE_NO_ANIMATION; break; } case REMOTE_IR_CMD_GET_TEMPERATURE: // get temperature { show_temperature = 1; break; } default: { break; } } #endif // SAVE_RAM == 0 if (time_changed) { if (rtc_is_up) { tm.tm_hour = hour; tm.tm_min = minute; tm.tm_sec = second; rtc_set_date_time (&tm); } time_changed = 0; } } return 0; }