Skip to content

Commit

Permalink
0.8.79
Browse files Browse the repository at this point in the history
* fix `opendtufusion` build (started only once USB-console was connected)
* code quality improvments
  • Loading branch information
lumapu committed Feb 11, 2024
1 parent 3e533e8 commit 315541e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
56 changes: 36 additions & 20 deletions patches/GxEPD2_SW_SPI.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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
+++ b/src/GxEPD2_EPD.cpp
@@ -19,9 +19,9 @@
Expand All @@ -14,25 +14,29 @@ index 40b1b13..d0dbdba 100644
{
_initial_write = true;
_initial_refresh = true;
@@ -61,7 +61,6 @@ 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
@@ -71,27 +71,30 @@ void GxEPD2_EPD::init(uint32_t serial_diag_bitrate, bool initial, uint16_t reset
{
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();
+}
+
+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))
+ {
{
- pinMode(_cs, INPUT);
- }
+ _sck = sck;
+ _mosi = mosi;
+ digitalWrite(_sck, LOW);
Expand All @@ -54,7 +58,7 @@ index 40b1b13..d0dbdba 100644
}

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;
}

Expand All @@ -67,7 +71,7 @@ index 40b1b13..d0dbdba 100644
void GxEPD2_EPD::_reset()
{
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)
{
Expand Down Expand Up @@ -300,26 +304,37 @@ index 40b1b13..d0dbdba 100644
+ _endTransaction();
}
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
+++ 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);
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(int16_t sck, int16_t mosi, uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration = 20, bool pulldown_rst_mode = false);
virtual void end(); // release SPI and control pins
// Support for Bitmaps (Sprites) to Controller Buffer and to Screen
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);
};
- void selectSPI(SPIClass& spi, SPISettings spi_settings);
protected:
void _reset();
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 _transfer(uint8_t value);
void _endTransfer();
Expand All @@ -331,11 +346,12 @@ index 3daf37e..96198c2 100644
+ void _readData(uint8_t* data, uint16_t n);
protected:
- 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;
bool _diag_enabled, _pulldown_rst_mode;
SPIClass* _pSPIx;
@@ -121,7 +127,7 @@ class GxEPD2_EPD
- SPIClass* _pSPIx;
SPISettings _spi_settings;
bool _initial_write, _initial_refresh;
bool _power_is_on, _using_partial_mode, _hibernating;
bool _init_display_done;
uint16_t _reset_duration;
Expand Down
4 changes: 4 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 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
* finalized API token access #1415
* possible fix of MqTT fix "total values are sent to often" #1421
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 78
#define VERSION_PATCH 79

//-------------------------------------
typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion src/hm/hmRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class HmRadio : public Radio {
mTimeslotStart = millis();
tempRxChIdx = mRxChIdx; // might be better to start off with one channel less?
mRxPendular = false;
mNRFloopChannels = (mLastIv->mCmd == MI_REQ_CH1 || mLastIv->mCmd == MI_REQ_CH1);
mNRFloopChannels = (mLastIv->mCmd == MI_REQ_CH1);
innerLoopTimeout = DURATION_LISTEN_MIN;
}

Expand Down
12 changes: 6 additions & 6 deletions src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.9
https://github.com/zinggjm/GxEPD2#1.5.5
https://github.com/zinggjm/GxEPD2#1.5.3
build_flags =
-std=c++17
-std=gnu++17
Expand Down Expand Up @@ -201,7 +201,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4
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}
-D ETHERNET
-DRELEASE
Expand All @@ -224,7 +224,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4
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}
-D ETHERNET
-DRELEASE
Expand Down Expand Up @@ -350,7 +350,7 @@ build_flags = ${env.build_flags}
-DDEF_LED1=17
-DLED_ACTIVE_HIGH
-DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1
#-DARDUINO_USB_CDC_ON_BOOT=1
monitor_filters =
esp32_exception_decoder, colorize

Expand Down Expand Up @@ -418,7 +418,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4
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
build_flags = ${env.build_flags}
-DETHERNET
Expand Down Expand Up @@ -463,7 +463,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4
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
build_flags = ${env.build_flags}
-DETHERNET
Expand Down

0 comments on commit 315541e

Please sign in to comment.