Start converting buttons. Not expected to compile

This commit is contained in:
Reed Nightingale 2020-02-09 23:07:12 -08:00
parent c4e9d3c156
commit dc5104324b

View File

@ -38,55 +38,173 @@ 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_WIDTH = 40;
static const unsigned int LAYOUT_TX_HEIGHT = 36; static const unsigned int LAYOUT_TX_HEIGHT = 36;
enum btn_set_e { void toVfo(char* text_out, const uint16_t max_text_size, const Vfo_e vfo)
BUTTON_VFOA, {
BUTTON_VFOB, if(max_text_size < 2){
BUTTON_RIT, return;//Can't do much with that space
BUTTON_USB, }
BUTTON_LSB, if(max_text_size < (3+10+1)){
BUTTON_CW, //Give an indicator that's debuggable
BUTTON_SPL, text_out[0] = 'X';
BUTTON_80, text_out[1] = '\0';
BUTTON_40, return;
BUTTON_30, }
BUTTON_20,
BUTTON_17, //Normal operation
BUTTON_15, if (globalSettings.splitOn){
BUTTON_10, if(vfo == globalSettings.activeVfo){
BUTTON_BLANK_1, text_out[0] = 'R';
BUTTON_MNU, }
BUTTON_FRQ, else{
BUTTON_TOTAL 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';
}
}
void bsVfo(const Vfo_e vfo){
(vfo == globalSettings.activeVfo) ? ButtonStatus_e::Active : ButtonStatus_e::Inactive;
}
void osVfo(const Vfo_e vfo){
globalSettings.activeVfo = vfo;
}
void toVfoA(char* text_out, const uint16_t max_text_size){
toVfo(text_out,max_text_size,Vfo_e::VFO_A);
}
ButtonStatus_e bsVfoA(){
bsVfo(Vfo_e::VFO_A);
}
void osVfoA(){
osVfo(Vfo_e::VFO_A);
}
constexpr Button bVfoA = {
LAYOUT_VFO_LABEL_X + 0*LAYOUT_VFO_LABEL_PITCH_X,
LAYOUT_VFO_LABEL_Y,
LAYOUT_VFO_LABEL_WIDTH,
LAYOUT_VFO_LABEL_HEIGHT,
nullptr,
toVfoA,
bsVfoA,
osVfoA,
'A'
}; };
void msVfoA(int8_t* val_out){ void toVfoB(char* text_out, const uint16_t max_text_size){
*val_out = (Vfo_e::VFO_A == globalSettings.activeVfo) ? 1 : -1; toVfo(text_out,max_text_size,Vfo_e::VFO_B);
} }
void msVfoB(int8_t* val_out){ ButtonStatus_e bsVfoB(){
*val_out = (Vfo_e::VFO_B == globalSettings.activeVfo) ? 1 : -1; bsVfo(Vfo_e::VFO_B);
} }
void msRit(int8_t* val_out){ void osVfoB(){
osVfo(Vfo_e::VFO_B);
}
constexpr Button bVfoB = {
LAYOUT_VFO_LABEL_X + 1*LAYOUT_VFO_LABEL_PITCH_X,
LAYOUT_VFO_LABEL_Y,
LAYOUT_VFO_LABEL_WIDTH,
LAYOUT_VFO_LABEL_HEIGHT,
nullptr,
toVfoB,
bsVfoB,
osVfoB,
'B'
};
constexpr char txtRit [] PROGMEM = "RIT";
ButtonStatus_e bsRit(){
*val_out = globalSettings.ritOn ? 1 : -1; *val_out = globalSettings.ritOn ? 1 : -1;
} }
void msUsb(int8_t* val_out){ void osRit(){
Button button;
if(!globalSettings.ritOn){
globalSettings.ritOn = true;
globalSettings.ritFrequency = GetActiveVfoFreq();
strncpy_P(b,(const char*)F("TX: "),sizeof(b));
formatFreq(globalSettings.ritFrequency, b+3, sizeof(b)-strlen(c));
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){
memcpy_P(&button,bVfoA,sizeof(button));
drawButton(&button);
}
else{
memcpy_P(&button,bVfoB,sizeof(button));
drawButton(&button);
}
}
memcpy_P(&button,bRit,sizeof(button));
drawButton(button);
}
constexpr Button bRit = {
LAYOUT_BUTTON_X + 0*LAYOUT_BUTTON_PITCH_X,
LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y,
LAYOUT_BUTTON_WIDTH,
LAYOUT_BUTTON_HEIGHT,
txtRit,
nullptr,
bsRit,
osRit,
'R'
};
ButtonStatus_e bsUsb(){
*val_out = (VfoMode_e::VFO_MODE_USB == GetActiveVfoMode()) ? 1 : -1; *val_out = (VfoMode_e::VFO_MODE_USB == GetActiveVfoMode()) ? 1 : -1;
} }
void msLsb(int8_t* val_out){ ButtonStatus_e bsLsb(){
*val_out = (VfoMode_e::VFO_MODE_LSB == GetActiveVfoMode()) ? 1 : -1; *val_out = (VfoMode_e::VFO_MODE_LSB == GetActiveVfoMode()) ? 1 : -1;
} }
void msCw(int8_t* val_out){ ButtonStatus_e bsCw(){
*val_out = (TuningMode_e::TUNE_CW == globalSettings.tuningMode) ? 1 : -1; *val_out = (TuningMode_e::TUNE_CW == globalSettings.tuningMode) ? 1 : -1;
} }
void msSpl(int8_t* val_out){ ButtonStatus_e bsSpl(){
*val_out = globalSettings.splitOn ? 1 : -1; *val_out = globalSettings.splitOn ? 1 : -1;
} }
void msIgnore(int8_t* val_out){ ButtonStatus_e bsIgnore(){
*val_out = 0; *val_out = 0;
} }
constexpr Button mainMenuButtons[] PROGMEM = { constexpr Button mainMenuButtons[] PROGMEM = {
{LAYOUT_VFO_LABEL_X + 0*LAYOUT_VFO_LABEL_PITCH_X, LAYOUT_VFO_LABEL_Y, LAYOUT_VFO_LABEL_WIDTH, LAYOUT_VFO_LABEL_HEIGHT, BUTTON_VFOA, "VFOA", 'A', msVfoA}, bVfoA,
{LAYOUT_VFO_LABEL_X + 1*LAYOUT_VFO_LABEL_PITCH_X, LAYOUT_VFO_LABEL_Y, LAYOUT_VFO_LABEL_WIDTH, LAYOUT_VFO_LABEL_HEIGHT, BUTTON_VFOB, "VFOB", 'B', msVfoB}, bVfoB,
bRit,
{LAYOUT_BUTTON_X + 0*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_RIT, "RIT", 'R', msRit}, {LAYOUT_BUTTON_X + 0*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_RIT, "RIT", 'R', msRit},
{LAYOUT_BUTTON_X + 1*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_USB, "USB", 'U', msUsb}, {LAYOUT_BUTTON_X + 1*LAYOUT_BUTTON_PITCH_X, LAYOUT_BUTTON_Y + 0*LAYOUT_BUTTON_PITCH_Y, LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT, BUTTON_USB, "USB", 'U', msUsb},