Compare commits

...
5 Commits
Author SHA1 Message Date
TD-erandGitHub 683b9668ef Merge pull request #5483 from TD-er/release/hotfix_mega-20260108_3
Release/hotfix mega 20260108
2026-01-21 23:27:38 +01:00
Ton HuismanandTD-er d1ce5cd078 [P073] Bugfix: Display stays blank after upgrade without settings-save (#5475)
* [P073] Bugfix: Display stays blank after upgrade without settings-save

* [P073] Revert to regular GPIO for TM1637 on ESP8266

* [P073] Minor code reduction (eliminate unneeded variables)
2026-01-21 14:27:53 +01:00
Ton HuismanandTD-er aa86a92d93 [MQTT] Bugfix: Import wasn't initiated and handled correctly 2026-01-21 14:27:46 +01:00
Ton HuismanandTD-er 47275a6264 [P135] Bugfix: Correct Discovery VTypes 2026-01-21 14:27:39 +01:00
TD-er 548c894a12 [OLED] Fix: 128×64 shows only left half in display_A builds (#5469)
Fixes: #5469
2026-01-21 14:27:32 +01:00
7 changed files with 158 additions and 96 deletions
+28 -14
View File
@@ -42,6 +42,9 @@
//
/** History
* 2026-01-17 tonhuisman: Revert to using 'regular' Arduino GPIO functions for TM1637 displays on ESP8266
* 2026-01-12 tonhuisman: Fix initialization of number of digits when upgrading to 20260108 build,
* formatted source with new Uncrustify config
* 2024-09-28 tonhuisman: Switch to using DIRECT_PIN_IO, to get better timing-accuracy for TM1637 displays
* 2024-09-27 tonhuisman: Add option to flash dot on second digit instead of the colon for blinking time
* 2024-08-24 tonhuisman: Add compiletime define P073_USE_74HC595_OVERRIDE that, when, set to 1, allows 74HC595 displays to be included
@@ -96,12 +99,13 @@
# include "src/PluginStructs/P073_data_struct.h"
boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string) {
boolean success = false;
switch (function) {
case PLUGIN_DEVICE_ADD: {
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
auto& dev = Device[++deviceCount];
dev.Number = PLUGIN_ID_073;
dev.Type = DEVICE_TYPE_TRIPLE;
@@ -113,13 +117,15 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
break;
}
case PLUGIN_GET_DEVICENAME: {
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_073);
break;
}
# if P073_SCROLL_TEXT || P073_USE_74HC595
case PLUGIN_SET_DEFAULTS: {
case PLUGIN_SET_DEFAULTS:
{
# if P073_SCROLL_TEXT
P073_CFG_SCROLLSPEED = 10; // Default 10 * 0.1 sec scroll speed
# endif // if P073_SCROLL_TEXT
@@ -134,7 +140,8 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
}
# endif // if P073_SCROLL_TEXT || P073_USE_74HC595
case PLUGIN_WEBFORM_LOAD: {
case PLUGIN_WEBFORM_LOAD:
{
addFormNote(F("TM1637: 1st=CLK-Pin, 2nd=DIO-Pin"));
addFormNote(F("MAX7219: 1st=DIN-Pin, 2nd=CLK-Pin, 3rd=CS-Pin"));
# if P073_USE_74HC595
@@ -151,7 +158,7 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
};
constexpr size_t optionCount = NR_ELEMENTS(displtype);
const FormSelectorOptions selector(optionCount, displtype);
selector.addFormSelector(F("Display Type"), F("displtype"), PCONFIG(0));
selector.addFormSelector(F("Display Type"), F("displtype"), P073_CFG_DISPLAYTYPE);
}
# if P073_USE_74HC595
@@ -258,7 +265,8 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
break;
}
case PLUGIN_WEBFORM_SAVE: {
case PLUGIN_WEBFORM_SAVE:
{
P073_CFG_DISPLAYTYPE = getFormItemInt(F("displtype"));
P073_CFG_OUTPUTTYPE = getFormItemInt(F("displout"));
P073_CFG_BRIGHTNESS = getFormItemInt(F("brightness"));
@@ -292,12 +300,14 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
break;
}
case PLUGIN_EXIT: {
case PLUGIN_EXIT:
{
success = true;
break;
}
case PLUGIN_INIT: {
case PLUGIN_INIT:
{
initPluginTaskData(event->TaskIndex, new (std::nothrow) P073_data_struct());
P073_data_struct *P073_data =
static_cast<P073_data_struct *>(getPluginTaskData(event->TaskIndex));
@@ -317,7 +327,8 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
break;
}
case PLUGIN_WRITE: {
case PLUGIN_WRITE:
{
P073_data_struct *P073_data =
static_cast<P073_data_struct *>(getPluginTaskData(event->TaskIndex));
@@ -327,7 +338,8 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
break;
}
case PLUGIN_ONCE_A_SECOND: {
case PLUGIN_ONCE_A_SECOND:
{
P073_data_struct *P073_data =
static_cast<P073_data_struct *>(getPluginTaskData(event->TaskIndex));
@@ -339,7 +351,8 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
}
# if P073_SCROLL_TEXT
case PLUGIN_TEN_PER_SECOND: {
case PLUGIN_TEN_PER_SECOND:
{
P073_data_struct *P073_data =
static_cast<P073_data_struct *>(getPluginTaskData(event->TaskIndex));
@@ -353,7 +366,8 @@ boolean Plugin_073(uint8_t function, struct EventStruct *event, String& string)
# if P073_USE_74HC595
case PLUGIN_TASKTIMER_IN: {
case PLUGIN_TASKTIMER_IN:
{
P073_data_struct *P073_data =
static_cast<P073_data_struct *>(getPluginTaskData(event->TaskIndex));
+2 -1
View File
@@ -77,7 +77,8 @@ boolean Plugin_135(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_GET_DISCOVERY_VTYPES:
{
event->Par1 = static_cast<int>(Sensor_VType::SENSOR_TYPE_CO2_ONLY);
event->Par2 = static_cast<int>(Sensor_VType::SENSOR_TYPE_TEMP_HUM);
event->Par2 = static_cast<int>(Sensor_VType::SENSOR_TYPE_HUM_ONLY);
event->Par3 = static_cast<int>(Sensor_VType::SENSOR_TYPE_TEMP_ONLY);
success = true;
break;
}
+4 -3
View File
@@ -1013,9 +1013,10 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str)
case PLUGIN_GET_UOM_GROUPS:
#endif // if FEATURE_TASKVALUE_UNIT_OF_MEASURE
// PLUGIN_MQTT_xxx functions are directly called from the scheduler.
// case PLUGIN_MQTT_CONNECTION_STATE:
// case PLUGIN_MQTT_IMPORT:
#if FEATURE_MQTT
case PLUGIN_MQTT_CONNECTION_STATE:
case PLUGIN_MQTT_IMPORT:
#endif // if FEATURE_MQTT
{
START_TIMER;
const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(event->TaskIndex);
+2 -7
View File
@@ -273,10 +273,6 @@ void scheduleNextMQTTdelayQueue() {
}
void schedule_all_MQTTimport_tasks() {
controllerIndex_t ControllerIndex = firstEnabledMQTT_ControllerIndex();
if (!validControllerIndex(ControllerIndex)) { return; }
constexpr pluginID_t PLUGIN_MQTT_IMPORT(PLUGIN_ID_MQTT_IMPORT);
deviceIndex_t DeviceIndex = getDeviceIndex(PLUGIN_MQTT_IMPORT); // Check if P037_MQTTimport is present in the build
@@ -358,9 +354,6 @@ void updateMQTTclient_connected() {
addLogMove(LOG_LEVEL_ERROR, connectionError);
}
MQTTclient_must_send_LWT_connected = false;
} else {
// Now schedule all tasks using the MQTT controller.
schedule_all_MQTTimport_tasks();
}
if (Settings.UseRules) {
if (MQTTclient_connected) {
@@ -369,6 +362,8 @@ void updateMQTTclient_connected() {
eventQueue.add(F("MQTT#Disconnected"));
}
}
// Now schedule all tasks using the MQTT Import plugin.
schedule_all_MQTTimport_tasks();
}
if (!MQTTclient_connected) {
// As suggested here: https://github.com/letscontrolit/ESPEasy/issues/1356
@@ -435,7 +435,6 @@ void P023_data_struct::sendStrXY(const char *string, int X, int Y) {
for (i = 0; i < char_width && currentPixels < maxPixels; ++i,++currentPixels) { // Prevent display overflow on the pixel-level
sendChar((i == 0 || i > 5) ? 0x00 : pgm_read_byte(baddr + i - 1));
}
currentPixels += char_width;
string++;
}
}
+117 -65
View File
@@ -2,7 +2,9 @@
#ifdef USES_P073
# include <GPIO_Direct_Access.h>
# ifdef ESP32
# include <GPIO_Direct_Access.h>
# endif // ifdef ESP32
uint8_t P073_getDefaultDigits(uint8_t displayModel,
uint8_t digits) {
@@ -34,7 +36,8 @@ uint8_t P073_mapCharToFontPosition(char character,
const String specialChars = F(" -^=/_%@.,;:+*#!?'\"<>\\()|");
const String chnorux = F("CHNORUX");
switch (fontset) {
switch (fontset)
{
case 1: // Siekoo
case 2: // Siekoo with uppercase 'CHNORUX'
@@ -58,16 +61,24 @@ uint8_t P073_mapCharToFontPosition(char character,
if (isDigit(character)) {
position = character - '0';
} else if (isAlpha(character)) {
}
else if (isAlpha(character)) {
position = character - (isLowerCase(character) ? 'a' : 'A') + 16;
} else {
switch (character) {
case ' ': position = 10; break;
case '-': position = 11; break;
case '^': position = 12; break; // degree
case '=': position = 13; break;
case '/': position = 14; break;
case '_': position = 15; break;
switch (character)
{
case ' ': position = 10;
break;
case '-': position = 11;
break;
case '^': position = 12;
break; // degree
case '=': position = 13;
break;
case '/': position = 14;
break;
case '_': position = 15;
break;
}
}
# if P073_EXTRA_FONTS
@@ -85,7 +96,8 @@ uint8_t P073_getFontChar(uint8_t index,
uint8_t fontset) {
# if P073_EXTRA_FONTS
switch (fontset) {
switch (fontset)
{
case 1: // Siekoo
case 2: // Siekoo uppercase CHNORUX
return pgm_read_byte(&(SiekooCharTable[index]));
@@ -143,10 +155,12 @@ void P073_display_output_selector(const __FlashStringHelper *id, int16_t value)
P073_DISP_DATE,
};
const FormSelectorOptions selector(NR_ELEMENTS(disploutOptions), displout, disploutOptions);
selector.addFormSelector(F("Display Output"), id, value);
}
# if P073_EXTRA_FONTS
void P073_font_selector(const __FlashStringHelper *id, int16_t value) {
const __FlashStringHelper *fontset[] = {
F("Default"),
@@ -154,7 +168,8 @@ void P073_font_selector(const __FlashStringHelper *id, int16_t value) {
F("Siekoo with uppercase 'CHNORUX'"),
F("dSEG7"),
};
const FormSelectorOptions selector(NR_ELEMENTS(fontset), fontset);
const FormSelectorOptions selector(NR_ELEMENTS(fontset), fontset);
selector.addFormSelector(F("Font set"), id, value);
addFormNote(F("Check documentation for examples of the font sets."));
}
@@ -202,9 +217,9 @@ void P073_data_struct::init(struct EventStruct *event)
# endif // if P073_SCROLL_TEXT
rightAlignTempMAX7219 = bitRead(P073_CFG_FLAGS, P073_OPTION_RIGHTALIGN);
suppressLeading0 = bitRead(P073_CFG_FLAGS, P073_OPTION_SUPPRESS0);
#if P073_BLINK_DOT
# if P073_BLINK_DOT
blinkdot = bitRead(P073_CFG_FLAGS, P073_OPTION_BLINK_DOT);
#endif // if P073_BLINK_DOT
# endif // if P073_BLINK_DOT
timesep = true;
# if P073_EXTRA_FONTS
fontset = P073_CFG_FONTSET;
@@ -233,11 +248,20 @@ void P073_data_struct::init(struct EventStruct *event)
}
# endif // if P073_USE_74HC595
if (0 == digits) {
digits = P073_getDefaultDigits(P073_CFG_DISPLAYTYPE);
}
if ((digits > 0) && (digits < 4)) {
hideDegree = true; // Hide degree symbol on small displays
}
switch (displayModel) {
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
addLog(LOG_LEVEL_INFO, strformat(F("P073 : Digits: %d, model: %d, pins: %d, %d, %d"), digits, displayModel, pin1, pin2, pin3));
}
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
case P073_TM1637_6DGT:
@@ -275,6 +299,7 @@ void P073_data_struct::init(struct EventStruct *event)
}
# if P073_USE_74HC595
bool P073_data_struct::plugin_fifty_per_second(struct EventStruct *event) {
# ifdef P073_DEBUG
counter50++;
@@ -289,9 +314,7 @@ bool P073_data_struct::plugin_fifty_per_second(struct EventStruct *event) {
return false;
}
bool P073_data_struct::is74HC595Matrix() {
return P073_74HC595_2_8DGT == displayModel && P073_HC595_MULTIPLEX;
}
bool P073_data_struct::is74HC595Matrix() { return P073_74HC595_2_8DGT == displayModel && P073_HC595_MULTIPLEX; }
// ====================================
// ---- 74HC595 specific functions ----
@@ -642,6 +665,7 @@ void P073_data_struct::FillBufferWithString(const String& textToShow,
}
# if P073_SCROLL_TEXT
int P073_data_struct::getEffectiveTextLength(const String& text) {
const int textLength = text.length();
int p = 0;
@@ -757,17 +781,14 @@ void P073_data_struct::setScrollSpeed(uint8_t speed) {
scrollPos = 0;
}
bool P073_data_struct::isScrollEnabled() {
return txtScrolling && scrollAllowed;
}
bool P073_data_struct::isScrollEnabled() { return txtScrolling && scrollAllowed; }
void P073_data_struct::setScrollEnabled(bool scroll) {
scrollAllowed = scroll;
}
void P073_data_struct::setScrollEnabled(bool scroll) { scrollAllowed = scroll; }
# endif // if P073_SCROLL_TEXT
# if P073_7DBIN_COMMAND
void P073_data_struct::setBinaryData(const String& data) {
binaryData = true;
# if P073_SCROLL_TEXT
@@ -783,6 +804,7 @@ void P073_data_struct::setBinaryData(const String& data) {
# endif // if P073_7DBIN_COMMAND
# ifdef P073_DEBUG
void P073_data_struct::LogBufferContent(String prefix) {
String log;
@@ -803,9 +825,7 @@ void P073_data_struct::LogBufferContent(String prefix) {
# endif // ifdef P073_DEBUG
// in case of error show all dashes
void P073_data_struct::FillBufferWithDash() {
memset(showbuffer, 11, sizeof(showbuffer));
}
void P073_data_struct::FillBufferWithDash() { memset(showbuffer, 11, sizeof(showbuffer)); }
void P073_data_struct::ClearBuffer() {
memset(showbuffer,
@@ -820,11 +840,9 @@ void P073_data_struct::ClearBuffer() {
}
uint8_t P073_data_struct::tm1637_getFontChar(uint8_t index,
uint8_t fontset) {
return P073_revert7bits(P073_getFontChar(index, fontset));
}
uint8_t fontset) { return P073_revert7bits(P073_getFontChar(index, fontset)); }
bool P073_data_struct::plugin_once_a_second(struct EventStruct *event) {
bool P073_data_struct::plugin_once_a_second(struct EventStruct *event) {
if (output == P073_DISP_MANUAL) {
return false;
}
@@ -855,16 +873,17 @@ bool P073_data_struct::plugin_once_a_second(struct EventStruct *event) {
);
}
#if P073_BLINK_DOT
# if P073_BLINK_DOT
if (blinkdot &&
((output == P073_DISP_CLOCK24BLNK) ||
(output == P073_DISP_CLOCK12BLNK))) {
showperiods[1] = timesep; // Blink dot on second digit
}
#endif // if P073_BLINK_DOT
# endif // if P073_BLINK_DOT
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
tm1637_ShowTimeTemp4(timesep, 0);
@@ -900,15 +919,18 @@ bool P073_data_struct::plugin_once_a_second(struct EventStruct *event) {
}
# if P073_SCROLL_TEXT
bool P073_data_struct::plugin_ten_per_second(struct EventStruct *event) {
if ((output != P073_DISP_MANUAL) || !isScrollEnabled()) {
return false;
}
if (NextScroll()) {
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS: {
case P073_TM1637_4DGTDOTS:
{
tm1637_ShowBuffer(0, 4
# if P073_7DBIN_COMMAND
, binaryData
@@ -916,7 +938,8 @@ bool P073_data_struct::plugin_ten_per_second(struct EventStruct *event) {
);
break;
}
case P073_TM1637_6DGT: {
case P073_TM1637_6DGT:
{
tm1637_SwapDigitInBuffer(0); // only needed for 6-digits displays
tm1637_ShowBuffer(0, 6
# if P073_7DBIN_COMMAND
@@ -925,13 +948,15 @@ bool P073_data_struct::plugin_ten_per_second(struct EventStruct *event) {
);
break;
}
case P073_MAX7219_8DGT: {
case P073_MAX7219_8DGT:
{
dotpos = -1; // avoid to display the dot
max7219_ShowBuffer();
break;
}
# if P073_USE_74HC595
case P073_74HC595_2_8DGT: {
case P073_74HC595_2_8DGT:
{
hc595_ToOutputBuffer();
if (hc595_Sequential()) { // Sequential displays don't need continuous refreshing
@@ -981,6 +1006,7 @@ enum class p073_commands_e : int8_t {
c7doff,
c7db,
c7output,
};
bool P073_data_struct::plugin_write(struct EventStruct *event,
@@ -1005,7 +1031,8 @@ bool P073_data_struct::plugin_write(struct EventStruct *event,
bool success = false;
bool displayon = false;
switch (cmd) {
switch (cmd)
{
case p073_commands_e::c7dn:
return plugin_write_7dn(event, text);
case p073_commands_e::c7dt:
@@ -1104,7 +1131,8 @@ bool P073_data_struct::plugin_write(struct EventStruct *event,
setScrollEnabled(newScroll);
# endif // if P073_SCROLL_TEXT
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
case P073_TM1637_6DGT:
@@ -1167,7 +1195,8 @@ bool P073_data_struct::plugin_write_7dn(struct EventStruct *event,
}
}
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
tm1637_ShowBuffer(TM1637_4DIGIT, 8);
@@ -1234,7 +1263,8 @@ bool P073_data_struct::plugin_write_7dt(const String& text) {
FillBufferWithTemp(p073_temptemp);
}
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
case P073_TM1637_6DGT:
@@ -1277,6 +1307,7 @@ bool P073_data_struct::plugin_write_7dt(const String& text) {
}
# if P073_7DDT_COMMAND
bool P073_data_struct::plugin_write_7ddt(const String& text) {
if (output != P073_DISP_MANUAL) {
return false;
@@ -1301,7 +1332,8 @@ bool P073_data_struct::plugin_write_7ddt(const String& text) {
}
# endif // ifndef BUILD_NO_DEBUG
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
case P073_TM1637_6DGT:
@@ -1403,7 +1435,8 @@ bool P073_data_struct::plugin_write_7dst(struct EventStruct *event) {
# endif // if P073_SUPPRESS_ZERO
);
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
tm1637_ShowTimeTemp4(timesep, 0);
@@ -1447,7 +1480,8 @@ bool P073_data_struct::plugin_write_7dsd(struct EventStruct *event) {
# endif // if P073_SUPPRESS_ZERO
);
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
tm1637_ShowTimeTemp4(timesep, 0);
@@ -1494,7 +1528,8 @@ bool P073_data_struct::plugin_write_7dtext(const String& text) {
{
FillBufferWithString(text);
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
tm1637_ShowBuffer(0, 4);
@@ -1522,6 +1557,7 @@ bool P073_data_struct::plugin_write_7dtext(const String& text) {
}
# if P073_EXTRA_FONTS
bool P073_data_struct::plugin_write_7dfont(struct EventStruct *event,
const String & text) {
if (!text.isEmpty()) {
@@ -1545,6 +1581,7 @@ bool P073_data_struct::plugin_write_7dfont(struct EventStruct *event,
# endif // if P073_EXTRA_FONTS
# if P073_7DBIN_COMMAND
bool P073_data_struct::plugin_write_7dbin(const String& text) {
if (!text.isEmpty()) {
String data;
@@ -1576,7 +1613,8 @@ bool P073_data_struct::plugin_write_7dbin(const String& text) {
{
FillBufferWithString(data, true);
switch (displayModel) {
switch (displayModel)
{
case P073_TM1637_4DGTCOLON:
case P073_TM1637_4DGTDOTS:
tm1637_ShowBuffer(0, 4);
@@ -1612,10 +1650,17 @@ bool P073_data_struct::plugin_write_7dbin(const String& text) {
// ---- TM1637 specific functions ----
// ===================================
# define CLK_HIGH() DIRECT_pinWrite(this->pin1, HIGH)
# define CLK_LOW() DIRECT_pinWrite(this->pin1, LOW)
# define DIO_HIGH() DIRECT_PINMODE_INPUT(this->pin2)
# define DIO_LOW() DIRECT_PINMODE_OUTPUT(this->pin2) //; DIRECT_pinWrite(this->pin2, LOW)
# ifdef ESP32
# define CLK_HIGH() DIRECT_pinWrite(this->pin1, HIGH)
# define CLK_LOW() DIRECT_pinWrite(this->pin1, LOW)
# define DIO_HIGH() DIRECT_PINMODE_INPUT(this->pin2)
# define DIO_LOW() DIRECT_PINMODE_OUTPUT(this->pin2) // ; DIRECT_pinWrite(this->pin2, LOW)
# else // ifdef ESP32
# define CLK_HIGH() digitalWrite(this->pin1, HIGH)
# define CLK_LOW() digitalWrite(this->pin1, LOW)
# define DIO_HIGH() pinMode(this->pin2, INPUT)
# define DIO_LOW() pinMode(this->pin2, OUTPUT)
# endif // ifdef ESP32
void P073_data_struct::tm1637_i2cStart() {
# ifdef P073_DEBUG
@@ -1642,7 +1687,7 @@ void P073_data_struct::tm1637_i2cStop() {
void P073_data_struct::tm1637_i2cAck() {
CLK_LOW();
pinMode(pin2, INPUT_PULLUP);
pinMode(this->pin2, INPUT_PULLUP);
// DIO_HIGH();
delayMicroseconds(TM1637_CLOCKDELAY);
@@ -1651,7 +1696,11 @@ void P073_data_struct::tm1637_i2cAck() {
# ifdef P073_DEBUG
const bool dummyAck =
# endif // ifdef P073_DEBUG
DIRECT_pinRead(pin2);
# ifdef ESP32
DIRECT_pinRead(this->pin2);
# else
digitalRead(this->pin2);
# endif // ifdef ESP32
# ifdef P073_DEBUG
@@ -1674,12 +1723,12 @@ void P073_data_struct::tm1637_i2cAck() {
void P073_data_struct::tm1637_i2cWrite_ack(uint8_t bytesToPrint[],
uint8_t length) {
#ifdef P073_DEBUG
# ifdef P073_DEBUG
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
addLog(LOG_LEVEL_INFO, concat(F("7DGT : TM1637 databuffer: 0x"), formatToHex_array(bytesToPrint, length)));
}
#endif // ifdef P073_DEBUG
# endif // ifdef P073_DEBUG
tm1637_i2cStart();
for (uint8_t i = 0; i < length; ++i) {
@@ -1697,9 +1746,8 @@ void P073_data_struct::tm1637_i2cWrite(uint8_t bytetoprint) {
# ifdef P073_DEBUG
addLog(LOG_LEVEL_DEBUG, F("7DGT : WriteByte"));
# endif // ifdef P073_DEBUG
uint8_t i;
for (i = 0; i < 8; ++i) {
for (uint8_t i = 0; i < 8; ++i) {
CLK_LOW();
if (bytetoprint & 0b00000001) {
@@ -1726,21 +1774,25 @@ void P073_data_struct::tm1637_SetPowerBrightness(uint8_t brightlvl,
# ifdef P073_DEBUG
addLog(LOG_LEVEL_INFO, F("7DGT : Set BRIGHT"));
# endif // ifdef P073_DEBUG
uint8_t brightvalue = (brightlvl & 0b111);
brightlvl &= 0b111;
if (poweron) {
brightvalue = TM1637_POWER_ON | brightvalue;
brightlvl |= TM1637_POWER_ON;
} else {
brightvalue = TM1637_POWER_OFF | brightvalue;
brightlvl |= TM1637_POWER_OFF;
}
const uint8_t byteToPrint = brightvalue;
tm1637_i2cWrite_ack(byteToPrint);
tm1637_i2cWrite_ack(brightlvl);
}
void P073_data_struct::tm1637_InitDisplay() {
DIRECT_PINMODE_OUTPUT(pin1);
DIRECT_PINMODE_OUTPUT(pin2);
# ifdef ESP32
DIRECT_PINMODE_OUTPUT(this->pin1);
DIRECT_PINMODE_OUTPUT(this->pin2);
# else // ifdef ESP32
pinMode(this->pin1, OUTPUT);
pinMode(this->pin2, OUTPUT);
# endif // ifdef ESP32
CLK_HIGH();
DIO_HIGH();
+5 -5
View File
@@ -308,9 +308,9 @@ public:
bool rightAlignTempMAX7219 = false;
bool suppressLeading0 = false;
uint8_t fontset = 0;
#if P073_BLINK_DOT
# if P073_BLINK_DOT
bool blinkdot = false;
#endif // if P073_BLINK_DOT
# endif // if P073_BLINK_DOT
# if P073_7DBIN_COMMAND
bool binaryData = false;
# endif // P073_7DBIN_COMMAND
@@ -404,12 +404,12 @@ private:
void hc595_ShowBuffer();
void hc595_ToOutputBuffer();
void hc595_AdjustBuffer();
bool hc595_Sequential() {
return P073_HC595_SEQUENTIAL;
}
bool hc595_Sequential() { return P073_HC595_SEQUENTIAL; }
uint8_t outputbuffer[8]{};
# endif // if P073_USE_74HC595
};
#endif // ifdef USES_P073