linux-st7735/demo/term.c
2020-08-02 21:32:02 +00:00

54 lines
1.4 KiB
C

#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;
}