wuhanstudio / u8g2-arm-linux

U8g2 for arm linux - a monochrome graphics library
https://github.com/wuhanstudio/u8g2-arm-linux/wiki
Other
51 stars 24 forks source link

Is there a chance this port goes upstream? #5

Closed shlyakpavel closed 3 years ago

shlyakpavel commented 3 years ago

Is there sense in preparing and leaving pull request here? Will it be reviewed and merged?

wuhanstudio commented 3 years ago

Hi, thank you for your interest, this project is alive.

I'm actively making contributions to u8g2. Recently I focus on the port for RT-Thread, and soon I may add C++ wrapper for this arm-linux port.

https://github.com/olikraus/u8g2/pull/1543

shlyakpavel commented 3 years ago

Is there a chance this port goes upstream? There is already linux i2c device support in u8g2, but SPI is still missing. I have added some display support to both this port https://github.com/shlyakpavel/u8g2-arm-linux and upstream https://github.com/olikraus/u8g2/pull/1545 Of course I would use upstream version as it provides updates and a better build system, but I'm not sure I can port your changes there myself

wuhanstudio commented 3 years ago

It would be great if this port goes upstream.

But upstream uses Arduino port by default in cppsrc. We need to change codebuild.c so that C++ wrapper can be generated automatically for the arm-linux port.

https://github.com/olikraus/u8g2/blob/master/tools/codebuild/codebuild.c

I'm trying to generate C++ wrapper for RT-Thread recently, and once it works, I'll try to upstream this repo so that we have both your new display and this port in the upstream.

antiprism commented 3 years ago

For libu8g2arm I generate the C++ wrapper for the Raspberry Pi package generator using the original codebuild.c code, but with some automated amendments. This is easily broken, but has only once required a minor change to account for U8g2 changes.

I am not sure how much of the C++ interface is useful for the Raspberry Pi. I have included all the U8G2 controller setup classes, but mainly to make U8g2 examples more accessible. Also, I generate extra interface code for both C and C++ to make the controllers and fonts available by name at runtime.

Adrian.

wuhanstudio commented 3 years ago

Thank you Adrian, I'm also checking your repo to find a good way to upstream the port for arm-linux.

For some small embedded systems, we may need some extra handling (#define U8G2_USE_HW_SPI) because HW SPI and HW I2C may not be available sometimes.

#if defined U8G2_USE_HW_SPI
class U8X8_SSD1306_128X64_VCOMH0_4W_HW_SPI : public U8X8 {
  public: U8X8_SSD1306_128X64_VCOMH0_4W_HW_SPI(uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
    u8x8_Setup(getU8x8(), u8x8_d_ssd1306_128x64_vcomh0, u8x8_cad_001, u8x8_byte_rt_4wire_hw_spi, u8x8_rt_gpio_and_delay);
    u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
  }
};
#endif

The port for RT-Thread has been merged into upstream. Hope the arm-linux port will be available in near future.

https://github.com/olikraus/u8g2/pull/1543

wuhanstudio commented 3 years ago

Hi, @antiprism @shlyakpavel

I've added C++ wrapper support for u8g2-arm-linux, and this project is now up-to-date with the upstream repo.

Besides, the speed of software GPIO is now much faster by reusing file descriptors.

Is there a chance this port goes upstream? There is already linux i2c device support in u8g2, but SPI is still missing. I have added some display support to both this port https://github.com/shlyakpavel/u8g2-arm-linux and upstream olikraus/u8g2#1545 Of course I would use upstream version as it provides updates and a better build system, but I'm not sure I can port your changes there myself

Now you can test your display on this repo with all the latest features from the upstream repo.

If possible, I'll try to upstream this arm-linux port.

antiprism commented 3 years ago

Hi Han

Just a few notes and comments...

I modified your code in libu8g2arm to make the I2C bus and SPI bus/cs selectable at runtime. This makes it harder to automatically synchronise with any changes you make to your code, and so I disabled the synchronisation during package generation and any future updates I make will be manual.

With newer linux kernels it is possible to configure I2C devices at boot which use different GPIO pins, and these can be accessed with the HW driver rather than having to use the SW driver, if there is support in the software for accessing the particular I2C bus.

I noticed that you added a Print.h for the C++ interface. I originally removed references to this as I did not have a version for the Raspberry Pi. I thought it would be a good idea to add it back in, using the version you have, but I see the licence is LGPL. Any binary that contains LGPL code has to be licensed under the LGPL/GPL, which means that statically linked program binaries may end up needing to be licensed LGPL/GPL. To keep things simple with the licensing, I have decided to continue leaving out the Print.h references.

Adrian.

wuhanstudio commented 3 years ago

Hi, Adrian,

It seems that we share virtually the same csrc and cppsrc folder, the major difference is that you removed Print.h, which comes from the Arduino library, and you removed Arduino related functions while I use ifdef #ARDUINO to ignore them, so that I can keep almost the same file as the upstream, making synchronization easier.

Indeed, it's better to change the device tree to configure the software i2c and SPI, so that the high-level library always sees /dev/i2cx and /dev/spix.x. The reason I add software gpio using sysfs (libgpiod could be a better choice) is to support 8080 mode.

It's really helpful to make the I2C bus and SPI bus/cs selectable at runtime. Perhaps you can consider upstream this feature. Because the upstream uses Arduino as the major port that usually has only one bus. For arm-linux and stm32, it's common to have multiple buses and multiple u8g2 instances.

shlyakpavel commented 3 years ago

Hello, Han

I have added some display support to both this port https://github.com/shlyakpavel/u8g2-arm-linux and upstream olikraus/u8g2#1545

Since my display support is now available in upstream, can you please sync it with this repo? Have a nice day!

wuhanstudio commented 3 years ago

Hello, Han

I have added some display support to both this port https://github.com/shlyakpavel/u8g2-arm-linux and upstream olikraus/u8g2#1545

Since my display support is now available in upstream, can you please sync it with this repo? Have a nice day!

Sure, this repo is now synced with the upstream, and I add a new tool that automatically sync this repo with upstream.

https://github.com/wuhanstudio/u8g2-arm-linux/tree/master/tools

I'll find a time (perhaps Dec./Jan.) to upstream the port, so we have both the port and your display in the upstream.

wuhanstudio commented 3 years ago

Hello, Han

I have added some display support to both this port https://github.com/shlyakpavel/u8g2-arm-linux and upstream olikraus/u8g2#1545

Since my display support is now available in upstream, can you please sync it with this repo? Have a nice day!

Hi, @shlyakpavel

I have created a PR for the arm-linux port, hope you may find it helpful.

https://github.com/olikraus/u8g2/pull/1610

wuhanstudio commented 3 years ago

I'm closing this because the arm-linux port is now available in the upstream repo, and the device lists can be automatically updated using make install under this foler.

https://github.com/olikraus/u8g2/tree/master/sys/arm-linux/tools/codebuild

Besides, I also create a script that automatically synchronize this repo with the upstream using auto_sync.sh:

https://github.com/wuhanstudio/u8g2-arm-linux/tree/master/tools

Thank you all for your help.