Basic init page
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
#define DEVICE_MODE_TX
|
||||
// #define DEVICE_MODE_RX
|
||||
|
||||
// #define FEATURE_TX_OLED
|
||||
#define FEATURE_TX_OLED
|
||||
// #define FORCE_TX_WITHOUT_INPUT
|
||||
|
||||
/*
|
||||
@@ -32,6 +32,5 @@
|
||||
#define DEBUG_SERIAL
|
||||
// #define DEBUG_PING_PONG
|
||||
// #define DEBUG_LED
|
||||
// #define DEBUG_TX_INPUT_ON_OLED
|
||||
|
||||
#endif
|
||||
|
||||
@@ -57,13 +57,8 @@ volatile int16_t TxInput::channels[TX_INPUT_CHANNEL_COUNT];
|
||||
BuzzerState_t buzzer;
|
||||
|
||||
#ifdef FEATURE_TX_OLED
|
||||
#include "Wire.h"
|
||||
|
||||
#define OLED_RESET -1
|
||||
#include <Adafruit_SSD1306.h>
|
||||
Adafruit_SSD1306 display(OLED_RESET);
|
||||
uint32_t lastOledTaskTime = 0;
|
||||
|
||||
#include "tx_oled.h"
|
||||
TxOled oled;
|
||||
#endif
|
||||
|
||||
#include "tactile.h"
|
||||
@@ -71,11 +66,6 @@ uint32_t lastOledTaskTime = 0;
|
||||
Tactile button0(BUTTON_0_PIN);
|
||||
Tactile button1(BUTTON_1_PIN);
|
||||
|
||||
// uint8_t buttonStates[2] = {HIGH, HIGH};
|
||||
// uint8_t previousButtonStates[2] = {HIGH, HIGH};
|
||||
// uint32_t buttonPressMillis[2] = {0, 0};
|
||||
// uint8_t buttonAction[2] = {BUTTON_ACTION_NONE, BUTTON_ACTION_NONE};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -252,13 +242,8 @@ void setup(void)
|
||||
#ifdef DEVICE_MODE_TX
|
||||
|
||||
#ifdef FEATURE_TX_OLED
|
||||
Wire.setClock(400000);
|
||||
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
oled.init(&radioState);
|
||||
oled.page(TX_PAGE_INIT);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -625,41 +610,38 @@ void loop(void)
|
||||
}
|
||||
|
||||
#ifdef FEATURE_TX_OLED
|
||||
if (
|
||||
currentMillis - lastOledTaskTime > OLED_UPDATE_RATE
|
||||
) {
|
||||
lastOledTaskTime = currentMillis;
|
||||
display.clearDisplay();
|
||||
// if (
|
||||
// currentMillis - lastOledTaskTime > OLED_UPDATE_RATE
|
||||
// ) {
|
||||
// lastOledTaskTime = millis();
|
||||
|
||||
display.setTextColor(WHITE, BLACK);
|
||||
display.setCursor(0, 0);
|
||||
display.setTextSize(3);
|
||||
display.print(radioState.rssi);
|
||||
|
||||
|
||||
display.setCursor(18, 28);
|
||||
display.setTextSize(2);
|
||||
display.print(radioState.snr);
|
||||
// display.setTextColor(WHITE, BLACK);
|
||||
// display.setCursor(0, 0);
|
||||
// display.setTextSize(3);
|
||||
// display.print(radioState.rssi);
|
||||
|
||||
display.setCursor(74, 0);
|
||||
display.setTextSize(3);
|
||||
display.print(rxDeviceState.rssi);
|
||||
// display.setCursor(18, 28);
|
||||
// display.setTextSize(2);
|
||||
// display.print(radioState.snr);
|
||||
|
||||
display.setCursor(92, 28);
|
||||
display.setTextSize(2);
|
||||
display.print(rxDeviceState.snr);
|
||||
// display.setCursor(74, 0);
|
||||
// display.setTextSize(3);
|
||||
// display.print(rxDeviceState.rssi);
|
||||
|
||||
#ifdef DEBUG_TX_INPUT_ON_OLED
|
||||
display.setCursor(0, 48);
|
||||
display.setTextSize(2);
|
||||
display.print(txInput.channels[0]);
|
||||
#endif
|
||||
// display.setCursor(92, 28);
|
||||
// display.setTextSize(2);
|
||||
// display.print(rxDeviceState.snr);
|
||||
|
||||
display.setCursor(54, 48);
|
||||
display.setTextSize(2);
|
||||
display.print(txDeviceState.roundtrip);
|
||||
// display.setCursor(54, 48);
|
||||
// display.setTextSize(2);
|
||||
// display.print(txDeviceState.roundtrip);
|
||||
|
||||
// display.display();
|
||||
|
||||
display.display();
|
||||
}
|
||||
// Serial.println(millis() - lastOledTaskTime);
|
||||
// }
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
39
crossbow/tx_oled.cpp
Normal file
39
crossbow/tx_oled.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "tx_oled.h"
|
||||
|
||||
TxOled::TxOled(void) {
|
||||
Adafruit_SSD1306 _display(-1);
|
||||
}
|
||||
|
||||
void TxOled::init(volatile RadioState_t *radioState) {
|
||||
_display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
|
||||
_display.setTextSize(1);
|
||||
_display.setTextColor(WHITE);
|
||||
_display.clearDisplay();
|
||||
_display.display();
|
||||
|
||||
_radioState = radioState;
|
||||
}
|
||||
|
||||
void TxOled::page(int page) {
|
||||
switch (page) {
|
||||
|
||||
case TX_PAGE_INIT:
|
||||
pageInit();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void TxOled::pageInit(void) {
|
||||
_display.clearDisplay();
|
||||
|
||||
_display.setTextColor(WHITE, BLACK);
|
||||
_display.setCursor(0, 0);
|
||||
_display.setTextSize(2);
|
||||
_display.print("Rdy ");
|
||||
_display.print(_radioState->loraTxPower);
|
||||
_display.print("dBm");
|
||||
}
|
||||
|
||||
|
||||
|
||||
28
crossbow/tx_oled.h
Normal file
28
crossbow/tx_oled.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef TX_OLED_H
|
||||
#define TX_OLED_H
|
||||
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include "Wire.h"
|
||||
#include "variables.h"
|
||||
|
||||
#define OLED_RESET -1
|
||||
|
||||
enum txOledPages {
|
||||
TX_PAGE_NONE,
|
||||
TX_PAGE_INIT,
|
||||
};
|
||||
|
||||
class TxOled {
|
||||
public:
|
||||
TxOled(void);
|
||||
void init(volatile RadioState_t *radioState);
|
||||
void page(int page);
|
||||
private:
|
||||
volatile RadioState_t *_radioState;
|
||||
Adafruit_SSD1306 _display;
|
||||
void pageInit(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user