Adding USB support to a barebone microcontroller project
When I asked the potential users of the frequency counter I am working on their advice on the design, most of them wrote to me that they actually would...
One of the very exciting possibilities when using an MCU is driving an LCD, OLED or TFT display module. In the recent years, the industry has produced a growing kind of modules:
Narrow with 0.49″ OLED
So there really is nothing more attractive than adding one of these modules to a project. One downside is that most MCUs were not conceived for this highly memory consuming application. But, fortunately the Atmega644 and Atmeg1284 are the 8 bits high end devices offering a sizeable quantity of memory, and thus are appropriate to drive such colour displays up to 240×240 pixels and more.
In this tutorial, we will present 3 possible implementations.
The problem of using such displays can be broken down into
Usually I2C lines will be connected to hardware I2C pins of the MCU but software I2C might also be used. If the display is not powered at the same voltage as the MCU/Board, it might be necessary to add a level shifter. See https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide/all
You will need a specific driver to communicate with the graphic chip implemented on the module. Most modules are using the same chips but you will need to check it on the product description or the datasheet. In the next examples the TFT module is driven by an ST7789 chip and the OLED is driven by an SSD1306 chip.
You will probably find an appropriate driver on github.com
Then you will need a library that exposes a graphic class to allow you to print things easily with commands like
tft.print(“The text I always wanted to print”)
Some libraries will include the driver and the graphic class all in one.
Following the theory exposed above:
You should get this
Here we will use a 0.49″ 64×32 OLED soldered on the Narrow board. So you don’t have to worry about the physical connection to the board.
You should get this
In this example we will show the memory capabilities of Narrow boards. Since Arduino arrays can’t be bigger than 32 KB, we have prepared this bitmap that stores on a little more than 31 KB of flash. It was saved in .bmp 16 bits “R5 G6 B5” format and transformed into an array of 16 bits hexadecimal data with the software https://www.riuson.com/lcd-image-converter. The array was saved in the file “bitmap.h” referenced in the script.
This sketch uses an optimised driver and the Adafruit GFX graphics class. So you will need to
You should get this
You can see how fast the image is displayed. The smooth scrolling is because the library exploits the hardware scrolling capabilities. There isn’t any data sent from the MCU while scrolling.
Hi there, You’ve performed an excellent job. I抣l certainly digg it and in my opinion recommend to my friends. I’m confident they’ll be benefited from this web site.