To use our beautiful ILi9325 display with ProxyLCD we need to manually edit settings.ini. This is not a good way:) Why is that? Because we cannot set a proper size. We are using a selector with predefined values. We need to change it to two text fields.
And we need the formatters, what is that you may ask? You shall see 🙂
It took some time but finally, we can exclude GfxLCD package from The Doton project. After this, we may focus on the next stage of Doton project.
But back to now:) We need to create a new package and publish it on the PyPi.
pip install gfxlcd
GfxLCD on PyPi
Old code, before module extraction, is under tag before-split. This way old posts still have some sense:)
Yey, another day with LCD. This time an OLED 0.96″ display with an SSD1306 chipset. Like with previous display, we will focus on learning how this works, how to initialize LCD and how to display something.
My OLED is a popular display, you can see it everywhere. It exists in a few variants most popular are with i2c bus or with SPI interface. It also varies in size, from 64×32 to 128×64.
My unit is 128×64 with SPI on the SSD1306 chipset. There are some fakes with an SH1106, almost same but with 132 pixels in width.
Now it is fascinating, this screen is twice bigger in the pixels that the one with NJU! And is much smaller! Woot technology.
I have chosen this LCD because it has SPI interface and OLED technology.
Before we do a restart and focus on creating GfxLCD module we need to know something more about other graphical displays. I have two more, one is monochrome 122×32 on NJU6450 chipset and second is OLED 0.96″ on SSD1306.
This time we gonna run NJU6450.
Why we need to know more? Because we will create a main gfx class and it’s drivers for different LCDs. And we should know biggest differences so we can be prepared for them. Like TFT is a color display but NJU is monochrome, so what to do with colors? How to do a conversion?
But before we answer those question let’s wire it and do a simple drawing.
We can draw lines and rectangles so next step should be filling rectangle areas. We will write a function to fill rectangle defined by given points. This will give us some info about performance.
And we will add drawing a circle and an arc.
Source @ GitHub
We can draw pixels so let move further and write an algorithm for drawing a line. We could use loop and draw_pixel for it but this would be very inefficient. Remember that we operate in selected area so using pixel would first select a 1×1 area and then set a color. Two operations for each point in the line.
So this is it. A start of a long road to the main control node. It needs output (display) and input(touch). I was thinking about using a ready-solution, hook shield to a RPi and do some web based GUI. But the web it is my daily work – so no! It must be something different. And I want to use Python!
So lets get to work and do some first drawing. My screen is 2.4″ TFT 240×320 v2.1 – this display has an ILI9325 controller for an LCD and AD7843 for touch. And it is GPIO only version without SPI (ok it has SPI for touch) but it may work in 8-bit mode (it has 16 data pins – we will use only 8).
We will start with dirty code and one goal in mind. Display something 🙂 Later we will do the same thing as with CharLCD – separate driver logic and wiring from the main class.