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

Heltec ble display #1295

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
43 changes: 22 additions & 21 deletions main/ZboardHeltec.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
#if defined(ZboardHELTEC)
# include "ArduinoLog.h"
# include "config_HELTEC.h"
// # include "heltec.h"

SemaphoreHandle_t semaphoreOLEDOperation;

void logToLCD(bool display) {
display ? Log.begin(LOG_LEVEL_LCD, &Oled) : Log.begin(LOG_LEVEL, &Serial); // Log on LCD following LOG_LEVEL_LCD
Expand Down Expand Up @@ -125,6 +126,10 @@ OledSerial::OledSerial(int x) {

void OledSerial::begin() {
// Heltec.begin(); // User OMG serial support

semaphoreOLEDOperation = xSemaphoreCreateBinary();
xSemaphoreGive(semaphoreOLEDOperation);

display->init();
display->flipScreenVertically();
display->setFont(ArialMT_Plain_10);
Expand Down Expand Up @@ -157,28 +162,24 @@ void OledSerial::fillScreen(OLEDDISPLAY_COLOR color) {
display->fillRect(0, 0, OLED_WIDTH, OLED_HEIGHT);
}

size_t OledSerial::write(uint8_t c) {
display->clear();
display->setColor(WHITE);
display->setFont(ArialMT_Plain_10);

display->write((char)c);
display->drawLogBuffer(0, 0);
display->display();
return 1;
}

size_t OledSerial::write(const uint8_t* buffer, size_t size) {
display->clear();
display->setColor(WHITE);
display->setFont(ArialMT_Plain_10);
while (size) {
display->write((char)*buffer++);
size--;
if (xPortGetCoreID() == CONFIG_ARDUINO_RUNNING_CORE) {
if (xSemaphoreTake(semaphoreOLEDOperation, pdMS_TO_TICKS(30000)) == pdTRUE) {
display->clear();
display->setColor(WHITE);
display->setFont(ArialMT_Plain_10);
while (size) {
display->write((char)*buffer++);
size--;
}
display->drawLogBuffer(0, 0);
display->display();
xSemaphoreGive(semaphoreOLEDOperation);
return size;
}
}
display->drawLogBuffer(0, 0);
display->display();
return size;
// Default to Serial output if the display is not available
return Serial.write(buffer, size);
}

/*
Expand Down
7 changes: 6 additions & 1 deletion main/config_HELTEC.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ class OledSerial : public Stream {

void fillScreen(OLEDDISPLAY_COLOR); // fillScreen display and set color

size_t write(uint8_t);
// This is a bit of lazy programmer simplifacation for the semapore and core detecting code. Not sure if it is truly space efficient.

inline size_t write(uint8_t x) {
return write(&x, 1);
}

size_t write(const uint8_t* buffer, size_t size);
inline size_t write(const char* buffer, size_t size) {
return write((uint8_t*)buffer, size);
Expand Down
16 changes: 16 additions & 0 deletions scripts/omg_firmware_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import subprocess

Import("env")

def get_firmware_specifier_build_flag():
#ret = subprocess.run(["git", "describe"], stdout=subprocess.PIPE, text=True) #Uses only annotated tags
ret = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True) #Uses any tags
branch = subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE, text=True)
build_version = env['PIOENV'] + "-" + ret.stdout.strip() + "[" + branch.stdout.strip() + "]"
build_flag = "-D OMG_VERSION=\\\"" + build_version + "\\\""
print ("OpenMQTTGateway Build Version: " + build_version)
return (build_flag)

env.Append(
BUILD_FLAGS=[get_firmware_specifier_build_flag()]
)