When I searched for a library to handle the ST7735 display in the project, every link in Google pointed to stm32-st7735. The library itself is simple and easy to use, and it has this nice function in its API (slightly modified example from the author’s blog):
ST7735_WriteString(0, 0, "Hello World", Font_7x10, ST7735_RED, ST7735_BLACK);
This method sets the initial position, text to display, font, and colors, making it easy to display some data and get things started. However, later on, it's easy but not really good:
- Fonts are hardcoded in the library: Changing the font requires modifying the library itself. I'm not a big fan of this because it usually means that either I’m doing something wrong, or the library has limitations.
- PC simulation problems: I plan to have various layouts to display data and allow the user to configure the device. Constantly flashing the device to test layout changes takes time, so a PC simulation would be great. However, the binding of high-level logic and SPI data-sending (the chip driving the display is quite complicated IMHO) makes it tough. One option would be writing an SPI HAL driver (the one generated from CubeMX) mock to extract data, but that’s a complex task.
Fortunately, the library also includes this method:
void ST7735_DrawImage(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint16_t *data);
With this method, font rendering can be managed directly in the user code and passed through ST7735_DrawImage, so the library doesn’t need to know about it, it just do it's work to ONLY send the buffer to the display's chip.
No high level logic not related to being a driver library. For a PC simulation, the entire library can be mocked, making the extraction of display data easy. I have the *data with the pixel content and x and y with the position I can just store this and then present it in my app (see the screenshot in the project description).
Even more, yesterday I found another library (ironically with the same name) for handling this display. It also has a similar method but is written in a much cleaner way. I’ll use it instead but the idea stay the same.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.