From 035d6cd16d8edcbc76d8a1aa4a1d2e2e3cde60ba Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Apr 2020 09:42:51 -0500 Subject: [PATCH] Patch i2c, info menu --- Marlin/src/HAL/HAL.h | 4 ++++ Marlin/src/HAL/LPC1768/HAL.h | 3 +++ Marlin/src/core/macros.h | 2 +- Marlin/src/lcd/menu/menu_info.cpp | 11 ++--------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index 2e024878ff..614c6cbaf9 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -27,6 +27,10 @@ #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION) +#ifndef I2C_ADDRESS + #define I2C_ADDRESS(A) (A) +#endif + inline void watchdog_refresh() { TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); } diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 70bb50e692..2d385fd16c 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -48,6 +48,9 @@ extern "C" volatile uint32_t _millis; #include #include +// i2c uses 8-bit shifted address +#define I2C_ADDRESS(A) ((A) << 1) + // // Default graphical display delays // diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 214539d830..c84d7b8116 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -292,7 +292,7 @@ #define FMOD(x, y) fmodf(x, y) #define HYPOT(x,y) SQRT(HYPOT2(x,y)) -#define I2C_ADDRESS(A) int(TERN(TARGET_LPC1768, (A) << 1, A)) +#define I2C_ADDRESS(A) (typeof(A))(TERN(TARGET_LPC1768, (A) << 1, A)) // Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments #define _NUM_ARGS(_,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,OUT,...) OUT diff --git a/Marlin/src/lcd/menu/menu_info.cpp b/Marlin/src/lcd/menu/menu_info.cpp index 2f6ab974f4..41baa5d2e0 100644 --- a/Marlin/src/lcd/menu/menu_info.cpp +++ b/Marlin/src/lcd/menu/menu_info.cpp @@ -34,8 +34,8 @@ #include "game/game.h" #endif -#define VALUE_ITEM(MSG, VALUE, STYL) do{ strcpy_P(buffer, PSTR(": ")); strcpy(buffer + 2, VALUE); STATIC_ITEM(MSG, STYL, buffer); }while(0) -#define VALUE_ITEM_P(MSG, PVALUE, STYL) do{ strcpy_P(buffer, PSTR(": ")); strcpy_P(buffer + 2, PSTR(PVALUE)); STATIC_ITEM(MSG, STYL, buffer); }while(0) +#define VALUE_ITEM(MSG, VALUE, STYL) do{ char buffer[21]; strcpy_P(buffer, PSTR(": ")); strcpy(buffer + 2, VALUE); STATIC_ITEM(MSG, STYL, buffer); }while(0) +#define VALUE_ITEM_P(MSG, PVALUE, STYL) do{ char buffer[21]; strcpy_P(buffer, PSTR(": ")); strcpy_P(buffer + 2, PSTR(PVALUE)); STATIC_ITEM(MSG, STYL, buffer); }while(0) #if ENABLED(PRINTCOUNTER) @@ -51,8 +51,6 @@ printStatistics stats = print_job_timer.getStats(); - char buffer[21]; - START_SCREEN(); // 12345678901234567890 VALUE_ITEM(MSG_INFO_PRINT_COUNT, i16tostr3left(stats.totalPrints), SS_LEFT); // Print Count: 999 VALUE_ITEM(MSG_INFO_COMPLETED_PRINTS, i16tostr3left(stats.finishedPrints), SS_LEFT); // Completed : 666 @@ -100,8 +98,6 @@ void menu_info_thermistors() { if (ui.use_click()) return ui.go_back(); - char buffer[21]; // For macro usage - START_SCREEN(); #if EXTRUDERS @@ -208,8 +204,6 @@ void menu_info_thermistors() { void menu_info_board() { if (ui.use_click()) return ui.go_back(); - char buffer[21]; // For macro usage - START_SCREEN(); STATIC_ITEM_P(PSTR(BOARD_INFO_NAME), SS_CENTER|SS_INVERT); // MyPrinterController #ifdef BOARD_WEBSITE_URL @@ -248,7 +242,6 @@ void menu_info_board() { STATIC_ITEM_P(PSTR(STRING_DISTRIBUTION_DATE)); // YYYY-MM-DD HH:MM STATIC_ITEM_P(PSTR(MACHINE_NAME)); // My3DPrinter STATIC_ITEM_P(PSTR(WEBSITE_URL)); // www.my3dprinter.com - char buffer[21]; VALUE_ITEM_P(MSG_INFO_EXTRUDERS, STRINGIFY(EXTRUDERS), SS_CENTER); // Extruders: 2 #if ENABLED(AUTO_BED_LEVELING_3POINT) STATIC_ITEM(MSG_3POINT_LEVELING); // 3-Point Leveling