Skip to content

Commit 0963341

Browse files
author
Scott Powell
committed
Merge branch 'dev'
2 parents 54fd704 + 483b316 commit 0963341

File tree

18 files changed

+333
-82
lines changed

18 files changed

+333
-82
lines changed

examples/companion_radio/MyMesh.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,10 +613,10 @@ void MyMesh::begin(bool has_display) {
613613
_prefs.cr = constrain(_prefs.cr, 5, 8);
614614
_prefs.tx_power_dbm = constrain(_prefs.tx_power_dbm, 1, MAX_LORA_TX_POWER);
615615

616-
#ifdef BLE_PIN_CODE
616+
#ifdef BLE_PIN_CODE // 123456 by default
617617
if (_prefs.ble_pin == 0) {
618618
#ifdef DISPLAY_CLASS
619-
if (has_display) {
619+
if (has_display && BLE_PIN_CODE == 123456) {
620620
StdRNG rng;
621621
_active_ble_pin = rng.nextInt(100000, 999999); // random pin each session
622622
} else {

examples/companion_radio/MyMesh.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
#define FIRMWARE_VER_CODE 6
1111

1212
#ifndef FIRMWARE_BUILD_DATE
13-
#define FIRMWARE_BUILD_DATE "29 Jun 2025"
13+
#define FIRMWARE_BUILD_DATE "2 Jul 2025"
1414
#endif
1515

1616
#ifndef FIRMWARE_VERSION
17-
#define FIRMWARE_VERSION "v1.7.1"
17+
#define FIRMWARE_VERSION "v1.7.2"
1818
#endif
1919

2020
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)

examples/simple_repeater/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
/* ------------------------------ Config -------------------------------- */
2323

2424
#ifndef FIRMWARE_BUILD_DATE
25-
#define FIRMWARE_BUILD_DATE "29 Jun 2025"
25+
#define FIRMWARE_BUILD_DATE "2 Jul 2025"
2626
#endif
2727

2828
#ifndef FIRMWARE_VERSION
29-
#define FIRMWARE_VERSION "v1.7.1"
29+
#define FIRMWARE_VERSION "v1.7.2"
3030
#endif
3131

3232
#ifndef LORA_FREQ

examples/simple_room_server/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
/* ------------------------------ Config -------------------------------- */
2323

2424
#ifndef FIRMWARE_BUILD_DATE
25-
#define FIRMWARE_BUILD_DATE "29 Jun 2025"
25+
#define FIRMWARE_BUILD_DATE "2 Jul 2025"
2626
#endif
2727

2828
#ifndef FIRMWARE_VERSION
29-
#define FIRMWARE_VERSION "v1.7.1"
29+
#define FIRMWARE_VERSION "v1.7.2"
3030
#endif
3131

3232
#ifndef LORA_FREQ

src/Mesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
135135
int k = 0;
136136
uint8_t path_len = data[k++];
137137
uint8_t* path = &data[k]; k += path_len;
138-
uint8_t extra_type = data[k++];
138+
uint8_t extra_type = data[k++] & 0x0F; // upper 4 bits reserved for future use
139139
uint8_t* extra = &data[k];
140140
uint8_t extra_len = len - k; // remainder of packet (may be padded with zeroes!)
141141
if (onPeerPathRecv(pkt, j, secret, path, path_len, extra_type, extra, extra_len)) {

src/helpers/CustomLR1110Wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CustomLR1110Wrapper : public RadioLibWrapper {
1717

1818
void onSendFinished() override {
1919
RadioLibWrapper::onSendFinished();
20-
_radio->setPreambleLength(8); // overcomes weird issues with small and big pkts
20+
_radio->setPreambleLength(16); // overcomes weird issues with small and big pkts
2121
}
2222

2323
float getLastRSSI() const override { return ((CustomLR1110 *)_radio)->getRSSI(); }

src/helpers/HeltecV3Board.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <helpers/RefCountedDigitalPin.h>
55

66
// LoRa radio module pins for Heltec V3
7-
// Also for Heltec Wireless Tracker
7+
// Also for Heltec Wireless Tracker/Paper
88
#define P_LORA_DIO_1 14
99
#define P_LORA_NSS 8
1010
#define P_LORA_RESET RADIOLIB_NC
@@ -14,7 +14,9 @@
1414
#define P_LORA_MOSI 10
1515

1616
// built-ins
17-
#define PIN_VBAT_READ 1
17+
#ifndef PIN_VBAT_READ // set in platformio.ini for boards like Heltec Wireless Paper (20)
18+
#define PIN_VBAT_READ 1
19+
#endif
1820
#ifndef PIN_ADC_CTRL // set in platformio.ini for Heltec Wireless Tracker (2)
1921
#define PIN_ADC_CTRL 37
2022
#endif

src/helpers/ui/E213Display.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#include "E213Display.h"
2+
3+
#include "../../MeshCore.h"
4+
5+
bool E213Display::begin() {
6+
if (_init) return true;
7+
8+
powerOn();
9+
display.begin();
10+
11+
// Set to landscape mode rotated 180 degrees
12+
display.setRotation(3);
13+
14+
_init = true;
15+
_isOn = true;
16+
17+
clear();
18+
display.fastmodeOn(); // Enable fast mode for quicker (partial) updates
19+
20+
return true;
21+
}
22+
23+
void E213Display::powerOn() {
24+
#ifdef PIN_VEXT_EN
25+
pinMode(PIN_VEXT_EN, OUTPUT);
26+
digitalWrite(PIN_VEXT_EN, LOW); // Active low
27+
delay(50); // Allow power to stabilize
28+
#endif
29+
}
30+
31+
void E213Display::powerOff() {
32+
#ifdef PIN_VEXT_EN
33+
digitalWrite(PIN_VEXT_EN, HIGH); // Turn off power
34+
#endif
35+
}
36+
37+
void E213Display::turnOn() {
38+
if (!_init) begin();
39+
powerOn();
40+
_isOn = true;
41+
}
42+
43+
void E213Display::turnOff() {
44+
powerOff();
45+
_isOn = false;
46+
}
47+
48+
void E213Display::clear() {
49+
display.clear();
50+
}
51+
52+
void E213Display::startFrame(Color bkg) {
53+
// Fill screen with white first to ensure clean background
54+
display.fillRect(0, 0, width(), height(), WHITE);
55+
if (bkg == LIGHT) {
56+
// Fill with black if light background requested (inverted for e-ink)
57+
display.fillRect(0, 0, width(), height(), BLACK);
58+
}
59+
}
60+
61+
void E213Display::setTextSize(int sz) {
62+
// The library handles text size internally
63+
display.setTextSize(sz);
64+
}
65+
66+
void E213Display::setColor(Color c) {
67+
// implemented in individual display methods
68+
}
69+
70+
void E213Display::setCursor(int x, int y) {
71+
display.setCursor(x, y);
72+
}
73+
74+
void E213Display::print(const char *str) {
75+
display.print(str);
76+
}
77+
78+
void E213Display::fillRect(int x, int y, int w, int h) {
79+
display.fillRect(x, y, w, h, BLACK);
80+
}
81+
82+
void E213Display::drawRect(int x, int y, int w, int h) {
83+
display.drawRect(x, y, w, h, BLACK);
84+
}
85+
86+
void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
87+
// Width in bytes for bitmap processing
88+
uint16_t widthInBytes = (w + 7) / 8;
89+
90+
// Process the bitmap row by row
91+
for (int by = 0; by < h; by++) {
92+
// Scan across the row bit by bit
93+
for (int bx = 0; bx < w; bx++) {
94+
// Get the current bit using MSB ordering (like GxEPDDisplay)
95+
uint16_t byteOffset = (by * widthInBytes) + (bx / 8);
96+
uint8_t bitMask = 0x80 >> (bx & 7);
97+
bool bitSet = bits[byteOffset] & bitMask;
98+
99+
// If the bit is set, draw the pixel
100+
if (bitSet) {
101+
display.drawPixel(x + bx, y + by, BLACK);
102+
}
103+
}
104+
}
105+
}
106+
107+
uint16_t E213Display::getTextWidth(const char *str) {
108+
int16_t x1, y1;
109+
uint16_t w, h;
110+
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
111+
return w;
112+
}
113+
114+
void E213Display::endFrame() {
115+
display.update();
116+
}

src/helpers/ui/E213Display.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#pragma once
2+
3+
#include "DisplayDriver.h"
4+
5+
#include <SPI.h>
6+
#include <Wire.h>
7+
#include <heltec-eink-modules.h>
8+
9+
// Display driver for E213 e-ink display
10+
class E213Display : public DisplayDriver {
11+
EInkDisplay_VisionMasterE213 display;
12+
bool _init = false;
13+
bool _isOn = false;
14+
15+
public:
16+
E213Display() : DisplayDriver(250, 122) {}
17+
18+
bool begin();
19+
bool isOn() override { return _isOn; }
20+
void turnOn() override;
21+
void turnOff() override;
22+
void clear() override;
23+
void startFrame(Color bkg = DARK) override;
24+
void setTextSize(int sz) override;
25+
void setColor(Color c) override;
26+
void setCursor(int x, int y) override;
27+
void print(const char *str) override;
28+
void fillRect(int x, int y, int w, int h) override;
29+
void drawRect(int x, int y, int w, int h) override;
30+
void drawXbm(int x, int y, const uint8_t *bits, int w, int h) override;
31+
uint16_t getTextWidth(const char *str) override;
32+
void endFrame() override;
33+
34+
private:
35+
void powerOn();
36+
void powerOff();
37+
};

variants/heltec_tracker/target.cpp

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,16 @@ HWTSensorManager sensors = HWTSensorManager(nmea);
2323
DISPLAY_CLASS display(&board.periph_power); // peripheral power pin is shared
2424
#endif
2525

26-
#ifndef LORA_CR
27-
#define LORA_CR 5
28-
#endif
29-
3026
bool radio_init() {
3127
fallback_clock.begin();
3228
rtc_clock.begin(Wire);
3329

34-
#ifdef SX126X_DIO3_TCXO_VOLTAGE
35-
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
36-
#else
37-
float tcxo = 1.6f;
38-
#endif
39-
4030
#if defined(P_LORA_SCLK)
41-
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
42-
#endif
43-
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
44-
if (status != RADIOLIB_ERR_NONE) {
45-
Serial.print("ERROR: radio init failed: ");
46-
Serial.println(status);
47-
return false; // fail
48-
}
49-
50-
radio.setCRC(1);
51-
52-
#ifdef SX126X_CURRENT_LIMIT
53-
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
54-
#endif
55-
#ifdef SX126X_DIO2_AS_RF_SWITCH
56-
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
57-
#endif
58-
#ifdef SX126X_RX_BOOSTED_GAIN
59-
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
31+
return radio.std_init(&spi);
32+
#else
33+
return radio.std_init();
6034
#endif
6135

62-
return true; // success
6336
}
6437

6538
uint32_t radio_get_rng_seed() {

0 commit comments

Comments
 (0)