mirror of
https://github.com/pelgraine/Meck.git
synced 2026-08-06 08:42:48 +02:00
T-Watch target.cpp: fixed preamble = (sf <= 8) ? 32 : 16 to (sf <= 9) which I should have done in the first place to match meshcore PR 1954. Testing on Watch before applying wider change.
T-Watch: So many UI changes. Also swapped render battery indicator to use the AXP2101 gauge for hopefully higher accuracy. Also implemnted meck rx duty cycle for watch builds only to test out power saving effects first on watch build before implementing elsewhere.
This commit is contained in:
@@ -86,6 +86,7 @@ void Dispatcher::loop() {
|
||||
rx_stuck_count = 0; // radio recovered — reset counter
|
||||
}
|
||||
}
|
||||
#if !defined(MECK_RX_DUTY_CYCLE)
|
||||
if (!is_recv && _ms->getMillis() - radio_nonrx_start > 8000) { // radio has not been in Rx mode for 8 seconds!
|
||||
_err_flags |= ERR_EVENT_STARTRX_TIMEOUT;
|
||||
|
||||
@@ -105,6 +106,7 @@ void Dispatcher::loop() {
|
||||
cad_busy_start = 0;
|
||||
next_agc_reset_time = futureMillis(getAGCResetInterval());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (outbound) { // waiting for outbound send to be completed
|
||||
if (_radio->isSendComplete()) {
|
||||
@@ -152,10 +154,12 @@ void Dispatcher::loop() {
|
||||
next_agc_reset_time = futureMillis(getAGCResetInterval());
|
||||
}
|
||||
|
||||
#if !defined(MECK_RX_DUTY_CYCLE)
|
||||
if (getAGCResetInterval() > 0 && millisHasNowPassed(next_agc_reset_time)) {
|
||||
_radio->resetAGC();
|
||||
next_agc_reset_time = futureMillis(getAGCResetInterval());
|
||||
}
|
||||
#endif
|
||||
|
||||
// check inbound (delayed) queue
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include "RadioLibWrappers.h"
|
||||
|
||||
@@ -63,6 +62,11 @@ void RadioLibWrapper::resetAGC() {
|
||||
}
|
||||
|
||||
void RadioLibWrapper::loop() {
|
||||
#if defined(MECK_RX_DUTY_CYCLE)
|
||||
// Duty-cycle RX sleeps the radio between listen windows, so RSSI floor
|
||||
// sampling would read garbage. Skip it; the noise floor keeps its default.
|
||||
return;
|
||||
#endif
|
||||
if (state == STATE_RX && _num_floor_samples < NUM_NOISE_FLOOR_SAMPLES) {
|
||||
if (!isReceivingPacket()) {
|
||||
int rssi = getCurrentRSSI();
|
||||
@@ -83,7 +87,14 @@ void RadioLibWrapper::loop() {
|
||||
}
|
||||
|
||||
void RadioLibWrapper::startRecv() {
|
||||
#if defined(MECK_RX_DUTY_CYCLE)
|
||||
// Watch: SX126x hardware RX duty cycling. senderPreambleLength 0 = use the
|
||||
// configured preamble; minSymbols 0 = library minimum. At preambles too
|
||||
// short to sleep, RadioLib falls back to continuous startReceive() itself.
|
||||
int err = ((SX126x*)_radio)->startReceiveDutyCycleAuto(0, 0);
|
||||
#else
|
||||
int err = _radio->startReceive();
|
||||
#endif
|
||||
if (err == RADIOLIB_ERR_NONE) {
|
||||
state = STATE_RX;
|
||||
} else {
|
||||
@@ -114,7 +125,11 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
|
||||
}
|
||||
|
||||
if (state != STATE_RX) {
|
||||
#if defined(MECK_RX_DUTY_CYCLE)
|
||||
int err = ((SX126x*)_radio)->startReceiveDutyCycleAuto(0, 0);
|
||||
#else
|
||||
int err = _radio->startReceive();
|
||||
#endif
|
||||
if (err == RADIOLIB_ERR_NONE) {
|
||||
state = STATE_RX;
|
||||
} else {
|
||||
@@ -188,4 +203,4 @@ float RadioLibWrapper::packetScoreInt(float snr, int sf, int packet_len) {
|
||||
auto collision_penalty = 1 - (packet_len / 256.0); // Assuming max packet of 256 bytes
|
||||
|
||||
return max(0.0, min(1.0, success_rate_based_on_snr * collision_penalty));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ bool LGFXDisplay::begin() {
|
||||
turnOn();
|
||||
display->init();
|
||||
display->setRotation(1);
|
||||
display->setBrightness(54);
|
||||
display->setBrightness(30);
|
||||
display->setColorDepth(8);
|
||||
display->setTextColor(TFT_WHITE);
|
||||
|
||||
|
||||
@@ -59,6 +59,19 @@ public:
|
||||
// ticker turns wrap off so a long scrolling line is clipped at the screen
|
||||
// edge instead of wrapping onto the rows below.
|
||||
void setTextWrap(bool en) { buffer.setTextWrap(en, false); }
|
||||
// Draw a string centred horizontally at mid_x with its top at y, in
|
||||
// FreeSansBold 24pt (used for the clock HH:MM), then restore the default
|
||||
// GLCD font + size so later text is unaffected.
|
||||
void printClockFont(int mid_x, int y, const char* str) {
|
||||
buffer.setFont(&fonts::FreeSansBold24pt7b);
|
||||
buffer.setTextColor(_color);
|
||||
buffer.setTextSize(1);
|
||||
int w = buffer.textWidth(str);
|
||||
buffer.setCursor(mid_x - w / 2, y);
|
||||
buffer.print(str);
|
||||
buffer.setFont(&fonts::Font0); // restore default 6x8 GLCD font
|
||||
buffer.setTextSize(1);
|
||||
}
|
||||
#endif
|
||||
void setCursor(int x, int y) override;
|
||||
void print(const char* str) override;
|
||||
|
||||
Reference in New Issue
Block a user