Merge branch 'bugfix-2.1.x' of https://github.com/dekutree64/Marlin into bugfix-2.1.x

This commit is contained in:
dekutree64 2026-02-27 01:16:47 -06:00
commit 31330afdfb
16 changed files with 65 additions and 54 deletions

View file

@ -41,7 +41,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
//#define STRING_DISTRIBUTION_DATE "2026-02-20"
//#define STRING_DISTRIBUTION_DATE "2026-02-21"
/**
* The protocol for communication to the host. Protocol indicates communication

View file

@ -137,7 +137,7 @@ int8_t digital_pin_to_analog_pin(pin_t pin) {
}
bool isAnalogPin(const pin_t pin) {
return digital_pin_to_analog_pin(pin) != -1;
return digital_pin_to_analog_pin(pin) >= 0;
}
#define digitalRead_mod(A) extDigitalRead(A) // must use Arduino pin numbers when doing reads

View file

@ -50,7 +50,7 @@
#define getPinByIndex(x) pin_array[x].pin
#define getPinIsDigitalByIndex(x) pin_array[x].is_digital
#define isValidPin(P) (P >= 0 && P < pin_t(NUMBER_PINS_TOTAL))
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) != -1)
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0)
#define pwm_status(P) digitalPinHasPWM(P)
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin

View file

@ -50,7 +50,7 @@
#define getPinByIndex(x) pin_array[x].pin
#define getPinIsDigitalByIndex(x) pin_array[x].is_digital
#define isValidPin(P) (P >= 0 && P < pin_t(NUMBER_PINS_TOTAL))
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) != -1)
#define isAnalogPin(P) (digitalPinToAnalogIndex(P) >= 0)
#define pwm_status(P) digitalPinHasPWM(P)
#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin

View file

@ -256,6 +256,7 @@
// Array shorthand
#define COUNT(a) (sizeof(a)/sizeof(*a))
#define ZERO(a) memset((void*)a,0,sizeof(a))
#define OBJZERO(a) memset(&a,0,sizeof(a))
#define COPY(a,b) do{ \
static_assert(sizeof(a[0]) == sizeof(b[0]), "COPY: '" STRINGIFY(a) "' and '" STRINGIFY(b) "' types (sizes) don't match!"); \
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \

View file

@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2026-02-20"
#define STRING_DISTRIBUTION_DATE "2026-02-21"
#endif
/**

View file

@ -311,7 +311,7 @@ void MarlinUI::init_lcd() {
#if ANY(MKS_12864OLED, MKS_12864OLED_SSD1306, FYSETC_242_OLED_12864, ZONESTAR_12864OLED, K3D_242_OLED_CONTROLLER)
#if defined(LCD_PINS_DC) && LCD_PINS_DC != -1
#if defined(LCD_PINS_DC) && LCD_PINS_DC >= 0
#if IS_I2C_LCD
I2C_TypeDef *i2cInstance1 = (I2C_TypeDef *)pinmap_peripheral(digitalPinToPinName(DOGLCD_SDA_PIN), PinMap_I2C_SDA);
I2C_TypeDef *i2cInstance2 = (I2C_TypeDef *)pinmap_peripheral(digitalPinToPinName(DOGLCD_SCL_PIN), PinMap_I2C_SCL);
@ -454,18 +454,21 @@ void MarlinUI::clear_for_drawing() {
// Mark a menu item and set font color if selected.
// Return 'false' if the item is not on screen.
static bool mark_as_selected(const uint8_t row, const bool sel) {
row_y1 = row * (MENU_FONT_HEIGHT) + 1;
row_y2 = row_y1 + MENU_FONT_HEIGHT - 1;
// Menu page has 2px top margin
row_y1 = 2 + row * (MENU_LINE_HEIGHT);
row_y2 = row_y1 + MENU_FONT_HEIGHT;
if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return false;
// Nothing at all to draw?
if (!PAGE_CONTAINS(row_y1, row_y2)) return false;
// Selected or not, draw background and set foreground color
if (sel) {
#if ENABLED(MENU_HOLLOW_FRAME)
u8g.drawHLine(0, row_y1 + 1, LCD_PIXEL_WIDTH);
u8g.drawHLine(0, row_y2 + 2, LCD_PIXEL_WIDTH);
u8g.drawHLine(0, row_y1, LCD_PIXEL_WIDTH); // solid line top
u8g.drawHLine(0, row_y2, LCD_PIXEL_WIDTH); // solid line bottom
#else
u8g.setColorIndex(1); // solid outline
u8g.drawBox(0, row_y1 + 2, LCD_PIXEL_WIDTH, MENU_FONT_HEIGHT - 1);
u8g.setColorIndex(1); // solid fill
u8g.drawBox(0, row_y1 + 1, LCD_PIXEL_WIDTH, MENU_FONT_HEIGHT - 1);
u8g.setColorIndex(0); // inverted text
#endif
}
@ -473,9 +476,11 @@ void MarlinUI::clear_for_drawing() {
else u8g.setColorIndex(1); // solid text
#endif
if (!PAGE_CONTAINS(row_y1, row_y2)) return false;
// Will text not fit? Return false.
if (!PAGE_CONTAINS(row_y1 - 1, row_y2 - MENU_FONT_DESCENT)) return false;
lcd_moveto(0, row_y2);
// Place the cursor at X = 0, Y = row, return true
lcd_moveto(0, row_y2 - MENU_FONT_DESCENT);
return true;
}

View file

@ -83,7 +83,7 @@
#if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_DOGM128_2X // 4 stripes
#define FORCE_SOFT_SPI // SW-SPI
#define DOGM_FORCE_SOFT_SPI // SW-SPI
#else
#define U8G_CLASS U8GLIB_DOGM128_2X // 4 stripes (HW-SPI)
#endif
@ -105,8 +105,8 @@
#define SMART_RAMPS MB(RAMPS_SMART_EFB, RAMPS_SMART_EEB, RAMPS_SMART_EFF, RAMPS_SMART_EEF, RAMPS_SMART_SF)
#define U8G_CLASS U8GLIB_64128N_2X_HAL // 4 stripes (HW-SPI)
#if (SMART_RAMPS && defined(__SAM3X8E__)) || (defined(DOGLCD_SCK) && (DOGLCD_SCK != -1 && DOGLCD_SCK != SD_SCK_PIN)) || (defined(DOGLCD_MOSI) && (DOGLCD_MOSI != -1 && DOGLCD_MOSI != SD_MOSI_PIN))
#define FORCE_SOFT_SPI // SW-SPI
#if (SMART_RAMPS && defined(__SAM3X8E__)) || (defined(DOGLCD_SCK) && (DOGLCD_SCK >= 0 && DOGLCD_SCK != SD_SCK_PIN)) || (defined(DOGLCD_MOSI) && (DOGLCD_MOSI >= 0 && DOGLCD_MOSI != SD_MOSI_PIN))
#define DOGM_FORCE_SOFT_SPI // SW-SPI
#endif
#elif ANY(FYSETC_MINI_12864, MKS_MINI_12864, ENDER2_STOCKDISPLAY)
@ -134,7 +134,7 @@
#if IS_I2C_LCD
#define U8G_CLASS U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE // I2C
#else
#define FORCE_SOFT_SPI // SW-SPI
#define DOGM_FORCE_SOFT_SPI // SW-SPI
#if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_SSD1306_128X64_2X // 4 stripes
#else
@ -147,7 +147,7 @@
// FYSETC OLED 2.42" 128 × 64 Full Graphics Controller
// or K3D OLED 2.42" 128 × 64 Full Graphics Controller
#define FORCE_SOFT_SPI // SW-SPI
#define DOGM_FORCE_SOFT_SPI // SW-SPI
#if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_SSD1306_128X64_2X // 4 stripes
@ -159,7 +159,7 @@
// Zonestar SSD1306 OLED SPI LCD
#define FORCE_SOFT_SPI // SW-SPI
#define DOGM_FORCE_SOFT_SPI // SW-SPI
#if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_SH1306_128X64_2X // 4 stripes
#else
@ -177,7 +177,7 @@
// Zonestar SH1106 OLED SPI LCD
#if !IS_I2C_LCD
#define FORCE_SOFT_SPI // SW-SPI
#define DOGM_FORCE_SOFT_SPI // SW-SPI
#endif
#if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_SH1106_128X64_2X // 4 stripes
@ -246,6 +246,11 @@
#endif
#if defined(DOGM_FORCE_SOFT_SPI) && !defined(FORCE_SOFT_SPI)
#define FORCE_SOFT_SPI
#endif
#undef DOGM_FORCE_SOFT_SPI
// Use HW-SPI if no other option is specified
#ifndef U8G_PARAM
#if IS_I2C_LCD

View file

@ -300,7 +300,7 @@ int uxg_GetUtf8StrPixelWidth(u8g_t *pu8g, const char *utf8_msg) {
if (!uxg_Utf8FontIsInited()) return -1;
memset(&data, 0, sizeof(data));
OBJZERO(data);
data.pu8g = pu8g;
data.adv = 0;
fontgroup_drawstring(group, fnt_default, utf8_msg, read_byte_ram, (void*)&data, fontgroup_cb_draw_u8gstrlen);
@ -326,7 +326,7 @@ int uxg_GetUtf8StrPixelWidthP(u8g_t *pu8g, PGM_P utf8_msg) {
if (!uxg_Utf8FontIsInited()) return -1;
memset(&data, 0, sizeof(data));
OBJZERO(data);
data.pu8g = pu8g;
data.adv = 0;
fontgroup_drawstring(group, fnt_default, utf8_msg, read_byte_rom, (void*)&data, fontgroup_cb_draw_u8gstrlen);

View file

@ -75,4 +75,4 @@
#include "../common/dwin_color.h"
#define Color_Bg_Heading 0x3344 // Static Heading
#define COLOR_BG_HEADING 0x3344 // Static Heading

View file

@ -292,7 +292,7 @@ void MarlinUI::draw_status_message(const bool blink) {
if (y >= LCD_PIXEL_HEIGHT) return false;
if (is_static && sel)
dwinDrawBox(1, Color_Bg_Heading, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
dwinDrawBox(1, COLOR_BG_HEADING, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);
else {
#if ENABLED(MENU_HOLLOW_FRAME)
dwinDrawBox(1, COLOR_BG_BLACK, 0, y, LCD_PIXEL_WIDTH, MENU_LINE_HEIGHT - 1);

View file

@ -513,7 +513,7 @@ void RTS::sendData() {
delay_us(1);
}
memset(&snddat, 0, sizeof(snddat));
OBJZERO(snddat);
ZERO(databuf);
snddat.head[0] = FHONE;
snddat.head[1] = FHTWO;
@ -626,7 +626,7 @@ void RTS::sendData(const unsigned long n, uint32_t addr, uint8_t cmd/*=VarAddr_W
void RTS::handleData() {
int16_t Checkkey = -1;
if (waitway > 0) { // for waiting
memset(&recdat, 0, sizeof(recdat));
OBJZERO(recdat);
recdat.head[0] = FHONE;
recdat.head[1] = FHTWO;
return;
@ -684,7 +684,7 @@ void RTS::handleData() {
}
if (Checkkey < 0) {
memset(&recdat, 0, sizeof(recdat));
OBJZERO(recdat);
recdat.head[0] = FHONE;
recdat.head[1] = FHTWO;
return;
@ -1639,7 +1639,7 @@ void RTS::handleData() {
default: break;
}
memset(&recdat, 0, sizeof(recdat));
OBJZERO(recdat);
recdat.head[0] = FHONE;
recdat.head[1] = FHTWO;
}

View file

@ -192,8 +192,8 @@ void ui_cfg_init() {
uiCfg.filament_unloading_time_cnt = 0;
#if ENABLED(MKS_WIFI_MODULE)
memset(&wifiPara, 0, sizeof(wifiPara));
memset(&ipPara, 0, sizeof(ipPara));
OBJZERO(wifiPara);
OBJZERO(ipPara);
strcpy_P(wifiPara.ap_name, PSTR(WIFI_AP_NAME));
strcpy_P(wifiPara.keyCode, PSTR(WIFI_KEY_CODE));
// client

View file

@ -1376,7 +1376,7 @@ static void net_msg_handle(const uint8_t * const msg, const uint16_t msgLen) {
ZERO(wifiPara.ap_name);
memcpy(wifiPara.ap_name, &msg[9], wifiNameLen);
memset(&wifi_list.wifiConnectedName, 0, sizeof(wifi_list.wifiConnectedName));
OBJZERO(wifi_list.wifiConnectedName);
memcpy(&wifi_list.wifiConnectedName, &msg[9], wifiNameLen);
// WiFi key

View file

@ -177,7 +177,7 @@ void RTS::sdCardInit() {
for (uint8_t j = 0; j < MAX_NUM_FILES; j++)
for (uint8_t i = 0; i < FILENAME_LEN; i++)
sendData(0, cardRec.addr[j] + i);
ZERO(&cardRec);
OBJZERO(cardRec);
}
}
@ -221,7 +221,7 @@ void RTS::sdCardUpdate() {
sendData(0, PRINT_FILE_TEXT_VP + j);
sendData(0, SELECT_FILE_TEXT_VP + j);
}
ZERO(&cardRec);
OBJZERO(cardRec);
}
lcd_sd_status = sd_status;
}
@ -422,7 +422,7 @@ void RTS::sendData() {
for (uint16_t i = 0; i < snddat.len + 3; i++)
LCD_SERIAL.write(databuf[i]);
ZERO(&snddat);
OBJZERO(snddat);
ZERO(databuf);
snddat.head[0] = FHONE;
snddat.head[1] = FHTWO;
@ -543,7 +543,7 @@ void RTS::handleData() {
int16_t checkKey = -1;
// For waiting
if (waitway > 0) {
memset(&recdat, 0, sizeof(recdat));
OBJZERO(recdat);
recdat.head[0] = FHONE;
recdat.head[1] = FHTWO;
return;
@ -556,7 +556,7 @@ void RTS::handleData() {
}
if (checkKey < 0) {
ZERO(&recdat);
OBJZERO(recdat);
recdat.head[0] = FHONE;
recdat.head[1] = FHTWO;
return;
@ -1512,7 +1512,7 @@ void RTS::handleData() {
default: break;
}
ZERO(&recdat);
OBJZERO(recdat);
recdat.head[0] = FHONE;
recdat.head[1] = FHTWO;
}

View file

@ -393,7 +393,7 @@ void CardReader::ls(const uint8_t lsflags/*=0*/) {
char *segment = &path[i]; // The segment after most slashes
// If a segment is empty (extra-slash) then exit
if (!*segment) break;
if (!segment[0]) break;
// Go to the next segment
while (path[++i]) { }
@ -439,7 +439,7 @@ void CardReader::ls(const uint8_t lsflags/*=0*/) {
// Zero out slashes to make segments
for (i = 0; i < pathLen; i++) if (bufShort[i] == '/') bufShort[i] = '\0';
SdFile diveDir = root; // start from the root for segment 1
MediaFile diveDir = root; // start from the root for segment 1
for (i = 0; i < pathLen;) {
if (bufShort[i] == '\0') i++; // move past a single nul
@ -447,7 +447,7 @@ void CardReader::ls(const uint8_t lsflags/*=0*/) {
char *segment = &bufShort[i]; // The segment after most slashes
// If a segment is empty (extra-slash) then exit
if (!*segment) break;
if (!segment[0]) break;
//SERIAL_ECHOLNPGM("Looking for segment: ", segment);
@ -838,11 +838,11 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ
abortFilePrintNow();
MediaFile *diveDir;
const char * const fname = diveToFile(true, diveDir, path);
MediaFile *diveDirPtr;
const char * const fname = diveToFile(true, diveDirPtr, path);
if (!fname) return openFailed(path);
if (myfile.open(diveDir, fname, O_READ)) {
if (myfile.open(diveDirPtr, fname, O_READ)) {
filesize = myfile.fileSize();
sdpos = 0;
@ -877,12 +877,12 @@ void CardReader::openFileWrite(const char * const path) {
abortFilePrintNow();
MediaFile *diveDir;
const char * const fname = diveToFile(false, diveDir, path);
MediaFile *diveDirPtr;
const char * const fname = diveToFile(false, diveDirPtr, path);
if (!fname) return openFailed(path);
#if DISABLED(SDCARD_READONLY)
if (myfile.open(diveDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
if (myfile.open(diveDirPtr, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
flag.saving = true;
selectFileByName(fname);
TERN_(EMERGENCY_PARSER, emergency_parser.disable());
@ -905,18 +905,18 @@ bool CardReader::fileExists(const char * const path) {
DEBUG_ECHOLNPGM("fileExists: ", path);
// Dive to the file's directory and get the base name
MediaFile *diveDir = nullptr;
const char * const fname = diveToFile(false, diveDir, path);
MediaFile *diveDirPtr = nullptr;
const char * const fname = diveToFile(false, diveDirPtr, path);
if (!fname) return false;
// Get the longname of the checked file
//diveDir->rewind();
//selectByName(*diveDir, fname);
//diveDir->close();
//diveDirPtr->rewind();
//selectByName(*diveDirPtr, fname);
//diveDirPtr->close();
// Try to open the file and return the result
MediaFile tmpFile;
const bool success = tmpFile.open(diveDir, fname, O_READ);
const bool success = tmpFile.open(diveDirPtr, fname, O_READ);
if (success) tmpFile.close();
return success;
}