Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial try with U8x8 #63

Merged
merged 6 commits into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
initial try with U8x8
  • Loading branch information
pawel-spychalski committed May 18, 2018
commit 68aafd179d054f9a2d2815dee9dc4f50c5bd2ddb
168 changes: 88 additions & 80 deletions crossbow/tx_oled.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#include "tx_oled.h"

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.clear();
_display.setFont(u8x8_font_chroma48medium8_r);
_display.drawString(0,0,"Hello World!");
}

void TxOled::loop() {
Expand Down Expand Up @@ -78,107 +77,116 @@ void TxOled::page(uint8_t page) {
}

void TxOled::renderPagePwr() {
_display.clearDisplay();
_display.setTextColor(WHITE, BLACK);
// _display.clearDisplay();
// _display.setTextColor(WHITE, BLACK);

_display.setCursor(0, 0);
_display.setTextSize(2);
_display.print("PWR");
// _display.setCursor(0, 0);
// _display.setTextSize(2);
// _display.print("PWR");

//TODO content
_display.setCursor(0, 25);
_display.setTextSize(3);
_display.print(radioNode.loraTxPower);
_display.print("dBm");
// //TODO content
// _display.setCursor(0, 25);
// _display.setTextSize(3);
// _display.print(radioNode.loraTxPower);
// _display.print("dBm");

_display.display();
// _display.display();
}

void TxOled::renderPageBind() {
_display.clearDisplay();
_display.setTextColor(WHITE, BLACK);
// _display.clearDisplay();
// _display.setTextColor(WHITE, BLACK);

_display.setCursor(0, 0);
_display.setTextSize(2);
_display.print("Bind");
// _display.setCursor(0, 0);
// _display.setTextSize(2);
// _display.print("Bind");

//TODO content
// //TODO content

_display.display();
// _display.display();
}

void TxOled::renderPageMode() {
_display.clearDisplay();
_display.setTextColor(WHITE, BLACK);
// _display.clearDisplay();
// _display.setTextColor(WHITE, BLACK);

_display.setCursor(0, 0);
_display.setTextSize(2);
_display.print("Mode");
// _display.setCursor(0, 0);
// _display.setTextSize(2);
// _display.print("Mode");

_display.setCursor(0, 25);
_display.setTextSize(3);
_display.print("Full");
// _display.setCursor(0, 25);
// _display.setTextSize(3);
// _display.print("Full");

_display.display();
// _display.display();
}

void TxOled::renderPageStats() {
_display.clearDisplay();
_display.setTextColor(WHITE, BLACK);
// _display.clearDisplay();
// _display.setTextColor(WHITE, BLACK);

_display.setCursor(0, 0);
_display.setTextSize(3);
_display.print(radioNode.rssi);
// _display.setCursor(0, 0);
// _display.setTextSize(3);
// _display.print(radioNode.rssi);

_display.setCursor(18, 28);
_display.setTextSize(2);
_display.print(radioNode.snr);
// _display.setCursor(18, 28);
// _display.setTextSize(2);
// _display.print(radioNode.snr);

_display.setCursor(74, 0);
_display.setTextSize(3);
_display.print(rxDeviceState.rssi);
// _display.setCursor(74, 0);
// _display.setTextSize(3);
// _display.print(rxDeviceState.rssi);

_display.setCursor(92, 28);
_display.setTextSize(2);
_display.print(rxDeviceState.snr);
// _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();
}

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");

_display.setTextSize(1);
_display.setCursor(0, 32);
_display.print("Bandwitdh: ");
_display.print(radioNode.loraBandwidth / 1000);
_display.print("kHz");

_display.setCursor(0, 42);
_display.print("SF: ");
_display.print(radioNode.loraSpreadingFactor);

_display.setCursor(64, 42);
_display.print("CR: ");
_display.print(radioNode.loraCodingRate);

_display.setCursor(0, 52);
_display.print("Rate: ");
_display.print(1000 / TX_TRANSMIT_SLOT_RATE);
_display.print("Hz");

_display.display();

_display.clear();

char buf[128];
snprintf(buf, "%s %d %s", "Rdy", radioNode.loraTxPower, "dBm");

_display.drawString(0, 0, buf);


// _display.clearDisplay();
// _display.setTextColor(WHITE, BLACK);
// _display.setTextSize(2);

// _display.setCursor(0, 0);
// _display.print("Rdy ");
// _display.print(radioNode.loraTxPower);
// _display.print("dBm");

// _display.setTextSize(1);
// _display.setCursor(0, 32);
// _display.print("Bandwitdh: ");
// _display.print(radioNode.loraBandwidth / 1000);
// _display.print("kHz");

// _display.setCursor(0, 42);
// _display.print("SF: ");
// _display.print(radioNode.loraSpreadingFactor);

// _display.setCursor(64, 42);
// _display.print("CR: ");
// _display.print(radioNode.loraCodingRate);

// _display.setCursor(0, 52);
// _display.print("Rate: ");
// _display.print(1000 / TX_TRANSMIT_SLOT_RATE);
// _display.print("Hz");

// _display.display();
}


Expand Down
4 changes: 2 additions & 2 deletions crossbow/tx_oled.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down