mirror of
https://codeberg.org/mclemens/ubitxv6.git
synced 2025-02-21 06:57:27 -05:00
Swap loop logic for new menu logic
This commit is contained in:
parent
e50857f181
commit
b29bd955ca
72
ubitxv6.ino
72
ubitxv6.ino
@ -30,6 +30,8 @@
|
|||||||
* Si5351 object to control the clocks.
|
* Si5351 object to control the clocks.
|
||||||
*/
|
*/
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
#include "menu.h"
|
||||||
|
#include "menu_main.h"
|
||||||
#include "morse.h"
|
#include "morse.h"
|
||||||
#include "nano_gui.h"
|
#include "nano_gui.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@ -302,41 +304,30 @@ void checkPTT(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//check if the encoder button was pressed
|
//check if the encoder button was pressed
|
||||||
void checkButton(){
|
static const uint8_t DEBOUNCE_DELAY_MS = 50;
|
||||||
//only if the button is pressed
|
static const uint16_t LONG_PRESS_TIME_MS = 3000;
|
||||||
if (!btnDown())
|
static const uint8_t LONG_PRESS_POLL_TIME_MS = 10;
|
||||||
return;
|
ButtonPress_e checkButton(){
|
||||||
active_delay(50);
|
if (!btnDown()){
|
||||||
if (!btnDown()) //debounce
|
return ButtonPress_e::NotPressed;
|
||||||
return;
|
}
|
||||||
|
delay(DEBOUNCE_DELAY_MS);
|
||||||
|
if (!btnDown()){//debounce
|
||||||
|
return ButtonPress_e::NotPressed;
|
||||||
|
}
|
||||||
|
|
||||||
//disengage any CAT work
|
uint16_t down_time = 0;
|
||||||
doingCAT = 0;
|
while(btnDown() && (down_time < LONG_PRESS_TIME_MS)){
|
||||||
|
delay(LONG_PRESS_POLL_TIME_MS);
|
||||||
|
down_time += LONG_PRESS_POLL_TIME_MS;
|
||||||
|
}
|
||||||
|
|
||||||
int downTime = 0;
|
if(down_time < LONG_PRESS_TIME_MS){
|
||||||
while(btnDown()){
|
return ButtonPress_e::ShortPress;
|
||||||
active_delay(10);
|
|
||||||
downTime++;
|
|
||||||
if (downTime > 300){
|
|
||||||
if(!globalSettings.morseMenuOn){
|
|
||||||
globalSettings.morseMenuOn = true;//set before playing
|
|
||||||
morseLetter(2);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
morseLetter(4);
|
return ButtonPress_e::LongPress;
|
||||||
globalSettings.morseMenuOn = false;//unset after playing
|
|
||||||
}
|
}
|
||||||
SaveSettingsToEeprom();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
active_delay(100);
|
|
||||||
|
|
||||||
doCommands();
|
|
||||||
//wait for the button to go up again
|
|
||||||
while(btnDown())
|
|
||||||
active_delay(10);
|
|
||||||
active_delay(50);//debounce
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchVFO(Vfo_e new_vfo){
|
void switchVFO(Vfo_e new_vfo){
|
||||||
@ -503,17 +494,16 @@ void loop(){
|
|||||||
checkPTT();
|
checkPTT();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkButton();
|
checkCAT();
|
||||||
//tune only when not tranmsitting
|
|
||||||
if(!globalSettings.txActive){
|
if(globalSettings.txActive){
|
||||||
if(globalSettings.ritOn){
|
//Don't run menus when transmitting
|
||||||
doRIT();
|
return;
|
||||||
}
|
|
||||||
else{
|
|
||||||
doTuning();
|
|
||||||
}
|
|
||||||
checkTouch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkCAT();
|
ButtonPress_e tuner_button = checkButton();
|
||||||
|
Point touch_point;
|
||||||
|
ButtonPress_e touch_button = checkTouch(&touch_point);
|
||||||
|
int16_t knob = enc_read();
|
||||||
|
rootMenu->runMenu(tuner_button,touch_button,touch_point,knob);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user