/** * \brief User Interface - LCD Initialization. */ void ui_lcd_init(void) { uint8_t const scrolling_str[] = "SAM4L-EK DEMO"; /* * LCDCA Controller Initialization and display SAM4L-EK DEMO texts on * segment LCD */ // Initialize the C42364A LCD glass component. c42364a_init(); // Start autonomous animation. c42364a_circular_animation_start(C42364A_CSR_RIGHT, 7, 0x03); // Show ARM Icon. c42364a_show_icon(C42364A_ICON_ARM); // Start scrolling text. c42364a_text_scrolling_start(scrolling_str, strlen((char const *)scrolling_str)); while(event_qtouch_sensors_idle_count<UI_IDLE_TIME){} event_qtouch_sensors_idle_count = 0; // Stop scrolling text. c42364a_text_scrolling_stop(); ui_lcd_refresh_txt(); }
/** * \brief Lower power and QTouch Demo for SAM4L entry point. * \return Unused (ANSI-C compatibility). */ int main(void) { uint8_t event_qtouch_slider_position = 0; power_scaling_t power_scaling = POWER_SCALING_PS1; sleep_mode_t sleep_mode = SLEEP_MODE_RUN; /* * QTouch library: * Use touch_config_sam4l.h file to configure Sensor Pins, number of Sensors * and Sensor Global configuration information. * Use touch.c touch_sensors_config() function to set Sensor specific * configuration data such as the Sensor Threshold setting. */ /* * At startup the application run in full demo mode (all features on, * includes QTouch and segment LCD). Initialize the board IO configuration, * clocks, QTouch library, External interrupts, NVIC and UI SAM4L is running * at 12 MHz from internal RCFAST (configured at 12MHz). */ app_init(); // Stay in full demo mode until push button PB0 button is pressed while (!event_is_push_button_pressed()){ // Runs prime number algorithm app_prime_number_run(); /* * Capture QTouch inputs (sliders and CS0 QTouch button): displays the * slider value (0..255) to the segment LCD, CS0 will change the SAM4L * Power Scaling mode (from PS0 to PS2). */ touch_sensors_measure(); if (event_qtouch_get_button_state()) { /* * Change Power Scaling Mode: circle from PS0 to PS2. * - Read current Power Scaling status, * - Change Power Scaling Value, * - Switch into this Power Scaling Value. */ power_scaling = ui_get_power_scaling_mcu_status(); if (power_scaling == POWER_SCALING_PS0) { power_scaling = POWER_SCALING_PS1; } else if ((power_scaling == POWER_SCALING_PS1) && (is_ps2_mode_supported_by_the_part())) { power_scaling = POWER_SCALING_PS2; } else { power_scaling = POWER_SCALING_PS0; } ui_set_power_scaling_mcu_status(power_scaling); app_switch_power_scaling(power_scaling); // Send new MCU status to the board monitor ui_bm_send_mcu_status(); // Refresh LCD Text area with this new power scaling value ui_lcd_refresh_txt(); // Initialize touch sensing after Power Scaling mode change touch_sensors_deinit(); touch_sensors_init(); } /* * Display slider value (0...255) if slider is pressed, clear display * if not. */ if (event_qtouch_get_slider_state(&event_qtouch_slider_position)) { ui_lcd_refresh_alphanum(true, event_qtouch_slider_position); } else { ui_lcd_refresh_alphanum(false, event_qtouch_slider_position); } } /* * Now PB0 push button has been pressed once, the application switches in * low power mode: Stop LCD controller, stop LCD back light, stop QTouch * acquisition, switch SAM4L in power scaling PS1 mode. * SAM4L is in RUN mode. */ app_init_lowpower(); while(1u){ // Runs prime number algorithm app_prime_number_run(); /* * Run in low power mode: if PB0 is pressed, the SAM4L will enter one of * the sleep modes (from RUN to WAIT to RET to BACKUP, then restart to * RUN). For each sleep mode transition, the SAM4L is sending the * information for the board monitor (over the USART). The current SAM4L * sleep mode is displayed by the board monitor on the OLED display. */ if (event_is_push_button_pressed()) { /* * Change Sleep Mode: RUN->WAIT->RET->BACKUP. * - Read current Sleep Mode status, * - Change Sleep Mode Value, * - Enter into this Sleep Mode Value. */ sleep_mode = ui_get_sleep_mode_mcu_status(); switch(sleep_mode){ case SLEEP_MODE_WAIT: sleep_mode = SLEEP_MODE_RETENTION; break; case SLEEP_MODE_RETENTION: sleep_mode = SLEEP_MODE_BACKUP; break; case SLEEP_MODE_BACKUP: sleep_mode = SLEEP_MODE_RUN; break; case SLEEP_MODE_RUN: default: sleep_mode = SLEEP_MODE_WAIT; break; } ui_set_sleep_mode_mcu_status(sleep_mode); // Send new MCU status to the board monitor ui_bm_send_mcu_status(); // Now we're ready to enter the selected sleep mode app_enter_sleep_mode(sleep_mode); } } }// end main function