mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-10 21:47:04 +03:00
SSD1326 correction + prepare new slimproto message for artwork
This commit is contained in:
@@ -74,7 +74,7 @@ static void Update( struct GDS_Device* Device ) {
|
|||||||
CurrentPage = p + 1;
|
CurrentPage = p + 1;
|
||||||
|
|
||||||
// actual write
|
// actual write
|
||||||
Device->WriteData( Device, Private->Shadowbuffer + p*width + first, last - first + 1 );
|
Device->WriteData( Device, Private->Shadowbuffer + p*width + first, last - first + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -115,10 +115,6 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
Device->WriteCommand( Device, 0x8D );
|
Device->WriteCommand( Device, 0x8D );
|
||||||
Device->WriteCommand( Device, 0x14 );
|
Device->WriteCommand( Device, 0x14 );
|
||||||
|
|
||||||
// set Clocks
|
|
||||||
Device->WriteCommand( Device, 0xD5 );
|
|
||||||
Device->WriteCommand( Device, ( 0x08 << 4 ) | 0x00 );
|
|
||||||
|
|
||||||
// COM pins HW config (alternative:EN if 64, DIS if 32, remap:DIS) - some display might need something different
|
// COM pins HW config (alternative:EN if 64, DIS if 32, remap:DIS) - some display might need something different
|
||||||
Device->WriteCommand( Device, 0xDA );
|
Device->WriteCommand( Device, 0xDA );
|
||||||
Device->WriteCommand( Device, ((Device->Height == 64 ? 1 : 0) << 4) | (0 < 5) );
|
Device->WriteCommand( Device, ((Device->Height == 64 ? 1 : 0) << 4) | (0 < 5) );
|
||||||
@@ -126,12 +122,6 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
// MUX Ratio
|
// MUX Ratio
|
||||||
Device->WriteCommand( Device, 0xA8 );
|
Device->WriteCommand( Device, 0xA8 );
|
||||||
Device->WriteCommand( Device, Device->Height - 1);
|
Device->WriteCommand( Device, Device->Height - 1);
|
||||||
// Page & GDDRAM Start Column High/Low
|
|
||||||
/*
|
|
||||||
Device->WriteCommand( Device, 0x00 );
|
|
||||||
Device->WriteCommand( Device, 0x10 );
|
|
||||||
Device->WriteCommand( Device, 0xB0 );
|
|
||||||
*/
|
|
||||||
// Display Offset
|
// Display Offset
|
||||||
Device->WriteCommand( Device, 0xD3 );
|
Device->WriteCommand( Device, 0xD3 );
|
||||||
Device->WriteCommand( Device, 0 );
|
Device->WriteCommand( Device, 0 );
|
||||||
@@ -143,6 +133,9 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
Device->SetHFlip( Device, false );
|
Device->SetHFlip( Device, false );
|
||||||
// no Display Inversion
|
// no Display Inversion
|
||||||
Device->WriteCommand( Device, 0xA6 );
|
Device->WriteCommand( Device, 0xA6 );
|
||||||
|
// set Clocks
|
||||||
|
Device->WriteCommand( Device, 0xD5 );
|
||||||
|
Device->WriteCommand( Device, ( 0x08 << 4 ) | 0x00 );
|
||||||
// set Adressing Mode Horizontal
|
// set Adressing Mode Horizontal
|
||||||
Device->WriteCommand( Device, 0x20 );
|
Device->WriteCommand( Device, 0x20 );
|
||||||
Device->WriteCommand( Device, 0 );
|
Device->WriteCommand( Device, 0 );
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ void GDS_DrawBitmapCBR(struct GDS_Device* Device, uint8_t *Data, int Width, int
|
|||||||
uint8_t *optr = Device->Framebuffer;
|
uint8_t *optr = Device->Framebuffer;
|
||||||
int LineLen = Device->Width >> 1;
|
int LineLen = Device->Width >> 1;
|
||||||
Height >>= 3;
|
Height >>= 3;
|
||||||
|
Color &= 0x0f;
|
||||||
for (int i = Width * Height, r = 0, c = 0; --i >= 0;) {
|
for (int i = Width * Height, r = 0, c = 0; --i >= 0;) {
|
||||||
uint8_t Byte = BitReverseTable256[*Data++];
|
uint8_t Byte = BitReverseTable256[*Data++];
|
||||||
// we need to linearize code to let compiler better optimize
|
// we need to linearize code to let compiler better optimize
|
||||||
@@ -223,7 +224,7 @@ void GDS_DrawBitmapCBR(struct GDS_Device* Device, uint8_t *Data, int Width, int
|
|||||||
*optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1;
|
||||||
*optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1;
|
||||||
*optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1;
|
||||||
*optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0x0f) | (((Byte & 0x01)*Color)<<4); optr += LineLen;
|
||||||
} else {
|
} else {
|
||||||
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
||||||
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
||||||
@@ -232,7 +233,7 @@ void GDS_DrawBitmapCBR(struct GDS_Device* Device, uint8_t *Data, int Width, int
|
|||||||
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
||||||
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
||||||
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
||||||
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen; Byte >>= 1;
|
*optr = (*optr & 0xf0) | (((Byte & 0x01)*Color)); optr += LineLen;
|
||||||
}
|
}
|
||||||
// end of a column, move to next one
|
// end of a column, move to next one
|
||||||
if (++r == Height) { c++; r = 0; optr = Device->Framebuffer + (c >> 1); }
|
if (++r == Height) { c++; r = 0; optr = Device->Framebuffer + (c >> 1); }
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ inline void IRAM_ATTR GDS_DrawPixel4Fast( struct GDS_Device* Device, int X, int
|
|||||||
uint8_t* FBOffset;
|
uint8_t* FBOffset;
|
||||||
|
|
||||||
FBOffset = Device->Framebuffer + ( (Y * Device->Width >> 1) + (X >> 1));
|
FBOffset = Device->Framebuffer + ( (Y * Device->Width >> 1) + (X >> 1));
|
||||||
*FBOffset = X & 0x01 ? (*FBOffset & 0x0f) | ((Color & 0x0f) << 4) : ((*FBOffset & 0xf0) | (Color & 0x0f));
|
*FBOffset = X & 0x01 ? (*FBOffset & 0x0f) | ((Color & 0x0f) << 4) : ((*FBOffset & 0xf0) | (Color & 0x0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void IRAM_ATTR GDS_DrawPixelFast( struct GDS_Device* Device, int X, int Y, int Color ) {
|
inline void IRAM_ATTR GDS_DrawPixelFast( struct GDS_Device* Device, int X, int Y, int Color ) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "gds.h"
|
#include "gds.h"
|
||||||
#include "gds_text.h"
|
#include "gds_text.h"
|
||||||
#include "gds_draw.h"
|
#include "gds_draw.h"
|
||||||
|
#include "gds_image.h"
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
@@ -59,6 +60,12 @@ struct grfg_packet {
|
|||||||
u16_t width; // # of pixels of scrollable
|
u16_t width; // # of pixels of scrollable
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct grfa_packet {
|
||||||
|
char opcode[4];
|
||||||
|
u32_t length;
|
||||||
|
u32_t offset;
|
||||||
|
};
|
||||||
|
|
||||||
struct visu_packet {
|
struct visu_packet {
|
||||||
char opcode[4];
|
char opcode[4];
|
||||||
u8_t which;
|
u8_t which;
|
||||||
@@ -130,6 +137,11 @@ static struct scroller_s {
|
|||||||
u32_t width;
|
u32_t width;
|
||||||
} scroller;
|
} scroller;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
u8_t *data;
|
||||||
|
u32_t size;
|
||||||
|
} artwork;
|
||||||
|
|
||||||
#define MAX_BARS 32
|
#define MAX_BARS 32
|
||||||
static EXT_RAM_ATTR struct {
|
static EXT_RAM_ATTR struct {
|
||||||
int bar_gap, bar_width, bar_border;
|
int bar_gap, bar_width, bar_border;
|
||||||
@@ -174,6 +186,7 @@ static void grfe_handler( u8_t *data, int len);
|
|||||||
static void grfb_handler(u8_t *data, int len);
|
static void grfb_handler(u8_t *data, int len);
|
||||||
static void grfs_handler(u8_t *data, int len);
|
static void grfs_handler(u8_t *data, int len);
|
||||||
static void grfg_handler(u8_t *data, int len);
|
static void grfg_handler(u8_t *data, int len);
|
||||||
|
static void grfa_handler(u8_t *data, int len);
|
||||||
static void visu_handler(u8_t *data, int len);
|
static void visu_handler(u8_t *data, int len);
|
||||||
|
|
||||||
static void displayer_task(void* arg);
|
static void displayer_task(void* arg);
|
||||||
@@ -360,6 +373,8 @@ static bool handler(u8_t *data, int len){
|
|||||||
grfs_handler(data, len);
|
grfs_handler(data, len);
|
||||||
} else if (!strncmp((char*) data, "grfg", 4)) {
|
} else if (!strncmp((char*) data, "grfg", 4)) {
|
||||||
grfg_handler(data, len);
|
grfg_handler(data, len);
|
||||||
|
} else if (!strncmp((char*) data, "grfa", 4)) {
|
||||||
|
grfa_handler(data, len);
|
||||||
} else if (!strncmp((char*) data, "visu", 4)) {
|
} else if (!strncmp((char*) data, "visu", 4)) {
|
||||||
visu_handler(data, len);
|
visu_handler(data, len);
|
||||||
} else {
|
} else {
|
||||||
@@ -636,6 +651,33 @@ static void grfg_handler(u8_t *data, int len) {
|
|||||||
vTaskResume(displayer.task);
|
vTaskResume(displayer.task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* Artwork
|
||||||
|
*/
|
||||||
|
static void grfa_handler(u8_t *data, int len) {
|
||||||
|
struct grfa_packet *pkt = (struct grfa_packet*) data;
|
||||||
|
int size = len - sizeof(struct grfa_packet);
|
||||||
|
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) {
|
||||||
|
if (artwork.data) free(artwork.data);
|
||||||
|
artwork.data = malloc(length);
|
||||||
|
artwork.size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy artwork data
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
* Update visualization bars
|
* Update visualization bars
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user