Browse Source

0.8.79

* fix `opendtufusion` build (started only once USB-console was connected)
* code quality improvments
pull/1433/head
lumapu 11 months ago
parent
commit
315541ea51
  1. 56
      patches/GxEPD2_SW_SPI.patch
  2. 4
      src/CHANGES.md
  3. 2
      src/defines.h
  4. 2
      src/hm/hmRadio.h
  5. 12
      src/platformio.ini

56
patches/GxEPD2_SW_SPI.patch

@ -1,5 +1,5 @@
diff --git a/src/GxEPD2_EPD.cpp b/src/GxEPD2_EPD.cpp diff --git a/src/GxEPD2_EPD.cpp b/src/GxEPD2_EPD.cpp
index 40b1b13..d0dbdba 100644 index 8df8bef..91d7f49 100644
--- a/src/GxEPD2_EPD.cpp --- a/src/GxEPD2_EPD.cpp
+++ b/src/GxEPD2_EPD.cpp +++ b/src/GxEPD2_EPD.cpp
@@ -19,9 +19,9 @@ @@ -19,9 +19,9 @@
@ -14,25 +14,29 @@ index 40b1b13..d0dbdba 100644
{ {
_initial_write = true; _initial_write = true;
_initial_refresh = true; _initial_refresh = true;
@@ -61,7 +61,6 @@ void GxEPD2_EPD::init(uint32_t serial_diag_bitrate, bool initial, uint16_t reset @@ -71,27 +71,30 @@ void GxEPD2_EPD::init(uint32_t serial_diag_bitrate, bool initial, uint16_t reset
digitalWrite(_cs, HIGH); // set (needed e.g. for RP2040)
}
_reset();
- _pSPIx->begin(); // may steal _rst pin (Waveshare Pico-ePaper-2.9)
if (_rst >= 0)
{
digitalWrite(_rst, HIGH); // preset (less glitch for any analyzer)
@@ -84,14 +83,30 @@ void GxEPD2_EPD::init(uint32_t serial_diag_bitrate, bool initial, uint16_t reset
{ {
pinMode(_busy, INPUT); pinMode(_busy, INPUT);
} }
- _pSPIx->begin();
- if (_busy == MISO) // may be overridden
- {
- pinMode(_busy, INPUT);
- }
- if (_dc == MISO) // may be overridden, TTGO T5 V2.66
- {
- pinMode(_dc, OUTPUT);
- }
- if (_cs == MISO) // may be overridden
+ if (_sck < 0) SPI.begin(); + if (_sck < 0) SPI.begin();
+} +}
+ +
+void GxEPD2_EPD::init(int16_t sck, int16_t mosi, uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration, bool pulldown_rst_mode) +void GxEPD2_EPD::init(int16_t sck, int16_t mosi, uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration, bool pulldown_rst_mode)
+{ +{
+ if ((sck >= 0) && (mosi >= 0)) + if ((sck >= 0) && (mosi >= 0))
+ { {
- pinMode(_cs, INPUT);
- }
+ _sck = sck; + _sck = sck;
+ _mosi = mosi; + _mosi = mosi;
+ digitalWrite(_sck, LOW); + digitalWrite(_sck, LOW);
@ -54,7 +58,7 @@ index 40b1b13..d0dbdba 100644
} }
void GxEPD2_EPD::setBusyCallback(void (*busyCallback)(const void*), const void* busy_callback_parameter) void GxEPD2_EPD::setBusyCallback(void (*busyCallback)(const void*), const void* busy_callback_parameter)
@@ -100,12 +115,6 @@ void GxEPD2_EPD::setBusyCallback(void (*busyCallback)(const void*), const void* @@ -100,12 +103,6 @@ void GxEPD2_EPD::setBusyCallback(void (*busyCallback)(const void*), const void*
_busy_callback_parameter = busy_callback_parameter; _busy_callback_parameter = busy_callback_parameter;
} }
@ -67,7 +71,7 @@ index 40b1b13..d0dbdba 100644
void GxEPD2_EPD::_reset() void GxEPD2_EPD::_reset()
{ {
if (_rst >= 0) if (_rst >= 0)
@@ -174,115 +183,201 @@ void GxEPD2_EPD::_waitWhileBusy(const char* comment, uint16_t busy_time) @@ -174,115 +171,201 @@ void GxEPD2_EPD::_waitWhileBusy(const char* comment, uint16_t busy_time)
void GxEPD2_EPD::_writeCommand(uint8_t c) void GxEPD2_EPD::_writeCommand(uint8_t c)
{ {
@ -300,10 +304,21 @@ index 40b1b13..d0dbdba 100644
+ _endTransaction(); + _endTransaction();
} }
diff --git a/src/GxEPD2_EPD.h b/src/GxEPD2_EPD.h diff --git a/src/GxEPD2_EPD.h b/src/GxEPD2_EPD.h
index 3daf37e..96198c2 100644 index 34c1145..c480b7d 100644
--- a/src/GxEPD2_EPD.h --- a/src/GxEPD2_EPD.h
+++ b/src/GxEPD2_EPD.h +++ b/src/GxEPD2_EPD.h
@@ -35,6 +35,7 @@ class GxEPD2_EPD @@ -8,6 +8,10 @@
// Version: see library.properties
//
// Library: https://github.com/ZinggJM/GxEPD2
+// To use SW SPI with GxEPD2:
+// add the special call to the added init method BEFORE the normal init method:
+// display.epd2.init(SW_SCK, SW_MOSI, 115200, true, 20, false); // define or replace SW_SCK, SW_MOSI
+// display.init(115200); // needed to init upper level
#ifndef _GxEPD2_EPD_H_
#define _GxEPD2_EPD_H_
@@ -35,6 +39,7 @@ class GxEPD2_EPD
uint16_t w, uint16_t h, GxEPD2::Panel p, bool c, bool pu, bool fpu); uint16_t w, uint16_t h, GxEPD2::Panel p, bool c, bool pu, bool fpu);
virtual void init(uint32_t serial_diag_bitrate = 0); // serial_diag_bitrate = 0 : disabled virtual void init(uint32_t serial_diag_bitrate = 0); // serial_diag_bitrate = 0 : disabled
virtual void init(uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration = 10, bool pulldown_rst_mode = false); virtual void init(uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration = 10, bool pulldown_rst_mode = false);
@ -311,7 +326,7 @@ index 3daf37e..96198c2 100644
virtual void end(); // release SPI and control pins virtual void end(); // release SPI and control pins
// Support for Bitmaps (Sprites) to Controller Buffer and to Screen // Support for Bitmaps (Sprites) to Controller Buffer and to Screen
virtual void clearScreen(uint8_t value) = 0; // init controller memory and screen (default white) virtual void clearScreen(uint8_t value) = 0; // init controller memory and screen (default white)
@@ -97,7 +98,6 @@ class GxEPD2_EPD @@ -97,7 +102,6 @@ class GxEPD2_EPD
{ {
return (a > b ? a : b); return (a > b ? a : b);
}; };
@ -319,7 +334,7 @@ index 3daf37e..96198c2 100644
protected: protected:
void _reset(); void _reset();
void _waitWhileBusy(const char* comment = 0, uint16_t busy_time = 5000); void _waitWhileBusy(const char* comment = 0, uint16_t busy_time = 5000);
@@ -111,8 +111,14 @@ class GxEPD2_EPD @@ -111,17 +115,22 @@ class GxEPD2_EPD
void _startTransfer(); void _startTransfer();
void _transfer(uint8_t value); void _transfer(uint8_t value);
void _endTransfer(); void _endTransfer();
@ -331,11 +346,12 @@ index 3daf37e..96198c2 100644
+ void _readData(uint8_t* data, uint16_t n); + void _readData(uint8_t* data, uint16_t n);
protected: protected:
- int16_t _cs, _dc, _rst, _busy, _busy_level; - int16_t _cs, _dc, _rst, _busy, _busy_level;
+ int16_t _cs, _dc, _rst, _busy, _busy_level, _sck, _mosi; + int16_t _cs, _dc, _rst, _busy, _busy_level, _sck, _mosi;;
uint32_t _busy_timeout; uint32_t _busy_timeout;
bool _diag_enabled, _pulldown_rst_mode; bool _diag_enabled, _pulldown_rst_mode;
SPIClass* _pSPIx; - SPIClass* _pSPIx;
@@ -121,7 +127,7 @@ class GxEPD2_EPD SPISettings _spi_settings;
bool _initial_write, _initial_refresh;
bool _power_is_on, _using_partial_mode, _hibernating; bool _power_is_on, _using_partial_mode, _hibernating;
bool _init_display_done; bool _init_display_done;
uint16_t _reset_duration; uint16_t _reset_duration;

4
src/CHANGES.md

@ -1,5 +1,9 @@
# Development Changes # Development Changes
## 0.8.79 - 2024-02-11
* fix `opendtufusion` build (started only once USB-console was connected)
* code quality improvments
## 0.8.78 - 2024-02-10 ## 0.8.78 - 2024-02-10
* finalized API token access #1415 * finalized API token access #1415
* possible fix of MqTT fix "total values are sent to often" #1421 * possible fix of MqTT fix "total values are sent to often" #1421

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_PATCH 78 #define VERSION_PATCH 79
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {

2
src/hm/hmRadio.h

@ -159,7 +159,7 @@ class HmRadio : public Radio {
mTimeslotStart = millis(); mTimeslotStart = millis();
tempRxChIdx = mRxChIdx; // might be better to start off with one channel less? tempRxChIdx = mRxChIdx; // might be better to start off with one channel less?
mRxPendular = false; mRxPendular = false;
mNRFloopChannels = (mLastIv->mCmd == MI_REQ_CH1 || mLastIv->mCmd == MI_REQ_CH1); mNRFloopChannels = (mLastIv->mCmd == MI_REQ_CH1);
innerLoopTimeout = DURATION_LISTEN_MIN; innerLoopTimeout = DURATION_LISTEN_MIN;
} }

12
src/platformio.ini

@ -32,7 +32,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3 bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4 https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.9 olikraus/U8g2 @ ^2.35.9
https://github.com/zinggjm/GxEPD2#1.5.5 https://github.com/zinggjm/GxEPD2#1.5.3
build_flags = build_flags =
-std=c++17 -std=c++17
-std=gnu++17 -std=gnu++17
@ -201,7 +201,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3 bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4 https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.9 olikraus/U8g2 @ ^2.35.9
https://github.com/zinggjm/GxEPD2#1.5.5 https://github.com/zinggjm/GxEPD2#1.5.3
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-D ETHERNET -D ETHERNET
-DRELEASE -DRELEASE
@ -224,7 +224,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3 bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4 https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.9 olikraus/U8g2 @ ^2.35.9
https://github.com/zinggjm/GxEPD2#1.5.5 https://github.com/zinggjm/GxEPD2#1.5.3
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-D ETHERNET -D ETHERNET
-DRELEASE -DRELEASE
@ -350,7 +350,7 @@ build_flags = ${env.build_flags}
-DDEF_LED1=17 -DDEF_LED1=17
-DLED_ACTIVE_HIGH -DLED_ACTIVE_HIGH
-DARDUINO_USB_MODE=1 -DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1 #-DARDUINO_USB_CDC_ON_BOOT=1
monitor_filters = monitor_filters =
esp32_exception_decoder, colorize esp32_exception_decoder, colorize
@ -418,7 +418,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3 bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4 https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.9 olikraus/U8g2 @ ^2.35.9
https://github.com/zinggjm/GxEPD2#1.5.5 https://github.com/zinggjm/GxEPD2#1.5.3
upload_protocol = esp-builtin upload_protocol = esp-builtin
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-DETHERNET -DETHERNET
@ -463,7 +463,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3 bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4 https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.9 olikraus/U8g2 @ ^2.35.9
https://github.com/zinggjm/GxEPD2#1.5.5 https://github.com/zinggjm/GxEPD2#1.5.3
upload_protocol = esp-builtin upload_protocol = esp-builtin
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-DETHERNET -DETHERNET

Loading…
Cancel
Save