After I got very very good support from you guys and ChibiOS itself, I'd like to give something back in return
I am currently working on a complete library for GLCDs and Touchpads. I developed it with a 3.2" 320x240 pixel TFT with a SSD1289 controller. The touchpad controller is a ADS7843.
It's the well known HY32 module from waveshare (16$ at ebay).
Sadly the GLCD library does only support direct GPIO 16 lines connection to the LCD yet, but SPI should be implementable easily, since you only need to change 3 __inline lowlevel functions.
The GLCD does support all four modes (portrait, landscape, portrait-inverted, landscape-inverted). Also, when you read the current touchpad coordinates using tpReadX() and tpReadY(), the coordinates you'll get are relative to the current screen zero-point (GLCD zero point is always in the upper left corner in each mode). This means, that you can simply do things like: lcdDrawPixel(tpReadX(), tpReadY(), Green); without needing to calculate touchpad-to-LCD offsets in each mode.
The touchpad does run in 12-bit mode. There's also a calibration mode which works great and very accurate (I can draw pixel-vise here). You do need to do a calibration every reset, because it dosen't store the calibrationvalues in the flash yet.
Besides the standard GLCD and touchpad features, I started to build a GUI on top of it.
The guiDrawButton() function draws a button at the given coordinates with the given size with the given button color, writes a string into the middle of it with the given font color, creates a thread which does set the variable to 1 if you touch inside the button area and set's it to 0 otherwise. This allows to make very easy user interfaces
For example, you can write in your main program:
Code: Select all
static msg_t Thread2(void *arg) {
uint8_t startState = 0, stopState = 0;
guiDrawButton(10, 10, 100, 100, "START", Black, Green, &startState);
guiDrawButton(10, 110, 100, 200, "STOP", Black, Red, &stopState);
while(TRUE) {
if(startState)
palSetPad(GPIOD, GPIOD_LED2);
if(stopState)
palClearPad(GPIOD, GPIOD_LED2);
}
}
Besides the GUI, I made a function which draws a 2D graphs. You just have to pass a two dimensional array, containing X and Y coordinates which get drawn as points, or connected with lines.
Here are two pictures:
Code used in the pictures:
Code: Select all
uint16_t coord[][2] = {{0,0}, {50,50}, {75,50}, {150,120}, {185,120}, {195,40},{220,40},{260, 0}};
graphDrawSystem(20, lcdGetWidth()-20, lcdGetHeight()-20, 20, Yellow); // draw the yellow arrows with the grid
graphDrawNet(coord, sizeof(coord)/sizeof(coord[0]), 2, Red, Green); // draw the points with green dots, radius 2 pixels
My library contains the following files:
- glcd.c / glcd.h
fonts.c / fonts.h
touchpad.c / touchpad.h
gui.c / gui.h
graph.c / graph.h
You can find the complete library here: https://github.com/Tectu/ChibiOS-LCD-Driver
Of course there is still much much much work to do, but I hope that someone can use this already.
The library does also lack of documentation, but i guess that 99% of the functions are very self explanatory.
Please just ask if you want to know anything more.
I am open for any kind of optimizations
~ Tectu