Skip to content

Commit 9139847

Browse files
thinkyheadalbertogg
authored andcommitted
Optimize LCD, Wifi, etc. libraries (MarlinFirmware#18730)
1 parent 01b0c57 commit 9139847

7 files changed

Lines changed: 47 additions & 68 deletions

File tree

Marlin/src/gcode/host/M360.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ void GcodeSuite::M360() {
115115
xyz_pos_t cmin = dmin, cmax = dmax;
116116
apply_motion_limits(cmin);
117117
apply_motion_limits(cmax);
118-
const xyz_pos_t lmin = dmin.asLogical(), lmax = dmax.asLogical(),
119-
wmin = cmin.asLogical(), wmax = cmax.asLogical();
118+
const xyz_pos_t wmin = cmin.asLogical(), wmax = cmax.asLogical();
120119

121120
PGMSTR(MIN_STR, "Min");
122121
PGMSTR(MAX_STR, "Max");

Marlin/src/inc/Conditionals_LCD.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,14 @@
399399
#endif
400400
#endif
401401

402+
#if ENABLED(SR_LCD_3W_NL)
403+
// Feature checks for SR_LCD_3W_NL
404+
#elif EITHER(LCD_I2C_TYPE_MCP23017, LCD_I2C_TYPE_MCP23008)
405+
#define USES_LIQUIDTWI2
406+
#elif ANY(HAS_CHARACTER_LCD, LCD_I2C_TYPE_PCF8575, LCD_I2C_TYPE_PCA8574, SR_LCD_2W_NL, LCM1602)
407+
#define USES_LIQUIDCRYSTAL
408+
#endif
409+
402410
#if ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS)
403411
#define HAS_LCD_MENU 1
404412
#endif

Marlin/src/lcd/HD44780/ultralcd_HD44780.h

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,13 @@
2222
#pragma once
2323

2424
/**
25-
* Implementation of the LCD display routines for a Hitachi HD44780 display.
26-
* These are the most common LCD character displays.
25+
* Hitachi HD44780 display defines and headers
2726
*/
2827

2928
#include "../../inc/MarlinConfig.h"
3029

31-
#if LCD_HEIGHT > 3
32-
#include "../../libs/duration_t.h"
33-
#endif
34-
35-
////////////////////////////////////
36-
// Setup button and encode mappings for each panel (into 'buttons' variable
37-
//
38-
// This is just to map common functions (across different panels) onto the same
39-
// macro name. The mapping is independent of whether the button is directly connected or
40-
// via a shift/i2c register.
41-
42-
////////////////////////////////////
43-
// Create LCD class instance and chipset-specific information
4430
#if ENABLED(LCD_I2C_TYPE_PCF8575)
31+
4532
// NOTE: These are register-mapped pins on the PCF8575 controller, not Arduino pins.
4633
#define LCD_I2C_PIN_BL 3
4734
#define LCD_I2C_PIN_EN 2
@@ -58,6 +45,7 @@
5845
#define LCD_CLASS LiquidCrystal_I2C
5946

6047
#elif ENABLED(LCD_I2C_TYPE_MCP23017)
48+
6149
// For the LED indicators (which may be mapped to different events in update_indicators())
6250
#define LCD_HAS_STATUS_INDICATORS
6351
#define LED_A 0x04 //100
@@ -69,40 +57,45 @@
6957
#define LCD_CLASS LiquidTWI2
7058

7159
#elif ENABLED(LCD_I2C_TYPE_MCP23008)
60+
7261
#include <Wire.h>
7362
#include <LiquidTWI2.h>
7463
#define LCD_CLASS LiquidTWI2
7564

7665
#elif ENABLED(LCD_I2C_TYPE_PCA8574)
66+
7767
#include <LiquidCrystal_I2C.h>
7868
#define LCD_CLASS LiquidCrystal_I2C
7969

8070
#elif ENABLED(SR_LCD_2W_NL)
71+
8172
// 2 wire Non-latching LCD SR from:
8273
// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
83-
// extern "C" void __cxa_pure_virtual() { while (1); }
8474
#include <LCD.h>
8575
#include <LiquidCrystal_SR.h>
8676
#define LCD_CLASS LiquidCrystal_SR
77+
8778
#elif ENABLED(SR_LCD_3W_NL)
8879

89-
//NewLiquidCrystal was not working for me, but this worked first try
90-
//https://github.com/mikeshub/SailfishLCD
91-
//uses the code directly from Sailfish
80+
// NewLiquidCrystal didn't work, so this uses
81+
// https://github.com/mikeshub/SailfishLCD
9282

9383
#include <SailfishLCD.h>
9484
#define LCD_CLASS LiquidCrystalSerial
9585

9686
#elif ENABLED(LCM1602)
87+
9788
#include <Wire.h>
9889
#include <LCD.h>
9990
#include <LiquidCrystal_I2C.h>
10091
#define LCD_CLASS LiquidCrystal_I2C
10192

10293
#else
94+
10395
// Standard directly connected LCD implementations
10496
#include <LiquidCrystal.h>
10597
#define LCD_CLASS LiquidCrystal
98+
10699
#endif
107100

108101
#include "../fontutils.h"

Marlin/src/pins/pins.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@
615615
//
616616

617617
#elif MB(ESPRESSIF_ESP32)
618-
619618
#include "esp32/pins_ESP32.h" // ESP32 env:esp32
620619
#elif MB(MRR_ESPA)
621620
#include "esp32/pins_MRR_ESPA.h" // ESP32 env:esp32

buildroot/share/PlatformIO/scripts/common-features-dependencies.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,24 @@ def load_config():
2020
config.read("platformio.ini")
2121
items = config.items('features')
2222
for key in items:
23-
deps = re.sub(',\\s*', '\n', key[1]).strip().split('\n')
24-
if not key[0].upper() in FEATURE_DEPENDENCIES:
25-
FEATURE_DEPENDENCIES[key[0].upper()] = {
23+
ukey = key[0].upper()
24+
if not ukey in FEATURE_DEPENDENCIES:
25+
FEATURE_DEPENDENCIES[ukey] = {
2626
'lib_deps': []
2727
}
28+
deps = re.sub(',\\s*', '\n', key[1]).strip().split('\n')
2829
for dep in deps:
2930
parts = dep.split('=')
3031
name = parts.pop(0)
3132
rest = '='.join(parts)
3233
if name == 'extra_scripts':
33-
FEATURE_DEPENDENCIES[key[0].upper()]['extra_scripts'] = rest
34+
FEATURE_DEPENDENCIES[ukey]['extra_scripts'] = rest
3435
elif name == 'src_filter':
35-
FEATURE_DEPENDENCIES[key[0].upper()]['src_filter'] = rest
36+
FEATURE_DEPENDENCIES[ukey]['src_filter'] = rest
37+
elif name == 'lib_ignore':
38+
FEATURE_DEPENDENCIES[ukey]['lib_ignore'] = rest
3639
else:
37-
FEATURE_DEPENDENCIES[key[0].upper()]['lib_deps'] += [dep]
40+
FEATURE_DEPENDENCIES[ukey]['lib_deps'] += [dep]
3841

3942
def get_all_known_libs():
4043
known_libs = []
@@ -126,7 +129,7 @@ def search_compiler():
126129
# the first path have the compiler
127130
for path in env['ENV']['PATH'].split(';'):
128131
if not re.search(r'platformio\\packages.*\\bin', path):
129-
continue
132+
continue
130133
#print(path)
131134
for file in os.listdir(path):
132135
if file.endswith("g++.exe"):
@@ -172,7 +175,9 @@ def load_marlin_features():
172175

173176
def MarlinFeatureIsEnabled(env, feature):
174177
load_marlin_features()
175-
return feature in env["MARLIN_FEATURES"]
178+
r = re.compile(feature)
179+
matches = list(filter(r.match, env["MARLIN_FEATURES"]))
180+
return len(matches) > 0
176181

177182
# add a method for others scripts to check if a feature is enabled
178183
env.AddMethod(MarlinFeatureIsEnabled)

buildroot/tests/esp32-tests

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ set -e
1111
#
1212
restore_configs
1313
opt_set MOTHERBOARD BOARD_ESPRESSIF_ESP32
14-
opt_enable WIFISUPPORT GCODE_MACROS BAUD_RATE_GCODE M115_GEOMETRY_REPORT REPETIER_GCODE_M360
14+
opt_enable WIFISUPPORT WEBSUPPORT GCODE_MACROS BAUD_RATE_GCODE M115_GEOMETRY_REPORT REPETIER_GCODE_M360
1515
opt_add WIFI_SSID "\"ssid\""
1616
opt_add WIFI_PWD "\"password\""
1717
opt_set TX_BUFFER_SIZE 64
18-
opt_add WEBSUPPORT
1918
exec_test $1 $2 "ESP32 with WIFISUPPORT and WEBSUPPORT"
2019

2120
#

platformio.ini

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,25 @@ lib_deps =
3939
TFT_LVGL_UI = MKS-LittlevGL=https://github.com/makerbase-mks/MKS-LittlevGL/archive/master.zip
4040
src_filter=+<src/lcd/extui/lib/mks_ui>
4141
HAS_TRINAMIC_CONFIG = TMCStepper@~0.7.1
42-
SR_LCD_2W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip
4342
SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip
44-
DIGIPOT_MCP4018 = SlowSoftI2CMaster
45-
DIGIPOT_MCP4451 = SlowSoftI2CMaster
43+
DIGIPOT_MCP4... = SlowSoftI2CMaster
4644
HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip
4745
HAS_L64XX = [email protected]
4846
NEOPIXEL_LED = Adafruit [email protected]
4947
MAX6675_IS_MAX31865 = Adafruit MAX31865 library@~1.1.0
5048
HAS_GRAPHICAL_LCD = [email protected]
5149
src_filter=+<src/lcd/dogm>
52-
50+
USES_LIQUIDCRYSTAL = [email protected]
51+
USES_LIQUIDTWI2 = [email protected]
5352
TOUCH_UI_FTDI_EVE = src_filter=+<src/lcd/extui/lib/ftdi_eve_touch_ui>
5453
HAS_DGUS_LCD = src_filter=+<src/lcd/extui/lib/dgus>
5554
DWIN_CREALITY_LCD = src_filter=+<src/lcd/dwin>
5655
HAS_LCD_MENU = src_filter=+<src/lcd/menu>
56+
(ESP32_)?WIFISUPPORT = AsyncTCP, ESP Async WebServer
57+
ESP3DLib=https://github.com/luc-github/ESP3DLib.git
58+
arduinoWebSockets=https://github.com/Links2004/arduinoWebSockets.git
59+
ESP32SSDP=https://github.com/luc-github/ESP32SSDP.git
60+
lib_ignore=ESPAsyncTCP
5761

5862
#
5963
# Default values apply to all 'env:' prefixed environments
@@ -305,14 +309,11 @@ lib_compat_mode = strict
305309
extra_scripts = ${common.extra_scripts}
306310
Marlin/src/HAL/LPC1768/upload_extra_script.py
307311
src_filter = ${common.default_src_filter} +<src/HAL/LPC1768>
308-
lib_deps = Servo
312+
lib_deps = ${common.lib_deps}
313+
Servo
309314
310-
311-
TMCStepper@~0.7.1
312315
Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/1.5.0.zip
313-
SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip
314316
build_flags = ${common.build_flags} -DU8G_HAL_LINKS -IMarlin/src/HAL/LPC1768/include -IMarlin/src/HAL/LPC1768/u8g
315-
lib_ignore = LiquidTWI2
316317
# debug options for backtrace
317318
#-funwind-tables
318319
#-mpoke-function-name
@@ -360,8 +361,7 @@ build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py
360361
${common.build_flags} -std=gnu++14 -DHAVE_SW_SERIAL
361362
build_unflags = -std=gnu++11
362363
src_filter = ${common.default_src_filter} +<src/HAL/STM32F1>
363-
lib_ignore =
364-
SPI
364+
lib_ignore = SPI
365365
lib_deps = ${common.lib_deps}
366366
SoftwareSerialM
367367

@@ -394,18 +394,10 @@ build_flags = ${common_stm32f1.build_flags}
394394
extra_scripts = ${common.extra_scripts}
395395
pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py
396396
buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py
397-
lib_deps =
398-
TMCStepper@~0.7.1
399-
Adafruit MAX31865 library@~1.1.0
400-
401-
402-
SlowSoftI2CMaster
403-
397+
lib_deps = ${common.lib_deps}
404398
Adafruit NeoPixel=https://github.com/ccccmagicboy/Adafruit_NeoPixel#meeb_3dp_use
405-
SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip
406399
SoftwareSerialM
407400
USBComposite for [email protected]
408-
lib_ignore = SPI
409401
debug_tool = stlink
410402
upload_protocol = dfu
411403

@@ -497,7 +489,6 @@ lib_deps = ${common_stm32f1.lib_deps}
497489
platform = ${common_stm32.platform}
498490
board = disco_f407vg
499491
build_flags = ${common.build_flags} -DUSE_STM32GENERIC -DSTM32GENERIC -DSTM32F4 -DMENU_USB_SERIAL -DMENU_SERIAL=SerialUSB -DHAL_IWDG_MODULE_ENABLED
500-
lib_ignore = Adafruit NeoPixel, TMCStepper
501492
src_filter = ${common.default_src_filter} +<src/HAL/STM32_F4_F7> -<src/HAL/STM32_F4_F7/STM32F7>
502493

503494
#
@@ -507,7 +498,6 @@ src_filter = ${common.default_src_filter} +<src/HAL/STM32_F4_F7> -<src/HAL/ST
507498
platform = ${common_stm32.platform}
508499
board = remram_v1
509500
build_flags = ${common.build_flags} -DUSE_STM32GENERIC -DSTM32GENERIC -DSTM32F7 -DMENU_USB_SERIAL -DMENU_SERIAL=SerialUSB -DHAL_IWDG_MODULE_ENABLED
510-
lib_ignore = Adafruit NeoPixel, TMCStepper
511501
src_filter = ${common.default_src_filter} +<src/HAL/STM32_F4_F7> -<src/HAL/STM32_F4_F7/STM32F4>
512502

513503
#
@@ -549,7 +539,6 @@ build_flags = ${common_stm32f1.build_flags}
549539
build_unflags = ${common_stm32f1.build_unflags}
550540
-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6
551541
lib_ignore = ${common_stm32f1.lib_ignore}
552-
LiquidTWI2
553542

554543
#
555544
# MKS Robin Mini (STM32F103VET6)
@@ -910,13 +899,6 @@ monitor_speed = 500000
910899
911900
board = esp32dev
912901
build_flags = ${common.build_flags} -DCORE_DEBUG_LEVEL=0
913-
lib_deps = ${common.lib_deps}
914-
AsyncTCP=https://github.com/me-no-dev/AsyncTCP/archive/master.zip
915-
ESPAsyncWebServer=https://github.com/me-no-dev/ESPAsyncWebServer/archive/master.zip
916-
ESP3DLib=https://github.com/luc-github/ESP3DLib.git
917-
arduinoWebSockets=https://github.com/Links2004/arduinoWebSockets.git
918-
ESP32SSDP=https://github.com/luc-github/ESP32SSDP.git
919-
lib_ignore = LiquidCrystal, LiquidTWI2, SailfishLCD, ESPAsyncTCP
920902
src_filter = ${common.default_src_filter} +<src/HAL/ESP32>
921903
upload_speed = 115200
922904
#upload_port = marlinesp.local
@@ -928,8 +910,6 @@ upload_speed = 115200
928910
[env:teensy31]
929911
platform = teensy
930912
board = teensy31
931-
lib_deps = ${common.lib_deps}
932-
TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip
933913
src_filter = ${common.default_src_filter} +<src/HAL/TEENSY31_32>
934914

935915
#
@@ -938,8 +918,6 @@ src_filter = ${common.default_src_filter} +<src/HAL/TEENSY31_32>
938918
[env:teensy35]
939919
platform = teensy
940920
board = teensy35
941-
lib_deps = ${common.lib_deps}
942-
TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip
943921
src_filter = ${common.default_src_filter} +<src/HAL/TEENSY35_36>
944922

945923
#
@@ -963,6 +941,4 @@ src_filter = ${common.default_src_filter} +<src/HAL/LINUX>
963941
platform = atmelavr
964942
board = megaatmega2560
965943
build_flags = -c -H -std=gnu++11 -Wall -Os -D__MARLIN_FIRMWARE__
966-
lib_deps = ${common.lib_deps}
967-
TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip
968944
src_filter = +<src/Marlin.cpp>

0 commit comments

Comments
 (0)