linux-st7735/demo/base.c
2021-03-24 15:29:48 +00:00

41 lignes
802 B
C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <wiringPi.h>
#include "spilcd.h"
#include "spilcd_gfx.h"
#include "base.h"
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; }
extern void lcd_setOrientation(lcd_t*, int);
lcd_t* demo_init()
{
setbuf(stdout, NULL);
srand(time(NULL));
wiringPiSetup();
lcd_t* lcd = lcd_init(30000000, 1, 15, 7, 8);
lcd_setOrientation(lcd, 4);
return lcd;
}
void demo_deinit(lcd_t* lcd)
{
printf("...waiting 2 seconds before shutdown...\n");
sleep(2);
printf("Terminating...\n");
lcd_fillScreen(lcd, 0, 0, 0);
lcd_deinit(lcd);
printf("DONE\n");
}