-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace u8glib with u8g2 #2184
Replace u8glib with u8g2 #2184
Conversation
app/include/u8g2_fonts.h
Outdated
// | ||
// Add a U8G2_FONT_TABLE_ENTRY for each font you want to compile into the image | ||
#define U8G2_FONT_TABLE \ | ||
U8G2_FONT_TABLE_ENTRY(font_6x10_tf) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add something like the below. This allows you to define the extra fonts that you want and include them in your config that is included everywhere (or via -include on the command line). This means that this file then doesn't need to be modified to choose fonts.
#ifndef U8G_FONT_TABLE_EXTRA
#define U8G_FONT_TABLE_EXTRA
#endif
#define U8G_FONT_TABLE_ENTRY(font)
#define U8G_FONT_TABLE \
U8G_FONT_TABLE_ENTRY(font_6x10) \
U8G_FONT_TABLE_EXTRA \
U8G_FONT_TABLE_ENTRY(font_chikita)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, seams to work.
Looks good to me..... |
Works well for me, but we should consider using https://github.com/pasko-zh/brzo_i2c. I did a quick POC and the difference is huge. My POC uses a hack to buffer bytes as u8g2 was splitting command into multiple calls of U8X8_MSG_BYTE_SEND and brzo_i2c_write stops transmission in the call, so I had to buffer data and send it in U8X8_MSG_BYTE_END_TRANSFER. I think the proper solution would be to modify brzo_i2c_write and move stop to brzo_i2c_end_transaction then replace original platform_i2c with support for FAST and FASTPLUS. This change most likely will be separate PR. |
@pjsg I extended your proposal also to the display drivers. You can now overload all config defines from an externally included file. @elektro255 thanks for the link to optimized i2c driver. I'd suggest to handle this in a separate issue. |
Yep, indeed. I don't have time for this atm, sorry. The submoduling stuff also means changing the cloud builder build script and the Docker build image. Those changes would be trivial and not time-consuming, though. Our |
Is there anything I can do to support getting this merged? |
Note that the license for the https://github.com/pasko-zh/brzo_i2c code is incompatible with the nodemcu license -- so this is a non-starter. |
Can anyone verify if u8g2 works in combination with spi? With i2c a connected display works correctly. My bad: I did not set the spi-master as first parameter. This seems to differ from current u8g and ucg implementations. @devsaurus time to merge? |
@FrankX0 my SPI display works well for me with the code in this branch. -- Hardware SPI CLK = GPIO14
-- Hardware SPI MOSI = GPIO13
-- Hardware SPI MISO = GPIO12 (not used)
-- Hardware SPI /CS = GPIO15 (not used)
-- CS, D/C, and RES can be assigned freely to available GPIOs
local cs = 8 -- GPIO15, pull-down 10k to GND
local dc = 4 -- GPIO2
local res = 0 -- GPIO16
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 8)
-- we won't be using the HSPI /CS line, so disable it again
gpio.mode(8, gpio.INPUT, gpio.PULLUP)
disp = u8g2.ssd1306_128x64_noname(1, cs, dc, res) |
@devsaurus I indeed did not put the SPI id as first parameter. |
Triggered by Philip's comment about the Brzo I2C license I checked the U8g2 license. The library/repository doesn't declare any license at all but several files carry a "GPL" or "GPL v2" license header. Do we need to ask Oli to clarify this first (and ask for a more permissive license)? Apart from that if people are willing to break the cloud builder and the Docker build image with this change than I guess this is ready for merging. I'm biased of course 😉and won't judge. Ideally I'd get PRs for U8g2-support in those projects (maintaining backwards compatibility) beforehand, though. |
Well, there's https://github.com/olikraus/u8g2/blob/master/LICENSE stating
Reading the full content I get the impression that we just need to add the copyright notice in the U8g2lib API chapter to cover both redistribution of source code and in binary form. Right?
Which artifacts exactly would need a change? I identified the |
Ouch, quite embarrassing that I missed the most obvious file, sorry 🤦♂️ I believe your assessment regarding the licensing constraints is correct.
I haven't checked whether we'd need additional tools at https://github.com/marcelstoer/docker-nodemcu-build/blob/master/Dockerfile#L11. If not then the Docker build is probably safe. As for the cloud builder the scripts you identified are the only ones affected AFAICT. I'm a little concerned about the font list, though. I can pull all images from the wiki repo (displayed at https://github.com/olikraus/u8g2/wiki/fntlistall) but I seriously hope the available fonts are more or less the same so that I don't have to adjust the HTML and PHP for the front end. |
I've been reviewing this because of my plans to include a compression / decompression library in NodeMCU and here are a couple of useful summaries that I came across (1), (2). I know that this has been raised before, so we should have a consistent policy on this. IMO the td;dr is that both are permissive licences, so the issues are limited, but our project MIT license allows for distribution without contribution credits, whereas BSD doesn't. So as far as I can see it, so long as we keep the BSD libraries in their own folders, and these contain the correct folder-based licence and attribution, then we should be OK, so long as we keep the This being said, I see that we already have BSD code in our distro: the tsl2561 library, the switec driver, and the tcs34725 module, plus some code in our |
Makefile Changes
Using submodules will break most
|
I finally found time to update the PR:
|
@TerryE regarding your inputs on submoduling u8g2lib. Having u8g2 as git submodule is not a prerequisite for integration, of course. It's just to get rid of verbatim source copies and avoid yet another binary blob sync mechanism similar to the SDK. |
I can not get this library to work with WEMOS OLED Shield 64x48
Section of code: -- setup I2c and connect display |
First of all: this pull request has been closed. For actual (firmware) issues please open a new defect. But judging from the response ( |
Dear Team, I believe that your intentions are good, but the new u8G2 just F***C everything I did in a half a year... I've been using @marcelstoer cloud base builder for 2 years and was very happy and grateful indeed until yesterday night... I've added some Json functionality to my project and, as always, headed to cloud based tool for a built. Downloaded it, flashed and crashed... Spent all day long to realise that it's not me stupid - it's your dirty games :) Uff, sooo mad. Can you, please, provide at least simplest example how to use this u8g2 with lua - now it crashes every time even if I only declare display like this: |
|
@nwf - thank you very much for the answer and sorry, do not want to insult anyone - I appreciate your contribution to the community and pretty sure a lot of us will benefit from your input.
init_display() ets Jan 8 2013,rst cause:2, boot mode:(3,6) load 0x40100000, len 26876, room 16 under function init_display() is this code: function init_display()
|
It seems the crashing is caused by not or (in your case) incorrectly setting an (initial) font. Furthermore you might want to clear the display buffer first, and updating the display by sending the buffer.
Hope this helps. |
Thanks, @FrankX0! It helped indeed! Share your Paypal address - will buy you a beer! |
@FrankX0 , how does one check to see if u8g2 is in the firmware build? I used the NodeMcu custom build site, and following the build it said u8g2 was included. Where would I find u8g2_displays.h file, or verify that it included #define U8G2_DISPLAY_TABLE_I2C ? |
Thanks for the reply, @FrankX0. That's what I was assuming. I did select the u8g2 module and the ssd1306 i2c display, so any idea why I get the 'ssd1306_i2c_128x64_noname' (a nil value) |
I've never been a big fan of mysterious cures, but I requested a new build, reflashed, and now it works. Ain't life grand! |
Fixes #1904.
dev
branch rather than formaster
.docs/en/*
.This PR replaces u8glib with u8g2 for reasons that
Lua developers need to update their scripts:
u8g
tou8g2
module with different display constructors (ref u8g2 module docs)Upstream u8g2 source is included as a git submodule. As a side effect firmware developers need to consider these points to avoid pitfalls:
git submodule update --init
after pullingdev
once after this PR is mergedgit clone --recurse-submodules
when starting from scratchThis is of course not specific to u8g2. It's more a strategic question of whether we continue with verbatim copies of upstream code or include them as submodules.
Last but not least, the configuration files changed a bit compared to former u8g integration - I expect that the cloud build service needs to be adapted to provide equivalent support for display and font selection.