170 lines
3.6 KiB
C++
170 lines
3.6 KiB
C++
//======================================================================
|
|
// menu.h
|
|
//======================================================================
|
|
|
|
#ifndef __menu_h__
|
|
#define __menu_h__
|
|
|
|
#include "rig.h"
|
|
|
|
// 16 characters on display
|
|
#define MAX_TEXT_LEN 16
|
|
#define MENU_SELECTED_CHAR '>'
|
|
|
|
const char blankLine[17] = " ";
|
|
|
|
class MenuItem {
|
|
public:
|
|
virtual ~MenuItem() {}
|
|
//virtual const char* text() = 0;
|
|
virtual void update() = 0;
|
|
virtual MenuItem* select() = 0;
|
|
virtual MenuItem* altSelect() = 0;
|
|
virtual MenuItem* exit() = 0;
|
|
virtual MenuItem* prev() = 0;
|
|
virtual MenuItem* next() = 0;
|
|
};
|
|
|
|
const char modeID[] = {'s', 'S', 'c', 'C', 'd', 'D', 't', 'T'};
|
|
const char* const filterID[NUM_RIG_MODES][NUM_RX_FILTERS] = {
|
|
{"2.8", "2.4", "1.8"}, // LSB
|
|
{"2.8", "2.4", "1.8"}, // USB
|
|
{"1.0", "500", "250"}, // CWL
|
|
{"1.0", "500", "250"}, // CWU
|
|
{"2.8", "2.4", "500"}, // DGL
|
|
{"2.8", "2.4", "500"}, // DGU
|
|
{"2.8", "2.4", "1.8"}, // TTL
|
|
{"2.8", "2.4", "1.8"}, // TTU
|
|
};
|
|
|
|
class TopMenu : public MenuItem {
|
|
public:
|
|
TopMenu(Rig& rig): _rig(rig), _dirty(false), _visible(false), _adjust_tx(false) {
|
|
strcpy(_text0, "R: T: ");
|
|
strcpy(_text1, "0123456789ABCDEF");
|
|
}
|
|
|
|
/* virtual const char* text() {
|
|
sprintf(_buffer, "%1c-%1c%6s%1c6s", modeID[rig.modeNum],
|
|
return _buffer;
|
|
}*/
|
|
|
|
virtual void update() {
|
|
sprintf(_text0, "%1cR:%3s %1cT: ",
|
|
_adjust_tx ? ' ' : MENU_SELECTED_CHAR,
|
|
filterID[_rig.modeNum()][_rig.filterNum()],
|
|
_adjust_tx ? MENU_SELECTED_CHAR : ' ');
|
|
if ((strcmp(_text0, _text1) != 0) || _dirty) {
|
|
if (_visible) {
|
|
sendIOPMenuDisplay(_text0);
|
|
USBDEBUG("updating menu:");
|
|
USBDEBUG(_text0);
|
|
} else {
|
|
sendIOPMenuInactive();
|
|
USBDEBUG("deactivating menu");
|
|
}
|
|
_dirty = false;
|
|
strncpy(_text1, _text0, MAX_TEXT_LEN);
|
|
}
|
|
}
|
|
|
|
virtual MenuItem* select() {
|
|
if (!_visible) {
|
|
_visible = true;
|
|
} else {
|
|
_adjust_tx = !_adjust_tx;
|
|
}
|
|
_dirty = true;
|
|
return this;
|
|
}
|
|
|
|
virtual MenuItem* altSelect() {
|
|
if (_visible) {
|
|
_visible = false;
|
|
_dirty = true;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
virtual MenuItem* exit() {
|
|
if (_visible) {
|
|
_visible = false;
|
|
_dirty = true;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
virtual MenuItem* prev() {
|
|
if (_visible) {
|
|
if (_adjust_tx) {
|
|
} else {
|
|
_rig.switchRxFilter(true);
|
|
}
|
|
_dirty = true;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
virtual MenuItem* next() {
|
|
if (_visible) {
|
|
if (_adjust_tx) {
|
|
} else {
|
|
_rig.switchRxFilter();
|
|
}
|
|
_dirty = true;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
private:
|
|
Rig& _rig;
|
|
bool _dirty;
|
|
bool _visible;
|
|
bool _adjust_tx;
|
|
char _text0[MAX_TEXT_LEN+1];
|
|
char _text1[MAX_TEXT_LEN+1];
|
|
};
|
|
|
|
/*
|
|
public class MenuItem {
|
|
public:
|
|
MenuItem(bool active = true, int timeout = 0): _active(active), _timeout(timeout), _elapsed(0) {}
|
|
void update() {
|
|
if ((_timeout > 0) && (_elapsed > _timeout)) {
|
|
_active = false;
|
|
}
|
|
}
|
|
inline void activate() { _active = true; _elapsed = 0; }
|
|
inline void deactivate() { _active = false; }
|
|
virtual MenuItem* accept();
|
|
virtual MenuItem* reject();
|
|
virtual MenuItem* next();
|
|
virtual MenuItem* prev();
|
|
|
|
private:
|
|
bool _active;
|
|
int _timeout;
|
|
elapsedMillis _elapsed;
|
|
};
|
|
|
|
public class SSBMenu {
|
|
public:
|
|
private:
|
|
};
|
|
|
|
public class DigiMenu {
|
|
public:
|
|
private:
|
|
}
|
|
|
|
public class CWMenu {
|
|
public:
|
|
private:
|
|
};
|
|
*/
|
|
#endif
|
|
|
|
//======================================================================
|
|
// EOF
|
|
//======================================================================
|