2020-08-01 19:49:42 +00:00
|
|
|
#include <stdio.h>
|
2020-08-02 13:51:47 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
2020-08-01 19:49:42 +00:00
|
|
|
#include <wiringPi.h>
|
2020-08-02 13:51:47 +00:00
|
|
|
#include "spilcd.h"
|
|
|
|
#include "spilcd_gfx.h"
|
|
|
|
#include "spilcd_font.h"
|
|
|
|
|
|
|
|
uint8 random_color_r(int seed);
|
|
|
|
uint8 random_color_g(int seed);
|
|
|
|
uint8 random_color_b(int seed);
|
|
|
|
inline uint8 random_color_r(int seed) { return seed % (256 / 7) * 7; }
|
|
|
|
inline uint8 random_color_g(int seed) { return seed % (256 / 13) * 13; }
|
|
|
|
inline uint8 random_color_b(int seed) { return seed % (256 / 23) * 23; }
|
2020-08-01 19:49:42 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
setbuf(stdout, NULL);
|
2020-08-02 13:51:47 +00:00
|
|
|
srand(time(NULL));
|
2020-08-01 19:49:42 +00:00
|
|
|
|
|
|
|
wiringPiSetup();
|
|
|
|
|
2020-08-02 13:51:47 +00:00
|
|
|
lcd_t* lcd = lcd_init(40000000, 1, 10, 7, 8);
|
2020-08-01 19:49:42 +00:00
|
|
|
|
|
|
|
printf("Fill display...");
|
|
|
|
printf("blue...");
|
2020-08-02 13:51:47 +00:00
|
|
|
lcd_fillScreen(lcd, 0, 70, 160);
|
|
|
|
printf("...waiting 1 second...");
|
|
|
|
sleep(1);
|
2020-08-01 19:49:42 +00:00
|
|
|
printf("black...");
|
2020-08-02 13:51:47 +00:00
|
|
|
lcd_fillScreen(lcd, 0, 0, 0);
|
2020-08-01 19:49:42 +00:00
|
|
|
printf("DONE\n");
|
2020-08-02 13:51:47 +00:00
|
|
|
|
|
|
|
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));
|
2020-08-01 19:49:42 +00:00
|
|
|
}
|
|
|
|
printf("DONE\n");
|
2020-08-02 13:51:47 +00:00
|
|
|
|
|
|
|
printf("...waiting 1 second...\n");
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
printf("Regions...");
|
|
|
|
int w = 15;
|
|
|
|
int h = 20;
|
|
|
|
for (int i = 1; i < 200; 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);
|
|
|
|
}
|
2020-08-01 19:49:42 +00:00
|
|
|
}
|
2020-08-02 13:51:47 +00:00
|
|
|
printf("DONE\n");
|
|
|
|
|
|
|
|
printf("...waiting 1 second...\n");
|
|
|
|
sleep(1);
|
|
|
|
|
2020-08-01 19:49:42 +00:00
|
|
|
printf("Rectangles...");
|
2020-08-02 13:51:47 +00:00
|
|
|
lcd_fillScreen(lcd, 0, 0, 0);
|
|
|
|
lcd_fillRect(lcd, 30, 10, 10, 10, 0, 255, 255);
|
|
|
|
lcd_fillRect(lcd, 30, 30, 10, 10, 255, 255, 0);
|
2020-08-01 19:49:42 +00:00
|
|
|
printf("DONE\n");
|
|
|
|
|
2020-08-02 13:51:47 +00:00
|
|
|
printf("...waiting 1 second...\n");
|
|
|
|
sleep(1);
|
|
|
|
|
2020-08-01 19:49:42 +00:00
|
|
|
printf("Text...");
|
2020-08-02 13:51:47 +00:00
|
|
|
lcd_fillScreen(lcd, 0, 0, 0);
|
|
|
|
lcd_printChar(lcd, 10, 90, 'A');
|
|
|
|
lcd_printText(lcd, 10, 50, "Hello, world!");
|
|
|
|
lcd_printChar(lcd, 10, 100, 'Z');
|
2020-08-01 19:49:42 +00:00
|
|
|
printf("DONE\n");
|
|
|
|
|
2020-08-02 13:51:47 +00:00
|
|
|
printf("...waiting 2 seconds...\n");
|
|
|
|
sleep(2);
|
2020-08-01 19:49:42 +00:00
|
|
|
|
2020-08-02 13:51:47 +00:00
|
|
|
printf("Pulsing color...");
|
|
|
|
for (int i = 0; i < 256; i++) {
|
|
|
|
lcd_fillScreen(lcd,
|
|
|
|
random_color_r(i),
|
|
|
|
random_color_g(i),
|
|
|
|
random_color_b(i));
|
|
|
|
}
|
|
|
|
printf("DONE\n");
|
|
|
|
|
|
|
|
printf("...waiting 2 seconds before shutdown...\n");
|
|
|
|
sleep(2);
|
|
|
|
printf("Terminating...\n");
|
|
|
|
lcd_fillScreen(lcd, 0, 0, 0);
|
|
|
|
lcd_deinit(lcd);
|
|
|
|
printf("DONE\n");
|
2020-08-01 19:49:42 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|