void screens::diversity(uint8_t diversity_mode) { reset(); drawTitleBox(PSTR2("DIVERSITY")); //selected display.fillRect(0, 10*diversity_mode+12, display.width(), 10, WHITE); display.setTextColor(diversity_mode == useReceiverAuto ? BLACK : WHITE); display.setCursor(5,10*1+3); display.print(PSTR2("AUTO")); display.setTextColor(diversity_mode == useReceiverA ? BLACK : WHITE); display.setCursor(5,10*2+3); display.print(PSTR2("RECEIVER A")); display.setTextColor(diversity_mode == useReceiverB ? BLACK : WHITE); display.setCursor(5,10*3+3); display.print(PSTR2("RECEIVER B")); // RSSI Strength display.setTextColor(WHITE); display.drawRect(0, display.height()-21, display.width(), 11, WHITE); display.setCursor(5,display.height()-19); display.print("A:"); display.setCursor(5,display.height()-9); display.print("B:"); display.display(); }
void screens::updateBandScanMode(bool in_setup, uint8_t channel, uint8_t rssi, uint8_t channelName, uint16_t channelFrequency, uint16_t rssi_setup_min_a, uint16_t rssi_setup_max_a, bool channel_enabled) { #define SCANNER_LIST_X_POS 60 static uint8_t writePos = SCANNER_LIST_X_POS; uint8_t rssi_scaled=map(rssi, 1, 100, 1, 30); uint16_t hight = (display.height()-12-rssi_scaled); if(channel != last_channel) // only updated on changes { display.fillRect((channel*3)+4,display.height()-12-30,3,30-rssi_scaled,BLACK); //Draw thick line for enabled channels and thin line for disabled channels if (channel_enabled) { display.fillRect((channel*3)+4,hight,3,rssi_scaled,WHITE); } else { display.drawRect((channel*3)+4,hight,1,rssi_scaled,WHITE); } // Show Scan Position display.fillRect((channel*3)+4+3,display.height()-12-30,1,30,BLACK); } if(!in_setup) { if (rssi > RSSI_SEEK_TRESHOLD) { if(best_rssi < rssi) { best_rssi = rssi; display.setTextColor(WHITE,BLACK); display.setCursor(36,12); display.print(channelName, HEX); display.setCursor(52,12); display.print(channelFrequency); } else { if(writePos+10>display.width()-12) { // keep writing on the screen writePos=SCANNER_LIST_X_POS; } } } } else { display.setCursor(30,12); display.setTextColor(WHITE,BLACK); display.print( PSTR2(" ") ); display.setCursor(30,12); display.print( rssi_setup_min_a , DEC); display.setCursor(85,12); display.setTextColor(WHITE,BLACK); display.setCursor(85,12); display.print( PSTR2(" ") ); display.print( rssi_setup_max_a , DEC); } display.display(); last_channel = channel; }
void screens::updateSetupMenu(uint8_t menu_id, bool settings_beeps, bool settings_orderby_channel, const char *call_sign, char editing){ reset(); drawTitleBox(PSTR2("SETUP MENU")); //selected display.fillRect(0, 10*menu_id+12, display.width(), 10, WHITE); display.setTextColor(menu_id == 0 ? BLACK : WHITE); display.setCursor(5,10*1+3); display.print(PSTR2("ORDER: ")); if(settings_orderby_channel) { display.print(PSTR2("CHANNEL ")); } else { display.print(PSTR2("FREQUENCY")); } display.setTextColor(menu_id == 1 ? BLACK : WHITE); display.setCursor(5,10*2+3); display.print(PSTR2("BEEPS: ")); if(settings_beeps) { display.print(PSTR2("ON ")); } else { display.print(PSTR2("OFF")); } display.setTextColor(menu_id == 2 ? BLACK : WHITE); display.setCursor(5,10*3+3); display.print(PSTR2("SIGN : ")); if(editing>=0) { display.fillRect(6*6+5, 10*2+13, display.width()-(6*6+6), 8, BLACK); display.fillRect(6*7+6*(editing)+4, 10*2+13, 7, 8, WHITE); //set cursor for(uint8_t i=0; i<10; i++) { display.setTextColor(i == editing ? BLACK : WHITE); display.print(call_sign[i]); } } else { display.print(call_sign); } display.setTextColor(menu_id == 3 ? BLACK : WHITE); display.setCursor(5,10*4+3); display.print(PSTR2("CALIBRATE RSSI")); display.setTextColor(menu_id == 4 ? BLACK : WHITE); display.setCursor(5,10*5+3); display.print(PSTR2("SAVE & EXIT")); display.display(); }
void screens::bandScanMode(uint8_t state) { reset(); // start from fresh screen. best_rssi = 0; if(state==STATE_SCAN) { drawTitleBox(PSTR2("BAND SCANNER")); display.setCursor(5,12); display.print(PSTR2("BEST:")); } else { drawTitleBox(PSTR2("RSSI SETUP")); display.setCursor(5,12); display.print(PSTR2("Min: Max:")); } display.drawFastHLine(0, 20, display.width(), WHITE); display.drawFastHLine(0, display.height()-11, display.width(), WHITE); display.setCursor(2,display.height()-9); #ifdef USE_LBAND display.print(PSTR2("5362")); #else display.print(PSTR2("5645")); #endif display.setCursor(55,display.height()-9); display.print(PSTR2("5800")); display.setCursor(display.width()-25,display.height()-9); display.print(PSTR2("5945")); display.display(); }
void screens::updateChannelSetupMenu(uint8_t menu_id, bool settings_orderby_channel, bool settings_channel_filter_on, const char *channel_filter_preset_name, int8_t channel_filter_preset_id) { reset(); //Screen Title drawTitleBox(PSTR2("CHANNEL SETUP")); //Highlight Selected display.fillRect(0, 10*menu_id+12, display.width(), 10, WHITE); //Channel Sort Channel / Frequency display.setTextColor(menu_id == 0 ? BLACK : WHITE); display.setCursor(5,10*1+3); display.print(PSTR2("ORDER: ")); if(settings_orderby_channel) { display.print(PSTR2("CHANNEL ")); } else { display.print(PSTR2("FREQUENCY")); } //Channel Filter On / Off display.setTextColor(menu_id == 1 ? BLACK : WHITE); display.setCursor(5,10*2+3); display.print(PSTR2("CHANNEL FILTER: ")); if(settings_channel_filter_on) { display.print(PSTR2("ON ")); } else { display.print(PSTR2("OFF")); } //Display Name of Current Preset display.setTextColor(menu_id == 2 ? BLACK : WHITE); display.setCursor(5,10*3+3); display.print(PSTR2("PRESET: ")); display.print(channel_filter_preset_name); //Edit Filter display.setTextColor(menu_id == 3 ? BLACK : WHITE); display.setCursor(5,10*4+3); display.print(PSTR2("EDIT FILTER")); //Exit display.setTextColor(menu_id == 4 ? BLACK : WHITE); display.setCursor(5,10*5+3); display.print(PSTR2("EXIT")); display.display(); }
void screens::updateEditChannelFilter(uint8_t channel_id, const uint8_t *channel_filter, const uint16_t *channelFreqTable, const uint8_t *channelNames) { int screen_line; int ce_ct; int ce_ct_adj; reset(); drawTitleBox(PSTR2("FILTER EDIT")); display.display(); screen_line = 1; display.fillRect(0, 10*2+12, display.width(), 10, WHITE); for (ce_ct=(channel_id-2);ce_ct<=(channel_id+2);ce_ct++) { if ((ce_ct>=CHANNEL_MIN-1) && (ce_ct<=CHANNEL_MAX+1)) { ce_ct_adj = ce_ct; } else if (ce_ct <= CHANNEL_MIN) { ce_ct_adj = (CHANNEL_MAX+1) + ce_ct; } else { ce_ct_adj = (CHANNEL_MIN-1) + abs((CHANNEL_MAX+1)-ce_ct); } display.setCursor(5,10*screen_line+3); display.setTextColor(screen_line == 3 ? BLACK : WHITE); if ((ce_ct_adj == (CHANNEL_MIN-1)) || (ce_ct_adj == (CHANNEL_MAX+1))) { display.print(PSTR2("EXIT")); } else { //Display Channel Name display.print(pgm_read_byte_near(channelNames + ce_ct_adj), HEX); //Display Channel Freq display.print(PSTR2(" (")); display.print(pgm_read_word_near(channelFreqTable + ce_ct_adj), DEC); display.print(PSTR2("): ")); //Display Channel Status On/Off display.print((bitRead(channel_filter[ce_ct_adj / 8], ce_ct_adj - (ce_ct_adj / 8) * 8)) == 1 ? PSTR2("On ") : PSTR2("Off")); } screen_line++; } display.display(); }
void screens::seekMode(uint8_t state) { last_channel = -1; reset(); // start from fresh screen. if (state == STATE_MANUAL) { drawTitleBox(PSTR2("MANUAL MODE")); } else if(state == STATE_SEEK) { drawTitleBox(PSTR2("AUTO SEEK MODE")); } display.setTextColor(WHITE); display.drawFastHLine(0, 20, display.width(), WHITE); display.drawFastHLine(0, 32, display.width(), WHITE); display.setCursor(5,12); display.drawFastVLine(97, 11, 9, WHITE); display.print(PSTR2("BAND:")); for(uint16_t i=0;i<8;i++) { display.setCursor(15*i+8,23); display.print((char) (i+'1')); } display.drawFastHLine(0, 36, display.width(), WHITE); display.drawFastHLine(0, display.height() - 11, display.width(), WHITE); display.setCursor(2,display.height()-9); #ifdef USE_LBAND display.print(PSTR2("5362")); #else display.print(PSTR2("5645")); #endif display.setCursor(55,display.height()-9); display.print(PSTR2("5800")); display.setCursor(display.width()-25,display.height()-9); display.print(PSTR2("5945")); display.display(); }
void screens::screenSaver(uint8_t diversity_mode, uint8_t channelName, uint16_t channelFrequency, const char *call_sign) { reset(); #ifdef USE_DIM_ON_SCREENSAVER display.dim(true); #endif display.setTextSize(6); display.setTextColor(WHITE); display.setCursor(0,0); display.print(channelName, HEX); display.setTextSize(1); display.setCursor(70,0); display.print(call_sign); display.setTextSize(2); display.setCursor(70,28); display.setTextColor(WHITE); display.print(channelFrequency); display.setTextSize(1); #ifdef USE_DIVERSITY if(isDiversity()) { display.setCursor(70,18); switch(diversity_mode) { case useReceiverAuto: display.print(PSTR2("AUTO")); break; case useReceiverA: display.print(PSTR2("ANTENNA A")); break; case useReceiverB: display.print(PSTR2("ANTENNA B")); break; } display.setTextColor(BLACK,WHITE); display.fillRect(0, display.height()-19, 7, 9, WHITE); display.setCursor(1,display.height()-18); display.print("A"); display.setTextColor(BLACK,WHITE); display.fillRect(0, display.height()-9, 7, 9, WHITE); display.setCursor(1,display.height()-8); display.print("B"); } #endif display.display(); }
void screens::mainMenu(uint8_t menu_id) { reset(); // start from fresh screen. drawTitleBox(PSTR2("MODE SELECTION")); display.fillRect(0, 10*menu_id+12, display.width(), 10,WHITE); display.setTextColor(menu_id == 0 ? BLACK : WHITE); display.setCursor(5,10*0+13); display.print(PSTR2("AUTO SEARCH")); display.setTextColor(menu_id == 1 ? BLACK : WHITE); display.setCursor(5,10*1+13); display.print(PSTR2("BAND SCANNER")); display.setTextColor(menu_id == 2 ? BLACK : WHITE); display.setCursor(5,10*2+13); display.print(PSTR2("MANUAL MODE")); #ifdef USE_DIVERSITY if(isDiversity()) { display.setTextColor(menu_id == 3 ? BLACK : WHITE); display.setCursor(5,10*3+13); display.print(PSTR2("DIVERSITY")); } #endif display.setTextColor(menu_id == 4 ? BLACK : WHITE); display.setCursor(5,10*4+13); display.print(PSTR2("SETUP MENU")); display.display(); }
void screens::voltage(uint8_t menu_id, int voltage_calibration, uint8_t warning_voltage, uint8_t critical_voltage) { reset(); drawTitleBox(PSTR2("VOLTAGE ALARM")); display.fillRect(0, 10*menu_id+12, display.width(), 10, WHITE); display.setTextColor(menu_id == 0 ? BLACK : WHITE); display.setCursor(5,10*1+3); display.print(PSTR2("Warning:")); display.setCursor(80 ,10*1+3); display.print((float)warning_voltage/10.0); display.setTextColor(menu_id == 1 ? BLACK : WHITE); display.setCursor(5,10*2+3); display.print(PSTR2("Critical:")); display.setCursor(80 ,10*2+3); display.print((float)critical_voltage/10.0); display.setTextColor(menu_id == 2 ? BLACK : WHITE); display.setCursor(5,10*3+3); display.print(PSTR2("Calibrate:")); display.setCursor(80 ,10*3+3); display.print(voltage_calibration); display.setTextColor(menu_id == 3 ? BLACK : WHITE); display.setCursor(5,10*4+3); display.print(PSTR2("Save")); display.setTextColor(WHITE); display.setCursor(5,10*5+3); display.print(PSTR2("Measured:")); display.display(); }
void screens::updateVoltageScreenSaver(int voltage, bool alarm){ if(alarm){ display.setTextColor((millis()%250 < 125) ? WHITE : BLACK, BLACK); } else { display.setTextColor(INVERT); } display.setCursor(70,9); display.print((float)voltage/10.0); display.print(PSTR2("V")); display.setTextColor(BLACK); display.display(); }
char screens::begin(const char *call_sign) { // Set the address of your OLED Display. // 128x64 ONLY!! #ifdef SH1106 display.begin(SH1106_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D or 0x3C (for the 128x64) #else display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D or 0x3C (for the 128x64) #endif #ifdef USE_FLIP_SCREEN flip(); #endif #ifdef USE_BOOT_LOGO display.display(); // show splash screen delay(3000); #endif // init done reset(); #ifdef USE_BOOT_CHECK display.fillRect(0, 0, display.width(), 11,WHITE); display.setTextColor(BLACK); display.setCursor(((display.width() - (10*6)) / 2),2); display.print(PSTR2("Boot Check")); display.setTextColor(WHITE); display.setCursor(0,8*1+4); display.print(PSTR2("Power:")); display.setCursor(display.width()-6*3,8*1+4); display.print(PSTR2("OK")); display.setCursor(0,8*2+4); display.display(); #ifdef USE_DIVERSITY display.print(PSTR2("Diversity:")); display.display(); delay(250); display.setCursor(display.width()-6*9,8*2+4); if(isDiversity()) { display.print(PSTR2(" ENABLED")); } else { display.print(PSTR2("DISABLED")); } #endif display.setCursor(((display.width() - (strlen(call_sign)*12)) / 2),8*4+4); display.setTextSize(2); display.print(call_sign); display.display(); delay(1250); #endif return 0; // no errors }
void screens::save(uint8_t mode, uint8_t channelIndex, uint16_t channelFrequency, const char *call_sign) { reset(); drawTitleBox(PSTR2("SAVE SETTINGS")); display.setTextColor(WHITE); display.setCursor(5,8*1+4); display.print(PSTR2("MODE:")); display.setCursor(38,8*1+4); switch (mode) { case STATE_SCAN: // Band Scanner display.print(PSTR2("BAND SCANNER")); break; case STATE_MANUAL: // manual mode display.print(PSTR2("MANUAL")); break; case STATE_SEEK: // seek mode display.print(PSTR2("AUTO SEEK")); break; } display.setCursor(5,8*2+4); display.print(PSTR2("BAND:")); display.setCursor(38,8*2+4); // print band if(channelIndex > 31) { display.print(PSTR2("C/Race")); } else if(channelIndex > 23) { display.print(PSTR2("F/Airwave")); } else if (channelIndex > 15) { display.print(PSTR2("E")); } else if (channelIndex > 7) { display.print(PSTR2("B")); } else { display.print(PSTR2("A")); } display.setCursor(5,8*3+4); display.print(PSTR2("CHAN:")); display.setCursor(38,8*3+4); uint8_t active_channel = channelIndex%CHANNEL_BAND_SIZE+1; // get channel inside band display.print(active_channel,DEC); display.setCursor(5,8*4+4); display.print(PSTR2("FREQ: GHz")); display.setCursor(38,8*4+4); display.print(channelFrequency); display.setCursor(5,8*5+4); display.print(PSTR2("SIGN:")); display.setCursor(38,8*5+4); display.print(call_sign); display.setCursor(((display.width()-11*6)/2),8*6+4); display.print(PSTR2("-- SAVED --")); display.display(); }
void screens::updateScreenSaver(char active_receiver, uint8_t rssi, uint8_t rssiA, uint8_t rssiB) { #ifdef USE_DIVERSITY if(isDiversity()) { // read rssi A #define RSSI_BAR_SIZE 119 uint8_t rssi_scaled=map(rssiA, 1, 100, 3, RSSI_BAR_SIZE); display.fillRect(7 + rssi_scaled, display.height()-19, (RSSI_BAR_SIZE-rssi_scaled), 9, BLACK); if(active_receiver == useReceiverA) { display.fillRect(7, display.height()-19, rssi_scaled, 9, WHITE); } else { display.fillRect(7, display.height()-19, (RSSI_BAR_SIZE), 9, BLACK); display.drawRect(7, display.height()-19, rssi_scaled, 9, WHITE); } // read rssi B rssi_scaled=map(rssiB, 1, 100, 3, RSSI_BAR_SIZE); display.fillRect(7 + rssi_scaled, display.height()-9, (RSSI_BAR_SIZE-rssi_scaled), 9, BLACK); if(active_receiver == useReceiverB) { display.fillRect(7, display.height()-9, rssi_scaled, 9, WHITE); } else { display.fillRect(7, display.height()-9, (RSSI_BAR_SIZE), 9, BLACK); display.drawRect(7, display.height()-9, rssi_scaled, 9, WHITE); } } else { display.setTextColor(BLACK); display.fillRect(0, display.height()-19, 25, 19, WHITE); display.setCursor(1,display.height()-13); display.print(PSTR2("RSSI")); #define RSSI_BAR_SIZE 101 uint8_t rssi_scaled=map(rssi, 1, 100, 1, RSSI_BAR_SIZE); display.fillRect(25 + rssi_scaled, display.height()-19, (RSSI_BAR_SIZE-rssi_scaled), 19, BLACK); display.fillRect(25, display.height()-19, rssi_scaled, 19, WHITE); } #else display.setTextColor(BLACK); display.fillRect(0, display.height()-19, 25, 19, WHITE); display.setCursor(1,display.height()-13); display.print(PSTR2("RSSI")); #define RSSI_BAR_SIZE 101 uint8_t rssi_scaled=map(rssi, 1, 100, 1, RSSI_BAR_SIZE); display.fillRect(25 + rssi_scaled, display.height()-19, (RSSI_BAR_SIZE-rssi_scaled), 19, BLACK); display.fillRect(25, display.height()-19, rssi_scaled, 19, WHITE); #endif if(rssi < 20) { display.setTextColor((millis()%250 < 125) ? WHITE : BLACK, BLACK); display.setCursor(50,display.height()-13); display.print(PSTR2("LOW SIGNAL")); } #ifdef USE_DIVERSITY else if(isDiversity()) { display.drawLine(50,display.height()-10,110,display.height()-10,BLACK); } #endif display.display(); }
void screens::updateSeekMode(uint8_t state, uint8_t channelIndex, uint8_t channel, uint8_t rssi, uint16_t channelFrequency, uint8_t rssi_seek_threshold, bool locked) { // display refresh handler if(channel != last_channel) // only updated on changes { if(channel > last_channel) { scan_position = 3; } else { scan_position = -1; } display.setTextColor(WHITE,BLACK); display.setCursor(36,12); // show current used channel of bank if(channelIndex > 31) { display.print(PSTR2("C/Race ")); } else if(channelIndex > 23) { display.print(PSTR2("F/Airwave")); } else if (channelIndex > 15) { display.print(PSTR2("E ")); } else if (channelIndex > 7) { display.print(PSTR2("B ")); } else { display.print(PSTR2("A ")); } uint8_t active_channel = channelIndex%CHANNEL_BAND_SIZE; // get channel inside band for(int i=0;i<8;i++) { display.fillRect(15*i+4,21,14,11,i==active_channel? WHITE:BLACK); display.setTextColor(i==active_channel? BLACK:WHITE); display.setCursor(15*i+8,23); display.print((char) (i+'1')); } // show frequence display.setCursor(101,12); display.setTextColor(WHITE,BLACK); display.print(channelFrequency); } // show signal strength uint8_t rssi_scaled=map(rssi, 1, 100, 1, display.width()-3); display.fillRect(1+rssi_scaled, 33, display.width()-3-rssi_scaled, 3, BLACK); display.fillRect(1, 33, rssi_scaled, 3, WHITE); rssi_scaled=map(rssi, 1, 100, 1, 14); display.fillRect((channel*3)+4,display.height()-12-14,3,14-rssi_scaled,BLACK); display.fillRect((channel*3)+4,(display.height()-12-rssi_scaled),3,rssi_scaled,WHITE); // handling for seek mode after screen and RSSI has been fully processed if(state == STATE_SEEK) // { // SEEK MODE // Show Scan Position display.fillRect((channel*3)+4+scan_position,display.height()-12-14,1,14,BLACK); rssi_scaled=map(rssi_seek_threshold, 1, 100, 1, 14); display.fillRect(1,display.height()-12-14,2,14,BLACK); display.drawLine(1,display.height()-12-rssi_scaled,2,display.height()-12-rssi_scaled, WHITE); display.fillRect(display.width()-3,display.height()-12-14,2,14,BLACK); display.drawLine(display.width()-3,display.height()-12-rssi_scaled,display.width(),display.height()-12-rssi_scaled, WHITE); if(locked) // search if not found { display.setTextColor(BLACK,WHITE); display.setCursor(((display.width()-14*6)/2),2); display.print(PSTR2("AUTO MODE LOCK")); } else { display.setTextColor(BLACK,WHITE); display.setCursor(((display.width()-14*6)/2),2); display.print(PSTR2("AUTO SEEK MODE")); } } last_channel = channel; display.display(); }