stealthylabs / libssd1306

C graphics and device driver library to write to OLED SSD1306 128x64 or 128x32 using I2C
MIT License
20 stars 8 forks source link

Support for scrolling #7

Closed Romonaga closed 1 year ago

Romonaga commented 1 year ago

Thanks for this lib, it is faster and way better than what I cobbled together. However, I noticed it does not have support for scrolling text, something I would like to have.

I have added this myself, while it works, I am not sure I did it correctly as the packets look different than yours.

I followed the logic in ssd1306_i2c_internal_get_cmd_bytes and I added 2 new cmds. Here is an example of one. The only way I would get it to work was by stuffing the Right Scroll command in cmdbuf[0..1] Thank you for considering this request. case SSD1306_I2C_CMD_RIGHT_HORIZONTAL_SCROLL: cmdbuf[0] = 0x26; cmdbuf[1] = 0x26; cmdbuf[2] = 0x00; cmdbuf[3] = 0x00; cmdbuf[4] = data[0]; cmdbuf[5] = 0x0F; cmdbuf[6] = 0x00; cmdbuf[7] = 0Xff; sz = 8; break;

stealthylabs commented 1 year ago

Hi @Romonaga

Thank you for using my library. Happy that it works for you.

I left out scrolling since if you read the datasheet, you can see that the scrolling part is just a bunch of I2C commands that can be sent out using one of the API calls for the I2C. But yes, to perform a scroll you have to send the same command several times to be able to scroll as much as possible.

I have not tested it. Would you be kind enough to send me a diff on your code that you have added. You can attach it to this issue. I can then test it out and see if I can implement scrolling and add it to the library quickly.

Thanks.

Romonaga commented 1 year ago

Here is a pull request that you can see the changes in. Please feel free to reject it once you seen my hack.

https://github.com/stealthylabs/libssd1306/pull/8

stealthylabs commented 1 year ago

Support for scrolling has been added in latest commit 9d62b38ce2ad0ae6dbb4cc7b4f4c39b902fa7cce

stealthylabs commented 1 year ago

The example now shows how to use the 4 types of scrolling correctly. It works on my Raspberry Pi with the SSD1306 OLED chip.

Romonaga commented 1 year ago

Thank you very much, will love to see how to do it correctly now.