Merge pull request #63 from DzikuVx/u8x8-lib

initial try with U8x8
This commit is contained in:
Paweł Spychalski
2018-05-21 15:27:47 +02:00
committed by GitHub
6 changed files with 63 additions and 85 deletions

View File

@@ -23,7 +23,7 @@ before_install:
fi
- arduino --pref "boardsmanager.additional.urls=" --save-prefs
install:
- arduino --install-library "Adafruit SSD1306","Adafruit GFX Library"
- arduino --install-library "U8g2"
script:
- cp -f $PWD/crossbow/configurations/config_${CONFIG}.h $PWD/crossbow/config.h &&
arduino --verify --board $BOARD $PWD/crossbow/crossbow.ino

View File

@@ -1,6 +1,6 @@
{
"board": "bsfrance:avr:lora32u4",
"sketch": "crossbow/crossbow.ino",
"port": "COM7",
"port": "COM5",
"output": "../build"
}

View File

@@ -18,6 +18,12 @@ Needs implementation:
* RX configuration from TX module
* Sending telemetry from TX to OpenTX radio
# Dependencies
To compile, following libraries have to be installed:
* [U8g2](https://github.com/olikraus/u8g2) for OLED support in TX module
# Protocol
| Byte | Description | Notes |

View File

@@ -29,7 +29,7 @@
*/
#define FEATURE_TX_INPUT_SBUS
// #define DEBUG_SERIAL
#define DEBUG_SERIAL
// #define DEBUG_PING_PONG
// #define DEBUG_LED

View File

@@ -1,15 +1,15 @@
#include "tx_oled.h"
#define OLED_COL_COUNT 16
TxOled::TxOled(void) {
Adafruit_SSD1306 _display(-1);
U8X8_SSD1306_128X64_NONAME_HW_I2C _display(U8X8_PIN_NONE);
}
void TxOled::init() {
_display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
_display.setTextSize(1);
_display.setTextColor(WHITE);
_display.clearDisplay();
_display.display();
_display.begin();
_display.setFont(u8x8_font_pxplustandynewtv_f);
_display.clear();
}
void TxOled::loop() {
@@ -78,107 +78,79 @@ void TxOled::page(uint8_t page) {
}
void TxOled::renderPagePwr() {
_display.clearDisplay();
_display.setTextColor(WHITE, BLACK);
char buf[OLED_COL_COUNT];
_display.setCursor(0, 0);
_display.setTextSize(2);
_display.print("PWR");
_display.clear();
_display.draw1x2String(0, 0, "Power");
//TODO content
_display.setCursor(0, 25);
_display.setTextSize(3);
_display.print(radioNode.loraTxPower);
_display.print("dBm");
_display.display();
snprintf(buf, OLED_COL_COUNT, "%d%s", radioNode.loraTxPower, "dBm");
_display.draw1x2String(0, 4, buf);
}
void TxOled::renderPageBind() {
_display.clearDisplay();
_display.setTextColor(WHITE, BLACK);
char buf[OLED_COL_COUNT];
_display.setCursor(0, 0);
_display.setTextSize(2);
_display.print("Bind");
_display.clear();
_display.draw1x2String(0, 0, "Bind");
//TODO content
_display.display();
snprintf(buf, OLED_COL_COUNT, "Bind?");
_display.draw1x2String(0, 4, buf);
}
void TxOled::renderPageMode() {
_display.clearDisplay();
_display.setTextColor(WHITE, BLACK);
char buf[OLED_COL_COUNT];
_display.setCursor(0, 0);
_display.setTextSize(2);
_display.print("Mode");
_display.clear();
_display.draw1x2String(0, 0, "Mode");
_display.setCursor(0, 25);
_display.setTextSize(3);
_display.print("Full");
_display.display();
snprintf(buf, OLED_COL_COUNT, "Full");
_display.draw1x2String(0, 4, buf);
}
void TxOled::renderPageStats() {
_display.clearDisplay();
_display.setTextColor(WHITE, BLACK);
char buf[OLED_COL_COUNT];
_display.clear();
_display.draw1x2String(0, 0, "Stats");
_display.drawString(0, 3, "RSSI");
_display.drawString(0, 5, "SNR");
_display.setCursor(0, 0);
_display.setTextSize(3);
_display.print(radioNode.rssi);
snprintf(buf, OLED_COL_COUNT, "%d", radioNode.rssi);
_display.drawString(6, 3, buf);
snprintf(buf, OLED_COL_COUNT, "%d", rxDeviceState.rssi);
_display.drawString(11, 3, buf);
_display.setCursor(18, 28);
_display.setTextSize(2);
_display.print(radioNode.snr);
snprintf(buf, OLED_COL_COUNT, "%d", radioNode.snr);
_display.drawString(6, 5, buf);
snprintf(buf, OLED_COL_COUNT, "%d", rxDeviceState.snr);
_display.drawString(11, 5, buf);
_display.setCursor(74, 0);
_display.setTextSize(3);
_display.print(rxDeviceState.rssi);
_display.setCursor(92, 28);
_display.setTextSize(2);
_display.print(rxDeviceState.snr);
_display.setCursor(54, 48);
_display.setTextSize(2);
_display.print(txDeviceState.roundtrip);
_display.display();
snprintf(buf, OLED_COL_COUNT, "Trip: %d", txDeviceState.roundtrip);
_display.drawString(0, 7, buf);
}
void TxOled::renderPageInit() {
_display.clearDisplay();
_display.setTextColor(WHITE, BLACK);
_display.setTextSize(2);
_display.setCursor(0, 0);
_display.print("Rdy ");
_display.print(radioNode.loraTxPower);
_display.print("dBm");
char buf[OLED_COL_COUNT];
_display.setTextSize(1);
_display.setCursor(0, 32);
_display.print("Bandwitdh: ");
_display.print(radioNode.loraBandwidth / 1000);
_display.print("kHz");
_display.clear();
_display.setCursor(0, 42);
_display.print("SF: ");
_display.print(radioNode.loraSpreadingFactor);
snprintf(buf, OLED_COL_COUNT, "Rdy %d %s", radioNode.loraTxPower, "dBm");
_display.draw1x2String(0, 0, buf);
_display.setCursor(64, 42);
_display.print("CR: ");
_display.print(radioNode.loraCodingRate);
snprintf(buf, OLED_COL_COUNT, "BW %dkHz", radioNode.loraBandwidth / 1000);
_display.drawString(0, 4, buf);
_display.setCursor(0, 52);
_display.print("Rate: ");
_display.print(1000 / TX_TRANSMIT_SLOT_RATE);
_display.print("Hz");
snprintf(buf, OLED_COL_COUNT, "SF %d", radioNode.loraSpreadingFactor);
_display.drawString(0, 5, buf);
_display.display();
snprintf(buf, OLED_COL_COUNT, "CR %d", radioNode.loraCodingRate);
_display.drawString(8, 5, buf);
snprintf(buf, OLED_COL_COUNT, "Rate: %dHz", 1000 / TX_TRANSMIT_SLOT_RATE);
_display.drawString(0, 7, buf);
}

View File

@@ -3,8 +3,8 @@
#ifndef TX_OLED_H
#define TX_OLED_H
#include <Adafruit_SSD1306.h>
#include "Wire.h"
#include <U8x8lib.h>
#include "variables.h"
#include "tactile.h"
#include "radio_node.h"
@@ -41,7 +41,7 @@ class TxOled {
void loop();
void page(uint8_t page);
private:
Adafruit_SSD1306 _display;
U8X8_SSD1306_128X64_NONAME_HW_I2C _display;
void renderPageInit();
void renderPageStats();
void renderPagePwr();