TFT examples updated.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
#include <sys/gpanel.h>
|
||||
#include <time.h>
|
||||
|
||||
#define BLACK 0x0000
|
||||
@@ -13,83 +14,56 @@
|
||||
|
||||
int fd = -1;
|
||||
|
||||
//#define PIX_BUF_SIZ 64 // 21 fps
|
||||
#define PIX_BUF_SIZ 128 // 28 fps on full-screen continuous box()
|
||||
//#define PIX_BUF_SIZ 256 // 32 fps
|
||||
//#define PIX_BUF_SIZ 512 // 34 fps
|
||||
|
||||
void pixel(unsigned x, unsigned y,
|
||||
unsigned short color)
|
||||
void pixel(unsigned x, unsigned y, unsigned color)
|
||||
{
|
||||
unsigned short wincoo[4];
|
||||
unsigned short data[2];
|
||||
struct gpanel_pixel_t param;
|
||||
|
||||
wincoo[0] = wincoo[2] = x;
|
||||
wincoo[1] = wincoo[3] = y;
|
||||
ioctl(fd, 0xC0C0, wincoo);
|
||||
|
||||
*data = 1;
|
||||
data[1] = color;
|
||||
ioctl(fd, 0xDADA, data);
|
||||
}
|
||||
|
||||
void fill(unsigned count, unsigned short color)
|
||||
{
|
||||
unsigned short data[1 + PIX_BUF_SIZ];
|
||||
|
||||
unsigned cnt = (count < PIX_BUF_SIZ) ? count : PIX_BUF_SIZ;
|
||||
while (cnt)
|
||||
data[cnt--] = color;
|
||||
|
||||
while (count)
|
||||
{
|
||||
cnt = (count < PIX_BUF_SIZ) ? count : PIX_BUF_SIZ;
|
||||
*data = cnt;
|
||||
ioctl(fd, 0xDADA, data);
|
||||
count -= cnt;
|
||||
}
|
||||
param.color = color;
|
||||
param.x = x;
|
||||
param.y = y;
|
||||
ioctl(fd, GPANEL_PIXEL, ¶m);
|
||||
}
|
||||
|
||||
void lineh(unsigned x, unsigned y,
|
||||
unsigned length, unsigned short color)
|
||||
unsigned length, unsigned color)
|
||||
{
|
||||
unsigned short wincoo[4];
|
||||
struct gpanel_line_t param;
|
||||
|
||||
wincoo[0] = x;
|
||||
wincoo[1] = wincoo[3] = y;
|
||||
wincoo[2] = x + length - 1;
|
||||
ioctl(fd, 0xC0C0, wincoo);
|
||||
|
||||
fill(length, color);
|
||||
param.color = color;
|
||||
param.x0 = x;
|
||||
param.y0 = y;
|
||||
param.x1 = x + length - 1;
|
||||
param.y1 = y;
|
||||
ioctl(fd, GPANEL_LINE, ¶m);
|
||||
}
|
||||
|
||||
void linev(unsigned x, unsigned y,
|
||||
unsigned length, unsigned short color)
|
||||
unsigned length, unsigned color)
|
||||
{
|
||||
unsigned short wincoo[4];
|
||||
struct gpanel_line_t param;
|
||||
|
||||
wincoo[0] = wincoo[2] = x;
|
||||
wincoo[1] = y;
|
||||
wincoo[3] = y + length - 1;
|
||||
ioctl(fd, 0xC0C0, wincoo);
|
||||
|
||||
fill(length, color);
|
||||
param.color = color;
|
||||
param.x0 = x;
|
||||
param.y0 = y;
|
||||
param.x1 = x;
|
||||
param.y1 = y + length - 1;
|
||||
ioctl(fd, GPANEL_LINE, ¶m);
|
||||
}
|
||||
|
||||
void box(unsigned x, unsigned y,
|
||||
unsigned width, unsigned height,
|
||||
unsigned short color,
|
||||
int solid)
|
||||
unsigned color, int solid)
|
||||
{
|
||||
if (solid)
|
||||
{
|
||||
unsigned short wincoo[4];
|
||||
struct gpanel_rect_t param;
|
||||
|
||||
wincoo[0] = x; wincoo[1] = y;
|
||||
wincoo[2] = x + width - 1; wincoo[3] = y + height - 1;
|
||||
ioctl(fd, 0xC0C0, wincoo);
|
||||
|
||||
fill(width * height, color);
|
||||
param.color = color;
|
||||
param.x0 = x;
|
||||
param.y0 = y;
|
||||
param.x1 = x + width - 1;
|
||||
param.y1 = y + height - 1;
|
||||
ioctl(fd, GPANEL_FILL, ¶m);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -41,6 +41,7 @@ volatile int jx = 0, jy = 0;
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/gpio.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/gpanel.h>
|
||||
|
||||
int fd = -1;
|
||||
int fdx = -1;
|
||||
@@ -71,65 +72,46 @@ void delay(unsigned long ms)
|
||||
usleep(ms * 1000);
|
||||
}
|
||||
|
||||
#define PIX_BUF_SIZ 128 // 28 fps on full-screen continuous box()
|
||||
|
||||
void fill(unsigned count, unsigned short color)
|
||||
{
|
||||
unsigned short data[1 + PIX_BUF_SIZ];
|
||||
|
||||
unsigned cnt = (count < PIX_BUF_SIZ) ? count : PIX_BUF_SIZ;
|
||||
while (cnt)
|
||||
data[cnt--] = color;
|
||||
|
||||
while (count)
|
||||
{
|
||||
cnt = (count < PIX_BUF_SIZ) ? count : PIX_BUF_SIZ;
|
||||
*data = cnt;
|
||||
ioctl(fd, 0xDADA, data);
|
||||
count -= cnt;
|
||||
}
|
||||
}
|
||||
|
||||
void lineh(unsigned x, unsigned y,
|
||||
unsigned length, unsigned short color)
|
||||
unsigned length, unsigned color)
|
||||
{
|
||||
unsigned short wincoo[4];
|
||||
struct gpanel_line_t param;
|
||||
|
||||
wincoo[0] = x;
|
||||
wincoo[1] = wincoo[3] = y;
|
||||
wincoo[2] = x + length - 1;
|
||||
ioctl(fd, 0xC0C0, wincoo);
|
||||
|
||||
fill(length, color);
|
||||
param.color = color;
|
||||
param.x0 = x;
|
||||
param.y0 = y;
|
||||
param.x1 = x + length - 1;
|
||||
param.y1 = y;
|
||||
ioctl(fd, GPANEL_LINE, ¶m);
|
||||
}
|
||||
|
||||
void linev(unsigned x, unsigned y,
|
||||
unsigned length, unsigned short color)
|
||||
unsigned length, unsigned color)
|
||||
{
|
||||
unsigned short wincoo[4];
|
||||
struct gpanel_line_t param;
|
||||
|
||||
wincoo[0] = wincoo[2] = x;
|
||||
wincoo[1] = y;
|
||||
wincoo[3] = y + length - 1;
|
||||
ioctl(fd, 0xC0C0, wincoo);
|
||||
|
||||
fill(length, color);
|
||||
param.color = color;
|
||||
param.x0 = x;
|
||||
param.y0 = y;
|
||||
param.x1 = x;
|
||||
param.y1 = y + length - 1;
|
||||
ioctl(fd, GPANEL_LINE, ¶m);
|
||||
}
|
||||
|
||||
void box(unsigned x, unsigned y,
|
||||
unsigned width, unsigned height,
|
||||
unsigned short color,
|
||||
int solid)
|
||||
unsigned color, int solid)
|
||||
{
|
||||
if (solid)
|
||||
{
|
||||
unsigned short wincoo[4];
|
||||
struct gpanel_rect_t param;
|
||||
|
||||
wincoo[0] = x; wincoo[1] = y;
|
||||
wincoo[2] = x + width - 1; wincoo[3] = y + height - 1;
|
||||
ioctl(fd, 0xC0C0, wincoo);
|
||||
|
||||
fill(width * height, color);
|
||||
param.color = color;
|
||||
param.x0 = x;
|
||||
param.y0 = y;
|
||||
param.x1 = x + width - 1;
|
||||
param.y1 = y + height - 1;
|
||||
ioctl(fd, GPANEL_FILL, ¶m);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ void gpanel_circle(int color, int x, int y, int radius)
|
||||
|
||||
param.color = color;
|
||||
param.x = x;
|
||||
param.y = x;
|
||||
param.y = y;
|
||||
param.radius = radius;
|
||||
ioctl(_gpanel_fd, GPANEL_CIRCLE, ¶m);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ void gpanel_image(int x, int y, int width, int height, const unsigned short *dat
|
||||
struct gpanel_image_t param;
|
||||
|
||||
param.x = x;
|
||||
param.y = x;
|
||||
param.y = y;
|
||||
param.width = width;
|
||||
param.height = height;
|
||||
param.image = data;
|
||||
|
||||
@@ -30,6 +30,6 @@ void gpanel_pixel(int color, int x, int y)
|
||||
|
||||
param.color = color;
|
||||
param.x = x;
|
||||
param.y = x;
|
||||
param.y = y;
|
||||
ioctl(_gpanel_fd, GPANEL_PIXEL, ¶m);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user