1st artwork version

This commit is contained in:
philippe44
2020-03-18 23:42:44 -07:00
parent 126d3f4e04
commit 5e5dc9ba29
15 changed files with 158 additions and 79 deletions

View File

@@ -60,6 +60,10 @@ void GDS_Clear( struct GDS_Device* Device, int Color ) {
}
void GDS_ClearWindow( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color ) {
// -1 means up to width/height
if (x2 < 0) x2 = Device->Width - 1;
if (y2 < 0) y2 = Device->Height - 1;
// driver can provide own optimized clear window
if (Device->ClearWindow) {
Device->ClearWindow( Device, x1, y1, x2, y2, Color );

View File

@@ -218,8 +218,10 @@ bool GDS_DrawJPEG( struct GDS_Device* Device, uint8_t *Source, int x, int y, int
// then place it
if (Fit & GDS_IMAGE_CENTER_X) Context.XOfs = (Device->Width + x - Context.Width) / 2;
else if (Fit & GDS_IMAGE_RIGHT) Context.XOfs = Device->Width - Context.Width;
if (Fit & GDS_IMAGE_CENTER_Y) Context.YOfs = (Device->Height + y - Context.Height) / 2;
else if (Fit & GDS_IMAGE_BOTTOM) Context.YOfs = Device->Height - Context.Height;
Context.XMin = x - Context.XOfs;
Context.YMin = y - Context.YOfs;

View File

@@ -9,8 +9,11 @@ struct GDS_Device;
enum { GDS_RGB565, GDS_RGB555, GDS_RGB444 };
#define GDS_IMAGE_TOP 0x00
#define GDS_IMAGE_LEFT 0x00
#define GDS_IMAGE_CENTER_X 0x01
#define GDS_IMAGE_RIGHT 0x04
#define GDS_IMAGE_TOP 0x00
#define GDS_IMAGE_BOTTOM 0x08
#define GDS_IMAGE_CENTER_Y 0x02
#define GDS_IMAGE_CENTER (GDS_IMAGE_CENTER_X | GDS_IMAGE_CENTER_Y)
#define GDS_IMAGE_FIT 0x10

View File

@@ -62,7 +62,9 @@ struct grfg_packet {
struct grfa_packet {
char opcode[4];
u32_t length;
u32_t length;
u16_t x;
u16_t y;
u32_t offset;
};
@@ -140,6 +142,7 @@ static struct scroller_s {
static struct {
u8_t *data;
u32_t size;
u16_t x, y;
} artwork;
#define MAX_BARS 32
@@ -313,7 +316,7 @@ static void send_server(void) {
pkt_header.length = htonl(sizeof(pkt_header) - 8);
pkt_header.mode = ANIC_resp;
send_packet((u8_t *)&pkt_header, sizeof(pkt_header));
send_packet((uint8_t *) &pkt_header, sizeof(pkt_header));
ANIC_resp = ANIM_NONE;
}
@@ -321,18 +324,22 @@ static void send_server(void) {
if (SETD_width) {
struct SETD_header pkt_header;
LOG_INFO("sending width %u", SETD_width);
memset(&pkt_header, 0, sizeof(pkt_header));
memcpy(&pkt_header.opcode, "SETD", 4);
pkt_header.id = 0xfe; // id 0xfe is width S:P:Squeezebox2
pkt_header.length = htonl(sizeof(pkt_header) + 2 - 8);
pkt_header.length = htonl(sizeof(pkt_header) + 4 - 8);
u16_t height = GDS_GetHeight(display);
LOG_INFO("sending dimension %ux%u", SETD_width, height);
SETD_width = htons(SETD_width);
send_packet((u8_t *)&pkt_header, sizeof(pkt_header));
send_packet((uint8_t*) &SETD_width, 2);
height = htons(height);
send_packet((uint8_t *) &pkt_header, sizeof(pkt_header));
send_packet((uint8_t *) &SETD_width, 2);
send_packet((uint8_t *) &height, 2);
SETD_width = 0;
}
@@ -661,10 +668,10 @@ static void grfa_handler(u8_t *data, int len) {
int offset = htonl(pkt->offset);
int length = htonl(pkt->length);
LOG_INFO("gfra l:%u o:%u s:%u", length, offset, size);
// new grfa artwork, allocate memory
if (!offset) {
artwork.x = htons(pkt->x);
artwork.y = htons(pkt->y);
if (artwork.data) free(artwork.data);
artwork.data = malloc(length);
artwork.size = 0;
@@ -674,8 +681,14 @@ static void grfa_handler(u8_t *data, int len) {
memcpy(artwork.data + offset, data + sizeof(struct grfa_packet), size);
artwork.size += size;
if (artwork.size == length) {
GDS_DrawJPEG(display, artwork.data, 0, 32, GDS_IMAGE_CENTER);
}
GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);
GDS_DrawJPEG(display, artwork.data, artwork.x, artwork.y, artwork.y < 32 ? (GDS_IMAGE_RIGHT | GDS_IMAGE_TOP) : GDS_IMAGE_CENTER);
free(artwork.data);
artwork.data = NULL;
artwork.size = 0;
}
LOG_INFO("gfra l:%u x:%hu, y:%hu, o:%u s:%u", length, artwork.x, artwork.y, offset, size);
}
/****************************************************************************************
@@ -820,7 +833,7 @@ static void visu_handler( u8_t *data, int len) {
visu.mode = pkt->which;
// little trick to clean the taller screens when switching visu
if (visu.row >= SB_HEIGHT) GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row - visu.height - 1);
if (visu.row >= SB_HEIGHT) GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row + visu.height - 1);
if (visu.mode) {
if (pkt->count >= 4) {
@@ -878,7 +891,7 @@ static void visu_handler( u8_t *data, int len) {
// reset bars maximum
for (int i = visu.n; --i >= 0;) visu.bars[i].max = 0;
GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row - visu.height - 1);
GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row + visu.height - 1);
LOG_INFO("Visualizer with %u bars of width %d:%d:%d:%d (%w:%u,h:%u,c:%u,r:%u,s:%.02f)", visu.n, visu.bar_border, visu.bar_width, visu.bar_gap, visu.border, visu.width, visu.height, visu.col, visu.row, visu.spectrum_scale);
} else {