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