2019-12-18 07:32:44 +01:00
|
|
|
#include <Arduino.h>
|
2020-02-10 00:56:43 +01:00
|
|
|
#include "colors.h"
|
2020-02-15 22:49:09 +01:00
|
|
|
#include "menu.h"
|
2019-12-18 07:32:44 +01:00
|
|
|
#include "morse.h"
|
2020-01-20 03:40:11 +01:00
|
|
|
#include "nano_gui.h"
|
2020-04-22 06:10:48 +02:00
|
|
|
#include "pin_definitions.h"
|
|
|
|
#include "scratch_space.h"
|
2020-01-20 03:40:11 +01:00
|
|
|
#include "setup.h"
|
2020-01-04 08:11:55 +01:00
|
|
|
#include "settings.h"
|
2020-04-22 06:10:48 +02:00
|
|
|
#include "tuner.h"
|
2020-02-08 23:59:06 +01:00
|
|
|
#include "utils.h"
|
2019-12-18 07:32:44 +01:00
|
|
|
|
|
|
|
/** Menus
|
|
|
|
* The Radio menus are accessed by tapping on the function button.
|
|
|
|
* - The main loop() constantly looks for a button press and calls doMenu() when it detects
|
|
|
|
* a function button press.
|
|
|
|
* - As the encoder is rotated, at every 10th pulse, the next or the previous menu
|
|
|
|
* item is displayed. Each menu item is controlled by it's own function.
|
|
|
|
* - Eache menu function may be called to display itself
|
|
|
|
* - Each of these menu routines is called with a button parameter.
|
|
|
|
* - The btn flag denotes if the menu itme was clicked on or not.
|
|
|
|
* - If the menu item is clicked on, then it is selected,
|
|
|
|
* - If the menu item is NOT clicked on, then the menu's prompt is to be displayed
|
|
|
|
*/
|
|
|
|
|
2020-01-04 09:53:00 +01:00
|
|
|
static const unsigned int COLOR_TEXT = DISPLAY_WHITE;
|
|
|
|
static const unsigned int COLOR_BACKGROUND = DISPLAY_BLACK;
|
|
|
|
static const unsigned int COLOR_TITLE_BACKGROUND = DISPLAY_NAVY;
|
|
|
|
static const unsigned int COLOR_SETTING_BACKGROUND = DISPLAY_NAVY;
|
|
|
|
static const unsigned int COLOR_ACTIVE_BORDER = DISPLAY_WHITE;
|
|
|
|
static const unsigned int COLOR_INACTIVE_BORDER = COLOR_BACKGROUND;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_OUTER_BORDER_X = 10;
|
|
|
|
static const unsigned int LAYOUT_OUTER_BORDER_Y = 10;
|
|
|
|
static const unsigned int LAYOUT_OUTER_BORDER_WIDTH = 300;
|
|
|
|
static const unsigned int LAYOUT_OUTER_BORDER_HEIGHT = 220;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_INNER_BORDER_X = 12;
|
|
|
|
static const unsigned int LAYOUT_INNER_BORDER_Y = 12;
|
|
|
|
static const unsigned int LAYOUT_INNER_BORDER_WIDTH = 296;
|
|
|
|
static const unsigned int LAYOUT_INNER_BORDER_HEIGHT = 216;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_TITLE_X = LAYOUT_INNER_BORDER_X;
|
|
|
|
static const unsigned int LAYOUT_TITLE_Y = LAYOUT_INNER_BORDER_Y;
|
|
|
|
static const unsigned int LAYOUT_TITLE_WIDTH = LAYOUT_INNER_BORDER_WIDTH;
|
|
|
|
static const unsigned int LAYOUT_TITLE_HEIGHT = 35;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_ITEM_X = 30;
|
|
|
|
static const unsigned int LAYOUT_ITEM_Y = LAYOUT_TITLE_Y + LAYOUT_TITLE_HEIGHT + 5;
|
|
|
|
static const unsigned int LAYOUT_ITEM_WIDTH = 260;
|
|
|
|
static const unsigned int LAYOUT_ITEM_HEIGHT = 30;
|
|
|
|
static const unsigned int LAYOUT_ITEM_PITCH_Y = LAYOUT_ITEM_HEIGHT + 1;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_SETTING_VALUE_X = LAYOUT_ITEM_X;
|
|
|
|
static const unsigned int LAYOUT_SETTING_VALUE_Y = LAYOUT_ITEM_Y + 3*LAYOUT_ITEM_PITCH_Y;
|
|
|
|
static const unsigned int LAYOUT_SETTING_VALUE_WIDTH = LAYOUT_ITEM_WIDTH;
|
|
|
|
static const unsigned int LAYOUT_SETTING_VALUE_HEIGHT = LAYOUT_ITEM_HEIGHT;
|
|
|
|
|
2020-01-19 21:56:14 +01:00
|
|
|
static const unsigned int LAYOUT_INSTRUCTIONS_TEXT_X = 20;
|
|
|
|
static const unsigned int LAYOUT_INSTRUCTIONS_TEXT_Y = LAYOUT_ITEM_Y;
|
|
|
|
static const unsigned int LAYOUT_INSTRUCTIONS_TEXT_WIDTH = LAYOUT_ITEM_WIDTH;
|
|
|
|
static const unsigned int LAYOUT_INSTRUCTIONS_TEXT_HEIGHT = LAYOUT_SETTING_VALUE_Y - LAYOUT_ITEM_Y - 1;
|
|
|
|
|
|
|
|
static const unsigned int LAYOUT_CONFIRM_TEXT_X = 20;
|
|
|
|
static const unsigned int LAYOUT_CONFIRM_TEXT_Y = LAYOUT_ITEM_Y + 5*LAYOUT_ITEM_PITCH_Y;
|
|
|
|
static const unsigned int LAYOUT_CONFIRM_TEXT_WIDTH = LAYOUT_ITEM_WIDTH;
|
|
|
|
static const unsigned int LAYOUT_CONFIRM_TEXT_HEIGHT = LAYOUT_ITEM_HEIGHT;
|
|
|
|
|
|
|
|
void displayDialog(const char* title,
|
|
|
|
const char* instructions){
|
2020-01-04 09:53:00 +01:00
|
|
|
displayClear(COLOR_BACKGROUND);
|
|
|
|
displayRect(LAYOUT_OUTER_BORDER_X,LAYOUT_OUTER_BORDER_Y,LAYOUT_OUTER_BORDER_WIDTH,LAYOUT_OUTER_BORDER_HEIGHT, COLOR_ACTIVE_BORDER);
|
|
|
|
displayRect(LAYOUT_INNER_BORDER_X,LAYOUT_INNER_BORDER_Y,LAYOUT_INNER_BORDER_WIDTH,LAYOUT_INNER_BORDER_HEIGHT, COLOR_ACTIVE_BORDER);
|
2020-01-20 04:00:45 +01:00
|
|
|
strncpy_P(b,title,sizeof(b));
|
2020-01-04 10:10:10 +01:00
|
|
|
displayText(b, LAYOUT_TITLE_X, LAYOUT_TITLE_Y, LAYOUT_TITLE_WIDTH, LAYOUT_TITLE_HEIGHT, COLOR_TEXT, COLOR_TITLE_BACKGROUND, COLOR_ACTIVE_BORDER);
|
2020-01-20 04:00:45 +01:00
|
|
|
strncpy_P(b,instructions,sizeof(b));
|
2020-01-28 08:09:34 +01:00
|
|
|
displayText(b, LAYOUT_INSTRUCTIONS_TEXT_X, LAYOUT_INSTRUCTIONS_TEXT_Y, LAYOUT_INSTRUCTIONS_TEXT_WIDTH, LAYOUT_INSTRUCTIONS_TEXT_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_BACKGROUND, TextJustification_e::Left);
|
2020-01-20 04:00:45 +01:00
|
|
|
strncpy_P(b,(const char*)F("Push Tune to Save"),sizeof(b));
|
2020-01-19 21:56:14 +01:00
|
|
|
displayText(b, LAYOUT_CONFIRM_TEXT_X, LAYOUT_CONFIRM_TEXT_Y, LAYOUT_CONFIRM_TEXT_WIDTH, LAYOUT_CONFIRM_TEXT_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_BACKGROUND);
|
2020-01-04 09:53:00 +01:00
|
|
|
}
|
|
|
|
|
2020-01-19 08:34:41 +01:00
|
|
|
struct SettingScreen_t {
|
|
|
|
const char* const Title;
|
|
|
|
const char* const AdditionalText;
|
|
|
|
const uint16_t KnobDivider;
|
2020-01-20 04:24:26 +01:00
|
|
|
const int16_t StepSize;//int so that it can be negative
|
2020-01-19 08:34:41 +01:00
|
|
|
void (*Initialize)(long int* start_value_out);
|
|
|
|
void (*Validate)(const long int candidate_value_in, long int* validated_value_out);
|
|
|
|
void (*OnValueChange)(const long int new_value, char* buff_out, const size_t buff_out_size);
|
|
|
|
void (*Finalize)(const long int final_value);
|
|
|
|
};
|
|
|
|
|
2020-02-15 23:17:55 +01:00
|
|
|
void drawSetting(const SettingScreen_t* const screen)
|
2020-01-19 08:34:41 +01:00
|
|
|
{
|
2020-02-15 23:29:23 +01:00
|
|
|
displayDialog(screen->Title,
|
|
|
|
screen->AdditionalText);
|
2020-02-15 21:36:01 +01:00
|
|
|
}
|
2020-01-19 08:34:41 +01:00
|
|
|
|
2020-02-15 23:17:55 +01:00
|
|
|
//State variables for settings
|
2020-02-15 21:36:01 +01:00
|
|
|
int32_t setupMenuRawValue = 0;
|
|
|
|
int32_t setupMenuLastValue = 0;
|
2020-02-15 23:29:23 +01:00
|
|
|
const SettingScreen_t* activeSettingP;
|
2020-02-15 23:17:55 +01:00
|
|
|
|
|
|
|
void activateSetting(SettingScreen_t* new_setting_P);
|
|
|
|
|
|
|
|
void initSetting();
|
|
|
|
MenuReturn_e runSetting(const ButtonPress_e tuner_button,
|
|
|
|
const ButtonPress_e touch_button,
|
|
|
|
const Point touch_point,
|
|
|
|
const int16_t knob);
|
|
|
|
Menu_t setupMenuActiveSettingMenu = {
|
|
|
|
initSetting,
|
|
|
|
runSetting,
|
|
|
|
nullptr
|
|
|
|
};
|
2020-01-19 08:34:41 +01:00
|
|
|
|
2020-02-15 23:17:55 +01:00
|
|
|
void initSetting()
|
2020-02-15 21:36:01 +01:00
|
|
|
{
|
2020-02-15 23:17:55 +01:00
|
|
|
if(nullptr == activeSettingP){
|
|
|
|
return;
|
|
|
|
}
|
2020-02-15 22:49:09 +01:00
|
|
|
SettingScreen_t screen = {nullptr,nullptr,0,0,nullptr,nullptr,nullptr,nullptr};
|
2020-02-15 23:17:55 +01:00
|
|
|
memcpy_P(&screen,activeSettingP,sizeof(screen));
|
2020-02-15 23:29:23 +01:00
|
|
|
drawSetting(&screen);
|
2020-02-15 21:36:01 +01:00
|
|
|
screen.Initialize(&setupMenuLastValue);
|
|
|
|
screen.OnValueChange(setupMenuLastValue,b,sizeof(b));
|
2020-01-19 08:34:41 +01:00
|
|
|
displayText(b, LAYOUT_SETTING_VALUE_X, LAYOUT_SETTING_VALUE_Y, LAYOUT_SETTING_VALUE_WIDTH, LAYOUT_SETTING_VALUE_HEIGHT, COLOR_TEXT, COLOR_TITLE_BACKGROUND, COLOR_BACKGROUND);
|
2020-02-15 21:36:01 +01:00
|
|
|
setupMenuRawValue = setupMenuLastValue * (int32_t)screen.KnobDivider;
|
|
|
|
}
|
2020-01-19 08:34:41 +01:00
|
|
|
|
2020-02-15 23:17:55 +01:00
|
|
|
MenuReturn_e runSetting(const ButtonPress_e tuner_button,
|
2020-02-15 21:36:01 +01:00
|
|
|
const ButtonPress_e touch_button,
|
|
|
|
const Point touch_point,
|
|
|
|
const int16_t knob)
|
|
|
|
{
|
2020-02-15 23:17:55 +01:00
|
|
|
if(nullptr == activeSettingP){
|
|
|
|
return MenuReturn_e::ExitedRedraw;
|
|
|
|
}
|
2020-02-15 22:49:09 +01:00
|
|
|
SettingScreen_t screen = {nullptr,nullptr,0,0,nullptr,nullptr,nullptr,nullptr};
|
2020-02-15 23:17:55 +01:00
|
|
|
memcpy_P(&screen,activeSettingP,sizeof(screen));
|
2020-02-15 22:49:09 +01:00
|
|
|
|
2020-02-15 21:36:01 +01:00
|
|
|
if(ButtonPress_e::NotPressed != tuner_button){
|
|
|
|
//Long or short press, we do the same thing
|
|
|
|
screen.Finalize(setupMenuLastValue);
|
|
|
|
return MenuReturn_e::ExitedRedraw;
|
|
|
|
}
|
2020-01-19 08:34:41 +01:00
|
|
|
|
2020-02-15 22:49:09 +01:00
|
|
|
(void)touch_button;(void)touch_point;//TODO: handle touch input?
|
2020-01-19 08:34:41 +01:00
|
|
|
|
2020-02-15 23:17:55 +01:00
|
|
|
if(0 != knob){
|
2020-02-15 21:36:01 +01:00
|
|
|
setupMenuRawValue += knob * screen.StepSize;
|
|
|
|
|
|
|
|
const int32_t candidate_value = setupMenuRawValue / (int32_t)screen.KnobDivider;
|
|
|
|
int32_t value = 0;
|
2020-01-19 19:48:07 +01:00
|
|
|
screen.Validate(candidate_value,&value);
|
2020-01-19 08:34:41 +01:00
|
|
|
|
|
|
|
//If we're going out of bounds, prevent the raw value from going too far out
|
|
|
|
if(candidate_value != value){
|
2020-02-15 21:36:01 +01:00
|
|
|
setupMenuRawValue = value * (int32_t)screen.KnobDivider;
|
2020-01-19 08:34:41 +01:00
|
|
|
}
|
|
|
|
|
2020-02-15 22:49:09 +01:00
|
|
|
if(value != setupMenuLastValue){
|
2020-01-19 19:48:07 +01:00
|
|
|
screen.OnValueChange(value,b,sizeof(b));
|
2020-01-19 08:34:41 +01:00
|
|
|
displayText(b, LAYOUT_SETTING_VALUE_X, LAYOUT_SETTING_VALUE_Y, LAYOUT_SETTING_VALUE_WIDTH, LAYOUT_SETTING_VALUE_HEIGHT, COLOR_TEXT, COLOR_TITLE_BACKGROUND, COLOR_BACKGROUND);
|
2020-02-15 21:36:01 +01:00
|
|
|
setupMenuLastValue = value;
|
2020-01-19 08:34:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-15 21:36:01 +01:00
|
|
|
return MenuReturn_e::StillActive;
|
2020-01-19 08:34:41 +01:00
|
|
|
}
|
|
|
|
|
2020-02-15 23:29:23 +01:00
|
|
|
void activateSetting(const SettingScreen_t *const new_setting_P)
|
2020-02-15 23:17:55 +01:00
|
|
|
{
|
|
|
|
activeSettingP = new_setting_P;
|
2020-02-16 00:31:14 +01:00
|
|
|
enterSubmenu(&setupMenuActiveSettingMenu);
|
2020-02-15 23:17:55 +01:00
|
|
|
}
|
|
|
|
|
2020-01-20 04:24:26 +01:00
|
|
|
//Local Oscillator
|
2020-01-20 03:40:11 +01:00
|
|
|
void ssLocalOscInitialize(long int* start_value_out){
|
2020-01-04 08:11:55 +01:00
|
|
|
{
|
|
|
|
uint32_t freq = GetActiveVfoFreq();
|
2020-01-20 04:24:26 +01:00
|
|
|
freq = (freq/1000L) * 1000L;//round off the current frequency the nearest kHz
|
2020-01-04 08:11:55 +01:00
|
|
|
setFrequency(freq);
|
|
|
|
}
|
2020-01-20 03:40:11 +01:00
|
|
|
*start_value_out = globalSettings.oscillatorCal;
|
|
|
|
}
|
|
|
|
void ssLocalOscValidate(const long int candidate_value_in, long int* validated_value_out)
|
|
|
|
{
|
|
|
|
*validated_value_out = candidate_value_in;//No check - allow anything
|
|
|
|
}
|
|
|
|
void ssLocalOscChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
|
|
|
{
|
|
|
|
si5351_set_calibration(new_value);
|
|
|
|
setFrequency(GetActiveVfoFreq());
|
|
|
|
const long int u = abs(new_value);
|
|
|
|
if(new_value != u){
|
2020-01-20 04:00:45 +01:00
|
|
|
strncpy_P(buff_out,(const char*)F("-"),buff_out_size);
|
2020-01-20 03:40:11 +01:00
|
|
|
++buff_out;
|
2019-12-18 07:32:44 +01:00
|
|
|
}
|
2020-01-20 04:00:45 +01:00
|
|
|
formatFreq(u,buff_out,buff_out_size - strlen(buff_out));
|
|
|
|
strncat_P(buff_out,(const char*)F("Hz"),buff_out_size - strlen(buff_out));
|
2020-01-20 03:40:11 +01:00
|
|
|
}
|
|
|
|
void ssLocalOscFinalize(const long int final_value)
|
|
|
|
{
|
|
|
|
globalSettings.oscillatorCal = final_value;
|
2020-01-04 08:11:55 +01:00
|
|
|
SaveSettingsToEeprom();
|
|
|
|
si5351_set_calibration(globalSettings.oscillatorCal);
|
|
|
|
setFrequency(GetActiveVfoFreq());
|
2019-12-18 07:32:44 +01:00
|
|
|
}
|
2020-01-20 05:51:19 +01:00
|
|
|
const char SS_LOCAL_OSC_T [] PROGMEM = "Local Oscillator";
|
2020-01-20 03:40:11 +01:00
|
|
|
const char SS_LOCAL_OSC_A [] PROGMEM = "Exit menu, tune so that the\ndial displays the desired freq,\nthen tune here until the\nsignal is zerobeat";
|
|
|
|
const SettingScreen_t ssLocalOsc PROGMEM = {
|
|
|
|
SS_LOCAL_OSC_T,
|
|
|
|
SS_LOCAL_OSC_A,
|
|
|
|
1,
|
2020-01-21 10:37:09 +01:00
|
|
|
50,
|
2020-01-20 03:40:11 +01:00
|
|
|
ssLocalOscInitialize,
|
|
|
|
ssLocalOscValidate,
|
|
|
|
ssLocalOscChange,
|
|
|
|
ssLocalOscFinalize
|
|
|
|
};
|
2020-02-15 23:17:55 +01:00
|
|
|
void runLocalOscSetting(){activateSetting(&ssLocalOsc);}
|
2019-12-18 07:32:44 +01:00
|
|
|
|
2020-01-20 04:24:26 +01:00
|
|
|
//BFO
|
|
|
|
void ssBfoInitialize(long int* start_value_out){
|
2020-01-04 08:11:55 +01:00
|
|
|
si5351bx_setfreq(0, globalSettings.usbCarrierFreq);
|
2020-01-20 04:24:26 +01:00
|
|
|
*start_value_out = globalSettings.usbCarrierFreq;
|
|
|
|
}
|
|
|
|
void ssBfoValidate(const long int candidate_value_in, long int* validated_value_out)
|
|
|
|
{
|
|
|
|
*validated_value_out = LIMIT(candidate_value_in,11048000L,11060000L);
|
|
|
|
}
|
|
|
|
void ssBfoChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
|
|
|
{
|
2020-01-20 05:42:44 +01:00
|
|
|
globalSettings.usbCarrierFreq = new_value;
|
2020-01-20 04:24:26 +01:00
|
|
|
setFrequency(GetActiveVfoFreq());
|
2020-01-20 05:42:44 +01:00
|
|
|
si5351bx_setfreq(0, new_value);
|
2020-01-20 04:24:26 +01:00
|
|
|
formatFreq(new_value,buff_out,buff_out_size);
|
|
|
|
strncat_P(buff_out,(const char*)F("Hz"),buff_out_size - strlen(buff_out));
|
|
|
|
}
|
|
|
|
void ssBfoFinalize(const long int final_value)
|
|
|
|
{
|
|
|
|
globalSettings.usbCarrierFreq = final_value;
|
2020-01-04 08:11:55 +01:00
|
|
|
SaveSettingsToEeprom();
|
|
|
|
si5351bx_setfreq(0, globalSettings.usbCarrierFreq);
|
|
|
|
setFrequency(GetActiveVfoFreq());
|
2019-12-18 07:32:44 +01:00
|
|
|
}
|
2020-01-20 05:51:19 +01:00
|
|
|
const char SS_BFO_T [] PROGMEM = "Beat Frequency Osc (BFO)";
|
2020-01-20 04:24:26 +01:00
|
|
|
const char SS_BFO_A [] PROGMEM = "Exit menu, tune to an unused\nfrequency, then tune here\nuntil the audio is between\n300-3000Hz";
|
|
|
|
const SettingScreen_t ssBfo PROGMEM = {
|
|
|
|
SS_BFO_T,
|
|
|
|
SS_BFO_A,
|
|
|
|
1,
|
|
|
|
-50,//Negative to make dial more intuitive: turning clockwise increases the perceived audio frequency
|
|
|
|
ssBfoInitialize,
|
|
|
|
ssBfoValidate,
|
|
|
|
ssBfoChange,
|
|
|
|
ssBfoFinalize
|
|
|
|
};
|
2020-02-15 23:17:55 +01:00
|
|
|
void runBfoSetting(){activateSetting(&ssBfo);}
|
2019-12-18 07:32:44 +01:00
|
|
|
|
2020-01-20 04:26:31 +01:00
|
|
|
//CW Tone
|
2020-01-20 04:40:03 +01:00
|
|
|
void ssCwToneInitialize(long int* start_value_out)
|
2020-01-20 04:26:31 +01:00
|
|
|
{
|
|
|
|
*start_value_out = globalSettings.cwSideToneFreq;
|
|
|
|
}
|
2020-01-20 04:40:03 +01:00
|
|
|
void ssCwToneValidate(const long int candidate_value_in, long int* validated_value_out)
|
2020-01-20 04:26:31 +01:00
|
|
|
{
|
|
|
|
*validated_value_out = LIMIT(candidate_value_in,100,2000);
|
|
|
|
}
|
2020-01-20 04:40:03 +01:00
|
|
|
void ssCwToneChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
2020-01-20 04:26:31 +01:00
|
|
|
{
|
|
|
|
globalSettings.cwSideToneFreq = new_value;
|
2020-04-22 06:10:48 +02:00
|
|
|
tone(PIN_CW_TONE, globalSettings.cwSideToneFreq);
|
2020-01-20 04:26:31 +01:00
|
|
|
ltoa(globalSettings.cwSideToneFreq,buff_out,10);
|
|
|
|
strncat_P(buff_out,(const char*)F("Hz"),buff_out_size - strlen(buff_out));
|
|
|
|
}
|
2020-01-20 04:40:03 +01:00
|
|
|
void ssCwToneFinalize(const long int final_value)
|
2020-01-20 04:26:31 +01:00
|
|
|
{
|
2020-04-22 06:10:48 +02:00
|
|
|
noTone(PIN_CW_TONE);
|
2020-01-20 04:26:31 +01:00
|
|
|
globalSettings.cwSideToneFreq = final_value;
|
|
|
|
SaveSettingsToEeprom();
|
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
const char SS_CW_TONE_T [] PROGMEM = "Tone";
|
2020-01-20 04:26:31 +01:00
|
|
|
const char SS_CW_TONE_A [] PROGMEM = "Select a frequency that\nCW mode to tune for";
|
|
|
|
const SettingScreen_t ssTone PROGMEM = {
|
|
|
|
SS_CW_TONE_T,
|
|
|
|
SS_CW_TONE_A,
|
|
|
|
1,
|
2020-01-21 10:37:09 +01:00
|
|
|
1,
|
2020-01-20 04:26:31 +01:00
|
|
|
ssCwToneInitialize,
|
|
|
|
ssCwToneValidate,
|
|
|
|
ssCwToneChange,
|
|
|
|
ssCwToneFinalize
|
|
|
|
};
|
2020-02-15 23:17:55 +01:00
|
|
|
void runToneSetting(){activateSetting(&ssTone);}
|
2020-01-20 04:26:31 +01:00
|
|
|
|
2020-01-20 04:40:03 +01:00
|
|
|
//CW Switch Delay
|
|
|
|
void ssCwSwitchDelayInitialize(long int* start_value_out)
|
|
|
|
{
|
|
|
|
*start_value_out = globalSettings.cwActiveTimeoutMs;
|
|
|
|
}
|
|
|
|
void ssCwSwitchDelayValidate(const long int candidate_value_in, long int* validated_value_out)
|
|
|
|
{
|
|
|
|
*validated_value_out = LIMIT(candidate_value_in,100,1000);
|
|
|
|
}
|
|
|
|
void ssCwSwitchDelayChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
|
|
|
{
|
|
|
|
ltoa(new_value,buff_out,10);
|
|
|
|
strncat_P(buff_out,(const char*)F("ms"),buff_out_size - strlen(buff_out));
|
2020-01-22 09:04:12 +01:00
|
|
|
morseText(buff_out);
|
|
|
|
enc_read();//Consume any rotations during morse playback
|
2020-01-20 04:40:03 +01:00
|
|
|
}
|
|
|
|
void ssCwSwitchDelayFinalize(const long int final_value)
|
|
|
|
{
|
|
|
|
globalSettings.cwActiveTimeoutMs = final_value;
|
2020-01-04 08:11:55 +01:00
|
|
|
SaveSettingsToEeprom();
|
2019-12-18 07:32:44 +01:00
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
const char SS_CW_SWITCH_T [] PROGMEM = "Tx to Rx Delay";
|
2020-01-20 04:40:03 +01:00
|
|
|
const char SS_CW_SWITCH_A [] PROGMEM = "Select how long the radio\nshould wait before switching\nbetween TX and RX when in\nCW mode";
|
|
|
|
const SettingScreen_t ssCwSwitchDelay PROGMEM = {
|
|
|
|
SS_CW_SWITCH_T,
|
|
|
|
SS_CW_SWITCH_A,
|
|
|
|
1,
|
2020-01-21 10:37:09 +01:00
|
|
|
10,
|
2020-01-20 04:40:03 +01:00
|
|
|
ssCwSwitchDelayInitialize,
|
|
|
|
ssCwSwitchDelayValidate,
|
|
|
|
ssCwSwitchDelayChange,
|
|
|
|
ssCwSwitchDelayFinalize
|
|
|
|
};
|
2020-02-15 23:17:55 +01:00
|
|
|
void runCwSwitchDelaySetting(){activateSetting(&ssCwSwitchDelay);}
|
2019-12-18 07:32:44 +01:00
|
|
|
|
2020-01-20 04:50:11 +01:00
|
|
|
//CW Keyer
|
|
|
|
void ssKeyerInitialize(long int* start_value_out)
|
2020-01-18 07:22:06 +01:00
|
|
|
{
|
2020-01-20 04:50:11 +01:00
|
|
|
*start_value_out = globalSettings.keyerMode;
|
|
|
|
}
|
|
|
|
void ssKeyerValidate(const long int candidate_value_in, long int* validated_value_out)
|
|
|
|
{
|
2020-01-26 19:40:59 +01:00
|
|
|
*validated_value_out = LIMIT(candidate_value_in,(uint8_t)KeyerMode_e::KEYER_STRAIGHT,(uint8_t)KeyerMode_e::KEYER_IAMBIC_B);
|
2020-01-20 04:50:11 +01:00
|
|
|
}
|
|
|
|
void ssKeyerChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
|
|
|
{
|
2020-01-22 09:04:12 +01:00
|
|
|
char m;
|
2020-01-20 04:50:11 +01:00
|
|
|
if(KeyerMode_e::KEYER_STRAIGHT == new_value){
|
2020-01-22 09:04:12 +01:00
|
|
|
strncpy_P(buff_out,(const char*)F("Hand Key"),buff_out_size);
|
|
|
|
m = 'S';
|
2020-01-04 08:11:55 +01:00
|
|
|
}
|
2020-01-20 04:50:11 +01:00
|
|
|
else if(KeyerMode_e::KEYER_IAMBIC_A == new_value){
|
2020-01-22 09:04:12 +01:00
|
|
|
strncpy_P(buff_out,(const char*)F("Iambic A"),buff_out_size);
|
|
|
|
m = 'A';
|
2020-01-04 08:11:55 +01:00
|
|
|
}
|
|
|
|
else{
|
2020-01-22 09:04:12 +01:00
|
|
|
strncpy_P(buff_out,(const char*)F("Iambic B"),buff_out_size);
|
|
|
|
m = 'B';
|
2020-01-04 08:11:55 +01:00
|
|
|
}
|
2020-01-22 09:04:12 +01:00
|
|
|
morseLetter(m);
|
|
|
|
enc_read();//Consume any rotations during morse playback
|
2020-01-18 07:22:06 +01:00
|
|
|
}
|
2020-01-20 04:50:11 +01:00
|
|
|
void ssKeyerFinalize(const long int final_value)
|
|
|
|
{
|
2020-01-26 19:40:59 +01:00
|
|
|
globalSettings.keyerMode = (KeyerMode_e)final_value;
|
2020-01-04 08:11:55 +01:00
|
|
|
SaveSettingsToEeprom();
|
2019-12-18 07:32:44 +01:00
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
const char SS_KEYER_T [] PROGMEM = "Keyer Type";
|
2020-01-20 04:50:11 +01:00
|
|
|
const char SS_KEYER_A [] PROGMEM = "Select which type of\nkeyer/paddle is being used";
|
|
|
|
const SettingScreen_t ssKeyer PROGMEM = {
|
|
|
|
SS_KEYER_T,
|
|
|
|
SS_KEYER_A,
|
|
|
|
10,
|
|
|
|
1,
|
|
|
|
ssKeyerInitialize,
|
|
|
|
ssKeyerValidate,
|
|
|
|
ssKeyerChange,
|
|
|
|
ssKeyerFinalize
|
|
|
|
};
|
2020-02-15 23:17:55 +01:00
|
|
|
void runKeyerSetting(){activateSetting(&ssKeyer);}
|
2019-12-18 07:32:44 +01:00
|
|
|
|
2020-01-22 09:11:52 +01:00
|
|
|
//Morse menu playback
|
|
|
|
void ssMorseMenuInitialize(long int* start_value_out)
|
2020-01-18 08:10:53 +01:00
|
|
|
{
|
2020-01-22 09:11:52 +01:00
|
|
|
*start_value_out = globalSettings.morseMenuOn;
|
2020-01-20 05:35:43 +01:00
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
void ssMorseMenuValidate(const long int candidate_value_in, long int* validated_value_out)
|
2020-01-20 05:35:43 +01:00
|
|
|
{
|
|
|
|
*validated_value_out = LIMIT(candidate_value_in,0,1);
|
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
void ssMorseMenuChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
2020-01-20 05:35:43 +01:00
|
|
|
{
|
2020-01-22 09:04:12 +01:00
|
|
|
char m;
|
2020-01-20 05:35:43 +01:00
|
|
|
if(new_value){
|
|
|
|
strncpy_P(buff_out,(const char*)F("Yes"),buff_out_size);
|
2020-01-22 09:04:12 +01:00
|
|
|
m = 'Y';
|
2020-01-18 08:23:56 +01:00
|
|
|
}
|
2020-01-20 05:35:43 +01:00
|
|
|
else{
|
|
|
|
strncpy_P(buff_out,(const char*)F("No"),buff_out_size);
|
2020-01-22 09:04:12 +01:00
|
|
|
m = 'N';
|
2020-01-18 08:10:53 +01:00
|
|
|
}
|
2020-01-22 09:04:12 +01:00
|
|
|
morseLetter(m);
|
|
|
|
enc_read();//Consume any rotations during morse playback
|
2020-01-20 05:35:43 +01:00
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
void ssMorseMenuFinalize(const long int final_value)
|
2020-01-20 05:35:43 +01:00
|
|
|
{
|
2020-01-22 09:11:52 +01:00
|
|
|
globalSettings.morseMenuOn = final_value;
|
|
|
|
SaveSettingsToEeprom();
|
2020-01-18 08:10:53 +01:00
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
const char SS_MORSE_MENU_T [] PROGMEM = "Menu Audio";
|
|
|
|
const char SS_MORSE_MENU_A [] PROGMEM = "When on, menu selections\nwill play morse code";
|
|
|
|
const SettingScreen_t ssMorseMenu PROGMEM = {
|
|
|
|
SS_MORSE_MENU_T,
|
|
|
|
SS_MORSE_MENU_A,
|
|
|
|
10,
|
2020-01-20 05:35:43 +01:00
|
|
|
1,
|
2020-01-22 09:11:52 +01:00
|
|
|
ssMorseMenuInitialize,
|
|
|
|
ssMorseMenuValidate,
|
|
|
|
ssMorseMenuChange,
|
|
|
|
ssMorseMenuFinalize
|
2020-01-20 05:35:43 +01:00
|
|
|
};
|
2020-02-15 23:17:55 +01:00
|
|
|
void runMorseMenuSetting(){activateSetting(&ssMorseMenu);}
|
2020-01-18 08:10:53 +01:00
|
|
|
|
2020-01-22 09:11:52 +01:00
|
|
|
//CW Speed
|
|
|
|
void ssCwSpeedInitialize(long int* start_value_out)
|
2020-01-22 09:04:12 +01:00
|
|
|
{
|
2020-01-22 09:11:52 +01:00
|
|
|
*start_value_out = 1200L/globalSettings.cwDitDurationMs;
|
2020-01-22 09:04:12 +01:00
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
void ssCwSpeedValidate(const long int candidate_value_in, long int* validated_value_out)
|
|
|
|
{
|
|
|
|
*validated_value_out = LIMIT(candidate_value_in,1,100);
|
|
|
|
}
|
2020-01-26 20:12:07 +01:00
|
|
|
void ssCwSpeedChange(const long int new_value, char* buff_out, const size_t /*buff_out_size*/)
|
2020-01-22 09:11:52 +01:00
|
|
|
{
|
|
|
|
ltoa(new_value, buff_out, 10);
|
|
|
|
morseText(buff_out,1200L/new_value);
|
|
|
|
enc_read();//Consume any rotations during morse playback
|
|
|
|
}
|
|
|
|
void ssCwSpeedFinalize(const long int final_value)
|
|
|
|
{
|
|
|
|
globalSettings.cwDitDurationMs = 1200L/final_value;
|
|
|
|
SaveSettingsToEeprom();
|
|
|
|
}
|
|
|
|
const char SS_CW_SPEED_T [] PROGMEM = "Play Speed";
|
|
|
|
const char SS_CW_SPEED_A [] PROGMEM = "Select speed to play CW\ncharacters";
|
|
|
|
const SettingScreen_t ssCwSpeed PROGMEM = {
|
|
|
|
SS_CW_SPEED_T,
|
|
|
|
SS_CW_SPEED_A,
|
|
|
|
5,
|
|
|
|
1,
|
|
|
|
ssCwSpeedInitialize,
|
|
|
|
ssCwSpeedValidate,
|
|
|
|
ssCwSpeedChange,
|
|
|
|
ssCwSpeedFinalize
|
|
|
|
};
|
2020-02-15 23:17:55 +01:00
|
|
|
void runCwSpeedSetting(){activateSetting(&ssCwSpeed);}
|
2020-01-22 09:11:52 +01:00
|
|
|
|
|
|
|
//Reset all settings
|
|
|
|
void ssResetAllInitialize(long int* start_value_out)
|
|
|
|
{
|
|
|
|
*start_value_out = 0;//Default to NOT resetting
|
|
|
|
}
|
|
|
|
void ssResetAllValidate(const long int candidate_value_in, long int* validated_value_out)
|
2020-01-22 09:04:12 +01:00
|
|
|
{
|
|
|
|
*validated_value_out = LIMIT(candidate_value_in,0,1);
|
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
void ssResetAllChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
2020-01-22 09:04:12 +01:00
|
|
|
{
|
|
|
|
char m;
|
|
|
|
if(new_value){
|
|
|
|
strncpy_P(buff_out,(const char*)F("Yes"),buff_out_size);
|
|
|
|
m = 'Y';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
strncpy_P(buff_out,(const char*)F("No"),buff_out_size);
|
|
|
|
m = 'N';
|
|
|
|
}
|
|
|
|
morseLetter(m);
|
|
|
|
enc_read();//Consume any rotations during morse playback
|
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
void ssResetAllFinalize(const long int final_value)
|
2020-01-22 09:04:12 +01:00
|
|
|
{
|
2020-01-22 09:11:52 +01:00
|
|
|
if(final_value){
|
|
|
|
LoadDefaultSettings();
|
|
|
|
SaveSettingsToEeprom();
|
|
|
|
setup();
|
|
|
|
}
|
2020-01-22 09:04:12 +01:00
|
|
|
}
|
2020-01-22 09:11:52 +01:00
|
|
|
const char SS_RESET_ALL_T [] PROGMEM = "Reset All";
|
|
|
|
const char SS_RESET_ALL_A [] PROGMEM = "WARNING: Selecting \"Yes\"\nwill reset all calibrations and\nsettings to their default\nvalues";
|
|
|
|
const SettingScreen_t ssResetAll PROGMEM = {
|
|
|
|
SS_RESET_ALL_T,
|
|
|
|
SS_RESET_ALL_A,
|
|
|
|
20,
|
2020-01-22 09:04:12 +01:00
|
|
|
1,
|
2020-01-22 09:11:52 +01:00
|
|
|
ssResetAllInitialize,
|
|
|
|
ssResetAllValidate,
|
|
|
|
ssResetAllChange,
|
|
|
|
ssResetAllFinalize
|
2020-01-22 09:04:12 +01:00
|
|
|
};
|
2020-02-15 23:17:55 +01:00
|
|
|
void runResetAllSetting(){activateSetting(&ssResetAll);}
|
|
|
|
|
2020-01-18 06:41:52 +01:00
|
|
|
struct MenuItem_t {
|
|
|
|
const char* const ItemName;
|
2020-02-15 23:29:23 +01:00
|
|
|
void (*OnSelect)();
|
2020-01-18 06:41:52 +01:00
|
|
|
};
|
|
|
|
|
2020-02-16 00:31:14 +01:00
|
|
|
void initSetupMenu(const MenuItem_t* const menu_items,
|
|
|
|
const uint16_t num_items);
|
|
|
|
MenuReturn_e runSetupMenu(const MenuItem_t* const menu_items,
|
|
|
|
const uint16_t num_items,
|
|
|
|
const ButtonPress_e tuner_button,
|
|
|
|
const ButtonPress_e touch_button,
|
|
|
|
const Point touch_point,
|
|
|
|
const int16_t knob);
|
|
|
|
|
|
|
|
#define GENERATE_MENU_T(menu_name) \
|
|
|
|
void initSetupMenu##menu_name(void)\
|
|
|
|
{\
|
|
|
|
initSetupMenu(menuItems##menu_name,sizeof(menuItems##menu_name)/sizeof(menuItems##menu_name[0]));\
|
|
|
|
}\
|
|
|
|
MenuReturn_e runSetupMenu##menu_name(const ButtonPress_e tuner_button,\
|
|
|
|
const ButtonPress_e touch_button,\
|
|
|
|
const Point touch_point,\
|
|
|
|
const int16_t knob)\
|
|
|
|
{\
|
|
|
|
return runSetupMenu(menuItems##menu_name,\
|
|
|
|
sizeof(menuItems##menu_name)/sizeof(menuItems##menu_name[0]),\
|
|
|
|
tuner_button,\
|
|
|
|
touch_button,\
|
|
|
|
touch_point,\
|
|
|
|
knob\
|
|
|
|
);\
|
|
|
|
}\
|
|
|
|
Menu_t setupMenu##menu_name = {\
|
|
|
|
initSetupMenu##menu_name,\
|
|
|
|
runSetupMenu##menu_name,\
|
|
|
|
nullptr\
|
|
|
|
};\
|
|
|
|
void run##menu_name##Menu(void)\
|
|
|
|
{\
|
|
|
|
enterSubmenu(&setupMenu##menu_name);\
|
|
|
|
}\
|
2020-01-18 06:41:52 +01:00
|
|
|
|
|
|
|
const char MT_CAL [] PROGMEM = "Calibrations";
|
2020-01-18 07:27:12 +01:00
|
|
|
const char MI_TOUCH [] PROGMEM = "Touch Screen";
|
2020-02-16 00:31:14 +01:00
|
|
|
const MenuItem_t menuItemsCalibration [] PROGMEM {
|
2020-01-18 06:41:52 +01:00
|
|
|
{MT_CAL,nullptr},//Title
|
2020-01-20 05:51:19 +01:00
|
|
|
{SS_LOCAL_OSC_T,runLocalOscSetting},
|
|
|
|
{SS_BFO_T,runBfoSetting},
|
2020-01-18 06:41:52 +01:00
|
|
|
{MI_TOUCH,setupTouch},
|
|
|
|
};
|
2020-02-16 00:31:14 +01:00
|
|
|
GENERATE_MENU_T(Calibration);
|
2020-01-02 03:42:34 +01:00
|
|
|
|
2020-01-22 09:11:52 +01:00
|
|
|
const char MT_CW [] PROGMEM = "CW Setup";
|
2020-02-16 00:31:14 +01:00
|
|
|
const MenuItem_t menuItemsCw [] PROGMEM {
|
2020-01-18 06:41:52 +01:00
|
|
|
{MT_CW,nullptr},//Title
|
2020-01-20 05:51:19 +01:00
|
|
|
{SS_CW_TONE_T,runToneSetting},
|
|
|
|
{SS_CW_SWITCH_T,runCwSwitchDelaySetting},
|
|
|
|
{SS_KEYER_T,runKeyerSetting},
|
2020-01-22 09:11:52 +01:00
|
|
|
{SS_MORSE_MENU_T,runMorseMenuSetting},
|
|
|
|
{SS_CW_SPEED_T,runCwSpeedSetting},
|
2020-01-02 03:42:34 +01:00
|
|
|
};
|
2020-02-16 00:31:14 +01:00
|
|
|
GENERATE_MENU_T(Cw);
|
2020-01-02 03:42:34 +01:00
|
|
|
|
2020-01-18 06:41:52 +01:00
|
|
|
const char MT_SETTINGS [] PROGMEM = "Settings";
|
2020-02-16 00:31:14 +01:00
|
|
|
const MenuItem_t menuItemsSetupRoot [] PROGMEM {
|
2020-01-18 06:41:52 +01:00
|
|
|
{MT_SETTINGS,nullptr},//Title
|
|
|
|
{MT_CAL,runCalibrationMenu},
|
|
|
|
{MT_CW,runCwMenu},
|
2020-01-20 05:35:43 +01:00
|
|
|
{SS_RESET_ALL_T,runResetAllSetting},
|
2020-01-02 03:42:34 +01:00
|
|
|
};
|
2020-02-16 00:31:14 +01:00
|
|
|
GENERATE_MENU_T(SetupRoot);
|
|
|
|
Menu_t *const setupMenu = &setupMenuSetupRoot;
|
2020-01-02 03:42:34 +01:00
|
|
|
|
2020-01-18 06:41:52 +01:00
|
|
|
const char MI_EXIT [] PROGMEM = "Exit";
|
|
|
|
const MenuItem_t exitMenu PROGMEM = {MI_EXIT,nullptr};
|
|
|
|
|
|
|
|
void drawMenu(const MenuItem_t* const items, const uint16_t num_items)
|
|
|
|
{
|
2020-01-02 03:42:34 +01:00
|
|
|
displayClear(COLOR_BACKGROUND);
|
2020-01-18 06:41:52 +01:00
|
|
|
MenuItem_t mi = {"",nullptr};
|
|
|
|
memcpy_P(&mi,&items[0],sizeof(mi));
|
2020-01-20 04:00:45 +01:00
|
|
|
strncpy_P(b,mi.ItemName,sizeof(b));
|
2020-01-02 03:42:34 +01:00
|
|
|
displayText(b, LAYOUT_TITLE_X, LAYOUT_TITLE_Y, LAYOUT_TITLE_WIDTH, LAYOUT_TITLE_HEIGHT, COLOR_TEXT, COLOR_TITLE_BACKGROUND, COLOR_ACTIVE_BORDER);
|
2020-01-18 06:41:52 +01:00
|
|
|
for(unsigned int i = 1; i < num_items; ++i){
|
|
|
|
memcpy_P(&mi,&items[i],sizeof(mi));
|
2020-01-20 04:00:45 +01:00
|
|
|
strncpy_P(b,mi.ItemName,sizeof(b));
|
2020-01-28 08:09:34 +01:00
|
|
|
displayText(b, LAYOUT_ITEM_X, LAYOUT_ITEM_Y + (i-1)*LAYOUT_ITEM_PITCH_Y, LAYOUT_ITEM_WIDTH, LAYOUT_ITEM_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_INACTIVE_BORDER, TextJustification_e::Left);
|
2020-01-02 03:42:34 +01:00
|
|
|
}
|
2020-01-18 06:41:52 +01:00
|
|
|
memcpy_P(&mi,&exitMenu,sizeof(mi));
|
2020-01-20 04:00:45 +01:00
|
|
|
strncpy_P(b,mi.ItemName,sizeof(b));
|
2020-01-28 08:09:34 +01:00
|
|
|
displayText(b, LAYOUT_ITEM_X, LAYOUT_ITEM_Y + (num_items-1)*LAYOUT_ITEM_PITCH_Y, LAYOUT_ITEM_WIDTH, LAYOUT_ITEM_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_INACTIVE_BORDER, TextJustification_e::Left);
|
2019-12-18 07:32:44 +01:00
|
|
|
}
|
|
|
|
|
2020-02-15 22:49:09 +01:00
|
|
|
void movePuck(unsigned int old_index,
|
|
|
|
unsigned int new_index)
|
2020-01-18 06:41:52 +01:00
|
|
|
{
|
2020-01-02 03:42:34 +01:00
|
|
|
//Don't update if we're already on the right selection
|
2020-01-18 06:41:52 +01:00
|
|
|
if(old_index == new_index){
|
2020-01-02 03:42:34 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-01-18 06:41:52 +01:00
|
|
|
else if(((unsigned int)-1) != old_index){
|
|
|
|
//Clear old
|
|
|
|
displayRect(LAYOUT_ITEM_X, LAYOUT_ITEM_Y + (old_index*LAYOUT_ITEM_PITCH_Y), LAYOUT_ITEM_WIDTH, LAYOUT_ITEM_HEIGHT, COLOR_INACTIVE_BORDER);
|
|
|
|
}
|
2020-01-02 03:42:34 +01:00
|
|
|
//Draw new
|
2020-01-18 06:41:52 +01:00
|
|
|
displayRect(LAYOUT_ITEM_X, LAYOUT_ITEM_Y + (new_index*LAYOUT_ITEM_PITCH_Y), LAYOUT_ITEM_WIDTH, LAYOUT_ITEM_HEIGHT, COLOR_ACTIVE_BORDER);
|
2019-12-18 07:32:44 +01:00
|
|
|
}
|
|
|
|
|
2020-02-15 22:49:09 +01:00
|
|
|
int16_t setupMenuSelector = 0;
|
2019-12-18 07:32:44 +01:00
|
|
|
|
2020-02-15 22:49:09 +01:00
|
|
|
void initSetupMenu(const MenuItem_t* const menu_items,
|
|
|
|
const uint16_t num_items)
|
|
|
|
{
|
2020-01-18 06:41:52 +01:00
|
|
|
drawMenu(menu_items,num_items);
|
2020-02-15 22:49:09 +01:00
|
|
|
setupMenuSelector = 0;
|
2020-01-22 09:04:12 +01:00
|
|
|
movePuck(-1,0);//Force draw of puck
|
2020-02-15 22:49:09 +01:00
|
|
|
}
|
2019-12-18 07:32:44 +01:00
|
|
|
|
2020-02-15 22:49:09 +01:00
|
|
|
MenuReturn_e runSetupMenu(const MenuItem_t* const menu_items,
|
|
|
|
const uint16_t num_items,
|
|
|
|
const ButtonPress_e tuner_button,
|
|
|
|
const ButtonPress_e touch_button,
|
|
|
|
const Point touch_point,
|
|
|
|
const int16_t knob)
|
|
|
|
{
|
|
|
|
const int16_t cur_index = setupMenuSelector/MENU_KNOB_COUNTS_PER_ITEM;
|
|
|
|
const int16_t exit_index = num_items - 1;
|
2020-01-22 09:04:12 +01:00
|
|
|
|
2020-02-15 22:49:09 +01:00
|
|
|
if(ButtonPress_e::NotPressed != tuner_button){
|
|
|
|
//Don't care what kind of press
|
|
|
|
if(exit_index <= cur_index){
|
|
|
|
return MenuReturn_e::ExitedRedraw;
|
2020-01-22 09:04:12 +01:00
|
|
|
}
|
|
|
|
|
2020-02-15 22:49:09 +01:00
|
|
|
MenuItem_t mi = {"",nullptr};
|
|
|
|
memcpy_P(&mi,&menu_items[cur_index+1],sizeof(mi));//The 0th element in the array is the title, so offset by 1
|
|
|
|
mi.OnSelect();
|
|
|
|
}
|
2020-01-18 06:41:52 +01:00
|
|
|
|
2020-02-15 22:49:09 +01:00
|
|
|
(void)touch_button;(void)touch_point;//TODO: handle touch input?
|
2019-12-18 07:32:44 +01:00
|
|
|
|
2020-02-15 23:17:55 +01:00
|
|
|
if(0 != knob){
|
2020-02-15 23:29:23 +01:00
|
|
|
setupMenuSelector = LIMIT(setupMenuSelector + knob,0,(int16_t)(num_items*MENU_KNOB_COUNTS_PER_ITEM - 1));
|
2020-02-15 22:49:09 +01:00
|
|
|
const int16_t new_index = setupMenuSelector/MENU_KNOB_COUNTS_PER_ITEM;
|
|
|
|
if(cur_index != new_index){
|
2020-02-15 23:29:23 +01:00
|
|
|
movePuck(cur_index,new_index);
|
2020-02-15 22:49:09 +01:00
|
|
|
if(globalSettings.morseMenuOn){//Only spend cycles copying menu item into RAM if we actually need to
|
|
|
|
if(exit_index <= cur_index){
|
|
|
|
strncpy_P(b,MI_EXIT,sizeof(b));
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
MenuItem_t mi = {"",nullptr};
|
2020-02-15 23:29:23 +01:00
|
|
|
memcpy_P(&mi,&menu_items[cur_index+1],sizeof(mi));//The 0th element in the array is the title, so offset by 1
|
2020-02-15 22:49:09 +01:00
|
|
|
strncpy_P(b,mi.ItemName,sizeof(b));
|
|
|
|
}
|
|
|
|
morseText(b);
|
|
|
|
}
|
2020-01-18 06:41:52 +01:00
|
|
|
}
|
2019-12-18 07:32:44 +01:00
|
|
|
}
|
2020-02-15 23:17:55 +01:00
|
|
|
|
|
|
|
return MenuReturn_e::StillActive;
|
2019-12-18 07:32:44 +01:00
|
|
|
}
|