static void as_event(enum sys_message msg) { if ( (msg & SYS_MSG_RTC_MINUTE) == SYS_MSG_RTC_MINUTE) { if(sAccel.mode == ACCEL_MODE_ON) sAccel.timeout--; //if timeout is over disable the accelerometer if(sAccel.timeout<1) { //disable accelerometer to save power as_stop(); //update the mode to remember sAccel.mode = ACCEL_MODE_OFF; } } if ( (msg & SYS_MSG_AS_INT) == SYS_MSG_AS_INT) { //Check the vti register for status information as_status.all_flags=as_get_status(); //TODO For debugging only _printf(0, LCD_SEG_L1_1_0, "%1u", as_status.all_flags); buzzer_play(smb); //if we were in free fall or motion detection mode check for the event if(as_status.int_status.falldet || as_status.int_status.motiondet){ //if such an event is detected enable the symbol //display_symbol(0, LCD_ICON_ALARM , SEG_SET | BLINK_ON); //read the data as_get_data(sAccel.xyz); //display_data(0); /* update menu screen */ lcd_screen_activate(0); }//if we were in measurment mode do a measurement and put it in the virtual screen else { //display_symbol(0, LCD_ICON_ALARM , SEG_SET | BLINK_OFF); display_data(1); /* refresh to accelerometer screen only if in that modality */ if (submenu_state== VIEW_AXIS )lcd_screen_activate(1); } } /* The 1 Hz timer is used to refresh the menu screen */ if ( (msg & SYS_MSG_RTC_SECOND) == SYS_MSG_RTC_SECOND) { /*check the status register for debugging purposes */ _printf(0, LCD_SEG_L1_1_0, "%1u", as_read_register(ADDR_INT_STATUS)); /* update menu screen */ lcd_screen_activate(0); } }
void up_callback(void) { lcd_screen_activate(0xff); display_symbol(lcd_screen_currentscreen(), LCD_SEG_L2_COL0, SEG_OFF); //sys_messagebus_unregister(&screenTimeout); //sys_messagebus_register(&screenTimeout, SYS_MSG_TIMER_4S); }
static void up_btn() { // Depending on the state what do we do? switch (submenu_state) { case VIEW_SET_MODE: as_config.mode++; as_config.mode %= 3; change_mode(as_config.mode); update_menu(); break; case VIEW_SET_PARAMS: _printf(0,LCD_SEG_L1_3_0 , "%04x", as_read_register(ADDR_CTRL)); break; case VIEW_STATUS: _printf(0,LCD_SEG_L1_3_0, "%1u", as_status.all_flags); break; case VIEW_AXIS: display_chars(0,LCD_SEG_L1_3_0 , "TODO", SEG_SET); break; default: break; } /* update menu screen */ lcd_screen_activate(0); }
void edit_mode_callback(void) { lcd_screen_activate(0); sys_messagebus_unregister(&update); sys_messagebus_unregister(&time_callback); display_symbol(0, LCD_SEG_L2_COL0, SEG_OFF); menu_editmode_start(&edit_save, edit_items); }
//* ************************************************************************************************ /// @fn edit_save(void) /// @brief Stuff to do when we exit the edit mode. /// @return none //* ************************************************************************************************ static void edit_save(void) { // Disable blinking for the offset value display_chars(1, LCD_SEG_L1_3_0, NULL, BLINK_OFF); // Revert to the default screen (0) lcd_screen_activate(0); }
static void edit_mo_sel(void) { lcd_screen_activate(0); #ifdef CONFIG_MOD_CLOCK_MONTH_FIRST display_chars(0, LCD_SEG_L2_4_3, NULL, BLINK_ON); #else display_chars(0, LCD_SEG_L2_1_0, NULL, BLINK_ON); #endif }
static void clock_event(enum sys_message msg) { #ifdef CONFIG_MOD_CLOCK_BLINKCOL display_symbol(0, LCD_SEG_L1_COL, ((rtca_time.sec & 0x01) ? SEG_ON : SEG_OFF)); #endif if (msg & SYS_MSG_RTC_YEAR) _printf(1, LCD_SEG_L1_3_0, "%04u", rtca_time.year); #ifdef CONFIG_MOD_CLOCK_MONTH_FIRST if (msg & SYS_MSG_RTC_MONTH) _printf(0, LCD_SEG_L2_4_3, "%02u", rtca_time.mon); if (msg & SYS_MSG_RTC_DAY) { _printf(0, LCD_SEG_L2_1_0, "%02u", rtca_time.day); #else if (msg & SYS_MSG_RTC_MONTH) _printf(0, LCD_SEG_L2_1_0, "%02u", rtca_time.mon); if (msg & SYS_MSG_RTC_DAY) { _printf(0, LCD_SEG_L2_4_3, "%02u", rtca_time.day); #endif _printf(1, LCD_SEG_L2_2_0, rtca_dow_str[rtca_time.dow], SEG_SET); } if (msg & SYS_MSG_RTC_HOUR) { #ifdef CONFIG_MOD_CLOCK_AMPM uint8_t tmp_hh = rtca_time.hour; if (tmp_hh > 12) { tmp_hh -= 12; display_symbol(0, LCD_SYMB_AM, SEG_OFF); display_symbol(0, LCD_SYMB_PM, SEG_SET); } else { if (tmp_hh == 12) { display_symbol(0, LCD_SYMB_AM, SEG_OFF); display_symbol(0, LCD_SYMB_PM, SEG_SET); } else { display_symbol(0, LCD_SYMB_PM, SEG_OFF); display_symbol(0, LCD_SYMB_AM, SEG_SET); } if (tmp_hh == 0) tmp_hh = 12; } _printf(0, LCD_SEG_L1_3_2, "%2u", tmp_hh); #else _printf(0, LCD_SEG_L1_3_2, "%02u", rtca_time.hour); #endif } if (msg & SYS_MSG_RTC_MINUTE) _printf(0, LCD_SEG_L1_1_0, "%02u", rtca_time.min); } /********************* edit mode callbacks ********************************/ static void edit_yy_sel(void) { lcd_screen_activate(1); display_chars(1, LCD_SEG_L1_3_0, NULL, BLINK_ON); }
void buttonDown(void) { if (activeDisplay <= 0) activeDisplay = 2; else activeDisplay = (activeDisplay - 1) % 3; lcd_screen_activate(activeDisplay); drawScreen(); }
/* MARK: - Activate and Deactivate */ void activate(void) { moduleActivated = 1; /* create three empty screens */ lcd_screens_create(3); activeDisplay = TIDE_DISPLAY_STATE_GRAPH; lcd_screen_activate(activeDisplay); drawScreen(); }
//* ************************************************************************************************ /// @fn mod_temperature_init(void) /// @brief Init the module. Sets default values, register menu entry. /// @return none //* ************************************************************************************************ static void temperature_edit(void) { // display_temp_symbols(0); // Switch to the edit screen (1) lcd_screen_activate(1); // Enable blinking for the offset value display_chars(1, LCD_SEG_L1_3_0, NULL, BLINK_ON); // We go into edit mode menu_editmode_start(&edit_save, edit_items); }
/* MARK: - Buttons */ void longStarButton(void) { /* clear screen */ display_clear(0, 0); lcd_screen_activate(0); uint16_t nowInMinutes = timeNowInMinutes(); uint16_t leftUntilLow = timeInMinutes(tide); enteredTimeOfNextLow = timeFromMinutes((nowInMinutes + leftUntilLow) % twentyFourHoursInMinutes); editModeActivated = 1; _printf(0, LCD_SEG_L1_3_2, "%02u", enteredTimeOfNextLow.hoursLeft); _printf(0, LCD_SEG_L1_1_0, "%02u", enteredTimeOfNextLow.minutesLeft); blinkCol(0, 1); menu_editmode_start(&endEditing, editModeItems); }
static void edit_save() { /* Here we return from the edit mode, fill in the new values! */ rtca_time.sec = 0; rtca_set_time(); rtca_set_date(); /* turn off only SOME blinking segments */ display_chars(0, LCD_SEG_L1_3_0, NULL, BLINK_OFF); display_chars(0, LCD_SEG_L2_4_0, NULL, BLINK_OFF); display_chars(1, LCD_SEG_L1_3_0, NULL, BLINK_OFF); /* return to main screen */ lcd_screen_activate(0); /* start the RTC */ rtca_start(); }
// This set/unset the background mode static void star_long_pressed() { if(sAccel.mode==ACCEL_MODE_ON) { sAccel.mode = ACCEL_MODE_BACKGROUND; //set the R symbol on so that is propagated when the user leaves the mode display_symbol(0, LCD_ICON_RECORD, SEG_SET | BLINK_ON); } else if(sAccel.mode==ACCEL_MODE_BACKGROUND) { sAccel.mode = ACCEL_MODE_ON; //unset the R symbol display_symbol(0, LCD_ICON_RECORD, SEG_SET | BLINK_OFF); } /* update menu screen */ lcd_screen_activate(0); }
void submenu_callback(void) { lcd_screen_activate(0); submenuState++; if(submenuState == 6) submenuState = 0; display_symbol(0, LCD_SEG_L2_COL0, SEG_OFF); if (submenuState == 0) { display_clear(0, 2); display_chars(0, LCD_SEG_L2_5_0, NULL, BLINK_OFF); } else { display_chars(0, LCD_SEG_L2_5_0, pre_str[submenuState-1], SEG_SET); display_chars(0, LCD_SEG_L2_5_0, NULL, BLINK_ON); } update(SYS_MSG_FAKE); }
/* lcd_screens_destroy() */ void lcd_screens_destroy(void) { uint8_t i = 0; /* switch to screen 0 and display any pending data */ lcd_screen_activate(0); /* now we can delete all the screens */ for (; i<display_nrscreens; i++) { if (i != display_activescr) { free(display_screens[i].segmem); free(display_screens[i].blkmem); } display_screens[i].segmem = NULL; display_screens[i].segmem = NULL; } free(display_screens); display_screens = NULL; }
/********************* edit mode callbacks ********************************/ static void edit_yy_sel(void) { lcd_screen_activate(1); display_chars(1, LCD_SEG_L1_3_0, NULL, BLINK_ON); }
/* Num button press callback */ static void num_pressed() { lcd_screen_activate(0xff); }
static void edit_hh_sel(void) { lcd_screen_activate(0); display_chars(0, LCD_SEG_L1_3_2, NULL, BLINK_ON); }
/* Enter the accelerometer menu */ static void acc_activated() { //register to the system bus for vti events as well as the RTC minute events sys_messagebus_register(&as_event, SYS_MSG_AS_INT | SYS_MSG_RTC_MINUTE | SYS_MSG_RTC_SECOND); /* create two screens, the first is always the active one */ lcd_screens_create(2); /* screen 0 will contain the menu structure and screen 1 the raw accelerometer data */ // Show warning if acceleration sensor was not initialised properly if (!as_ok) { display_chars(0, LCD_SEG_L1_3_0, "ERR", SEG_SET); } else { /* Initialization is required only if not in background mode! */ if (sAccel.mode != ACCEL_MODE_BACKGROUND) { // Clear previous acceleration value sAccel.data = 0; // 2 g range as_config.range=2; // 100 Hz sampling rate as_config.sampling=SAMPLING_10_HZ; // keep mode as_config.mode=ACTIVITY_MODE; //time window is 10 msec for free fall and 100 msec for activity //2g multiple 71 mg: 0F=4 * 71 mg= 1.065 g as_config.MDTHR=2; as_config.MDFFTMR=1; // Set timeout counter sAccel.timeout = ACCEL_MEASUREMENT_TIMEOUT; // Set mode for screen sAccel.mode = ACCEL_MODE_ON; // Start with mode selection submenu_state=VIEW_SET_MODE; // Select Axis X sAccel.view_style=DISPLAY_ACCEL_Z; // Start sensor in motion detection mode as_start(ACTIVITY_MODE); // After this call interrupts will be generated } if (!as_ok) { display_chars(0, LCD_SEG_L1_3_0, "FAIL", SEG_SET); } display_chars(0, LCD_SEG_L1_3_0 , "ACTI", SEG_SET); display_chars(0, LCD_SEG_L2_4_0 , "MODE", SEG_SET); } /* return to main screen */ lcd_screen_activate(0); }
void buttonUp(void) { lcd_screen_activate(0xff); drawScreen(); }
static void down_btn() { //not necessary at the moment /* update menu screen */ lcd_screen_activate(0); }
void screenTimeout(void) { lcd_screen_activate(0); }