2020-02-10 10:02:03 +01:00
|
|
|
#include "menu_main_buttons.h"
|
|
|
|
|
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <WString.h>//F()
|
|
|
|
|
|
|
|
#include "bands.h"
|
2020-04-26 04:47:02 +02:00
|
|
|
#include "button.h"
|
2020-04-26 05:31:10 +02:00
|
|
|
#include "callsign.h"
|
2020-02-10 10:02:03 +01:00
|
|
|
#include "color_theme.h"
|
2020-02-15 03:51:28 +01:00
|
|
|
#include "menu_main.h"
|
|
|
|
#include "menu_numpad.h"
|
2020-02-12 08:36:43 +01:00
|
|
|
#include "morse.h"
|
2020-02-10 10:02:03 +01:00
|
|
|
#include "nano_gui.h"
|
2020-04-22 06:19:47 +02:00
|
|
|
#include "scratch_space.h"
|
2020-02-10 10:02:03 +01:00
|
|
|
#include "settings.h"
|
2020-02-16 00:31:14 +01:00
|
|
|
#include "setup.h"
|
2020-04-22 06:19:47 +02:00
|
|
|
#include "tuner.h"
|
2020-02-10 10:02:03 +01:00
|
|
|
#include "utils.h"
|
2020-04-26 05:31:10 +02:00
|
|
|
#include "version.h"
|
2020-02-10 10:02:03 +01:00
|
|
|
|
|
|
|
static const unsigned int LAYOUT_VFO_LABEL_X = 0;
|
|
|
|
static const unsigned int LAYOUT_VFO_LABEL_Y = 10;
|
|
|
|
static const unsigned int LAYOUT_VFO_LABEL_WIDTH = 159;
|
|
|
|
static const unsigned int LAYOUT_VFO_LABEL_HEIGHT = 36;
|
|
|
|
static const unsigned int LAYOUT_VFO_LABEL_PITCH_X = 160;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_MODE_TEXT_X = 0;
|
|
|
|
static const unsigned int LAYOUT_MODE_TEXT_Y = LAYOUT_VFO_LABEL_Y + LAYOUT_VFO_LABEL_HEIGHT + 1;
|
|
|
|
static const unsigned int LAYOUT_MODE_TEXT_WIDTH = 320;
|
|
|
|
static const unsigned int LAYOUT_MODE_TEXT_HEIGHT = 36;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_BUTTON_X = 2;
|
|
|
|
static const unsigned int LAYOUT_BUTTON_Y = LAYOUT_MODE_TEXT_Y + LAYOUT_MODE_TEXT_HEIGHT + 1;
|
|
|
|
static const unsigned int LAYOUT_BUTTON_WIDTH = 60;
|
|
|
|
static const unsigned int LAYOUT_BUTTON_HEIGHT = 36;
|
|
|
|
static const unsigned int LAYOUT_BUTTON_PITCH_X = 64;
|
|
|
|
static const unsigned int LAYOUT_BUTTON_PITCH_Y = 40;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_CW_TEXT_X = 0;
|
|
|
|
static const unsigned int LAYOUT_CW_TEXT_Y = LAYOUT_BUTTON_Y + 3*LAYOUT_BUTTON_PITCH_Y + 1;
|
|
|
|
static const unsigned int LAYOUT_CW_TEXT_WIDTH = 220;
|
|
|
|
static const unsigned int LAYOUT_CW_TEXT_HEIGHT = 36;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_VERSION_TEXT_X = LAYOUT_CW_TEXT_X + LAYOUT_CW_TEXT_WIDTH + 1;
|
|
|
|
static const unsigned int LAYOUT_VERSION_TEXT_Y = LAYOUT_CW_TEXT_Y;
|
|
|
|
static const unsigned int LAYOUT_VERSION_TEXT_WIDTH = 320 - LAYOUT_CW_TEXT_WIDTH - 1;
|
|
|
|
static const unsigned int LAYOUT_VERSION_TEXT_HEIGHT = LAYOUT_CW_TEXT_HEIGHT;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_TX_X = 280;
|
|
|
|
static const unsigned int LAYOUT_TX_Y = LAYOUT_MODE_TEXT_Y;
|
|
|
|
static const unsigned int LAYOUT_TX_WIDTH = 40;
|
|
|
|
static const unsigned int LAYOUT_TX_HEIGHT = 36;
|
|
|
|
|
2020-04-26 05:31:10 +02:00
|
|
|
void drawTx()
|
|
|
|
{
|
|
|
|
if(globalSettings.txActive){
|
|
|
|
strncpy_P(b,(const char*)F("TX"),sizeof(b));
|
|
|
|
displayText(b,LAYOUT_TX_X,LAYOUT_TX_Y,LAYOUT_TX_WIDTH,LAYOUT_TX_HEIGHT,COLOR_ACTIVE_TEXT,COLOR_ACTIVE_BACKGROUND,COLOR_BACKGROUND);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
displayFillrect(LAYOUT_TX_X,LAYOUT_TX_Y,LAYOUT_TX_WIDTH,LAYOUT_TX_HEIGHT,COLOR_BACKGROUND);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void drawVersion()
|
|
|
|
{
|
|
|
|
strncpy_P(b,VERSION_STRING,sizeof(b));
|
|
|
|
displayText(b,LAYOUT_VERSION_TEXT_X,LAYOUT_VERSION_TEXT_Y,LAYOUT_VERSION_TEXT_WIDTH,LAYOUT_VERSION_TEXT_HEIGHT,COLOR_VERSION_TEXT,COLOR_BACKGROUND,COLOR_BACKGROUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
void drawCallsign()
|
|
|
|
{
|
2020-04-26 05:34:47 +02:00
|
|
|
strncpy_P(b,CALLSIGN_STRING,sizeof(b));
|
2020-04-26 07:56:35 +02:00
|
|
|
displayText(b,LAYOUT_CW_TEXT_X,LAYOUT_CW_TEXT_Y,LAYOUT_CW_TEXT_WIDTH,LAYOUT_CW_TEXT_HEIGHT,COLOR_VERSION_TEXT,COLOR_BACKGROUND,COLOR_BACKGROUND);
|
2020-04-26 05:31:10 +02:00
|
|
|
}
|
|
|
|
|
2020-02-10 10:17:47 +01:00
|
|
|
void toVfoA(char* text_out, const uint16_t max_text_size);
|
|
|
|
ButtonStatus_e bsVfoA();
|
|
|
|
void osVfoA();
|
|
|
|
constexpr Button bVfoA PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_VFO_LABEL_X + 0*LAYOUT_VFO_LABEL_PITCH_X,
|
|
|
|
LAYOUT_VFO_LABEL_Y,
|
|
|
|
LAYOUT_VFO_LABEL_WIDTH,
|
|
|
|
LAYOUT_VFO_LABEL_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
nullptr,
|
|
|
|
toVfoA,
|
|
|
|
bsVfoA,
|
|
|
|
osVfoA,
|
|
|
|
'A'
|
|
|
|
};
|
|
|
|
|
|
|
|
void toVfoB(char* text_out, const uint16_t max_text_size);
|
|
|
|
ButtonStatus_e bsVfoB();
|
|
|
|
void osVfoB();
|
|
|
|
constexpr Button bVfoB PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_VFO_LABEL_X + 1*LAYOUT_VFO_LABEL_PITCH_X,
|
|
|
|
LAYOUT_VFO_LABEL_Y,
|
|
|
|
LAYOUT_VFO_LABEL_WIDTH,
|
|
|
|
LAYOUT_VFO_LABEL_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
nullptr,
|
|
|
|
toVfoB,
|
|
|
|
bsVfoB,
|
|
|
|
osVfoB,
|
|
|
|
'B'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txtRit [] PROGMEM = "RIT";
|
|
|
|
ButtonStatus_e bsRit();
|
|
|
|
void osRit();
|
|
|
|
constexpr Button bRit PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 0*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txtRit,
|
|
|
|
nullptr,
|
|
|
|
bsRit,
|
|
|
|
osRit,
|
|
|
|
'R'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txtUsb [] PROGMEM = "USB";
|
|
|
|
ButtonStatus_e bsUsb();
|
|
|
|
void osUsb();
|
|
|
|
constexpr Button bUsb PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 1*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txtUsb,
|
|
|
|
nullptr,
|
|
|
|
bsUsb,
|
|
|
|
osUsb,
|
|
|
|
'U'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txtLsb [] PROGMEM = "LSB";
|
|
|
|
ButtonStatus_e bsLsb();
|
|
|
|
void osLsb();
|
|
|
|
constexpr Button bLsb PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 2*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txtLsb,
|
|
|
|
nullptr,
|
|
|
|
bsLsb,
|
|
|
|
osLsb,
|
|
|
|
'L'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txtCw [] PROGMEM = "CW";
|
|
|
|
ButtonStatus_e bsCw();
|
|
|
|
void osCw();
|
|
|
|
constexpr Button bCw PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 3*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txtCw,
|
|
|
|
nullptr,
|
|
|
|
bsCw,
|
|
|
|
osCw,
|
|
|
|
'C'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txtSpl [] PROGMEM = "SPL";
|
|
|
|
ButtonStatus_e bsSpl();
|
|
|
|
void osSpl();
|
|
|
|
constexpr Button bSpl PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 4*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txtSpl,
|
|
|
|
nullptr,
|
|
|
|
bsSpl,
|
|
|
|
osSpl,
|
|
|
|
'S'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txt80 [] PROGMEM = "80";
|
|
|
|
ButtonStatus_e bs80();
|
|
|
|
void os80();
|
|
|
|
constexpr Button b80 PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 0*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 1*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txt80,
|
|
|
|
nullptr,
|
|
|
|
bs80,
|
|
|
|
os80,
|
|
|
|
'8'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txt40 [] PROGMEM = "40";
|
|
|
|
ButtonStatus_e bs40();
|
|
|
|
void os40();
|
|
|
|
constexpr Button b40 PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 1*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 1*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txt40,
|
|
|
|
nullptr,
|
|
|
|
bs40,
|
|
|
|
os40,
|
|
|
|
'4'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txt30 [] PROGMEM = "30";
|
|
|
|
ButtonStatus_e bs30();
|
|
|
|
void os30();
|
|
|
|
constexpr Button b30 PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 2*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 1*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txt30,
|
|
|
|
nullptr,
|
|
|
|
bs30,
|
|
|
|
os30,
|
|
|
|
'3'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txt20 [] PROGMEM = "20";
|
|
|
|
ButtonStatus_e bs20();
|
|
|
|
void os20();
|
|
|
|
constexpr Button b20 PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 3*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 1*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txt20,
|
|
|
|
nullptr,
|
|
|
|
bs20,
|
|
|
|
os20,
|
|
|
|
'2'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txt17 [] PROGMEM = "17";
|
|
|
|
ButtonStatus_e bs17();
|
|
|
|
void os17();
|
|
|
|
constexpr Button b17 PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 4*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 1*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txt17,
|
|
|
|
nullptr,
|
|
|
|
bs17,
|
|
|
|
os17,
|
|
|
|
'7'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txt15 [] PROGMEM = "15";
|
|
|
|
ButtonStatus_e bs15();
|
|
|
|
void os15();
|
|
|
|
constexpr Button b15 PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 0*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txt15,
|
|
|
|
nullptr,
|
|
|
|
bs15,
|
|
|
|
os15,
|
|
|
|
'5'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txt10 [] PROGMEM = "10";
|
|
|
|
ButtonStatus_e bs10();
|
|
|
|
void os10();
|
|
|
|
constexpr Button b10 PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 1*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txt10,
|
|
|
|
nullptr,
|
|
|
|
bs10,
|
|
|
|
os10,
|
|
|
|
'1'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txtMenu [] PROGMEM = "\x7F";//gear icon
|
|
|
|
ButtonStatus_e bsIgnore();
|
|
|
|
void osMenu();
|
2020-02-12 06:44:40 +01:00
|
|
|
constexpr Button bMenu PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 3*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txtMenu,
|
|
|
|
nullptr,
|
|
|
|
bsIgnore,
|
|
|
|
osMenu,
|
|
|
|
'M'
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr char txtNumpad [] PROGMEM = "FRQ";
|
|
|
|
ButtonStatus_e bsIgnore();
|
|
|
|
void osNumpad();
|
2020-02-12 06:44:40 +01:00
|
|
|
constexpr Button bNumpad PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
LAYOUT_BUTTON_X + 4*LAYOUT_BUTTON_PITCH_X,
|
|
|
|
LAYOUT_BUTTON_Y + 2*LAYOUT_BUTTON_PITCH_Y,
|
|
|
|
LAYOUT_BUTTON_WIDTH,
|
|
|
|
LAYOUT_BUTTON_HEIGHT,
|
2020-02-10 10:17:47 +01:00
|
|
|
txtNumpad,
|
|
|
|
nullptr,
|
|
|
|
bsIgnore,
|
|
|
|
osNumpad,
|
|
|
|
'F'
|
|
|
|
};
|
|
|
|
|
2020-04-26 04:46:36 +02:00
|
|
|
const Button* const mainMenuButtons [] PROGMEM = {
|
2020-04-26 04:47:02 +02:00
|
|
|
&bVfoA, &bVfoB,
|
2020-04-26 04:46:36 +02:00
|
|
|
|
2020-04-26 04:47:02 +02:00
|
|
|
&bRit, &bUsb, &bLsb, &bCw, &bSpl,
|
|
|
|
&b80, &b40, &b30, &b20, &b17,
|
|
|
|
&b15, &b10, &bMenu, &bNumpad
|
2020-04-26 04:46:36 +02:00
|
|
|
};
|
2020-02-10 10:17:47 +01:00
|
|
|
|
2020-04-26 04:47:02 +02:00
|
|
|
const uint8_t MAIN_MENU_NUM_BUTTONS = sizeof(mainMenuButtons) / sizeof(mainMenuButtons[0]);
|
|
|
|
|
2020-02-12 08:09:18 +01:00
|
|
|
void updateBandButtons(const uint32_t old_freq)
|
|
|
|
{
|
|
|
|
const Button* band_buttons[] = {&b80,&b40,&b30,&b20,&b17,&b15,&b10};
|
|
|
|
const uint8_t bands [] = { 80, 40, 30, 20, 17, 15, 10};
|
|
|
|
const uint32_t curr_freq = GetActiveVfoFreq();
|
|
|
|
|
|
|
|
Button button;
|
|
|
|
for(uint8_t i = 0; i < sizeof(bands)/sizeof(bands[0]); ++i){
|
|
|
|
if(isFreqInBand(old_freq,bands[i]) != isFreqInBand(curr_freq,bands[i])){
|
|
|
|
memcpy_P(&button,band_buttons[i],sizeof(button));
|
2020-04-26 04:47:02 +02:00
|
|
|
drawButton(&button);
|
2020-02-12 08:36:43 +01:00
|
|
|
morseBool(ButtonStatus_e::Active == button.status());
|
2020-02-12 08:09:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-10 10:17:47 +01:00
|
|
|
|
2020-02-10 10:02:03 +01:00
|
|
|
void toVfo(char* text_out, const uint16_t max_text_size, const Vfo_e vfo)
|
|
|
|
{
|
|
|
|
if(max_text_size < 2){
|
|
|
|
return;//Can't do much with that space
|
|
|
|
}
|
|
|
|
if(max_text_size < (3+10+1)){
|
|
|
|
//Give an indicator that's debuggable
|
|
|
|
text_out[0] = 'X';
|
|
|
|
text_out[1] = '\0';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Normal operation
|
|
|
|
if (globalSettings.splitOn){
|
|
|
|
if(vfo == globalSettings.activeVfo){
|
|
|
|
text_out[0] = 'R';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
text_out[0] = 'T';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(VFO_A == vfo){
|
|
|
|
text_out[0] = 'A';
|
|
|
|
}
|
|
|
|
else if(VFO_B == vfo){
|
|
|
|
text_out[0] = 'B';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
text_out[0] = '?';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
text_out[1] = ':';
|
|
|
|
text_out[2] = ' ';
|
|
|
|
if(VFO_A == vfo){
|
|
|
|
formatFreq(globalSettings.vfoA.frequency, text_out+3, max_text_size-3, 10);
|
|
|
|
}
|
|
|
|
else if(VFO_B == vfo){
|
|
|
|
formatFreq(globalSettings.vfoB.frequency, text_out+3, max_text_size-3, 10);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
text_out[3] = '?';
|
|
|
|
text_out[4] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bsVfo(const Vfo_e vfo){
|
|
|
|
return (vfo == globalSettings.activeVfo) ? ButtonStatus_e::Active : ButtonStatus_e::Inactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
void osVfo(const Vfo_e vfo){
|
2020-02-12 08:09:18 +01:00
|
|
|
const uint32_t old_freq = GetActiveVfoFreq();
|
2020-02-10 10:02:03 +01:00
|
|
|
globalSettings.activeVfo = vfo;
|
2020-02-12 07:18:52 +01:00
|
|
|
SaveSettingsToEeprom();
|
2020-02-12 08:09:18 +01:00
|
|
|
|
2020-02-13 07:18:02 +01:00
|
|
|
ltoa(GetActiveVfoFreq(),b,10);
|
|
|
|
morseText(b);
|
|
|
|
|
2020-04-26 04:47:02 +02:00
|
|
|
Button button;
|
|
|
|
memcpy_P(&button,&bVfoA,sizeof(button));
|
|
|
|
drawButton(&button);
|
|
|
|
memcpy_P(&button,&bVfoB,sizeof(button));
|
|
|
|
drawButton(&button);
|
2020-02-12 08:09:18 +01:00
|
|
|
updateBandButtons(old_freq);
|
2020-04-26 08:06:16 +02:00
|
|
|
updateSidebandButtons();
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void toVfoA(char* text_out, const uint16_t max_text_size){
|
|
|
|
toVfo(text_out,max_text_size,Vfo_e::VFO_A);
|
|
|
|
}
|
|
|
|
ButtonStatus_e bsVfoA(){
|
|
|
|
return bsVfo(Vfo_e::VFO_A);
|
|
|
|
}
|
|
|
|
void osVfoA(){
|
|
|
|
osVfo(Vfo_e::VFO_A);
|
|
|
|
}
|
|
|
|
|
|
|
|
void toVfoB(char* text_out, const uint16_t max_text_size){
|
|
|
|
toVfo(text_out,max_text_size,Vfo_e::VFO_B);
|
|
|
|
}
|
|
|
|
ButtonStatus_e bsVfoB(){
|
|
|
|
return bsVfo(Vfo_e::VFO_B);
|
|
|
|
}
|
|
|
|
void osVfoB(){
|
|
|
|
osVfo(Vfo_e::VFO_B);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bsRit(){
|
|
|
|
return globalSettings.ritOn ? ButtonStatus_e::Active : ButtonStatus_e::Inactive;
|
|
|
|
}
|
|
|
|
void osRit(){
|
2020-04-26 04:47:02 +02:00
|
|
|
Button button;
|
2020-02-10 10:02:03 +01:00
|
|
|
if(!globalSettings.ritOn){
|
|
|
|
globalSettings.ritOn = true;
|
|
|
|
globalSettings.ritFrequency = GetActiveVfoFreq();
|
|
|
|
|
|
|
|
strncpy_P(b,(const char*)F("TX: "),sizeof(b));
|
|
|
|
formatFreq(globalSettings.ritFrequency, b + strlen(b), sizeof(b)-strlen(b));
|
|
|
|
if (VFO_A == globalSettings.activeVfo){
|
|
|
|
displayText(b, LAYOUT_VFO_LABEL_X + 0*LAYOUT_VFO_LABEL_PITCH_X, LAYOUT_MODE_TEXT_Y, LAYOUT_VFO_LABEL_WIDTH, LAYOUT_MODE_TEXT_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_BACKGROUND);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
displayText(b, LAYOUT_VFO_LABEL_X + 1*LAYOUT_VFO_LABEL_PITCH_X, LAYOUT_MODE_TEXT_Y, LAYOUT_VFO_LABEL_WIDTH, LAYOUT_MODE_TEXT_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_BACKGROUND);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
globalSettings.ritOn = false;
|
|
|
|
setFrequency(globalSettings.ritFrequency);
|
|
|
|
|
|
|
|
displayFillrect(LAYOUT_MODE_TEXT_X,LAYOUT_MODE_TEXT_Y,LAYOUT_MODE_TEXT_WIDTH,LAYOUT_MODE_TEXT_HEIGHT, COLOR_BACKGROUND);
|
|
|
|
if(Vfo_e::VFO_A == globalSettings.activeVfo){
|
2020-04-26 04:47:02 +02:00
|
|
|
memcpy_P(&button,&bVfoA,sizeof(button));
|
|
|
|
drawButton(&button);
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|
|
|
|
else{
|
2020-04-26 04:47:02 +02:00
|
|
|
memcpy_P(&button,&bVfoB,sizeof(button));
|
|
|
|
drawButton(&button);
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-26 04:47:02 +02:00
|
|
|
memcpy_P(&button,&bRit,sizeof(button));
|
|
|
|
drawButton(&button);
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void osSidebandMode(VfoMode_e mode){
|
|
|
|
SetActiveVfoMode(mode);
|
2020-02-12 08:31:14 +01:00
|
|
|
setFrequency(GetActiveVfoFreq());
|
2020-02-12 07:18:52 +01:00
|
|
|
SaveSettingsToEeprom();
|
2020-02-10 10:02:03 +01:00
|
|
|
|
2020-04-26 04:47:02 +02:00
|
|
|
Button button;
|
|
|
|
memcpy_P(&button,&bUsb,sizeof(button));
|
|
|
|
drawButton(&button);
|
|
|
|
memcpy_P(&button,&bLsb,sizeof(button));
|
|
|
|
drawButton(&button);
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|
|
|
|
|
2020-04-25 21:10:25 +02:00
|
|
|
void updateSidebandButtons()
|
|
|
|
{
|
|
|
|
osSidebandMode(GetActiveVfoMode());
|
|
|
|
}
|
|
|
|
|
2020-02-10 10:02:03 +01:00
|
|
|
ButtonStatus_e bsUsb(){
|
|
|
|
return (VfoMode_e::VFO_MODE_USB == GetActiveVfoMode()) ? ButtonStatus_e::Active : ButtonStatus_e::Inactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
void osUsb(){
|
|
|
|
osSidebandMode(VfoMode_e::VFO_MODE_USB);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bsLsb(){
|
|
|
|
return (VfoMode_e::VFO_MODE_LSB == GetActiveVfoMode()) ? ButtonStatus_e::Active : ButtonStatus_e::Inactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
void osLsb(){
|
|
|
|
osSidebandMode(VfoMode_e::VFO_MODE_LSB);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bsCw(){
|
|
|
|
return (TuningMode_e::TUNE_CW == globalSettings.tuningMode) ? ButtonStatus_e::Active : ButtonStatus_e::Inactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
void osCw(){
|
|
|
|
if(TuningMode_e::TUNE_CW != globalSettings.tuningMode){
|
|
|
|
globalSettings.tuningMode = TuningMode_e::TUNE_CW;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
globalSettings.tuningMode = TuningMode_e::TUNE_SSB;
|
|
|
|
}
|
|
|
|
|
2020-02-12 08:31:14 +01:00
|
|
|
setFrequency(GetActiveVfoFreq());
|
|
|
|
|
2020-04-26 04:47:02 +02:00
|
|
|
Button button;
|
|
|
|
memcpy_P(&button,&bCw,sizeof(button));
|
|
|
|
drawButton(&button);
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bsSpl(){
|
|
|
|
return globalSettings.splitOn ? ButtonStatus_e::Active : ButtonStatus_e::Inactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
void osSpl(){
|
|
|
|
globalSettings.splitOn = !globalSettings.splitOn;
|
|
|
|
|
2020-04-26 04:47:02 +02:00
|
|
|
Button button;
|
|
|
|
memcpy_P(&button,&bSpl,sizeof(button));
|
|
|
|
drawButton(&button);
|
|
|
|
memcpy_P(&button,&bVfoA,sizeof(button));
|
|
|
|
drawButton(&button);
|
|
|
|
memcpy_P(&button,&bVfoB,sizeof(button));
|
|
|
|
drawButton(&button);
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bsBand(const uint8_t band){
|
|
|
|
return isFreqInBand(GetActiveVfoFreq(),band) ? ButtonStatus_e::Active : ButtonStatus_e::Inactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
void osBand(const uint8_t band){
|
2020-02-12 08:09:18 +01:00
|
|
|
const uint32_t old_freq = GetActiveVfoFreq();
|
|
|
|
SetActiveVfoFreq(getFreqInBand(old_freq,band));
|
2020-04-25 21:35:59 +02:00
|
|
|
if(autoSelectSidebandChanged(old_freq)){
|
|
|
|
updateSidebandButtons();
|
|
|
|
}
|
2020-02-12 08:09:18 +01:00
|
|
|
|
2020-04-26 04:47:02 +02:00
|
|
|
Button button;
|
2020-02-12 08:09:18 +01:00
|
|
|
if(Vfo_e::VFO_A == globalSettings.activeVfo){
|
2020-04-26 04:47:02 +02:00
|
|
|
memcpy_P(&button,&bVfoA,sizeof(button));
|
|
|
|
drawButton(&button);
|
2020-02-12 08:09:18 +01:00
|
|
|
}
|
|
|
|
else if(Vfo_e::VFO_B == globalSettings.activeVfo){
|
2020-04-26 04:47:02 +02:00
|
|
|
memcpy_P(&button,&bVfoB,sizeof(button));
|
|
|
|
drawButton(&button);
|
2020-02-12 08:09:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
updateBandButtons(old_freq);
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bs80(){
|
|
|
|
return bsBand(80);
|
|
|
|
}
|
|
|
|
|
|
|
|
void os80(){
|
|
|
|
osBand(80);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bs40(){
|
|
|
|
return bsBand(40);
|
|
|
|
}
|
|
|
|
|
|
|
|
void os40(){
|
|
|
|
osBand(40);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bs30(){
|
|
|
|
return bsBand(30);
|
|
|
|
}
|
|
|
|
|
|
|
|
void os30(){
|
|
|
|
osBand(30);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bs20(){
|
|
|
|
return bsBand(20);
|
|
|
|
}
|
|
|
|
|
|
|
|
void os20(){
|
|
|
|
osBand(20);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bs17(){
|
|
|
|
return bsBand(17);
|
|
|
|
}
|
|
|
|
|
|
|
|
void os17(){
|
|
|
|
osBand(17);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bs15(){
|
|
|
|
return bsBand(15);
|
|
|
|
}
|
|
|
|
|
|
|
|
void os15(){
|
|
|
|
osBand(15);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bs10(){
|
|
|
|
return bsBand(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void os10(){
|
|
|
|
osBand(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonStatus_e bsIgnore(){
|
|
|
|
return ButtonStatus_e::Stateless;
|
|
|
|
}
|
|
|
|
|
|
|
|
void osMenu(){
|
2020-02-16 00:31:14 +01:00
|
|
|
enterSubmenu(setupMenu);
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void osNumpad(){
|
2020-04-22 06:38:34 +02:00
|
|
|
enterSubmenu(numpadMenu);
|
2020-02-10 10:02:03 +01:00
|
|
|
}
|