linux-st7735/spilcd.h

92 lines
2.0 KiB
C
Raw Normal View History

2020-08-02 13:51:47 +00:00
#ifndef uint8
#define uint8 unsigned char
#endif
#ifndef __SPILCD_H__
#define __SPILCD_H__
typedef struct
{
int channel;
int cs, a0, rs;
uint8 width, height;
} 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.
*
*/
uint8 lcd_setWindow(lcd_t* lcd, uint8 x1, uint8 y1, uint8 x2, uint8 y2);
/*
* 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__