linux-st7735/demo/simple.c

57 lines
1.1 KiB
C
Raw Normal View History

2020-08-02 21:32:02 +00:00
#include "base.h"
#include "spilcd_gfx.h"
int main(int argc, char *argv[])
{
lcd_t* lcd = demo_init();
printf("Fill display...");
printf("blue...");
lcd_fillScreen(lcd, 0, 70, 160);
lcd_redrawBuffer(lcd);
printf("...waiting 1 second...");
sleep(1);
printf("black...");
lcd_fillScreen(lcd, 0, 0, 0);
lcd_redrawBuffer(lcd);
printf("DONE\n");
printf("...waiting 1 second...\n");
sleep(1);
printf("Points...");
for (int i = 1; i < 2000; i++) {
int r = rand();
lcd_drawPixel(lcd, r % 128, i % 160,
random_color_r(i),
random_color_g(i),
random_color_b(i));
}
lcd_redrawBuffer(lcd);
printf("DONE\n");
printf("...waiting 1 second...\n");
sleep(1);
printf("Regions...");
int w = 15;
int h = 20;
for (int i = 1; i < 100; i++) {
int x = rand() % (128 - w);
int y = rand() % (160 - h);
lcd_setWindow(lcd, x, y, x + w - 1, y + h - 1);
uint8 r = rand();
uint8 g = rand();
uint8 b = rand();
for (int p = 0; p < w*h; p++) {
lcd_pushPixel(lcd, r * p / (w*h), g * (w*h-p) / (w*h), b);
}
lcd_redrawBuffer(lcd);
}
printf("DONE\n");
demo_deinit(lcd);
return 0;
}