Demos restructuring. Added term demo.
This commit is contained in:
parent
e7b5cfdf7e
commit
911ffd78e6
34
demo/base.c
Normal file
34
demo/base.c
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#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; }
|
||||||
|
|
||||||
|
lcd_t* demo_init()
|
||||||
|
{
|
||||||
|
setbuf(stdout, NULL);
|
||||||
|
srand(time(NULL));
|
||||||
|
|
||||||
|
wiringPiSetup();
|
||||||
|
|
||||||
|
return lcd_init(40000000, 1, 10, 7, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
14
demo/base.h
Normal file
14
demo/base.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <wiringPi.h>
|
||||||
|
#include "spilcd.h"
|
||||||
|
|
||||||
|
uint8 random_color_r(int seed);
|
||||||
|
uint8 random_color_g(int seed);
|
||||||
|
uint8 random_color_b(int seed);
|
||||||
|
|
||||||
|
lcd_t* demo_init();
|
||||||
|
void demo_deinit(lcd_t* lcd);
|
||||||
|
|
1295
demo/img_green_screen.h
Executable file
1295
demo/img_green_screen.h
Executable file
File diff suppressed because it is too large
Load Diff
56
demo/simple.c
Normal file
56
demo/simple.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <linux/i2c-dev.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -18,9 +17,9 @@
|
|||||||
#include <linux/if_link.h>
|
#include <linux/if_link.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
//#include "ssd1306.h"
|
|
||||||
#include "spilcd_gfx.h"
|
#include "spilcd_gfx.h"
|
||||||
#include "spilcd_font.h"
|
#include "spilcd_font.h"
|
||||||
|
#include "base.h"
|
||||||
|
|
||||||
|
|
||||||
#define NI_MAXHOST 1025
|
#define NI_MAXHOST 1025
|
||||||
@ -29,8 +28,6 @@
|
|||||||
volatile sig_atomic_t done = 0;
|
volatile sig_atomic_t done = 0;
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
|
|
||||||
//extern FONT_INFO *_font;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
@ -117,39 +114,80 @@ int main(int argc, char** argv) {
|
|||||||
perror("Error: cannot handle SIGTERM"); // Should not happen
|
perror("Error: cannot handle SIGTERM"); // Should not happen
|
||||||
}
|
}
|
||||||
|
|
||||||
wiringPiSetup();
|
lcd_t* lcd = demo_init();
|
||||||
|
|
||||||
lcd_t* lcd = lcd_init(40000000, 1, 10, 7, 8);
|
|
||||||
|
|
||||||
|
int rowy = 10;
|
||||||
while (done == 0) {
|
while (done == 0) {
|
||||||
row = 2;
|
row = 0;
|
||||||
//_font = (FONT_INFO*)&ubuntuMono_8ptFontInfo;
|
|
||||||
/* Display time */
|
// Date and Time
|
||||||
mytime = time(NULL);
|
mytime = time(NULL);
|
||||||
tm = localtime (&mytime);
|
tm = localtime (&mytime);
|
||||||
//ssd1306ClearScreen(LAYER0 | LAYER1) ;
|
|
||||||
lcd_fillScreen(lcd, 0, 0, 0);
|
lcd_fillScreen(lcd, 0, 0, 0);
|
||||||
strftime(time_buffer, 80," %H:%M:%S %x", tm);
|
strftime(time_buffer, 80," %H:%M:%S", tm);
|
||||||
//ssd1306DrawString(0, row * 8, time_buffer, 1, WHITE, LAYER0);
|
lcd_drawText(lcd, 0, row * rowy, time_buffer, 255, 255, 255);
|
||||||
lcd_drawText(lcd, 0, row * 8, time_buffer, 255, 255, 255);
|
row++;
|
||||||
|
strftime(time_buffer, 80," %x", tm);
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, time_buffer, 200, 200, 200);
|
||||||
|
row++;
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
/* Display IP */
|
// CPU
|
||||||
/* Get network information */
|
float c = GetCPULoad() ;
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, "CPU load:", 255, 255, 100);
|
||||||
|
row++;
|
||||||
|
snprintf(text_buffer, sizeof(text_buffer), " %0.2f", c);
|
||||||
|
printf("CPU load avg: %s\n", text_buffer);
|
||||||
|
if (c < 0.2) {
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 50, 255, 50);
|
||||||
|
} else if (c < 0.5) {
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 255, 255, 50);
|
||||||
|
} else {
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 255, 50, 50);
|
||||||
|
}
|
||||||
|
row++;
|
||||||
|
|
||||||
|
/* Memory usage */
|
||||||
|
float m = GetMemUsage();
|
||||||
|
snprintf(text_buffer, sizeof(text_buffer), " %3.0f%%", m*100);
|
||||||
|
printf("Mem used: %s\n", text_buffer);
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, "Mem used:", 150, 150, 255);
|
||||||
|
row++;
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 255, 255, 255);
|
||||||
|
//ssd1306DrawRect(0, 0, 127, 13, INVERSE, LAYER0);
|
||||||
|
//ssd1306FillRect(2, 2, (int)(123 * m), 9, INVERSE, LAYER0);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
/* CPU temperature */
|
||||||
|
int t = GetCPUTemp() ;
|
||||||
|
snprintf ( text_buffer, sizeof(text_buffer), "%3d C", t );
|
||||||
|
printf("CPU temp: %s\n", text_buffer);
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, "CPU temp:", 255, 180, 170);
|
||||||
|
row++;
|
||||||
|
if (t < 20) {
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 150, 150, 255);
|
||||||
|
} else if (t < 25) {
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 150, 255, 150);
|
||||||
|
} else if (t < 30) {
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 255, 255, 100);
|
||||||
|
} else if (t < 35) {
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 255, 120, 100);
|
||||||
|
} else {
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 255, 80, 20);
|
||||||
|
}
|
||||||
|
row++;
|
||||||
|
|
||||||
|
// Network devices and IPs
|
||||||
if (getifaddrs(&ifaddr) == -1)
|
if (getifaddrs(&ifaddr) == -1)
|
||||||
{
|
{
|
||||||
perror("getifaddrs");
|
perror("getifaddrs");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
/* Walk through linked list, maintaining head pointer so we
|
|
||||||
can free list later */
|
|
||||||
for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) {
|
for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) {
|
||||||
if (ifa->ifa_addr == NULL)
|
if (ifa->ifa_addr == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
family = ifa->ifa_addr->sa_family;
|
family = ifa->ifa_addr->sa_family;
|
||||||
/* Display interface name and family (including symbolic
|
|
||||||
form of the latter for the common families) */
|
|
||||||
if ((strncmp ("eth", ifa->ifa_name, 3 ) == 0) && family == AF_INET) {
|
if ((strncmp ("eth", ifa->ifa_name, 3 ) == 0) && family == AF_INET) {
|
||||||
s = getnameinfo(ifa->ifa_addr,
|
s = getnameinfo(ifa->ifa_addr,
|
||||||
(ifa->ifa_addr->sa_family == AF_INET) ? sizeof(struct sockaddr_in) :
|
(ifa->ifa_addr->sa_family == AF_INET) ? sizeof(struct sockaddr_in) :
|
||||||
@ -161,9 +199,11 @@ int main(int argc, char** argv) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
printf("%-8s <%s>\n", ifa->ifa_name, host);
|
printf("%-8s <%s>\n", ifa->ifa_name, host);
|
||||||
snprintf ( text_buffer, sizeof(text_buffer), "%s: %s",ifa->ifa_name, host );
|
snprintf ( text_buffer, sizeof(text_buffer), "%s:", ifa->ifa_name);
|
||||||
//ssd1306DrawString(0, row * 8, text_buffer, 1, WHITE, LAYER0);
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 200, 200, 255);
|
||||||
lcd_drawText(lcd, 0, row * 8, text_buffer, 255, 255, 255);
|
row++;
|
||||||
|
snprintf ( text_buffer, sizeof(text_buffer), " %s", host );
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 200, 255, 200);
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
if ((strncmp ("wlan", ifa->ifa_name, 4 ) == 0) && family == AF_INET) {
|
if ((strncmp ("wlan", ifa->ifa_name, 4 ) == 0) && family == AF_INET) {
|
||||||
@ -177,53 +217,21 @@ int main(int argc, char** argv) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
printf("%-8s <%s>\n", ifa->ifa_name, host);
|
printf("%-8s <%s>\n", ifa->ifa_name, host);
|
||||||
snprintf ( text_buffer, sizeof(text_buffer), "%s: %s",ifa->ifa_name, host );
|
snprintf ( text_buffer, sizeof(text_buffer), "%s:",ifa->ifa_name);
|
||||||
//ssd1306DrawString(0, row * 8, text_buffer, 1, WHITE, LAYER0);
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 255, 200, 200);
|
||||||
lcd_drawText(lcd, 0, row * 8, text_buffer, 255, 255, 255);
|
row++;
|
||||||
|
snprintf ( text_buffer, sizeof(text_buffer), " %s", host );
|
||||||
|
lcd_drawText(lcd, 0, row * rowy, text_buffer, 200, 255, 200);
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freeifaddrs(ifaddr);
|
freeifaddrs(ifaddr);
|
||||||
|
|
||||||
/* CPU usage
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
float c = GetCPULoad() ;
|
|
||||||
snprintf ( text_buffer, sizeof(text_buffer), "CPU loadavg: %0.2f", c );
|
|
||||||
printf("%s\n", text_buffer);
|
|
||||||
//ssd1306DrawString(0, row * 8, text_buffer, 1, WHITE, LAYER0);
|
|
||||||
lcd_drawText(lcd, 0, row * 8, text_buffer, 255, 255, 255);
|
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
/* Memory usage */
|
|
||||||
float m = GetMemUsage();
|
|
||||||
snprintf ( text_buffer, sizeof(text_buffer), "Mem used: %3.0f%%", m*100 );
|
|
||||||
printf("%s\n", text_buffer);
|
|
||||||
//ssd1306DrawString(4, 2, text_buffer, 1, WHITE, LAYER0);
|
|
||||||
lcd_drawText(lcd, 4, 2, text_buffer, 255, 255, 255);
|
|
||||||
//ssd1306DrawRect(0, 0, 127, 13, INVERSE, LAYER0);
|
|
||||||
//ssd1306FillRect(2, 2, (int)(123 * m), 9, INVERSE, LAYER0);
|
|
||||||
|
|
||||||
/* CPU temperature */
|
|
||||||
int t = GetCPUTemp() ;
|
|
||||||
snprintf ( text_buffer, sizeof(text_buffer), "CPU temp: %3d C", t );
|
|
||||||
printf("%s\n", text_buffer);
|
|
||||||
//ssd1306DrawString(0, row * 8, text_buffer, 1, WHITE, LAYER0);
|
|
||||||
lcd_drawText(lcd, 0, row * 8, text_buffer, 255, 255, 255);
|
|
||||||
row++;
|
|
||||||
|
|
||||||
/* Refresh screen */
|
|
||||||
//ssd1306Refresh();
|
|
||||||
//SSD1306MSDELAY(1000);
|
|
||||||
lcd_redrawBuffer(lcd);
|
lcd_redrawBuffer(lcd);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
demo_deinit(lcd);
|
||||||
//_font = (FONT_INFO*)&ubuntuMono_24ptFontInfo;
|
|
||||||
//ssd1306ClearScreen(LAYER0 | LAYER1) ;
|
|
||||||
//ssd1306Refresh();
|
|
||||||
printf("All done!\r\n");
|
|
||||||
return (EXIT_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
53
demo/term.c
Normal file
53
demo/term.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#include "base.h"
|
||||||
|
#include "spilcd_gfx.h"
|
||||||
|
#include "spilcd_font.h"
|
||||||
|
#include "img_green_screen.h"
|
||||||
|
|
||||||
|
#define ABS(x) ((x) < 0 ? -(x) : (x))
|
||||||
|
#define GLOW (((i + row) % 6)*8)
|
||||||
|
|
||||||
|
void draw_background(lcd_t* lcd, uint8 lightness)
|
||||||
|
{
|
||||||
|
lcd_setWindow(lcd, 0, 0, lcd->width-1, lcd->height-1);
|
||||||
|
char* img = header_data;
|
||||||
|
for (int i = 0; i < lcd->width * lcd->height; i++) {
|
||||||
|
uint8 pixel[3];
|
||||||
|
HEADER_PIXEL(img, pixel)
|
||||||
|
lcd_pushPixel(lcd, pixel[0] * (int)lightness / 255, pixel[1] * (int)lightness / 255, pixel[2] * (int)lightness / 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
lcd_t* lcd = demo_init();
|
||||||
|
|
||||||
|
for (int p = 0; p < 20; p++) {
|
||||||
|
draw_background(lcd, p * 200 / 20);
|
||||||
|
lcd_redrawBuffer(lcd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rowy = 9;
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
draw_background(lcd, 200 - ABS(4 - (i%8)) * 6);
|
||||||
|
int shift_x = ABS(4 - (i%8)) / 4;
|
||||||
|
int shift_y = ABS(5 - (i%10)) / 4;
|
||||||
|
int row = 2;
|
||||||
|
lcd_drawText(lcd, 12 + shift_x, row*rowy + shift_y, "SPI Term v1.8", 0, 220-GLOW, 0);
|
||||||
|
row++;
|
||||||
|
row++;
|
||||||
|
lcd_drawText(lcd, 8 + shift_x, row*rowy + shift_y, "#/> dir", 0, 220-GLOW, 0);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
lcd_drawText(lcd, 8 + shift_x, row*rowy + shift_y, " a.out", 0, 220-GLOW, 0);
|
||||||
|
row++;
|
||||||
|
lcd_drawText(lcd, 8 + shift_x, row*rowy + shift_y, " db.txt", 0, 220-GLOW, 0);
|
||||||
|
row++;
|
||||||
|
lcd_drawText(lcd, 8 + shift_x, row*rowy + shift_y, "#/>", 0, 220-GLOW, 0);
|
||||||
|
lcd_redrawBuffer(lcd);
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
demo_deinit(lcd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
116
main.c
116
main.c
@ -1,116 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <wiringPi.h>
|
|
||||||
#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; }
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
setbuf(stdout, NULL);
|
|
||||||
srand(time(NULL));
|
|
||||||
|
|
||||||
wiringPiSetup();
|
|
||||||
|
|
||||||
lcd_t* lcd = lcd_init(40000000, 1, 10, 7, 8);
|
|
||||||
|
|
||||||
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 < 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);
|
|
||||||
}
|
|
||||||
lcd_redrawBuffer(lcd);
|
|
||||||
}
|
|
||||||
printf("DONE\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
printf("...waiting 1 second...\n");
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
printf("Rectangles...");
|
|
||||||
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);
|
|
||||||
lcd_redrawBuffer(lcd);
|
|
||||||
printf("DONE\n");
|
|
||||||
|
|
||||||
printf("...waiting 1 second...\n");
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
printf("Text...");
|
|
||||||
lcd_fillScreen(lcd, 0, 0, 0);
|
|
||||||
lcd_drawChar(lcd, 10, 90, 'A', 255, 0, 0);
|
|
||||||
lcd_drawText(lcd, 10, 50, "Hello, world!", 0, 255, 0);
|
|
||||||
lcd_drawChar(lcd, 10, 100, 'Z', 0, 0, 255);
|
|
||||||
lcd_redrawBuffer(lcd);
|
|
||||||
printf("DONE\n");
|
|
||||||
|
|
||||||
printf("...waiting 2 seconds...\n");
|
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
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));
|
|
||||||
lcd_redrawBuffer(lcd);
|
|
||||||
}
|
|
||||||
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");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
|||||||
project('dejvino-ST7735', 'c')
|
project('dejvino-ST7735', 'c')
|
||||||
src1 = ['main.c', 'spilcd_gfx.c', 'spilcd_font.c', 'st7735.c']
|
src_lib = ['spilcd_gfx.c', 'spilcd_font.c', 'st7735.c']
|
||||||
src2 = ['example.c', 'spilcd_gfx.c', 'spilcd_font.c', 'st7735.c']
|
src_demo = src_lib + ['demo/base.c']
|
||||||
executable('st7735', src1, link_args: '-lwiringPi')
|
executable('demo_simple', src_demo + ['demo/simple.c'], link_args: '-lwiringPi')
|
||||||
executable('example', src2, link_args: '-lwiringPi')
|
executable('demo_term', src_demo + ['demo/term.c'], link_args: '-lwiringPi')
|
||||||
|
executable('demo_system_monitor', src_demo + ['demo/system_monitor.c'], link_args: '-lwiringPi')
|
||||||
|
Loading…
Reference in New Issue
Block a user