More fixes
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
* DEVICE_MODE_TX
|
||||
* DEVICE_MODE_RX
|
||||
*/
|
||||
// #define DEVICE_MODE_TX
|
||||
#define DEVICE_MODE_RX
|
||||
#define DEVICE_MODE_TX
|
||||
// #define DEVICE_MODE_RX
|
||||
|
||||
#define FEATURE_TX_OLED
|
||||
// #define FORCE_TX_WITHOUT_INPUT
|
||||
|
||||
@@ -178,11 +178,7 @@ void setup(void)
|
||||
|
||||
#ifdef FEATURE_TX_OLED
|
||||
oled.init();
|
||||
oled.page(
|
||||
&rxDeviceState,
|
||||
&txDeviceState,
|
||||
TX_PAGE_INIT
|
||||
);
|
||||
oled.page(TX_PAGE_INIT);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -291,12 +287,7 @@ void loop(void)
|
||||
button1.loop();
|
||||
|
||||
#ifdef FEATURE_TX_OLED
|
||||
oled.loop(
|
||||
&rxDeviceState,
|
||||
&txDeviceState,
|
||||
&button0,
|
||||
&button1
|
||||
);
|
||||
oled.loop();
|
||||
#endif
|
||||
|
||||
txInput.recoverStuckFrames();
|
||||
|
||||
@@ -12,12 +12,7 @@ void TxOled::init() {
|
||||
_display.display();
|
||||
}
|
||||
|
||||
void TxOled::loop(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState,
|
||||
Tactile *button0,
|
||||
Tactile *button1
|
||||
) {
|
||||
void TxOled::loop() {
|
||||
bool update = false;
|
||||
|
||||
//Depending on page, things might be different
|
||||
@@ -29,7 +24,7 @@ void TxOled::loop(
|
||||
|
||||
case TX_PAGE_STATS:
|
||||
//Second button refreshes this page
|
||||
if (button1->getState() == TACTILE_STATE_SHORT_PRESS) {
|
||||
if (button1.getState() == TACTILE_STATE_SHORT_PRESS) {
|
||||
update = true;
|
||||
}
|
||||
break;
|
||||
@@ -37,7 +32,7 @@ void TxOled::loop(
|
||||
}
|
||||
|
||||
//Short press of button0 always toggles no next page
|
||||
if (button0->getState() == TACTILE_STATE_SHORT_PRESS) {
|
||||
if (button0.getState() == TACTILE_STATE_SHORT_PRESS) {
|
||||
_mainPageSequenceIndex++;
|
||||
if (_mainPageSequenceIndex == TX_OLED_PAGE_COUNT) {
|
||||
_mainPageSequenceIndex = 0;
|
||||
@@ -46,45 +41,43 @@ void TxOled::loop(
|
||||
}
|
||||
|
||||
if (update) {
|
||||
page(
|
||||
rxDeviceState,
|
||||
txDeviceState,
|
||||
pageSequence[_mainPageSequenceIndex]
|
||||
);
|
||||
page(pageSequence[_mainPageSequenceIndex]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TxOled::page(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState,
|
||||
int page
|
||||
) {
|
||||
void TxOled::page(uint8_t page) {
|
||||
|
||||
static uint32_t lastUpdate = 0;
|
||||
|
||||
//Do not allow for OLED to be updated too often
|
||||
if (lastUpdate > 0 && millis() - lastUpdate < 200) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (page) {
|
||||
case TX_PAGE_INIT:
|
||||
renderPageInit(rxDeviceState, txDeviceState);
|
||||
renderPageInit();
|
||||
break;
|
||||
case TX_PAGE_STATS:
|
||||
renderPageStats(rxDeviceState, txDeviceState);
|
||||
renderPageStats();
|
||||
break;
|
||||
case TX_PAGE_PWR:
|
||||
renderPagePwr(rxDeviceState, txDeviceState);
|
||||
renderPagePwr();
|
||||
break;
|
||||
case TX_PAGE_BIND:
|
||||
renderPageBind(rxDeviceState, txDeviceState);
|
||||
renderPageBind();
|
||||
break;
|
||||
case TX_PAGE_MODE:
|
||||
renderPageMode(rxDeviceState, txDeviceState);
|
||||
renderPageMode();
|
||||
break;
|
||||
|
||||
}
|
||||
_page = page;
|
||||
|
||||
lastUpdate = millis();
|
||||
}
|
||||
|
||||
void TxOled::renderPagePwr(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
) {
|
||||
void TxOled::renderPagePwr() {
|
||||
_display.clearDisplay();
|
||||
_display.setTextColor(WHITE, BLACK);
|
||||
|
||||
@@ -101,10 +94,7 @@ void TxOled::renderPagePwr(
|
||||
_display.display();
|
||||
}
|
||||
|
||||
void TxOled::renderPageBind(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
) {
|
||||
void TxOled::renderPageBind() {
|
||||
_display.clearDisplay();
|
||||
_display.setTextColor(WHITE, BLACK);
|
||||
|
||||
@@ -117,10 +107,7 @@ void TxOled::renderPageBind(
|
||||
_display.display();
|
||||
}
|
||||
|
||||
void TxOled::renderPageMode(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
) {
|
||||
void TxOled::renderPageMode() {
|
||||
_display.clearDisplay();
|
||||
_display.setTextColor(WHITE, BLACK);
|
||||
|
||||
@@ -135,10 +122,7 @@ void TxOled::renderPageMode(
|
||||
_display.display();
|
||||
}
|
||||
|
||||
void TxOled::renderPageStats(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
) {
|
||||
void TxOled::renderPageStats() {
|
||||
_display.clearDisplay();
|
||||
_display.setTextColor(WHITE, BLACK);
|
||||
|
||||
@@ -152,23 +136,20 @@ void TxOled::renderPageStats(
|
||||
|
||||
_display.setCursor(74, 0);
|
||||
_display.setTextSize(3);
|
||||
_display.print(rxDeviceState->rssi);
|
||||
_display.print(rxDeviceState.rssi);
|
||||
|
||||
_display.setCursor(92, 28);
|
||||
_display.setTextSize(2);
|
||||
_display.print(rxDeviceState->snr);
|
||||
_display.print(rxDeviceState.snr);
|
||||
|
||||
_display.setCursor(54, 48);
|
||||
_display.setTextSize(2);
|
||||
_display.print(txDeviceState->roundtrip);
|
||||
_display.print(txDeviceState.roundtrip);
|
||||
|
||||
_display.display();
|
||||
}
|
||||
|
||||
void TxOled::renderPageInit(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
) {
|
||||
void TxOled::renderPageInit() {
|
||||
_display.clearDisplay();
|
||||
_display.setTextColor(WHITE, BLACK);
|
||||
_display.setTextSize(2);
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
#include "radio_node.h"
|
||||
|
||||
extern RadioNode radioNode;
|
||||
extern RxDeviceState_t rxDeviceState;
|
||||
extern TxDeviceState_t txDeviceState;
|
||||
extern Tactile button0;
|
||||
extern Tactile button1;
|
||||
|
||||
enum txOledPages {
|
||||
TX_PAGE_NONE,
|
||||
@@ -34,39 +38,15 @@ class TxOled {
|
||||
public:
|
||||
TxOled(void);
|
||||
void init();
|
||||
void loop(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState,
|
||||
Tactile *button0,
|
||||
Tactile *button1
|
||||
);
|
||||
void page(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState,
|
||||
int page
|
||||
);
|
||||
void loop();
|
||||
void page(uint8_t page);
|
||||
private:
|
||||
Adafruit_SSD1306 _display;
|
||||
void renderPageInit(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
);
|
||||
void renderPageStats(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
);
|
||||
void renderPagePwr(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
);
|
||||
void renderPageBind(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
);
|
||||
void renderPageMode(
|
||||
RxDeviceState_t *rxDeviceState,
|
||||
TxDeviceState_t *txDeviceState
|
||||
);
|
||||
void renderPageInit();
|
||||
void renderPageStats();
|
||||
void renderPagePwr();
|
||||
void renderPageBind();
|
||||
void renderPageMode();
|
||||
uint8_t _page = TX_PAGE_NONE;
|
||||
uint8_t _mainPageSequenceIndex = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user