2020-08-02 13:51:47 +00:00
|
|
|
#ifndef uint8
|
|
|
|
#define uint8 unsigned char
|
|
|
|
#endif
|
|
|
|
|
2021-03-24 15:29:48 +00:00
|
|
|
#ifndef uint16
|
|
|
|
#define uint16 unsigned short
|
|
|
|
#endif
|
|
|
|
|
2020-08-02 13:51:47 +00:00
|
|
|
#ifndef __SPILCD_H__
|
|
|
|
#define __SPILCD_H__
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int channel;
|
|
|
|
int cs, a0, rs;
|
2021-03-24 15:29:48 +00:00
|
|
|
uint16 width, height;
|
2020-08-02 13:51:47 +00:00
|
|
|
} lcd_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the display.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* spiSpeed - Speed of the SPI interface.
|
|
|
|
* channel - SPI channel
|
|
|
|
* cs - Chip selection pin.
|
|
|
|
* a0 - Data/Command pin.
|
|
|
|
* rs - Optional reset pin. Use -1 when not connected.
|
|
|
|
*
|
|
|
|
* Return: Pointer to the structure with display data.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
lcd_t *lcd_init(int spiSpeed, int channel, int cs, int a0, int rs);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the specified display and clear the previously assigned memory.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* lcd - display to use
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*/
|
|
|
|
void lcd_deinit(lcd_t *lcd);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the drawing area.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* lcd - display to use
|
|
|
|
* x1 - The X parameter of the starting point.
|
|
|
|
* y1 - The Y parameter of the starting point.
|
|
|
|
* x2 - The X parameter of the ending point.
|
|
|
|
* y2 - The Y parameter of the ending point.
|
|
|
|
*
|
|
|
|
* Return: 0 for success, 1 for error.
|
|
|
|
*
|
|
|
|
*/
|
2021-03-24 15:29:48 +00:00
|
|
|
uint16 lcd_setWindow(lcd_t* lcd, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
|
2020-08-02 13:51:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Push a pixel into the previously set drawing area.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* lcd - display to use
|
|
|
|
* r - red color (0 to 255)
|
|
|
|
* g - green color (0 to 255)
|
|
|
|
* b - blue color (0 to 255)
|
|
|
|
*/
|
|
|
|
void lcd_pushPixel(lcd_t* lcd, uint8 r, uint8 g, uint8 b);
|
|
|
|
|
2020-08-02 19:38:10 +00:00
|
|
|
/*
|
|
|
|
* Push a 'transparent' pixel into the previously set drawing area.
|
|
|
|
* Requires buffering to be enabled.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* lcd - display to use
|
|
|
|
*/
|
|
|
|
void lcd_pushPixelSkip(lcd_t* lcd);
|
|
|
|
|
2020-08-02 13:51:47 +00:00
|
|
|
/*
|
|
|
|
* Push an array of pixels into the previously set drawing area.
|
|
|
|
* Significantly faster than pushing pixels individually.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* lcd - display to use
|
|
|
|
* pixels - array of pixels where:
|
|
|
|
* pixels[i * 3 + 0] = i-th red color (0 to 255)
|
|
|
|
* pixels[i * 3 + 1] = i-th green color (0 to 255)
|
|
|
|
* pixels[i * 3 + 2] = i-th blue color (0 to 255)
|
|
|
|
* count - number of pixels in the array
|
|
|
|
*/
|
|
|
|
void lcd_pushPixels(lcd_t* lcd, uint8* pixels, size_t count);
|
|
|
|
|
2020-08-02 17:38:03 +00:00
|
|
|
void lcd_redrawBuffer(lcd_t* lcd);
|
|
|
|
|
2020-08-02 13:51:47 +00:00
|
|
|
#endif // __SPILCD_H__
|
|
|
|
|