42 lines
1.0 KiB
C
42 lines
1.0 KiB
C
|
#include <stdio.h>
|
||
|
#include <stdint.h>
|
||
|
#include <stdlib.h>
|
||
|
#include "spilcd_gfx.h"
|
||
|
|
||
|
void lcd_drawPixel(lcd_t* lcd, uint8 x, uint8 y, uint8 r, uint8 g, uint8 b)
|
||
|
{
|
||
|
if(lcd_setWindow(lcd, x, y, x, y)) return;
|
||
|
lcd_pushPixel(lcd, r, g, b);
|
||
|
}
|
||
|
|
||
|
void lcd_fillRect(lcd_t* lcd, uint8 x, uint8 y, uint8 w, uint8 h,
|
||
|
uint8 r, uint8 g, uint8 b)
|
||
|
{
|
||
|
if((w == 0) || (h == 0)) return;
|
||
|
if((x+w-1) >= lcd->width) w = lcd->width - x;
|
||
|
if((y+h-1) >= lcd->height) h = lcd->height - y;
|
||
|
|
||
|
if(lcd_setWindow(lcd, x, y, x+w-1, y+h-1)) return;
|
||
|
|
||
|
#define BUFFER_PIXELS 64
|
||
|
int wh = w*h;
|
||
|
uint8 buffer[BUFFER_PIXELS * sizeof(uint8) * 3];
|
||
|
for (int p = 0; p < wh; p += BUFFER_PIXELS) {
|
||
|
for(int pb = 0; pb < BUFFER_PIXELS; pb++) {
|
||
|
buffer[pb * 3 + 0] = r;
|
||
|
buffer[pb * 3 + 1] = g;
|
||
|
buffer[pb * 3 + 2] = b;
|
||
|
}
|
||
|
int rem = wh - p;
|
||
|
lcd_pushPixels(lcd, buffer, ((rem < BUFFER_PIXELS) ? rem : BUFFER_PIXELS));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void lcd_fillScreen(lcd_t* lcd, uint8 r, uint8 g, uint8 b)
|
||
|
{
|
||
|
lcd_fillRect(lcd, 0, 0,
|
||
|
lcd->width, lcd->height,
|
||
|
r, g, b);
|
||
|
}
|
||
|
|