void screens::seekMode(uint8_t state) {
    last_channel = -1;
    reset(); // start from fresh screen.
    if (state == STATE_MANUAL)
    {
        drawTitleBox("MANUAL MODE");
    }
    else if(state == STATE_SEEK)
    {
        drawTitleBox("AUTO SEEK MODE");
    }
    TV.draw_line(0,1*TV_Y_GRID,TV_X_MAX,1*TV_Y_GRID,WHITE);
    TV.printPGM(5,TV_Y_OFFSET+1*TV_Y_GRID,  PSTR("BAND: "));
    TV.draw_line(0,2*TV_Y_GRID,TV_X_MAX,2*TV_Y_GRID,WHITE);
    TV.printPGM(5 ,TV_Y_OFFSET-1+2*TV_Y_GRID,  PSTR("1 2 3 4 5 6 7 8"));
    TV.draw_line(0,3*TV_Y_GRID,TV_X_MAX,3*TV_Y_GRID,WHITE);
    TV.printPGM(5,TV_Y_OFFSET+3*TV_Y_GRID,  PSTR("FREQ:     GHz"));
    TV.draw_line(0,4*TV_Y_GRID,TV_X_MAX,4*TV_Y_GRID,WHITE);
    TV.select_font(font4x6);
    TV.printPGM(5,TV_Y_OFFSET+4*TV_Y_GRID,  PSTR("RSSI:"));
    TV.draw_line(0,5*TV_Y_GRID-4,TV_X_MAX,5*TV_Y_GRID-4,WHITE);
    // frame for tune graph
    TV.draw_rect(0,TV_ROWS - TV_SCANNER_OFFSET,TV_X_MAX,13,  WHITE); // lower frame
    TV.print(2, (TV_ROWS - TV_SCANNER_OFFSET + 2), "5645");
    TV.print(57, (TV_ROWS - TV_SCANNER_OFFSET + 2), "5800");
    TV.print(111, (TV_ROWS - TV_SCANNER_OFFSET + 2), "5945");

}
void screens::diversity(uint8_t diversity_mode) {
    reset();
    drawTitleBox("DIVERSITY");
    TV.printPGM(10, 5+1*MENU_Y_SIZE, PSTR("Auto"));
    TV.printPGM(10, 5+2*MENU_Y_SIZE, PSTR("Receiver A"));
    TV.printPGM(10, 5+3*MENU_Y_SIZE, PSTR("Receiver B"));
    // RSSI Strength
    TV.draw_line(0,3+4*MENU_Y_SIZE, TV_X_MAX, 3+4*MENU_Y_SIZE, WHITE);
    TV.printPGM(10, 6+4*MENU_Y_SIZE, PSTR("A:"));
    TV.draw_line(0,3+5*MENU_Y_SIZE, TV_X_MAX, 3+5*MENU_Y_SIZE, WHITE);
    TV.printPGM(10, 6+5*MENU_Y_SIZE, PSTR("B:"));

    TV.draw_rect(0,3+(diversity_mode+1)*MENU_Y_SIZE,127,12,  WHITE, INVERT);
}
void screens::mainMenu(uint8_t menu_id) {
    reset(); // start from fresh screen.
    drawTitleBox("MODE SELECTION");

    TV.printPGM(10, 5+1*MENU_Y_SIZE, PSTR("Auto Search"));
    TV.printPGM(10, 5+2*MENU_Y_SIZE, PSTR("Band Scanner"));
    TV.printPGM(10, 5+3*MENU_Y_SIZE, PSTR("Manual Mode"));
#ifdef USE_DIVERSITY
    TV.printPGM(10, 5+4*MENU_Y_SIZE, PSTR("Diversity"));
#endif
    TV.printPGM(10, 5+5*MENU_Y_SIZE, PSTR("Save Setup"));
    // selection by inverted box

    TV.draw_rect(0,3+(menu_id+1)*MENU_Y_SIZE,127,12,  WHITE, INVERT);
}
void screens::save(uint8_t mode, uint8_t channelIndex, uint16_t channelFrequency) {
    reset();
    drawTitleBox("SAVE SETTINGS");
    TV.printPGM(10, 5+1*MENU_Y_SIZE, PSTR("Mode:"));
    switch (mode)
    {
        case STATE_SCAN: // Band Scanner
            TV.printPGM(50,5+1*MENU_Y_SIZE,  PSTR("Scanner"));
        break;
        case STATE_MANUAL: // manual mode
            TV.printPGM(50,5+1*MENU_Y_SIZE,  PSTR("Manual"));
        break;
        case STATE_SEEK: // seek mode
            TV.printPGM(50,5+1*MENU_Y_SIZE,  PSTR("Search"));
        break;
    }
    TV.printPGM(10, 5+2*MENU_Y_SIZE, PSTR("Band:"));
    // print band
    if(channelIndex > 31)
    {
        TV.printPGM(50,5+2*MENU_Y_SIZE,  PSTR("C/Race   "));
    }
    else if(channelIndex > 23)
    {
        TV.printPGM(50,5+2*MENU_Y_SIZE,  PSTR("F/Airwave"));
    }
    else if (channelIndex > 15)
    {
        TV.printPGM(50,5+2*MENU_Y_SIZE,  PSTR("E        "));
    }
    else if (channelIndex > 7)
    {
        TV.printPGM(50,5+2*MENU_Y_SIZE,  PSTR("B        "));
    }
    else
    {
        TV.printPGM(50,5+2*MENU_Y_SIZE,  PSTR("A        "));
    }
    TV.printPGM(10, 5+3*MENU_Y_SIZE, PSTR("Chan:"));
    uint8_t active_channel = channelIndex%CHANNEL_BAND_SIZE+1; // get channel inside band
    TV.print(50,5+3*MENU_Y_SIZE,active_channel,DEC);
    TV.printPGM(10, 5+4*MENU_Y_SIZE, PSTR("FREQ:     GHz"));
    TV.print(50,5+4*MENU_Y_SIZE, channelFrequency);
    TV.printPGM(10, 5+5*MENU_Y_SIZE, PSTR("--- SAVED ---"));
}
void screens::updateSeekMode(uint8_t state, uint8_t channelIndex, uint8_t channel, uint8_t rssi, uint16_t channelFrequency, bool locked) {
    // display refresh handler
    TV.select_font(font8x8);
    if(channelIndex != last_channel) // only updated on changes
    {
        // show current used channel of bank
        if(channelIndex > 31)
        {
            TV.printPGM(50,TV_Y_OFFSET+1*TV_Y_GRID,  PSTR("C/Race   "));
        }
        else if(channelIndex > 23)
        {
            TV.printPGM(50,TV_Y_OFFSET+1*TV_Y_GRID,  PSTR("F/Airwave"));
        }
        else if (channelIndex > 15)
        {
            TV.printPGM(50,TV_Y_OFFSET+1*TV_Y_GRID,  PSTR("E        "));
        }
        else if (channelIndex > 7)
        {
            TV.printPGM(50,TV_Y_OFFSET+1*TV_Y_GRID,  PSTR("B        "));
        }
        else
        {
            TV.printPGM(50,TV_Y_OFFSET+1*TV_Y_GRID,  PSTR("A        "));
        }
        // show channel inside band
        uint8_t active_channel = channelIndex%CHANNEL_BAND_SIZE; // get channel inside band

        TV.draw_rect(1 ,TV_Y_OFFSET-2+2*TV_Y_GRID,125,12,  BLACK, BLACK); // mark current channel
        TV.printPGM(5 ,TV_Y_OFFSET-1+2*TV_Y_GRID,  PSTR("1 2 3 4 5 6 7 8"));
        // set new marker
        TV.draw_rect(active_channel*16+2 ,TV_Y_OFFSET-2+2*TV_Y_GRID,12,12,  WHITE, INVERT); // mark current channel

        // clear last square
        TV.draw_rect(1, (TV_ROWS - TV_SCANNER_OFFSET + 8),125,SCANNER_MARKER_SIZE,  BLACK, BLACK);
        // draw next
        TV.draw_rect((channel * 3)+5, (TV_ROWS - TV_SCANNER_OFFSET + 8),SCANNER_MARKER_SIZE,SCANNER_MARKER_SIZE,  WHITE, WHITE);

        // show frequence
        TV.print(50,TV_Y_OFFSET+3*TV_Y_GRID, channelFrequency);
    }
    // show signal strength
    #define RSSI_BAR_SIZE 100
    uint8_t rssi_scaled=map(rssi, 1, 100, 1, RSSI_BAR_SIZE);
    // clear last bar
    TV.draw_rect(25, TV_Y_OFFSET+4*TV_Y_GRID, RSSI_BAR_SIZE,4 , BLACK, BLACK);
    //  draw new bar
    TV.draw_rect(25, TV_Y_OFFSET+4*TV_Y_GRID, rssi_scaled, 4 , WHITE, WHITE);
    // print bar for spectrum

    #define SCANNER_BAR_MINI_SIZE 14
    rssi_scaled=map(rssi, 1, 100, 1, SCANNER_BAR_MINI_SIZE);
    // clear last bar
    TV.draw_rect((channel * 3)+4, (TV_ROWS - TV_SCANNER_OFFSET - SCANNER_BAR_MINI_SIZE), 2, SCANNER_BAR_MINI_SIZE , BLACK, BLACK);
    //  draw new bar
    TV.draw_rect((channel * 3)+4, (TV_ROWS - TV_SCANNER_OFFSET - rssi_scaled), 2, rssi_scaled , WHITE, WHITE);
    // handling for seek mode after screen and RSSI has been fully processed
    if(state == STATE_SEEK)
    { // SEEK MODE
        if(last_channel != channelIndex) {
            // fix title flicker
            TV.draw_rect(0,0,127,14, WHITE,BLACK);
            if(locked) {
                TV.printPGM(((127-14*8)/2), TV_Y_OFFSET,  PSTR("AUTO MODE LOCK"));
            }
            else
            {
                TV.printPGM(((127-14*8)/2), TV_Y_OFFSET,  PSTR("AUTO MODE SEEK"));
            }
            TV.draw_rect(0,0,127,14,  WHITE,INVERT);
        }
    }

    last_channel = channelIndex;
}