コード例 #1
0
static void show_new_state(const boolean is_on)
{
    if (is_on)
        display_show_important_info(FROM_FLASH(msg_activated), 1);
    else
        display_show_important_info(FROM_FLASH(msg_deactivated), 1);

    menu_active = false;
}
コード例 #2
0
static void display_menu()
{
#if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA) || (DISPLAY_TYPE & DISPLAY_TYPE_16X2)
    // Check if user has been idle for too long
    if (menu_activity_expire && millis() > menu_activity_expire)
    {
        menu_active = false;
        return;
    }
    if (!menu_changed)
        return;

    menu_changed = false;
    menu_activity_expire = millis() + menu_idle_timeout_secs * 1000;

    // Display the menu
    Menu const* menu = menu_system.get_current_menu();
    MenuComponent const* selected = menu->get_selected();

    lcd.clear();

    // Scroll to currently selected item for long menus
    byte current_lcd_row = 0;
    byte items_to_skip = 0;


#if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA)
    const byte num_screen_rows = 6;
#elif (DISPLAY_TYPE & DISPLAY_TYPE_16X2)
    const byte num_screen_rows = 2;
#endif

    if (menu->get_cur_menu_component_num() >= num_screen_rows)
        items_to_skip = menu->get_cur_menu_component_num() - num_screen_rows + 1;

    for (byte i = 0; i < menu->get_num_menu_components(); ++i)
    {
        // Handle scrolling of long menus
        if (items_to_skip)
        {
            --items_to_skip;
            continue;
        }

        lcd.setCursor(0, current_lcd_row);

        MenuComponent const *item = menu->get_menu_component(i);
        if (item == selected)
            lcd.print(MY_F("> "));
        else
            lcd.print(MY_F("  "));

        lcd.print(FROM_FLASH((item->get_name())));

        ++current_lcd_row;
        if (current_lcd_row == num_screen_rows)
            break;
    }
#endif
}
コード例 #3
0
void display_show_welcome_msg()
{
#if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA) || (DISPLAY_TYPE & DISPLAY_TYPE_16X2)
    display_show_important_info(FROM_FLASH(msg_welcome), 5);

#if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA)
    lcd.setCursor(0, 5);
    const byte max_len = 12;
#elif (DISPLAY_TYPE & DISPLAY_TYPE_16X2)
    lcd.setCursor(0, 1);
    const byte max_len = 14;
#endif

    // Show total mileage (right aligned)
    unsigned long total_km = (odo * wheel_circumference/1000);
    byte number_len = calc_number_length(total_km);
    // Safety check
    if (number_len >= max_len)
        return;

    number_len = max_len - number_len;
    while(number_len > 1)
    {
        lcd.print(MY_F(" "));
        --number_len;
    }

    lcd.print(total_km);
    lcd.print(MY_F(" km"));
#endif
}
コード例 #4
0
static void handle_shutdown(MenuItem* p_menu_item)
{
    // Shut down system
#if HARDWARE_REV >=2
    display_show_important_info(FROM_FLASH(msg_shutdown), 60);
    save_eeprom();
    digitalWrite(fet_out,HIGH);
#endif

    menu_active = false;
}