Q: u8g2 lib ported to chibiOS - anybody already started?

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general.
robert_o
Posts: 36
Joined: Fri Feb 17, 2017 11:25 pm
Has thanked: 1 time
Been thanked: 4 times

Q: u8g2 lib ported to chibiOS - anybody already started?

Postby robert_o » Mon Jan 15, 2018 1:27 pm

While i am aware of uGFX (in fact i already worked with it and written some drivers) i thought it would be a good idea to have support for u8g2 lib as well. Does anybody have some implementation working an help me get started. I was thinking of taking the c-source an implementing ChibiOS HAL for the callbacks.
Any information would be appreciated.
Thank you,
Robert

User avatar
tfAteba
Posts: 510
Joined: Fri Oct 16, 2015 11:03 pm
Location: Chartres, France
Has thanked: 75 times
Been thanked: 44 times

Re: Q: u8g2 lib ported to chibiOS - anybody already started?

Postby tfAteba » Tue Jan 16, 2018 10:38 pm

Hi Robert,

I'm not aware of the u8g2 lib, it looks interresting. I will have a close look, because two or tree years ago I started to write a driver to support an oLED LCD with SSD1306 controller. I will try to see if there is more support that what I did.

You can take a look to this topic also, that will give you the link to my git repository if you want to take a look to my code :)

Have fun: http://www.chibios.com/forum/viewtopic.php?f=16&t=4434
regards,

Theo.

robert_o
Posts: 36
Joined: Fri Feb 17, 2017 11:25 pm
Has thanked: 1 time
Been thanked: 4 times

Re: Q: u8g2 lib ported to chibiOS - anybody already started?

Postby robert_o » Wed Jan 17, 2018 9:18 am

Thank you.
I started with porting by making the following steps:

.) made chibios176/u8g2 folder plus u8g2.mk
.) copied all of u8g2/csrc to u8g2/src
.) made new file src/ch_hal.c and ch_hal.h
.) in main.c:
#include "src/ch_hal.h"
u8g2_t u8g2; //global var for display
u8g2_Setup_ssd1306_128x64_noname_f(
&u8g2,
U8G2_R0,
u8g2_ch_spi_byte_cb,
u8g2_ch_gpio_and_delay_cb); // init u8g2 structure
u8g2_InitDisplay(&u8g2); // send init sequence to the display, display is in sleep mode after this,
u8g2_SetPowerSave(&u8g2, 0); // wake up display
u8g2_ClearBuffer(&u8g2);
u8g2_DrawBox(&u8g2, 10,20, 20, 30);
u8g2_SetFont(&u8g2, u8g2_font_ncenB14_tr);
u8g2_DrawStr(&u8g2, 0,15,"Hello World!");
u8g2_SendBuffer(&u8g2);
.) in ch_hal.c:
uint8_t u8g2_ch_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
uint8_t u8g2_ch_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
.) in Makefile include:
include ./u8g2/u8g2.mk
$(U8G2SRC)
$(U8G2INC)

the work is now in ch_hal.c/h where all the os specific delay, io and spi callbacks are.

I made this on a vanilla nucleo 401 project with added shell. It compiles fine for now but, as mentioned, the work is starting now.
As an attachment are the files i made for now.
Attachments
src.zip
(5.93 KiB) Downloaded 12 times

User avatar
tfAteba
Posts: 510
Joined: Fri Oct 16, 2015 11:03 pm
Location: Chartres, France
Has thanked: 75 times
Been thanked: 44 times

Re: Q: u8g2 lib ported to chibiOS - anybody already started?

Postby tfAteba » Wed Jan 17, 2018 9:09 pm

Hi Robert,

Good job :) , I wander why you have use ch_hal.h and ch_hal.c for the work you did with the library.

I will be interrested on this if the support of the I2C is added. This is the interface used on my LCD.

Also, you can take a look on how some third party such as "fatfs" and "lwip" are added into ChibiOS project. I think you can do the same thing with you library.
regards,

Theo.

robert_o
Posts: 36
Joined: Fri Feb 17, 2017 11:25 pm
Has thanked: 1 time
Been thanked: 4 times

Re: Q: u8g2 lib ported to chibiOS - anybody already started?

Postby robert_o » Wed Jan 17, 2018 10:05 pm

I made ch_hal.c/h as abstraction layer between u8g2 library and chibios. You need this according to https://github.com/olikraus/u8g2/wiki/Porting-to-new-MCU-platform.
I that file you need to fill in the function for pin set/reset, delay and hardware interfaces like SPI and I2C.
Tomorrow i can borrow an SPI Display (Nokia 5110) and i can continue. Unfortunately i don't have an i2c display but maybe you can add the functions as soon as i have a working library. with the project i have started it should be quite easy.
cheers,
robert

User avatar
tfAteba
Posts: 510
Joined: Fri Oct 16, 2015 11:03 pm
Location: Chartres, France
Has thanked: 75 times
Been thanked: 44 times

Re: Q: u8g2 lib ported to chibiOS - anybody already started?

Postby tfAteba » Wed Jan 17, 2018 10:50 pm

Interesting, I also have an old Nokia 5110 spi lcd, so I will be happy to test you work when you will finish.

If necessary, I will also add I2C support at the right time.

Thanks.
regards,

Theo.


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 1 guest