Merge upstream/dev (11 commits) [upstream-sync]
This commit is contained in:
commit
021df7116a
23 files changed
+2699
-8
No files matched your search
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "nrf52840_s140_v6.ld"
|
||||
},
|
||||
"core": "nRF5",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DNRF52840_XXAA",
|
||||
"f_cpu": "64000000L",
|
||||
"hwids": [
|
||||
["0x239A", "0x4405"],
|
||||
["0x239A", "0x0029"],
|
||||
["0x239A", "0x002A"],
|
||||
["0x1915", "0x1667"]
|
||||
],
|
||||
"usb_product": "pocket-v2",
|
||||
"mcu": "nrf52840",
|
||||
"variant": "heltec_meshpocket_v2",
|
||||
"bsp": {
|
||||
"name": "adafruit"
|
||||
},
|
||||
"softdevice": {
|
||||
"sd_flags": "-DS140",
|
||||
"sd_name": "s140",
|
||||
"sd_version": "6.1.1",
|
||||
"sd_fwid": "0x00B6"
|
||||
},
|
||||
"bootloader": {
|
||||
"settings_addr": "0xFF000"
|
||||
}
|
||||
},
|
||||
"connectivity": ["bluetooth"],
|
||||
"debug": {
|
||||
"jlink_device": "nRF52840_xxAA",
|
||||
"onboard_tools": ["jlink"],
|
||||
"svd_path": "nrf52840.svd",
|
||||
"openocd_target": "nrf52840-mdk-rs"
|
||||
},
|
||||
"frameworks": ["arduino"],
|
||||
"name": "Heltec Mesh Pocket V2 (Adafruit BSP)",
|
||||
"upload": {
|
||||
"maximum_ram_size": 237568,
|
||||
"maximum_size": 815104,
|
||||
"speed": 115200,
|
||||
"protocol": "nrfutil",
|
||||
"protocols": ["jlink", "nrfjprog", "nrfutil", "stlink"],
|
||||
"use_1200bps_touch": true,
|
||||
"require_upload_port": true,
|
||||
"wait_for_upload_port": true
|
||||
},
|
||||
"url": "https://heltec.org",
|
||||
"vendor": "Heltec"
|
||||
}
|
||||
@@ -15,6 +15,7 @@ class DisplayDriver {
|
||||
int _w, _h;
|
||||
protected:
|
||||
DisplayDriver(int w, int h) { _w = w; _h = h; }
|
||||
void setLogicalSize(int w, int h) { _w = w; _h = h; }
|
||||
public:
|
||||
//enum Color { DARK=0, LIGHT, RED, GREEN, BLUE, YELLOW, ORANGE }; // on b/w screen, colors will be !=0 synonym of light
|
||||
|
||||
|
||||
@@ -107,21 +107,27 @@ ColorVal UIColor::popup_bkg = 0x07FF; // CYAN
|
||||
ColorVal UIColor::popup_txt = 0x0000;
|
||||
ColorVal UIColor::corp_blue = 0x001A;
|
||||
|
||||
static int scaleX(int x) {
|
||||
return (int)(x * DISPLAY_SCALE_X);
|
||||
void NV3001BDisplay::setNativePixels(bool enabled) {
|
||||
nativePixels = enabled;
|
||||
setLogicalSize(enabled ? NV3001B_SCREEN_WIDTH : NV3001B_LOGICAL_WIDTH,
|
||||
enabled ? NV3001B_SCREEN_HEIGHT : NV3001B_LOGICAL_HEIGHT);
|
||||
}
|
||||
|
||||
static int scaleY(int y) {
|
||||
return (int)(y * DISPLAY_SCALE_Y);
|
||||
int NV3001BDisplay::scaleX(int x) const {
|
||||
return nativePixels ? x : (int)(x * DISPLAY_SCALE_X);
|
||||
}
|
||||
|
||||
static int scaleWidth(int x, int w) {
|
||||
int NV3001BDisplay::scaleY(int y) const {
|
||||
return nativePixels ? y : (int)(y * DISPLAY_SCALE_Y);
|
||||
}
|
||||
|
||||
int NV3001BDisplay::scaleWidth(int x, int w) const {
|
||||
if (w <= 0) return 0;
|
||||
int scaled = scaleX(x + w) - scaleX(x);
|
||||
return scaled > 0 ? scaled : 1;
|
||||
}
|
||||
|
||||
static int scaleHeight(int y, int h) {
|
||||
int NV3001BDisplay::scaleHeight(int y, int h) const {
|
||||
if (h <= 0) return 0;
|
||||
int scaled = scaleY(y + h) - scaleY(y);
|
||||
return scaled > 0 ? scaled : 1;
|
||||
@@ -183,7 +189,8 @@ static int textPixelScaleX(uint8_t size) {
|
||||
return size <= 1 ? NV3001B_TEXT_SIZE1_SCALE_X : NV3001B_TEXT_SIZE2_SCALE_X;
|
||||
}
|
||||
|
||||
static int textPixelScaleY(uint8_t size) {
|
||||
int NV3001BDisplay::textPixelScaleY(uint8_t size) const {
|
||||
if (nativePixels) return textPixelScaleX(size); // Square glyph pixels on the native canvas.
|
||||
return size <= 1 ? NV3001B_TEXT_SIZE1_SCALE_Y : NV3001B_TEXT_SIZE2_SCALE_Y;
|
||||
}
|
||||
|
||||
@@ -254,10 +261,26 @@ void NV3001BDisplay::writeColor(uint16_t rgb, uint32_t count) {
|
||||
spi.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, SPI_MODE0));
|
||||
digitalWrite(PIN_TFT_DC, HIGH);
|
||||
digitalWrite(PIN_TFT_CS, LOW);
|
||||
#ifdef NRF52_PLATFORM
|
||||
// EasyDMA needs a RAM buffer. Send repeated pixels in bursts.
|
||||
uint8_t pixels[64];
|
||||
size_t bytes = sizeof(pixels);
|
||||
if (count < bytes / 2) bytes = count * 2;
|
||||
for (size_t i = 0; i < bytes; i += 2) {
|
||||
pixels[i] = hi;
|
||||
pixels[i + 1] = lo;
|
||||
}
|
||||
while (count) {
|
||||
if (count < bytes / 2) bytes = count * 2;
|
||||
spi.transfer(pixels, nullptr, bytes);
|
||||
count -= bytes / 2;
|
||||
}
|
||||
#else
|
||||
while (count--) {
|
||||
spi.transfer(hi);
|
||||
spi.transfer(lo);
|
||||
}
|
||||
#endif
|
||||
digitalWrite(PIN_TFT_CS, HIGH);
|
||||
spi.endTransaction();
|
||||
}
|
||||
@@ -462,6 +485,9 @@ void NV3001BDisplay::turnOff() {
|
||||
if (!is_on) return;
|
||||
|
||||
writeOptionalPin(PIN_TFT_BL, !PIN_TFT_BL_ACTIVE);
|
||||
#ifdef NRF52_PLATFORM
|
||||
spi.end();
|
||||
#endif
|
||||
writeOptionalPin(PIN_TFT_EN, !PIN_TFT_EN_ACTIVE);
|
||||
is_on = false;
|
||||
if (periph_power) periph_power->release();
|
||||
@@ -550,7 +576,8 @@ uint16_t NV3001BDisplay::getTextWidth(const char* str) {
|
||||
|
||||
uint16_t len = 0;
|
||||
while (str[len] && str[len] != '\n' && str[len] != '\r') len++;
|
||||
return (uint16_t)((len * 6 * textPixelScaleX(text_size)) / DISPLAY_SCALE_X);
|
||||
const int pixels = len * 6 * textPixelScaleX(text_size);
|
||||
return nativePixels ? pixels : (uint16_t)(pixels / DISPLAY_SCALE_X);
|
||||
}
|
||||
|
||||
void NV3001BDisplay::endFrame() {
|
||||
|
||||
@@ -34,6 +34,13 @@ class NV3001BDisplay : public DisplayDriver {
|
||||
uint8_t text_size = 1;
|
||||
int cursor_x = 0;
|
||||
int cursor_y = 0;
|
||||
bool nativePixels = false;
|
||||
|
||||
int scaleX(int x) const;
|
||||
int scaleY(int y) const;
|
||||
int scaleWidth(int x, int w) const;
|
||||
int scaleHeight(int y, int h) const;
|
||||
int textPixelScaleY(uint8_t size) const;
|
||||
|
||||
void writeCommand(uint8_t cmd);
|
||||
void writeBytes(const uint8_t* data, size_t len);
|
||||
@@ -59,6 +66,7 @@ public:
|
||||
#endif
|
||||
|
||||
bool begin();
|
||||
void setNativePixels(bool enabled);
|
||||
static const char* driverName() { return "NV3001B"; }
|
||||
static uint16_t physicalWidth() { return NV3001B_PANEL_WIDTH; }
|
||||
static uint16_t physicalHeight() { return NV3001B_PANEL_HEIGHT; }
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "HeltecMeshPocketV2Board.h"
|
||||
#include <nrf_gpio.h>
|
||||
|
||||
void HeltecMeshPocketV2Board::begin() {
|
||||
NRF52Board::begin();
|
||||
powerBank.begin();
|
||||
pinMode(PIN_USER_BTN, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
uint16_t HeltecMeshPocketV2Board::getBattMilliVolts() {
|
||||
const auto& status = powerBank.snapshot();
|
||||
if (status.cw.ready) return status.cw.voltageMv;
|
||||
return status.hltLive() ? status.hlt.batteryMv : 0;
|
||||
}
|
||||
|
||||
void HeltecMeshPocketV2Board::setUsbDataEnabled(bool enabled) {
|
||||
digitalWrite(PIN_IO_CSA, enabled ? HIGH : LOW);
|
||||
}
|
||||
|
||||
bool HeltecMeshPocketV2Board::toggleUsbData() {
|
||||
const bool enabled = !isUsbDataEnabled();
|
||||
setUsbDataEnabled(enabled);
|
||||
return enabled;
|
||||
}
|
||||
|
||||
bool HeltecMeshPocketV2Board::isUsbDataEnabled() const {
|
||||
return digitalRead(PIN_IO_CSA) == HIGH;
|
||||
}
|
||||
|
||||
void HeltecMeshPocketV2Board::shutdownPeripherals() {
|
||||
NRF52Board::shutdownPeripherals();
|
||||
powerBank.end();
|
||||
setUsbDataEnabled(false);
|
||||
nrf_gpio_cfg_sense_input(PIN_USER_BTN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
|
||||
pinMode(PIN_9006_IO1, INPUT_PULLDOWN);
|
||||
// A held-high IO1 must not immediately wake the board from SYSTEM OFF.
|
||||
const auto sense = digitalRead(PIN_9006_IO1) ? NRF_GPIO_PIN_SENSE_LOW : NRF_GPIO_PIN_SENSE_HIGH;
|
||||
nrf_gpio_cfg_sense_input(PIN_9006_IO1, NRF_GPIO_PIN_PULLDOWN, sense);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <helpers/NRF52Board.h>
|
||||
#include "PowerBank.h"
|
||||
|
||||
class HeltecMeshPocketV2Board : public NRF52Board {
|
||||
public:
|
||||
HeltecMeshPocketV2Board() : NRF52Board("MeshPocket_V2_OTA") {}
|
||||
PowerBank powerBank;
|
||||
void begin() override;
|
||||
void loop() override { powerBank.poll(); }
|
||||
uint16_t getBattMilliVolts() override;
|
||||
bool isChargerActive() override { return powerBank.snapshot().hasChargingInput(); }
|
||||
bool toggleUsbData();
|
||||
bool isUsbDataEnabled() const;
|
||||
const char* getManufacturerName() const override { return "Heltec MeshPocket V2"; }
|
||||
void shutdownPeripherals() override;
|
||||
|
||||
private:
|
||||
void setUsbDataEnabled(bool enabled);
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
#include "PowerBank.h"
|
||||
|
||||
namespace {
|
||||
constexpr uint32_t hltPollMs = 100;
|
||||
constexpr uint32_t hltStatusMs = 500;
|
||||
constexpr uint32_t hltStaleMs = 3000;
|
||||
constexpr uint32_t io1WindowMs = 120;
|
||||
constexpr uint32_t gaugeNormalMs = 3000;
|
||||
constexpr uint32_t gaugeFastMs = 500;
|
||||
|
||||
// Only the ISR writes this counter. The main loop consumes a single aligned read.
|
||||
volatile uint32_t io1Pulses = 0;
|
||||
void onIo1Rise() {
|
||||
++io1Pulses;
|
||||
}
|
||||
|
||||
bool stateChanged(const HLT331Serial::Status& before, const HLT331Serial::Status& after) {
|
||||
return !before.valid || before.systemWorking != after.systemWorking ||
|
||||
(after.systemWorking &&
|
||||
(before.charging != after.charging || before.c1State != after.c1State ||
|
||||
before.c2State != after.c2State || before.wirelessWork != after.wirelessWork ||
|
||||
before.wirelessFull != after.wirelessFull));
|
||||
}
|
||||
}
|
||||
|
||||
bool PowerBankSnapshot::hltLive() const {
|
||||
return hlt.valid && hlt.systemWorking && uint32_t(millis() - hlt.lastFrameMs) <= hltStaleMs;
|
||||
}
|
||||
|
||||
bool PowerBankSnapshot::hasChargingInput() const {
|
||||
return hltLive() && (hlt.charging || hlt.c1State == HLT331Serial::PORT_CHARGING ||
|
||||
hlt.c2State == HLT331Serial::PORT_CHARGING);
|
||||
}
|
||||
|
||||
void PowerBank::begin() {
|
||||
gaugeStarted = gauge.begin(Wire);
|
||||
if (gaugeStarted) readGauge();
|
||||
hltStarted = hlt.begin(Serial2, PIN_SERIAL2_RX, PIN_SERIAL2_TX);
|
||||
if (hltStarted) {
|
||||
hlt.configurePins(PIN_CW_INT, PIN_9006_IO1, PIN_9006_IO2, -1);
|
||||
attachInterrupt(digitalPinToInterrupt(PIN_9006_IO1), onIo1Rise, RISING);
|
||||
readHlt();
|
||||
}
|
||||
// Capture the boot sample as a baseline before the UI starts.
|
||||
pageEvent = false;
|
||||
}
|
||||
|
||||
void PowerBank::updateFault(bool& sourceFault, bool active) {
|
||||
const bool wasFault = cwFault || hltFault;
|
||||
sourceFault = active;
|
||||
if (wasFault != (cwFault || hltFault)) {
|
||||
pageEvent = true;
|
||||
fastGaugeReads = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void PowerBank::readGauge() {
|
||||
status.cw.ready = gauge.readStatus(status.cw);
|
||||
lastGauge = millis();
|
||||
if (fastGaugeReads) --fastGaugeReads;
|
||||
if (status.cw.ready) updateFault(cwFault, !status.cw.profile.matches);
|
||||
}
|
||||
|
||||
void PowerBank::readHlt() {
|
||||
const bool valid = hlt.readStatus(status.hlt);
|
||||
lastHlt = millis();
|
||||
if (!valid || status.hlt.ageMs > hltStaleMs) return;
|
||||
|
||||
const auto& sample = status.hlt;
|
||||
if (sample.systemWorking) updateFault(hltFault, sample.ntcOverTemp || sample.wirelessFod);
|
||||
if (stateChanged(previous, sample)) {
|
||||
pageEvent = true;
|
||||
fastGaugeReads = 3;
|
||||
}
|
||||
previous = sample;
|
||||
}
|
||||
|
||||
void PowerBank::poll() {
|
||||
const uint32_t now = millis();
|
||||
if (hltStarted && now - lastPoll >= hltPollMs) {
|
||||
lastPoll = now;
|
||||
hlt.poll();
|
||||
}
|
||||
const uint32_t pulses = io1Pulses;
|
||||
if (pulses != seenPulses) {
|
||||
seenPulses = pulses;
|
||||
drainStarted = now;
|
||||
draining = true;
|
||||
fastGaugeReads = 3;
|
||||
}
|
||||
if (draining && now - drainStarted >= io1WindowMs) {
|
||||
// Collect any bytes received since the regular UART poll.
|
||||
hlt.poll();
|
||||
readHlt();
|
||||
pageEvent = true;
|
||||
draining = false;
|
||||
} else if (hltStarted && !draining && now - lastHlt >= hltStatusMs) {
|
||||
readHlt();
|
||||
}
|
||||
const uint32_t interval = fastGaugeReads ? gaugeFastMs : gaugeNormalMs;
|
||||
if (gaugeStarted && now - lastGauge >= interval) readGauge();
|
||||
}
|
||||
|
||||
bool PowerBank::takePageEvent() {
|
||||
const bool pending = pageEvent;
|
||||
pageEvent = false;
|
||||
return pending;
|
||||
}
|
||||
|
||||
void PowerBank::end() {
|
||||
if (hltStarted) {
|
||||
detachInterrupt(digitalPinToInterrupt(PIN_9006_IO1));
|
||||
Serial2.end();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <CW221X.h>
|
||||
#include <HLT331Serial.h>
|
||||
|
||||
struct PowerBankSnapshot {
|
||||
CW221X::Status cw{};
|
||||
HLT331Serial::Status hlt{};
|
||||
|
||||
bool hltLive() const;
|
||||
bool hasChargingInput() const;
|
||||
};
|
||||
|
||||
class PowerBank {
|
||||
public:
|
||||
void begin();
|
||||
void poll();
|
||||
void end();
|
||||
const PowerBankSnapshot& snapshot() const { return status; }
|
||||
bool takePageEvent();
|
||||
|
||||
private:
|
||||
void readGauge();
|
||||
void readHlt();
|
||||
void updateFault(bool& sourceFault, bool active);
|
||||
|
||||
CW221X gauge;
|
||||
HLT331Serial hlt;
|
||||
PowerBankSnapshot status;
|
||||
HLT331Serial::Status previous{};
|
||||
bool gaugeStarted = false;
|
||||
bool hltStarted = false;
|
||||
bool cwFault = false;
|
||||
bool hltFault = false;
|
||||
bool pageEvent = false;
|
||||
bool draining = false;
|
||||
uint8_t fastGaugeReads = 0;
|
||||
uint32_t seenPulses = 0;
|
||||
uint32_t drainStarted = 0;
|
||||
uint32_t lastPoll = 0;
|
||||
uint32_t lastHlt = 0;
|
||||
uint32_t lastGauge = 0;
|
||||
};
|
||||
@@ -0,0 +1,334 @@
|
||||
#include "PowerBankPage.h"
|
||||
#include "PowerBank.h"
|
||||
|
||||
namespace {
|
||||
constexpr ColorVal background = 0x0063;
|
||||
constexpr ColorVal blue = 0x653d;
|
||||
constexpr ColorVal purple = 0x611f;
|
||||
constexpr ColorVal card = 0xdefc;
|
||||
constexpr ColorVal dark = 0x31c8;
|
||||
constexpr ColorVal white = 0xffff;
|
||||
constexpr ColorVal green = 0x06ae;
|
||||
constexpr ColorVal gold = 0xff0e;
|
||||
constexpr ColorVal red = 0xfa69;
|
||||
constexpr ColorVal off = 0x3a6b;
|
||||
constexpr ColorVal well = 0x1127, shine = 0x47d5, track = 0x94b8;
|
||||
constexpr ColorVal badgeFace = 0xffbf, tempFace = 0xf776, tempInk = 0xa465;
|
||||
constexpr ColorVal divider = 0x9515, lightDivider = 0xd71e, boltInk = 0x93ba;
|
||||
constexpr int temperatureCenterX = 134;
|
||||
|
||||
void label(DisplayDriver& d, int x, int y, const char* value, ColorVal ink, int size = 1) {
|
||||
d.setColor(ink);
|
||||
d.setTextSize(size);
|
||||
d.setCursor(x, y);
|
||||
d.print(value);
|
||||
}
|
||||
|
||||
void panel(DisplayDriver& d, int x, int y, int w, int h, ColorVal color, int r = 6) {
|
||||
d.setColor(color);
|
||||
if (h > 2 * r) d.fillRect(x, y + r, w, h - 2 * r);
|
||||
int span = 0;
|
||||
for (int row = 0; row < r; ++row) {
|
||||
int dy = r - row;
|
||||
while ((span + 1) * (span + 1) + dy * dy <= r * (r + 1)) ++span;
|
||||
int inset = r - span;
|
||||
d.fillRect(x + inset, y + row, w - 2 * inset, 1);
|
||||
d.fillRect(x + inset, y + h - 1 - row, w - 2 * inset, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void drawPortCard(DisplayDriver& d, int x, const char* name) {
|
||||
panel(d, x, 72, 70, 54, card);
|
||||
label(d, x + 5, 78, name, dark, 2);
|
||||
d.setColor(divider);
|
||||
d.fillRect(x + 5, 97, 60, 1);
|
||||
}
|
||||
|
||||
void drawUsbConnector(DisplayDriver& d, int x, ColorVal ink) {
|
||||
panel(d, x + 33, 82, 25, 10, ink, 4);
|
||||
panel(d, x + 34, 83, 23, 8, card, 3);
|
||||
d.setColor(ink);
|
||||
d.fillRect(x + 38, 87, 15, 1);
|
||||
}
|
||||
|
||||
void drawUsbCard(DisplayDriver& d, int x, const char* name) {
|
||||
drawPortCard(d, x, name);
|
||||
drawUsbConnector(d, x, dark);
|
||||
}
|
||||
|
||||
void drawLayout(DisplayDriver& d) {
|
||||
d.startFrame(background);
|
||||
panel(d, 2, 2, 164, 66, blue);
|
||||
label(d, 8, 10, "Battery", white);
|
||||
panel(d, 89, 23, 4, 9, white, 1);
|
||||
panel(d, 49, 16, 40, 23, white, 4);
|
||||
panel(d, 50, 17, 38, 21, well, 3);
|
||||
d.setColor(white);
|
||||
d.fillRect(8, 50, 85, 8);
|
||||
d.setColor(track);
|
||||
d.fillRect(9, 51, 83, 6);
|
||||
d.setColor(white);
|
||||
for (int i = 1; i < 10; ++i) d.fillRect(9 + i * 83 / 10, 51, 1, 6);
|
||||
d.setColor(lightDivider);
|
||||
d.fillRect(8, 44, 85, 1);
|
||||
d.fillRect(101, 9, 1, 51);
|
||||
panel(d, temperatureCenterX - 11, 13, 23, 23, badgeFace, 11);
|
||||
panel(d, temperatureCenterX - 8, 16, 17, 17, tempFace, 8);
|
||||
label(d, temperatureCenterX - 2, 21, "T", tempInk);
|
||||
panel(d, 169, 2, 49, 66, purple);
|
||||
panel(d, 182, 13, 23, 23, badgeFace, 11);
|
||||
drawUsbCard(d, 2, "C1");
|
||||
drawUsbCard(d, 75, "C2");
|
||||
drawPortCard(d, 148, "Qi2");
|
||||
label(d, 154, 103, "FOD:", dark);
|
||||
}
|
||||
|
||||
bool connected(uint8_t port) {
|
||||
return port == HLT331Serial::PORT_CHARGING || port == HLT331Serial::PORT_DISCHARGING;
|
||||
}
|
||||
|
||||
// Write only the changed span inside each segment, skipping the white dividers.
|
||||
void updateBar(DisplayDriver& d, int x, int y, int w, int h, int before, int after,
|
||||
ColorVal filled, ColorVal empty, int segments = 1) {
|
||||
int oldWidth = before > 0 ? (w * before + 50) / 100 : 0;
|
||||
int newWidth = after > 0 ? (w * after + 50) / 100 : 0;
|
||||
if (oldWidth == newWidth) return;
|
||||
d.setColor(newWidth > oldWidth ? filled : empty);
|
||||
for (int i = 0; i < segments; ++i) {
|
||||
int left = max(min(oldWidth, newWidth), i * w / segments + (i != 0));
|
||||
int right = min(max(oldWidth, newWidth), (i + 1) * w / segments);
|
||||
if (left < right) d.fillRect(x + left, y, right - left, h);
|
||||
}
|
||||
}
|
||||
|
||||
void clearField(DisplayDriver& d, int x, int y, int w, int h, ColorVal color) {
|
||||
d.setColor(color);
|
||||
d.fillRect(x, y, w, h);
|
||||
}
|
||||
|
||||
void drawTemperature(DisplayDriver& d, const char* value) {
|
||||
const bool hasPoint = strchr(value, '.') != nullptr;
|
||||
const int glyphs = strlen(value) - hasPoint;
|
||||
const int size = glyphs <= 3 ? 2 : 1; // Leave room for the unit on longer readings.
|
||||
const int advance = 5 * size + 1;
|
||||
const int width = glyphs * advance + (hasPoint ? 3 : 0);
|
||||
int x = temperatureCenterX - (width - 1) / 2;
|
||||
|
||||
clearField(d, 102, 43, 64, 14, blue);
|
||||
d.setColor(white);
|
||||
d.setTextSize(size);
|
||||
for (const char* p = value; *p; ++p) {
|
||||
if (*p == '.') {
|
||||
d.fillRect(x, 55, 2, 2);
|
||||
x += 3;
|
||||
} else {
|
||||
char glyph[] = {*p, '\0'};
|
||||
d.setCursor(x, 57 - 7 * size);
|
||||
d.print(glyph);
|
||||
x += advance;
|
||||
}
|
||||
}
|
||||
d.drawRect(x + 1, 49, 3, 3);
|
||||
label(d, x + 5, 50, "C", white);
|
||||
}
|
||||
|
||||
void drawPowerRays(DisplayDriver& d, ColorVal ink) {
|
||||
d.setColor(ink);
|
||||
d.fillRect(193, 7, 1, 4);
|
||||
d.fillRect(193, 38, 1, 4);
|
||||
d.fillRect(176, 24, 4, 1);
|
||||
d.fillRect(207, 24, 4, 1);
|
||||
for (int offset = 10; offset <= 12; ++offset) {
|
||||
d.fillRect(193 - offset, 24 - offset, 1, 1);
|
||||
d.fillRect(193 + offset, 24 - offset, 1, 1);
|
||||
d.fillRect(193 - offset, 24 + offset, 1, 1);
|
||||
d.fillRect(193 + offset, 24 + offset, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void drawWatts(DisplayDriver& d, int32_t wattsX10) {
|
||||
char value[16] = "--";
|
||||
if (wattsX10 >= 0) {
|
||||
snprintf(value, sizeof(value), "%ld.%ld", long(wattsX10 / 10), long(wattsX10 % 10));
|
||||
}
|
||||
clearField(d, 170, 43, 47, 14, purple);
|
||||
if (wattsX10 >= 1000) { // Three integer digits only fit in the small font.
|
||||
d.setTextSize(1);
|
||||
int digits = d.getTextWidth(value);
|
||||
int x = 193 - (digits + 7) / 2;
|
||||
label(d, x, 50, value, white);
|
||||
label(d, x + digits + 1, 50, "W", white);
|
||||
return;
|
||||
}
|
||||
// Budget 11 pixels per digit, 3 for the decimal point and 7 for the unit.
|
||||
int width = 7;
|
||||
for (const char* p = value; *p; ++p) width += (*p == '.') ? 3 : 11;
|
||||
int x = 193 - width / 2;
|
||||
d.setColor(white);
|
||||
d.setTextSize(2);
|
||||
for (const char* p = value; *p; ++p) {
|
||||
if (*p == '.') {
|
||||
d.fillRect(x, 55, 2, 2);
|
||||
x += 3;
|
||||
} else {
|
||||
char digit[] = {*p, '\0'};
|
||||
d.setCursor(x, 43);
|
||||
d.print(digit);
|
||||
x += 11;
|
||||
}
|
||||
}
|
||||
label(d, x + 1, 50, "W", white);
|
||||
}
|
||||
}
|
||||
|
||||
void PowerBankPage::drawUsb(DisplayDriver& d, int x, UsbPort& last, uint8_t state, uint8_t mode, bool shared, bool force) {
|
||||
if (!painted || force || state != last.state) {
|
||||
const char* name = "--";
|
||||
ColorVal badge = off;
|
||||
switch (state) {
|
||||
case HLT331Serial::PORT_NOT_CONNECTED: name = "OFF"; break;
|
||||
case HLT331Serial::PORT_CHARGING: name = "CHG"; badge = green; break;
|
||||
case HLT331Serial::PORT_DISCHARGING: name = "DCHG"; badge = gold; break;
|
||||
}
|
||||
clearField(d, x + 5, 102, 60, 10, card);
|
||||
panel(d, x + 6, 102, 28, 10, badge, 5);
|
||||
d.setTextSize(1);
|
||||
label(d, x + 21 - d.getTextWidth(name) / 2, 104, name, badge == off ? white : dark);
|
||||
last.state = state;
|
||||
}
|
||||
char protocol[sizeof(last.protocol)] = "";
|
||||
if (connected(state) && mode != HLT331Serial::FAST_CHARGE_NONE) {
|
||||
snprintf(protocol, sizeof(protocol), "%s%s", HLT331Serial::fastChargeName(mode), shared ? "*" : "");
|
||||
}
|
||||
if (!painted || force || strcmp(last.protocol, protocol) != 0) {
|
||||
clearField(d, x + 6, 116, 63, 7, card);
|
||||
label(d, x + 6, 116, protocol, dark);
|
||||
strcpy(last.protocol, protocol);
|
||||
}
|
||||
}
|
||||
|
||||
void PowerBankPage::drawUsbDataMode(DisplayDriver& d, int x) {
|
||||
drawUsbConnector(d, x, blue);
|
||||
|
||||
clearField(d, x + 5, 102, 60, 10, card);
|
||||
panel(d, x + 21, 102, 28, 10, blue, 5);
|
||||
d.setTextSize(1);
|
||||
const char* badge = "USB";
|
||||
label(d, x + 35 - d.getTextWidth(badge) / 2, 104, badge, white);
|
||||
|
||||
clearField(d, x + 6, 116, 63, 7, card);
|
||||
const char* blocked = "CHG/DCHG";
|
||||
const int width = d.getTextWidth(blocked);
|
||||
const int textX = x + 35 - width / 2;
|
||||
label(d, textX, 116, blocked, dark);
|
||||
d.setColor(red);
|
||||
const int dischargeX = textX + d.getTextWidth("CHG/");
|
||||
d.fillRect(dischargeX, 119, d.getTextWidth("DCHG"), 1);
|
||||
}
|
||||
|
||||
void PowerBankPage::drawBattery(DisplayDriver& d, const PowerBankSnapshot& status) {
|
||||
const auto& cw = status.cw;
|
||||
const int nextPercent = cw.ready ? min(100, int(cw.socPercent)) : -1;
|
||||
char value[16];
|
||||
if (!painted || percent != nextPercent) {
|
||||
if (nextPercent < 0) strcpy(value, "--");
|
||||
else snprintf(value, sizeof(value), "%d", nextPercent);
|
||||
clearField(d, 8, 25, 41, 14, blue);
|
||||
label(d, 8, 25, value, white, 2);
|
||||
label(d, min(43, 10 + d.getTextWidth(value)), 31, "%", white);
|
||||
int before = painted ? percent : 0;
|
||||
updateBar(d, 52, 19, 34, 7, before, nextPercent, shine, well);
|
||||
updateBar(d, 52, 26, 34, 10, before, nextPercent, green, well);
|
||||
updateBar(d, 9, 51, 83, 6, before, nextPercent, green, track, 10);
|
||||
percent = nextPercent;
|
||||
}
|
||||
const int32_t nextTemp = cw.ready ? cw.temperatureX10C : INT32_MIN;
|
||||
if (!painted || nextTemp != temperature) {
|
||||
if (!cw.ready) strcpy(value, "--");
|
||||
else {
|
||||
const int temp = cw.temperatureX10C;
|
||||
snprintf(value, sizeof(value), "%s%d.%d", temp < 0 ? "-" : "", abs(temp) / 10, abs(temp) % 10);
|
||||
}
|
||||
drawTemperature(d, value);
|
||||
temperature = nextTemp;
|
||||
}
|
||||
}
|
||||
|
||||
void PowerBankPage::drawPower(DisplayDriver& d, const PowerBankSnapshot& status, bool live) {
|
||||
const auto& hlt = status.hlt;
|
||||
const bool active = live && (hlt.charging || connected(hlt.c1State) || connected(hlt.c2State) || hlt.wirelessWork);
|
||||
if (!painted || active != boltActive) {
|
||||
static const uint8_t bolt[] = {0x0c, 0x18, 0x30, 0x7e, 0x0c, 0x18, 0x30};
|
||||
drawPowerRays(d, active ? badgeFace : purple);
|
||||
d.setColor(active ? dark : boltInk);
|
||||
d.drawXbm(190, 21, bolt, 8, 7);
|
||||
boltActive = active;
|
||||
}
|
||||
const int32_t nextWatts = live ? int32_t(uint32_t(hlt.busMv) * hlt.busMa / 100000) : -1;
|
||||
if (!painted || nextWatts != wattsX10) {
|
||||
drawWatts(d, nextWatts);
|
||||
wattsX10 = nextWatts;
|
||||
}
|
||||
}
|
||||
|
||||
void PowerBankPage::drawWireless(DisplayDriver& d, const PowerBankSnapshot& status, bool live) {
|
||||
const auto& hlt = status.hlt;
|
||||
const char* state = "--";
|
||||
if (live) {
|
||||
if (hlt.wirelessFod) state = "FOD!";
|
||||
else state = hlt.wirelessWork ? "ON" : "OFF";
|
||||
}
|
||||
if (!painted || strcmp(state, qiState) != 0) {
|
||||
const bool fault = live && hlt.wirelessFod;
|
||||
const bool on = live && hlt.wirelessWork;
|
||||
ColorVal fill = fault ? red : off;
|
||||
if (on && !fault) fill = green;
|
||||
panel(d, 188, 82, 28, 11, fill, 5);
|
||||
if (fault) {
|
||||
label(d, 190, 84, state, dark);
|
||||
} else {
|
||||
panel(d, on ? 207 : 190, 84, 7, 7, white, 3);
|
||||
label(d, on ? 191 : 197, 84, state, on ? dark : white);
|
||||
}
|
||||
qiState = state;
|
||||
}
|
||||
const int nextFod = live ? int(hlt.wirelessFod) : -1;
|
||||
if (!painted || nextFod != fod) {
|
||||
ColorVal fill = off;
|
||||
if (live) fill = hlt.wirelessFod ? red : gold;
|
||||
panel(d, 182, 102, 13, 10, fill, 4);
|
||||
const char* value = "--";
|
||||
if (live) value = hlt.wirelessFod ? "1" : "0";
|
||||
label(d, live ? 186 : 183, 104, value, live ? dark : white);
|
||||
fod = nextFod;
|
||||
}
|
||||
const char* protocol = "";
|
||||
if (live && hlt.wirelessWork && hlt.wirelessProtocol != HLT331Serial::WIRELESS_NULL) {
|
||||
protocol = HLT331Serial::wirelessProtocolName(hlt.wirelessProtocol);
|
||||
}
|
||||
if (!painted || strcmp(protocol, qiProtocol) != 0) {
|
||||
clearField(d, 154, 116, 63, 7, card);
|
||||
label(d, 154, 116, protocol, dark);
|
||||
snprintf(qiProtocol, sizeof(qiProtocol), "%s", protocol);
|
||||
}
|
||||
}
|
||||
|
||||
void PowerBankPage::draw(DisplayDriver& d, const PowerBankSnapshot& status, bool usbDataEnabled) {
|
||||
if (!painted) drawLayout(d);
|
||||
const auto& hlt = status.hlt;
|
||||
const bool live = status.hltLive();
|
||||
const bool shared = !usbDataEnabled && connected(hlt.c1State) && connected(hlt.c2State);
|
||||
const bool usbModeChanged = !painted || usbDataMode != usbDataEnabled;
|
||||
drawBattery(d, status);
|
||||
drawPower(d, status, live);
|
||||
drawUsb(d, 2, c1, live ? hlt.c1State : HLT331Serial::PORT_RESERVED, hlt.fastCharge, shared);
|
||||
if (usbDataEnabled) {
|
||||
if (usbModeChanged) drawUsbDataMode(d, 75);
|
||||
} else {
|
||||
if (usbModeChanged) drawUsbConnector(d, 75, dark);
|
||||
drawUsb(d, 75, c2, live ? hlt.c2State : HLT331Serial::PORT_RESERVED, hlt.fastCharge, shared, usbModeChanged);
|
||||
}
|
||||
drawWireless(d, status, live);
|
||||
usbDataMode = usbDataEnabled;
|
||||
painted = true;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <helpers/ui/DisplayDriver.h>
|
||||
|
||||
struct PowerBankSnapshot;
|
||||
|
||||
class PowerBankPage {
|
||||
public:
|
||||
void invalidate() { painted = false; }
|
||||
void draw(DisplayDriver& display, const PowerBankSnapshot& status, bool usbDataEnabled);
|
||||
|
||||
private:
|
||||
struct UsbPort {
|
||||
uint8_t state = 0;
|
||||
char protocol[16]{};
|
||||
};
|
||||
|
||||
void drawBattery(DisplayDriver& d, const PowerBankSnapshot& status);
|
||||
void drawPower(DisplayDriver& d, const PowerBankSnapshot& status, bool live);
|
||||
void drawUsb(DisplayDriver& d, int x, UsbPort& last, uint8_t state, uint8_t mode, bool shared, bool force = false);
|
||||
void drawUsbDataMode(DisplayDriver& d, int x);
|
||||
void drawWireless(DisplayDriver& d, const PowerBankSnapshot& status, bool live);
|
||||
|
||||
bool painted = false;
|
||||
int percent = -1;
|
||||
int32_t temperature = 0;
|
||||
int32_t wattsX10 = -1;
|
||||
bool boltActive = false;
|
||||
bool usbDataMode = false;
|
||||
UsbPort c1, c2;
|
||||
const char* qiState = "";
|
||||
int fod = -1;
|
||||
char qiProtocol[16]{};
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "PowerBankUi.h"
|
||||
#include "HeltecMeshPocketV2Board.h"
|
||||
#include <helpers/ui/NV3001BDisplay.h>
|
||||
|
||||
PowerBankUi::PowerBankUi(HeltecMeshPocketV2Board& board)
|
||||
: board(board), secondaryButton(PIN_BUTTON2, 1000, true, true, false) {}
|
||||
|
||||
void PowerBankUi::begin() {
|
||||
secondaryButton.begin();
|
||||
}
|
||||
|
||||
uint8_t PowerBankUi::pollEvents() {
|
||||
uint8_t events = 0;
|
||||
const int buttonEvent = secondaryButton.check();
|
||||
if (buttonEvent == BUTTON_EVENT_CLICK) events |= EVENT_SHOW_PAGE;
|
||||
#ifdef MESHPOCKET_V2_USB_SWITCHABLE
|
||||
if (buttonEvent == BUTTON_EVENT_LONG_PRESS) events |= EVENT_PAGE_ACTION;
|
||||
#endif
|
||||
if (board.powerBank.takePageEvent()) events |= EVENT_REQUEST_FOCUS;
|
||||
return events;
|
||||
}
|
||||
|
||||
void PowerBankUi::handlePageAction() {
|
||||
#ifdef MESHPOCKET_V2_USB_SWITCHABLE
|
||||
board.toggleUsbData();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t PowerBankUi::render(NV3001BDisplay& display, bool fullRefresh) {
|
||||
if (fullRefresh) page.invalidate();
|
||||
display.setNativePixels(true);
|
||||
page.draw(display, board.powerBank.snapshot(), board.isUsbDataEnabled());
|
||||
display.setNativePixels(false);
|
||||
return 500;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#include "PowerBankPage.h"
|
||||
|
||||
class HeltecMeshPocketV2Board;
|
||||
class NV3001BDisplay;
|
||||
|
||||
class PowerBankUi {
|
||||
HeltecMeshPocketV2Board& board;
|
||||
PowerBankPage page;
|
||||
MomentaryButton secondaryButton;
|
||||
|
||||
public:
|
||||
enum Event : uint8_t {
|
||||
EVENT_SHOW_PAGE = 1 << 0,
|
||||
EVENT_PAGE_ACTION = 1 << 1,
|
||||
EVENT_REQUEST_FOCUS = 1 << 2,
|
||||
};
|
||||
|
||||
explicit PowerBankUi(HeltecMeshPocketV2Board& board);
|
||||
void begin();
|
||||
uint8_t pollEvents();
|
||||
void handlePageAction();
|
||||
uint32_t render(NV3001BDisplay& display, bool fullRefresh);
|
||||
};
|
||||
@@ -0,0 +1,87 @@
|
||||
[heltec_meshpocket_v2]
|
||||
extends = nrf52_base
|
||||
board = heltec_meshpocket_v2
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I variants/heltec_meshpocket_v2
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
-D HELTEC_MESH_POCKET_V2
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D DISPLAY_CLASS=NV3001BDisplay
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<../variants/heltec_meshpocket_v2/*.cpp>
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
+<helpers/ui/NV3001BDisplay.cpp>
|
||||
lib_deps = ${nrf52_base.lib_deps}
|
||||
https://github.com/Quency-D/heltec-meshpocket-v2-power/releases/download/v0.2.0/HeltecMeshPocketV2Power-0.2.0.zip
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
bakercp/CRC32 @ ^2.0.0
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[heltec_meshpocket_v2_companion]
|
||||
extends = heltec_meshpocket_v2
|
||||
build_flags = ${heltec_meshpocket_v2.build_flags}
|
||||
-I variants/heltec_meshpocket_v2/ui-companion
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
build_src_filter = ${heltec_meshpocket_v2.build_src_filter}
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../variants/heltec_meshpocket_v2/ui-companion/*.cpp>
|
||||
lib_deps = ${heltec_meshpocket_v2.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:heltec_meshpocket_v2_companion_radio_ble]
|
||||
extends = heltec_meshpocket_v2_companion
|
||||
build_flags = ${heltec_meshpocket_v2_companion.build_flags}
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${heltec_meshpocket_v2_companion.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
|
||||
[env:heltec_meshpocket_v2_companion_radio_usb]
|
||||
extends = heltec_meshpocket_v2_companion
|
||||
build_flags = ${heltec_meshpocket_v2_companion.build_flags}
|
||||
-D ENABLE_USB_INTERFACE
|
||||
-D MESHPOCKET_V2_USB_SWITCHABLE
|
||||
|
||||
[heltec_meshpocket_v2_server]
|
||||
extends = heltec_meshpocket_v2
|
||||
build_flags = ${heltec_meshpocket_v2.build_flags}
|
||||
-I variants/heltec_meshpocket_v2/ui-server
|
||||
-D MESHPOCKET_V2_USB_SWITCHABLE
|
||||
build_src_filter = ${heltec_meshpocket_v2.build_src_filter}
|
||||
+<helpers/ui/BaseUITask.cpp>
|
||||
+<../variants/heltec_meshpocket_v2/ui-server/*.cpp>
|
||||
|
||||
[env:heltec_meshpocket_v2_repeater]
|
||||
extends = heltec_meshpocket_v2_server
|
||||
build_flags = ${heltec_meshpocket_v2_server.build_flags}
|
||||
-D ADVERT_NAME='"MeshPocket V2 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=50
|
||||
build_src_filter = ${heltec_meshpocket_v2_server.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
|
||||
[env:heltec_meshpocket_v2_room_server]
|
||||
extends = heltec_meshpocket_v2_server
|
||||
build_flags = ${heltec_meshpocket_v2_server.build_flags}
|
||||
-D MESHPOCKET_V2_ROOM_SERVER
|
||||
-D ADVERT_NAME='"MeshPocket V2 Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
build_src_filter = ${heltec_meshpocket_v2_server.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "target.h"
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
HeltecMeshPocketV2Board board;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
VolatileRTCClock rtc_clock;
|
||||
NmeaGpsDriver gps_driver(Serial1);
|
||||
MicroNMEALocationProvider gps(gps_driver, &rtc_clock);
|
||||
EnvironmentSensorManager sensors(gps);
|
||||
DISPLAY_CLASS display(&SPI1);
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true);
|
||||
|
||||
bool radio_init() {
|
||||
return radio.std_init(&SPI);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#include <helpers/ui/NV3001BDisplay.h>
|
||||
#include <UITask.h>
|
||||
#include "HeltecMeshPocketV2Board.h"
|
||||
|
||||
extern HeltecMeshPocketV2Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
extern UITask ui_task;
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,145 @@
|
||||
// Based on src/helpers/ui/companion-new/UITask.h at 88bbae29.
|
||||
#pragma once
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <helpers/ui/DisplayDriver.h>
|
||||
#include <helpers/ui/UIScreen.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/BaseChatMesh.h>
|
||||
#include <helpers/MultiSerialInterface.h>
|
||||
#include <Arduino.h>
|
||||
#include <helpers/sensors/LPPDataHelpers.h>
|
||||
|
||||
#ifndef LED_STATE_ON
|
||||
#define LED_STATE_ON 1
|
||||
#endif
|
||||
|
||||
#ifdef PIN_BUZZER
|
||||
#include <helpers/ui/buzzer.h>
|
||||
#endif
|
||||
#ifdef PIN_VIBRATION
|
||||
#include <helpers/ui/GenericVibration.h>
|
||||
#endif
|
||||
|
||||
#include <helpers/ui/AbstractUITask.h>
|
||||
#include <helpers/CompanionNodePrefs.h>
|
||||
#include "HeltecMeshPocketV2Board.h"
|
||||
#include "PowerBankUi.h"
|
||||
|
||||
#ifdef UI_NO_DISCOVER_SCREEN
|
||||
#error "UI_NO_DISCOVER_SCREEN is obsolete - use -D UI_DISCOVER_SCREEN=0 instead"
|
||||
#endif
|
||||
|
||||
#ifndef UI_DISCOVER_SCREEN
|
||||
#define UI_DISCOVER_SCREEN 1
|
||||
#endif
|
||||
|
||||
#if UI_DISCOVER_SCREEN
|
||||
#ifdef UI_RECENT_LIST_SIZE
|
||||
#define DISCOVERED_NODES_TABLE_SIZE UI_RECENT_LIST_SIZE
|
||||
#else
|
||||
#define DISCOVERED_NODES_TABLE_SIZE 4
|
||||
#endif
|
||||
|
||||
struct DiscoveredNode {
|
||||
float snr_in;
|
||||
float snr_out;
|
||||
uint8_t pubkey_prefix[9];
|
||||
uint8_t type;
|
||||
char name[32];
|
||||
};
|
||||
#endif
|
||||
|
||||
class UITask : public AbstractUITask {
|
||||
PowerBankUi powerUi;
|
||||
DisplayDriver* _display;
|
||||
SensorManager* _sensors;
|
||||
BaseChatMesh* the_mesh;
|
||||
uint32_t _ble_pin;
|
||||
#ifdef PIN_BUZZER
|
||||
genericBuzzer buzzer;
|
||||
#endif
|
||||
#ifdef PIN_VIBRATION
|
||||
GenericVibration vibration;
|
||||
#endif
|
||||
unsigned long _next_refresh, _auto_off;
|
||||
NodePrefs* _node_prefs;
|
||||
char _alert[80];
|
||||
unsigned long _alert_expiry;
|
||||
int _msgcount;
|
||||
unsigned long ui_started_at, next_batt_chck;
|
||||
unsigned long next_backlight_btn_check = 0;
|
||||
unsigned long _backlight_off = 0;
|
||||
#ifdef PIN_STATUS_LED
|
||||
int led_state = 0;
|
||||
int next_led_change = 0;
|
||||
int last_led_increment = 0;
|
||||
#endif
|
||||
|
||||
#ifdef PIN_USER_BTN_ANA
|
||||
unsigned long _analogue_pin_read_millis = millis();
|
||||
#endif
|
||||
|
||||
UIScreen* splash;
|
||||
UIScreen* home;
|
||||
UIScreen* msg_preview;
|
||||
UIScreen* curr;
|
||||
bool powerPageHadAlert = false;
|
||||
|
||||
void userLedHandler();
|
||||
|
||||
// Button action handlers
|
||||
char checkDisplayOn(char c);
|
||||
char handleLongPress(char c);
|
||||
char handleDoubleClick(char c);
|
||||
char handleTripleClick(char c);
|
||||
|
||||
void setCurrScreen(UIScreen* c);
|
||||
void handlePowerPageFocus(uint8_t events, bool handlingInput);
|
||||
|
||||
public:
|
||||
|
||||
UITask(HeltecMeshPocketV2Board& board, DisplayDriver* display = NULL) :
|
||||
AbstractUITask(&board), powerUi(board), _display(display), _sensors(NULL) {
|
||||
next_batt_chck = _next_refresh = 0;
|
||||
ui_started_at = 0;
|
||||
curr = NULL;
|
||||
}
|
||||
void begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* node_prefs, MultiSerialInterface* serial,
|
||||
BaseChatMesh* mesh, uint32_t ble_pin, const char* ver, const char* build_date);
|
||||
|
||||
void gotoHomeScreen() { setCurrScreen(home); }
|
||||
void showAlert(const char* text, int duration_millis);
|
||||
int getMsgCount() const { return _msgcount; }
|
||||
bool hasDisplay() const { return _display != NULL; }
|
||||
bool isButtonPressed() const;
|
||||
|
||||
BaseChatMesh* getMesh() const { return the_mesh; }
|
||||
uint32_t getBLEPin() const { return _ble_pin; }
|
||||
|
||||
bool isBuzzerQuiet() {
|
||||
#ifdef PIN_BUZZER
|
||||
return buzzer.isQuiet();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void toggleBuzzer();
|
||||
bool getGPSState();
|
||||
void toggleGPS();
|
||||
void triggerGPS();
|
||||
|
||||
// MeshEventListener
|
||||
void onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, const char* text) override;
|
||||
void onChannelMessageRecv(mesh::Packet *pkt, ChannelDetails& channel_details, const char* text) override;
|
||||
void onQueueSizeChanged(int offline_queue_size) override;
|
||||
void onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) override;
|
||||
void onControlDataRecv(const mesh::Packet* pkt) override;
|
||||
|
||||
// from AbstractUITask
|
||||
void notify(UIEventType t = UIEventType::none) override;
|
||||
void loop() override;
|
||||
|
||||
void shutdown(bool restart = false);
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "target.h"
|
||||
|
||||
UITask ui_task(board);
|
||||
@@ -0,0 +1,206 @@
|
||||
// Based on src/helpers/ui/server/UITask.cpp at upstream 88bbae29.
|
||||
#include "UITask.h"
|
||||
#include "target.h"
|
||||
#include <Arduino.h>
|
||||
#include <helpers/CommonCLI.h>
|
||||
|
||||
#ifndef USER_BTN_PRESSED
|
||||
#define USER_BTN_PRESSED LOW
|
||||
#endif
|
||||
|
||||
#define AUTO_OFF_MILLIS 20000 // 20 seconds
|
||||
#define BOOT_SCREEN_MILLIS 4000 // 4 seconds
|
||||
|
||||
#define POWEROFF_DELAY 3000
|
||||
|
||||
// 'meshcore', 128x13px
|
||||
static const uint8_t meshcore_logo [] PROGMEM = {
|
||||
0x3c, 0x01, 0xe3, 0xff, 0xc7, 0xff, 0x8f, 0x03, 0x87, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe,
|
||||
0x3c, 0x03, 0xe3, 0xff, 0xc7, 0xff, 0x8e, 0x03, 0x8f, 0xfe, 0x3f, 0xfe, 0x1f, 0xff, 0x1f, 0xfe,
|
||||
0x3e, 0x03, 0xc3, 0xff, 0x8f, 0xff, 0x0e, 0x07, 0x8f, 0xfe, 0x7f, 0xfe, 0x1f, 0xff, 0x1f, 0xfc,
|
||||
0x3e, 0x07, 0xc7, 0x80, 0x0e, 0x00, 0x0e, 0x07, 0x9e, 0x00, 0x78, 0x0e, 0x3c, 0x0f, 0x1c, 0x00,
|
||||
0x3e, 0x0f, 0xc7, 0x80, 0x1e, 0x00, 0x0e, 0x07, 0x1e, 0x00, 0x70, 0x0e, 0x38, 0x0f, 0x3c, 0x00,
|
||||
0x7f, 0x0f, 0xc7, 0xfe, 0x1f, 0xfc, 0x1f, 0xff, 0x1c, 0x00, 0x70, 0x0e, 0x38, 0x0e, 0x3f, 0xf8,
|
||||
0x7f, 0x1f, 0xc7, 0xfe, 0x0f, 0xff, 0x1f, 0xff, 0x1c, 0x00, 0xf0, 0x0e, 0x38, 0x0e, 0x3f, 0xf8,
|
||||
0x7f, 0x3f, 0xc7, 0xfe, 0x0f, 0xff, 0x1f, 0xff, 0x1c, 0x00, 0xf0, 0x1e, 0x3f, 0xfe, 0x3f, 0xf0,
|
||||
0x77, 0x3b, 0x87, 0x00, 0x00, 0x07, 0x1c, 0x0f, 0x3c, 0x00, 0xe0, 0x1c, 0x7f, 0xfc, 0x38, 0x00,
|
||||
0x77, 0xfb, 0x8f, 0x00, 0x00, 0x07, 0x1c, 0x0f, 0x3c, 0x00, 0xe0, 0x1c, 0x7f, 0xf8, 0x38, 0x00,
|
||||
0x73, 0xf3, 0x8f, 0xff, 0x0f, 0xff, 0x1c, 0x0e, 0x3f, 0xf8, 0xff, 0xfc, 0x70, 0x78, 0x7f, 0xf8,
|
||||
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfe, 0x3c, 0x0e, 0x3f, 0xf8, 0xff, 0xfc, 0x70, 0x3c, 0x7f, 0xf8,
|
||||
0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8,
|
||||
};
|
||||
|
||||
void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version, const char* role_lbl) {
|
||||
powerUi.begin();
|
||||
#ifdef MESHPOCKET_V2_ROOM_SERVER
|
||||
_prevBtnState = HIGH;
|
||||
_started_at = 0; // The Room Server's splash starts at power-on.
|
||||
#else
|
||||
_started_at = millis();
|
||||
#endif
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS;
|
||||
_node_prefs = node_prefs;
|
||||
_display->turnOn();
|
||||
|
||||
#ifndef MESHPOCKET_V2_ROOM_SERVER
|
||||
user_btn.begin();
|
||||
#endif
|
||||
|
||||
// strip off dash and commit hash by changing dash to null terminator
|
||||
// e.g: v1.2.3-abcdef -> v1.2.3
|
||||
char *version = strdup(firmware_version);
|
||||
char *dash = strchr(version, '-');
|
||||
if (dash){
|
||||
*dash = 0;
|
||||
}
|
||||
|
||||
// v1.2.3 (1 Jan 2025)
|
||||
snprintf(_version_info, sizeof(_version_info), "%s (%s)", version, build_date);
|
||||
free(version);
|
||||
|
||||
_role_label = role_lbl;
|
||||
}
|
||||
|
||||
long UITask::renderCurrScreen() {
|
||||
if (!_powering_off_at && _power_page_selected) {
|
||||
const long interval = powerUi.render(::display, _power_page_full_refresh);
|
||||
_power_page_full_refresh = false;
|
||||
return interval;
|
||||
}
|
||||
_display->startFrame();
|
||||
char tmp[80];
|
||||
if (millis() < _started_at + BOOT_SCREEN_MILLIS) { // boot screen
|
||||
// meshcore logo
|
||||
_display->setColor(UIColor::corp_blue);
|
||||
int logoWidth = 128;
|
||||
_display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
|
||||
|
||||
// meshcore website
|
||||
const char* website = "https://meshcore.io";
|
||||
_display->setColor(UIColor::primary_txt);
|
||||
_display->setTextSize(1);
|
||||
_display->drawTextCentered(_display->width() / 2, 22, website);
|
||||
|
||||
// version info
|
||||
_display->setTextSize(1);
|
||||
_display->drawTextCentered(_display->width() / 2, 35, _version_info);
|
||||
|
||||
// node type
|
||||
_display->drawTextCentered(_display->width() / 2, 48, _role_label);
|
||||
} else if (_powering_off_at > 0) {
|
||||
// meshcore logo
|
||||
_display->setColor(UIColor::corp_blue);
|
||||
int logoWidth = 128;
|
||||
_display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13);
|
||||
|
||||
// meshcore website
|
||||
const char* website = "https://meshcore.io";
|
||||
_display->setColor(UIColor::primary_txt);
|
||||
_display->setTextSize(1);
|
||||
_display->drawTextCentered(_display->width()/ 2, 22, website);
|
||||
|
||||
// Powering off
|
||||
const char* poweroff_string = "Turning OFF";
|
||||
uint16_t poffWidth = _display->getTextWidth(poweroff_string);
|
||||
_display->setCursor((_display->width() - poffWidth) / 2, 48);
|
||||
_display->drawTextCentered(_display->width()/2, 48, poweroff_string);
|
||||
} else {
|
||||
_display->setCursor(0, 0);
|
||||
_display->setTextSize(1);
|
||||
_display->setColor(UIColor::primary_txt);
|
||||
_display->print(_node_prefs->node_name);
|
||||
|
||||
// freq / sf
|
||||
_display->setCursor(0, 20);
|
||||
sprintf(tmp, "FREQ: %06.3f SF%d", _node_prefs->freq, _node_prefs->sf);
|
||||
_display->print(tmp);
|
||||
|
||||
// bw / cr
|
||||
_display->setCursor(0, 30);
|
||||
sprintf(tmp, "BW: %03.2f CR: %d", _node_prefs->bw, _node_prefs->cr);
|
||||
_display->print(tmp);
|
||||
}
|
||||
return 1000; // 1 sec interval
|
||||
}
|
||||
|
||||
int UITask::readPrimaryButton() {
|
||||
#ifdef MESHPOCKET_V2_ROOM_SERVER
|
||||
if (millis() < _next_read) return BUTTON_EVENT_NONE;
|
||||
const int state = digitalRead(PIN_USER_BTN);
|
||||
const bool pressed = state == USER_BTN_PRESSED && state != _prevBtnState;
|
||||
_prevBtnState = state;
|
||||
_next_read = millis() + 200;
|
||||
return pressed ? BUTTON_EVENT_CLICK : BUTTON_EVENT_NONE;
|
||||
#else
|
||||
return user_btn.check();
|
||||
#endif
|
||||
}
|
||||
|
||||
void UITask::showPowerPage() {
|
||||
if (!_display->isOn()) _display->turnOn();
|
||||
if (!_power_page_selected) _power_page_full_refresh = true;
|
||||
_power_page_selected = true;
|
||||
_next_refresh = 0;
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS;
|
||||
}
|
||||
|
||||
void UITask::loop() {
|
||||
if (!_display->isOn()) _power_page_full_refresh = true;
|
||||
const uint8_t events = powerUi.pollEvents();
|
||||
const bool canChangePage = !_powering_off_at && millis() - _started_at >= BOOT_SCREEN_MILLIS;
|
||||
bool handlingInput = false;
|
||||
if (canChangePage && (events & PowerBankUi::EVENT_SHOW_PAGE)) {
|
||||
showPowerPage();
|
||||
handlingInput = true;
|
||||
} else if (canChangePage && (events & PowerBankUi::EVENT_PAGE_ACTION) &&
|
||||
_display->isOn() && _power_page_selected) {
|
||||
powerUi.handlePageAction();
|
||||
_next_refresh = 0;
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS;
|
||||
handlingInput = true;
|
||||
}
|
||||
|
||||
const int ev = readPrimaryButton();
|
||||
handlingInput = handlingInput || ev != BUTTON_EVENT_NONE;
|
||||
if (ev == BUTTON_EVENT_CLICK) {
|
||||
if (!_display->isOn()) {
|
||||
_display->turnOn();
|
||||
} else if (canChangePage) {
|
||||
_power_page_selected = !_power_page_selected;
|
||||
_power_page_full_refresh = true;
|
||||
_next_refresh = 0;
|
||||
}
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS;
|
||||
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
||||
_display->turnOn();
|
||||
Serial.println("Powering Off");
|
||||
_powering_off_at = millis() + POWEROFF_DELAY;
|
||||
_next_refresh = 0;
|
||||
_auto_off = millis() + AUTO_OFF_MILLIS;
|
||||
}
|
||||
|
||||
const bool canTakePowerEvent = !_powering_off_at && millis() - _started_at >= BOOT_SCREEN_MILLIS;
|
||||
if (!handlingInput && canTakePowerEvent && (events & PowerBankUi::EVENT_REQUEST_FOCUS)) {
|
||||
showPowerPage();
|
||||
}
|
||||
|
||||
if (_display->isOn()) {
|
||||
if (millis() >= _next_refresh) {
|
||||
const long interval = renderCurrScreen();
|
||||
_display->endFrame();
|
||||
_next_refresh = millis() + interval;
|
||||
}
|
||||
if (millis() > _auto_off) _display->turnOff();
|
||||
}
|
||||
|
||||
if (_powering_off_at > 0) { // power off timer armed
|
||||
#if defined(LED_PIN) && defined(LED_STATE_ON)
|
||||
digitalWrite(LED_PIN, LED_STATE_ON); // switch on the led until poweroff
|
||||
delay(1000);
|
||||
digitalWrite(LED_PIN, !LED_STATE_ON); // off LED
|
||||
#endif
|
||||
if (millis() > _powering_off_at) {
|
||||
_board->powerOff(); // should not return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Based on src/helpers/ui/server/UITask.h at upstream 88bbae29.
|
||||
#pragma once
|
||||
|
||||
#include <helpers/ui/BaseUITask.h>
|
||||
#include <helpers/CommonCLI.h>
|
||||
#include "HeltecMeshPocketV2Board.h"
|
||||
#include "PowerBankUi.h"
|
||||
|
||||
class UITask : public BaseUITask {
|
||||
PowerBankUi powerUi;
|
||||
bool _power_page_selected = false;
|
||||
bool _power_page_full_refresh = true;
|
||||
#ifdef MESHPOCKET_V2_ROOM_SERVER
|
||||
unsigned long _next_read = 0;
|
||||
int _prevBtnState;
|
||||
#endif
|
||||
NodePrefs* _node_prefs;
|
||||
char _version_info[32];
|
||||
const char* _role_label;
|
||||
unsigned long _powering_off_at = 0;
|
||||
unsigned long _started_at = 0;
|
||||
|
||||
int readPrimaryButton();
|
||||
void showPowerPage();
|
||||
|
||||
protected:
|
||||
long renderCurrScreen() override;
|
||||
|
||||
public:
|
||||
UITask(HeltecMeshPocketV2Board& board, DisplayDriver* display) : BaseUITask(&board, display), powerUi(board) {}
|
||||
void begin(NodePrefs* node_prefs, const char* build_date, const char* firmware_version, const char* role_lbl);
|
||||
|
||||
void loop() override;
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "target.h"
|
||||
|
||||
UITask ui_task(board, &display);
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
const uint32_t g_ADigitalPinMap[] = {
|
||||
0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
|
||||
};
|
||||
|
||||
void initVariant() {
|
||||
// Preload the output latch before driving the USB data switch.
|
||||
digitalWrite(PIN_IO_CSA, LOW);
|
||||
pinMode(PIN_IO_CSA, OUTPUT);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
#define USE_LFXO
|
||||
#define VARIANT_MCK 64000000ul
|
||||
#define PINS_COUNT 48
|
||||
#define NUM_DIGITAL_PINS 48
|
||||
#define NUM_ANALOG_INPUTS 0
|
||||
#define NUM_ANALOG_OUTPUTS 0
|
||||
#define PIN_LED1 (-1)
|
||||
#define LED_BUILTIN PIN_LED1
|
||||
#define LED_BLUE (-1)
|
||||
#define LED_GREEN (-1)
|
||||
#define LED_STATE_ON 1
|
||||
#define PIN_USER_BTN 43
|
||||
#define PIN_BUTTON2 42
|
||||
|
||||
#define WIRE_INTERFACES_COUNT 1
|
||||
#define PIN_WIRE_SDA 13
|
||||
#define PIN_WIRE_SCL 5
|
||||
#define PIN_CW_INT 12
|
||||
#define PIN_IO_CSA 20
|
||||
#define PIN_9006_IO1 4
|
||||
#define PIN_9006_IO2 41
|
||||
#define PIN_SERIAL2_RX 26
|
||||
#define PIN_SERIAL2_TX 15
|
||||
|
||||
// EnvironmentSensorManager names the UART pins from the GPS module's side.
|
||||
#define PIN_GPS_TX 34
|
||||
#define PIN_GPS_RX 36
|
||||
#define PIN_SERIAL1_RX PIN_GPS_TX
|
||||
#define PIN_SERIAL1_TX PIN_GPS_RX
|
||||
#define PIN_GPS_EN 22
|
||||
#define PIN_GPS_EN_ACTIVE LOW
|
||||
#define PIN_GPS_RESET 38
|
||||
#define PIN_GPS_RESET_ACTIVE LOW
|
||||
#define PIN_GPS_PPS 10
|
||||
#define GPS_BAUD_RATE 115200
|
||||
|
||||
#define SPI_INTERFACES_COUNT 2
|
||||
#define PIN_SPI_MISO 2
|
||||
#define PIN_SPI_MOSI 47
|
||||
#define PIN_SPI_SCK 45
|
||||
#define P_LORA_MISO PIN_SPI_MISO
|
||||
#define P_LORA_MOSI PIN_SPI_MOSI
|
||||
#define P_LORA_SCLK PIN_SPI_SCK
|
||||
#define P_LORA_NSS 14
|
||||
#define P_LORA_DIO_1 31
|
||||
#define P_LORA_BUSY 29
|
||||
#define P_LORA_RESET 11
|
||||
#define SX126X_DIO2_AS_RF_SWITCH true
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8f
|
||||
|
||||
#define PIN_SPI1_MISO 3
|
||||
#define PIN_SPI1_MOSI 39
|
||||
#define PIN_SPI1_SCK 33
|
||||
#define PIN_TFT_SDA PIN_SPI1_MOSI
|
||||
#define PIN_TFT_SCL PIN_SPI1_SCK
|
||||
#define PIN_TFT_CS 16
|
||||
#define PIN_TFT_DC 32
|
||||
#define PIN_TFT_RST 24
|
||||
#define PIN_TFT_EN 9
|
||||
#define PIN_TFT_EN_ACTIVE LOW
|
||||
#define PIN_TFT_BL 25
|
||||
#define PIN_TFT_BL_ACTIVE HIGH
|
||||
#define SPI_FREQUENCY 8000000
|
||||
#define DISPLAY_ROTATION 3 // NV3001B MADCTL MX | MV
|
||||
Reference in new issue
Block a user