Jomelo / LCDMenuLib2

Create a tree menu. Use it with different lcd types / console output / ssh console.
MIT License
249 stars 46 forks source link

Lib compile issue. #85

Closed larryl79 closed 2 years ago

larryl79 commented 2 years ago

example code #vscode #platformio #esp32 devkit

I've edited your LCDML_001_liquidCrystal.ino example for platformio (renamed to main.cpp, and included rest of the files as .h after constructor).

src dir: LCDML_condition.h LCDML_control.h LCDML_display_dynFunction.h LCDML_display_menu.h LCDML_display_menuFunction.h main.cpp

main.cpp (edited part): `// // Objects // LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change) LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows-_LCDML_DSIP_use_header, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control);

include

include

include

include

include

// // LCDML MENU/DISP // `

(for another try I downloaded the latest lib from github, and overwritten in the libs dir. It's same issue) when I try compile, I got error messages for the lib itself only.

In file included from C:\Users\larry\.platformio\lib\LCDMenuLib2\src/LCDMenuLib2.h:183:0, from src\main.cpp:24: src/LCDML_display_menu.h: In function 'void lcdml_menu_display()': C:\Users\larry\.platformio\lib\LCDMenuLib2\src/LCDMenuLib2_macros.h:118:29: error: 'g_LCDML_DISP_lang_lcdml_table' was not declared in this scope strcpy(var, g_LCDML_DISP_lang_ ## lang ## _table[id]); \ ^ C:\Users\larry\.platformio\lib\LCDMenuLib2\src/LCDMenuLib2_macros.h:138:9: note: in expansion of macro 'LCDML_getCustomContent' LCDML_getCustomContent(lcdml, var, id) ^ src/LCDML_display_menu.h:50:9: note: in expansion of macro 'LCDML_getContent' LCDML_getContent(content_text, LCDML.MENU_getParentID()); ^ C:\Users\larry\.platformio\lib\LCDMenuLib2\src/LCDMenuLib2_macros.h:118:29: error: 'g_LCDML_DISP_lang_lcdml_table' was not declared in this scope strcpy(var, g_LCDML_DISP_lang_ ## lang ## _table[id]); \ ^ C:\Users\larry\.platformio\lib\LCDMenuLib2\src/LCDMenuLib2_macros.h:138:9: note: in expansion of macro 'LCDML_getCustomContent' LCDML_getCustomContent(lcdml, var, id) ^ src/LCDML_display_menu.h:69:13: note: in expansion of macro 'LCDML_getContent' LCDML_getContent(content_text, tmp->getID()); ^ *** [.pio\build\esp32doit-devkit-v1\src\main.cpp.o] Error 1

larryl79 commented 2 years ago

Solution !!!!

extern char* g_LCDML_DISP_lang_lcdml_table[254];

into a right place in the example code:

`// ============================================================ // Example: LCDML_serialmonitor // ============================================================

[...]

//#define _LCDML_cfg_use_ram

// // includes //

include

include

extern char* g_LCDML_DISP_lang_lcdml_table[254];

// U8g2lib

include

// #include // #include

ifdef U8X8_HAVE_HW_SPI

include

endif

ifdef U8X8_HAVE_HW_I2C

include

endif

// // U8GLIB // // U8g2 Constructor List (Frame Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, / CS=/ 53, / reset=/ U8X8_PIN_NONE); // (MEGA, ... //U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, / CS=/ 12, / reset=/ U8X8_PIN_NONE); // (Uno and co U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, / clock=/ 25, / data= /R/w / 33, / CS=/ 32, / reset= / U8X8_PIN_NONE ); // ESP32

// settings for u8g lib and LCD

define _LCDML_DISP_w 128 // LCD width

define _LCDML_DISP_h 64 // LCD height

// font settings

define _LCDML_DISP_font u8g2_font_squeezed_r7_tr // u8g_font_6x13 // u8glib font (more fonts under u8g.h line 1520 ...)

define _LCDML_DISP_font_w 7 // font width

define _LCDML_DISP_font_h 8 // font height

// cursor settings

define _LCDML_DISP_cursor_char ">" // cursor char

define _LCDML_DISP_cur_space_before 2 // cursor space between

define _LCDML_DISP_cur_space_behind 4 // cursor space between

// menu position and size

define _LCDML_DISP_box_x0 0 // start point (x0, y0)

define _LCDML_DISP_box_y0 0 // start point (x0, y0)

define _LCDML_DISP_box_x1 128 // width x (x0 + width)

define _LCDML_DISP_box_y1 64 // hight y (y0 + height)

define _LCDML_DISP_draw_frame 1 // draw a box around the menu

// scrollbar width

define _LCDML_DISP_scrollbar_w 6 // scrollbar width (if this value is < 3, the scrollbar is disabled)

// nothing change here

define _LCDML_DISP_cols_max ((_LCDML_DISP_box_x1-_LCDML_DISP_box_x0)/_LCDML_DISP_font_w)

define _LCDML_DISP_rows_max ((_LCDML_DISP_box_y1-_LCDML_DISP_box_y0-((_LCDML_DISP_box_y1-_LCDML_DISP_box_y0)/_LCDML_DISP_font_h))/_LCDML_DISP_font_h)

// rows and cols // when you use more rows or cols as allowed change in LCDMenuLib.h the define "_LCDML_DISP_cfg_max_rows" and "_LCDML_DISP_cfg_max_string_length" // the program needs more ram with this changes

define _LCDML_DISP_rows _LCDML_DISP_rows_max // max rows

define _LCDML_DISP_cols 20 // max cols

// // Prototypes // void lcdml_menu_display(); void lcdml_menu_clear(); void lcdml_menu_control();

// // Objects // LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL); // root menu element (do not change) LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control);

include

include

include

include

include

// // LCDML MENU/DISP // // LCDML_0 => layer 0 // LCDML_0_X => layer 1 // LCDML_0_X_X => layer 2 // LCDML_0_X_X_X => layer 3 // LCDML0... => layer ...

// For beginners // LCDML_add(id, prev_layer, new_num, lang_char_array, callback_function)

[...] `