nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32
https://nodemcu.readthedocs.io
MIT License
7.65k stars 3.12k forks source link

u8g -> u8g2 #1904

Closed joysfera closed 6 years ago

joysfera commented 7 years ago

Missing feature

Please consider replacing the u8g module with u8g2

Justification

The u8g is good for MCU with less than 512 bytes of RAM only, IMHO. ESP8266 has 100 times more RAM. The u8g requires unfamiliar and slow paging - four calls just for updating even so small diplays like Nokia 5110 with just 84 bytes of video RAM. This is ridiculous. ESP8266 can dedicate few hundred bytes for a video RAM easily thus u8g2 is totally appropriate and is far more straightforward to use, IMHO.

Workarounds

None.

devsaurus commented 7 years ago

Switching to u8g2 library would be the proper evolution step, also since upstream development of u8g (almost) stopped. Though I'm not planning to look into this in the near future. Any takers?

joysfera commented 7 years ago

How much work is involved? Is there any HOWTO for making NodeMCU modules from existing Arduino libraries?

devsaurus commented 7 years ago

Is there any HOWTO for making NodeMCU modules from existing Arduino libraries?

None that I am aware of, but there's a lot of information in Porting to new MCU platform.

A rough outline of the workpackages, not necessarily in correct order:

pjsg commented 7 years ago

Is there any progress? I'm looking to add a new driver and it makes more sense to do it for u8g2....

devsaurus commented 7 years ago

I'm currently checking the feasibility to have u8g2 integrated in both esp8266 and esp32. Should take me a few days to come up with a first short in the esp32 realm. Then copy&paste to esp8266.

Would vote to include the source tree as a git submodule for esp8266 as well.

pjsg commented 7 years ago

I'm agnostic as to a submodule / copies. In the latter case, we should provide a script that does the copying. I did this for the spiffs code... This makes it fairly easy to update. The one difficult file is the configuration which may have to be edited by hand.

pjsg commented 7 years ago

Also see https://github.com/nkolban/esp32-snippets/tree/master/hardware/displays/U8G2 for a port to ESP-IDF

devsaurus commented 7 years ago

A prototype integration of u8g2 for the esp32 firmware is available at https://github.com/devsaurus/nodemcu-firmware/tree/dev-esp32-u8g2. It needs some polishing and I'll add docs during the next days (see graphics_test.lua for basic usage).

Porting this back to the esp8266 firmware should just require a specific implementation of the platform hal code. And a viable solution how to share code between the platforms.

pastukhov commented 7 years ago

I can't compile

pastukhov@pastukhov-Latitude-E5450:~/build/nodemcu/nodemcu-firmware-devsaurus$ make
CC u8g2.o
/home/pastukhov/build/nodemcu/nodemcu-firmware-devsaurus/components/modules/./u8g2.c:7:18: fatal error: u8g2.h: No such file or directory
compilation terminated.
/home/pastukhov/esp/esp-idf/make/component_wrapper.mk:176: ошибка выполнения рецепта для цели «u8g2.o»
make[1]: *** [u8g2.o] Ошибка 1
/home/pastukhov/esp/esp-idf/make/project.mk:386: ошибка выполнения рецепта для цели «modules-build»
make: *** [modules-build] Ошибка 2
devsaurus commented 7 years ago

The u8g2 code is included as a git submodule. You're probably missing a git submodule init --recursive. That should pull the upstream release.

pastukhov commented 7 years ago

Thanks It is compiled with git submodule update --init --recursive

pastukhov commented 7 years ago

Working with SSD1306 SPI and u8g2.ssd1306_128x64_noname driver!

v1993 commented 6 years ago

Any progress?

devsaurus commented 6 years ago

I'll have a look at porting the ESP32 integration over to the ESP8266 firmware. It's more a matter of available time than feasibility.

devsaurus commented 6 years ago

There's a functional version at https://github.com/devsaurus/nodemcu-firmware/tree/u8g2_port Need to review the docs again and re-check submodule within the build system.

joysfera commented 6 years ago

I'm going to give it a try ASAP, thank you!

joysfera commented 6 years ago

I have cloned your repository, the u8g2_port branch, ran docker command and got this error:

In file included from u8x8_nodemcu_hal.c:8:0:
u8x8_nodemcu_hal.h:5:18: fatal error: u8g2.h: No such file or directory
 #include "u8g2.h"
                  ^
compilation terminated.

"u8g2.h" is nowhere in the repository, AFAICS.

Any idea what I have done wrong? Thanks!

EDIT: I see! --recurse-submodules helps git cloning a lot! :-)

joysfera commented 6 years ago

Hmm, malloc is missing? How could I fix that?

u8g2lib/.output/eagle/debug/lib/u8g2lib.a(u8x8_d_fbrle.o):(.text.u8x8_d_overlay+0x0): undefined reference to `malloc'
u8g2lib/.output/eagle/debug/lib/u8g2lib.a(u8x8_d_fbrle.o):(.text.u8x8_d_overlay+0x4): undefined reference to `free'
u8g2lib/.output/eagle/debug/lib/u8g2lib.a(u8x8_d_fbrle.o): In function `u8x8_d_fbrle':
/opt/nodemcu-firmware/app/u8g2lib/u8x8_d_fbrle.c:90: undefined reference to `malloc'
/opt/nodemcu-firmware/app/u8g2lib/u8x8_d_fbrle.c:143: undefined reference to `free'
collect2: error: ld returned 1 exit status
../Makefile:339: recipe for target '.output/eagle/debug/image/eagle.app.v6.out' failed
devsaurus commented 6 years ago

Hmm, malloc is missing?

Strange, didn't fail for me. But that needs to be c_malloc, included from c_stdlib.h.

joysfera commented 6 years ago

what does that mean? Should I go ahead and replace malloc with c_malloc in u8g2lib?

devsaurus commented 6 years ago

Yes, in app/u8g2lib/u8x8_d_fbrle.c replace malloc with c_malloc, free with c_free and stdlib.h with c_stdlib.h. That should do the trick. I'll check tonight why I haven't seen it in my build environment.

joysfera commented 6 years ago

That helped, thanks. Going to flash the firmware, test it a bit and report back.

devsaurus commented 6 years ago

Thanks for your feedback, that slipped through... It's also fixed in my branch now.

joysfera commented 6 years ago

@devsaurus works great, thank you! This is a great addition to NodeMCU@ESP8266.

joysfera commented 6 years ago

hmmm, drawStr() doesn't seem to be coping yet. Will have to double check if fonts are indeed included. My fault, this works OK:

disp:setFont(u8g2.font_6x10_tf)
disp:drawStr(10,10,"AAAA")

I'm really excited and looking forward to start using it. The u8g's paging was pain to use, this will be so much better!

devsaurus commented 6 years ago

Yes, u8g2 is much cleaner. Thanks for test driving the port! I'll prepare a PR soon.

v1993 commented 6 years ago

I'm trying to test u8g2 module on esp32, I've enabled it in make menuconfig, but require 'u8g2' fails, and no global u8g2 aviable. What is wrong?

devsaurus commented 6 years ago

Closing, PR was merged into dev.