ST7565 tidyup (#10907)

This commit is contained in:
Ryan 2020-11-26 23:44:17 +11:00 committed by GitHub
parent 1c0e8a6bb4
commit 3afe0ea9b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 136 additions and 159 deletions

View File

@ -8,8 +8,9 @@
#ifndef _GDISP_LLD_BOARD_H #ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H #define _GDISP_LLD_BOARD_H
#define ST7565_LCD_BIAS ST7565_LCD_BIAS_9 // actually 6 #include "quantum.h"
#define ST7565_ADC ST7565_ADC_NORMAL
#define ST7565_LCD_BIAS ST7565_LCD_BIAS_7
#define ST7565_COM_SCAN ST7565_COM_SCAN_DEC #define ST7565_COM_SCAN ST7565_COM_SCAN_DEC
#define ST7565_PAGE_ORDER 0, 1, 2, 3 #define ST7565_PAGE_ORDER 0, 1, 2, 3
/* /*
@ -17,19 +18,12 @@
* #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3 * #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3
*/ */
#define ST7565_GPIOPORT GPIOC #define ST7565_A0_PIN C7
#define ST7565_PORT PORTC #define ST7565_RST_PIN C8
#define ST7565_A0_PIN 7 #define ST7565_MOSI_PIN C6
#define ST7565_RST_PIN 8 #define ST7565_SCLK_PIN C5
#define ST7565_MOSI_PIN 6 #define ST7565_SS_PIN C4
#define ST7565_SLCK_PIN 5
#define ST7565_SS_PIN 4
#define palSetPadModeRaw(portname, bits) ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits
#define palSetPadModeNamed(portname, portmode) palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode)
#define ST7565_SPI_MODE PORTx_PCRn_DSE | PORTx_PCRn_MUX(2)
// DSPI Clock and Transfer Attributes // DSPI Clock and Transfer Attributes
// Frame Size: 8 bits // Frame Size: 8 bits
// MSB First // MSB First
@ -38,9 +32,9 @@ static const SPIConfig spi1config = {
// Operation complete callback or @p NULL. // Operation complete callback or @p NULL.
.end_cb = NULL, .end_cb = NULL,
// The chip select line port - when not using pcs. // The chip select line port - when not using pcs.
.ssport = ST7565_GPIOPORT, .ssport = PAL_PORT(ST7565_SS_PIN),
// brief The chip select line pad number - when not using pcs. // brief The chip select line pad number - when not using pcs.
.sspad = ST7565_SS_PIN, .sspad = PAL_PAD(ST7565_SS_PIN),
// SPI initialization data. // SPI initialization data.
.tar0 = SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes .tar0 = SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes
| SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns | SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns
@ -66,13 +60,14 @@ static GFXINLINE void release_bus(GDisplay *g) {
static GFXINLINE void init_board(GDisplay *g) { static GFXINLINE void init_board(GDisplay *g) {
(void)g; (void)g;
palSetPadModeNamed(A0, PAL_MODE_OUTPUT_PUSHPULL); setPinOutput(ST7565_A0_PIN);
palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); writePinHigh(ST7565_A0_PIN);
palSetPadModeNamed(RST, PAL_MODE_OUTPUT_PUSHPULL); setPinOutput(ST7565_RST_PIN);
palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN); writePinHigh(ST7565_RST_PIN);
palSetPadModeRaw(MOSI, ST7565_SPI_MODE); setPinOutput(ST7565_SS_PIN);
palSetPadModeRaw(SLCK, ST7565_SPI_MODE);
palSetPadModeNamed(SS, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(PAL_PORT(ST7565_MOSI_PIN), PAL_PAD(ST7565_MOSI_PIN), PAL_MODE_ALTERNATIVE_2);
palSetPadMode(PAL_PORT(ST7565_SCLK_PIN), PAL_PAD(ST7565_SCLK_PIN), PAL_MODE_ALTERNATIVE_2);
spiInit(); spiInit();
spiStart(&SPID1, &spi1config); spiStart(&SPID1, &spi1config);
@ -83,19 +78,18 @@ static GFXINLINE void post_init_board(GDisplay *g) { (void)g; }
static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) { static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
(void)g; (void)g;
if (state) { writePin(ST7565_RST_PIN, !state);
palClearPad(ST7565_GPIOPORT, ST7565_RST_PIN);
} else {
palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN);
}
} }
static GFXINLINE void enter_data_mode(GDisplay *g) { palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); } static GFXINLINE void write_cmd(GDisplay *g, gU8 cmd) {
static GFXINLINE void enter_cmd_mode(GDisplay *g) { palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN); }
static GFXINLINE void write_data(GDisplay *g, uint8_t *data, uint16_t length) {
(void)g; (void)g;
writePinLow(ST7565_A0_PIN);
spiSend(&SPID1, 1, &cmd);
}
static GFXINLINE void write_data(GDisplay *g, gU8 *data, gU16 length) {
(void)g;
writePinHigh(ST7565_A0_PIN);
spiSend(&SPID1, length, data); spiSend(&SPID1, length, data);
} }

View File

@ -1,3 +1,3 @@
GFXINC += drivers/ugfx/gdisp/st7565 GFXINC += drivers/ugfx/gdisp/st7565
GFXSRC += drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c GFXSRC += drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c
GDISP_DRIVER_LIST += GDISPVMT_ST7565_QMK GDISP_DRIVER_LIST += GDISPVMT_ST7565_QMK

View File

@ -49,31 +49,15 @@
# define ST7565_COM_SCAN ST7565_COM_SCAN_INC # define ST7565_COM_SCAN ST7565_COM_SCAN_INC
# endif # endif
# ifndef ST7565_PAGE_ORDER # ifndef ST7565_PAGE_ORDER
# define ST7565_PAGE_ORDER 0, 1, 2, 3 # define ST7565_PAGE_ORDER 0, 1, 2, 3, 4, 5, 6, 7
# endif # endif
/*===========================================================================*/ /*===========================================================================*/
/* Driver local functions. */ /* Driver local functions. */
/*===========================================================================*/ /*===========================================================================*/
typedef struct {
bool_t buffer2;
uint8_t data_pos;
uint8_t data[16];
uint8_t ram[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH / 8];
} PrivData;
// Some common routines and macros // Some common routines and macros
# define PRIV(g) ((PrivData *)g->priv) # define RAM(g) ((gU8 *)g->priv)
# define RAM(g) (PRIV(g)->ram)
static GFXINLINE void write_cmd(GDisplay *g, uint8_t cmd) { PRIV(g)->data[PRIV(g)->data_pos++] = cmd; }
static GFXINLINE void flush_cmd(GDisplay *g) {
write_data(g, PRIV(g)->data, PRIV(g)->data_pos);
PRIV(g)->data_pos = 0;
}
# define write_cmd2(g, cmd1, cmd2) \ # define write_cmd2(g, cmd1, cmd2) \
{ \ { \
write_cmd(g, cmd1); \ write_cmd(g, cmd1); \
@ -106,9 +90,10 @@ static GFXINLINE void flush_cmd(GDisplay *g) {
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// The private area is the display surface. // The private area is the display surface.
g->priv = gfxAlloc(sizeof(PrivData)); g->priv = gfxAlloc(GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH / 8);
PRIV(g)->buffer2 = false; if (!g->priv) {
PRIV(g)->data_pos = 0; return gFalse;
}
// Initialise the board interface // Initialise the board interface
init_board(g); init_board(g);
@ -119,25 +104,33 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
setpin_reset(g, FALSE); setpin_reset(g, FALSE);
gfxSleepMilliseconds(20); gfxSleepMilliseconds(20);
acquire_bus(g); acquire_bus(g);
enter_cmd_mode(g);
write_cmd(g, ST7565_RESET);
write_cmd(g, ST7565_LCD_BIAS); write_cmd(g, ST7565_LCD_BIAS);
write_cmd(g, ST7565_ADC); write_cmd(g, ST7565_ADC);
write_cmd(g, ST7565_COM_SCAN); write_cmd(g, ST7565_COM_SCAN);
write_cmd(g, ST7565_RESISTOR_RATIO | 0x1);
write_cmd2(g, ST7565_CONTRAST, GDISP_INITIAL_CONTRAST);
// turn on internal power supply (VC=1, VR=1, VF=1)
write_cmd(g, ST7565_POWER_CONTROL | 0x07);
write_cmd(g, ST7565_INVERT_DISPLAY);
write_cmd(g, ST7565_ALLON_NORMAL);
write_cmd(g, ST7565_START_LINE | 0); write_cmd(g, ST7565_START_LINE | 0);
write_cmd2(g, ST7565_CONTRAST, GDISP_INITIAL_CONTRAST * 64 / 101);
write_cmd(g, ST7565_RESISTOR_RATIO | 0x1);
// turn on voltage converter (VC=1, VR=0, VF=0)
write_cmd(g, ST7565_POWER_CONTROL | 0x04);
delay_ms(50);
// turn on voltage regulator (VC=1, VR=1, VF=0)
write_cmd(g, ST7565_POWER_CONTROL | 0x06);
delay_ms(50);
// turn on voltage follower (VC=1, VR=1, VF=1)
write_cmd(g, ST7565_POWER_CONTROL | 0x07);
delay_ms(50);
write_cmd(g, ST7565_DISPLAY_ON);
write_cmd(g, ST7565_ALLON_NORMAL);
write_cmd(g, ST7565_INVERT_DISPLAY); // Disable Inversion of display.
write_cmd(g, ST7565_RMW); write_cmd(g, ST7565_RMW);
flush_cmd(g);
// Finish Init // Finish Init
post_init_board(g); post_init_board(g);
@ -163,22 +156,14 @@ LLDSPEC void gdisp_lld_flush(GDisplay *g) {
if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return;
acquire_bus(g); acquire_bus(g);
enter_cmd_mode(g); gU8 pagemap[] = {ST7565_PAGE_ORDER};
unsigned dstOffset = (PRIV(g)->buffer2 ? 4 : 0); for (p = 0; p < sizeof(pagemap); p++) {
for (p = 0; p < 4; p++) { write_cmd(g, ST7565_PAGE | pagemap[p]);
write_cmd(g, ST7565_PAGE | (p + dstOffset));
write_cmd(g, ST7565_COLUMN_MSB | 0); write_cmd(g, ST7565_COLUMN_MSB | 0);
write_cmd(g, ST7565_COLUMN_LSB | 0); write_cmd(g, ST7565_COLUMN_LSB | 0);
write_cmd(g, ST7565_RMW); write_cmd(g, ST7565_RMW);
flush_cmd(g);
enter_data_mode(g);
write_data(g, RAM(g) + (p * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH); write_data(g, RAM(g) + (p * GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH);
enter_cmd_mode(g);
} }
unsigned line = (PRIV(g)->buffer2 ? 32 : 0);
write_cmd(g, ST7565_START_LINE | line);
flush_cmd(g);
PRIV(g)->buffer2 = !PRIV(g)->buffer2;
release_bus(g); release_bus(g);
g->flags &= ~GDISP_FLG_NEEDFLUSH; g->flags &= ~GDISP_FLG_NEEDFLUSH;
@ -243,6 +228,7 @@ LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
} }
# endif # endif
# if GDISP_HARDWARE_BITFILLS
LLDSPEC void gdisp_lld_blit_area(GDisplay *g) { LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
uint8_t *buffer = (uint8_t *)g->p.ptr; uint8_t *buffer = (uint8_t *)g->p.ptr;
int linelength = g->p.cx; int linelength = g->p.cx;
@ -268,6 +254,7 @@ LLDSPEC void gdisp_lld_blit_area(GDisplay *g) {
} }
g->flags |= GDISP_FLG_NEEDFLUSH; g->flags |= GDISP_FLG_NEEDFLUSH;
} }
# endif
# if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL # if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
LLDSPEC void gdisp_lld_control(GDisplay *g) { LLDSPEC void gdisp_lld_control(GDisplay *g) {
@ -279,16 +266,12 @@ LLDSPEC void gdisp_lld_control(GDisplay *g) {
case powerSleep: case powerSleep:
case powerDeepSleep: case powerDeepSleep:
acquire_bus(g); acquire_bus(g);
enter_cmd_mode(g);
write_cmd(g, ST7565_DISPLAY_OFF); write_cmd(g, ST7565_DISPLAY_OFF);
flush_cmd(g);
release_bus(g); release_bus(g);
break; break;
case powerOn: case powerOn:
acquire_bus(g); acquire_bus(g);
enter_cmd_mode(g);
write_cmd(g, ST7565_DISPLAY_ON); write_cmd(g, ST7565_DISPLAY_ON);
flush_cmd(g);
release_bus(g); release_bus(g);
break; break;
default: default:
@ -318,12 +301,11 @@ LLDSPEC void gdisp_lld_control(GDisplay *g) {
return; return;
case GDISP_CONTROL_CONTRAST: case GDISP_CONTROL_CONTRAST:
g->g.Contrast = (unsigned)g->p.ptr & 63; if ((unsigned)g->p.ptr > 100) g->p.ptr = (void *)100;
acquire_bus(g); acquire_bus(g);
enter_cmd_mode(g); write_cmd2(g, ST7565_CONTRAST, ((((unsigned)g->p.ptr) << 6) / 101) & 0x3F);
write_cmd2(g, ST7565_CONTRAST, g->g.Contrast);
flush_cmd(g);
release_bus(g); release_bus(g);
g->g.Contrast = (unsigned)g->p.ptr;
return; return;
} }
} }

View File

@ -8,105 +8,88 @@
#ifndef _GDISP_LLD_BOARD_H #ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H #define _GDISP_LLD_BOARD_H
#define ST7565_LCD_BIAS ST7565_LCD_BIAS_9 // actually 6 #include "quantum.h"
#define ST7565_ADC ST7565_ADC_NORMAL
#define ST7565_COM_SCAN ST7565_COM_SCAN_DEC #define ST7565_LCD_BIAS ST7565_LCD_BIAS_7
#define ST7565_PAGE_ORDER 0,1,2,3 #define ST7565_COM_SCAN ST7565_COM_SCAN_DEC
#define ST7565_PAGE_ORDER 0, 1, 2, 3
/* /*
* Custom page order for several LCD boards, e.g. HEM12864-99 * Custom page order for several LCD boards, e.g. HEM12864-99
* #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3 * #define ST7565_PAGE_ORDER 4,5,6,7,0,1,2,3
*/ */
#define ST7565_GPIOPORT GPIOC #define ST7565_A0_PIN C7
#define ST7565_PORT PORTC #define ST7565_RST_PIN C8
#define ST7565_A0_PIN 7 #define ST7565_MOSI_PIN C6
#define ST7565_RST_PIN 8 #define ST7565_SCLK_PIN C5
#define ST7565_MOSI_PIN 6 #define ST7565_SS_PIN C4
#define ST7565_SLCK_PIN 5
#define ST7565_SS_PIN 4
#define palSetPadModeRaw(portname, bits) \
ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits
#define palSetPadModeNamed(portname, portmode) \
palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode)
#define ST7565_SPI_MODE PORTx_PCRn_DSE | PORTx_PCRn_MUX(2)
// DSPI Clock and Transfer Attributes // DSPI Clock and Transfer Attributes
// Frame Size: 8 bits // Frame Size: 8 bits
// MSB First // MSB First
// CLK Low by default // CLK Low by default
static const SPIConfig spi1config = { static const SPIConfig spi1config = {
// Operation complete callback or @p NULL. // Operation complete callback or @p NULL.
.end_cb = NULL, .end_cb = NULL,
//The chip select line port - when not using pcs. // The chip select line port - when not using pcs.
.ssport = ST7565_GPIOPORT, .ssport = PAL_PORT(ST7565_SS_PIN),
// brief The chip select line pad number - when not using pcs. // brief The chip select line pad number - when not using pcs.
.sspad=ST7565_SS_PIN, .sspad = PAL_PAD(ST7565_SS_PIN),
// SPI initialization data. // SPI initialization data.
.tar0 = .tar0 = SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes
SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes | SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns
| SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns | SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns
| SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns | SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns
| SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns | SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2
| SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2 | SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns
| SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns
}; };
static GFXINLINE void acquire_bus(GDisplay *g) { static GFXINLINE void acquire_bus(GDisplay *g) {
(void) g; (void)g;
// Only the LCD is using the SPI bus, so no need to acquire // Only the LCD is using the SPI bus, so no need to acquire
// spiAcquireBus(&SPID1); // spiAcquireBus(&SPID1);
spiSelect(&SPID1); spiSelect(&SPID1);
} }
static GFXINLINE void release_bus(GDisplay *g) { static GFXINLINE void release_bus(GDisplay *g) {
(void) g; (void)g;
// Only the LCD is using the SPI bus, so no need to release // Only the LCD is using the SPI bus, so no need to release
//spiReleaseBus(&SPID1); // spiReleaseBus(&SPID1);
spiUnselect(&SPID1); spiUnselect(&SPID1);
} }
static GFXINLINE void init_board(GDisplay *g) { static GFXINLINE void init_board(GDisplay *g) {
(void) g; (void)g;
palSetPadModeNamed(A0, PAL_MODE_OUTPUT_PUSHPULL); setPinOutput(ST7565_A0_PIN);
palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); writePinHigh(ST7565_A0_PIN);
palSetPadModeNamed(RST, PAL_MODE_OUTPUT_PUSHPULL); setPinOutput(ST7565_RST_PIN);
palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN); writePinHigh(ST7565_RST_PIN);
palSetPadModeRaw(MOSI, ST7565_SPI_MODE); setPinOutput(ST7565_SS_PIN);
palSetPadModeRaw(SLCK, ST7565_SPI_MODE);
palSetPadModeNamed(SS, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(PAL_PORT(ST7565_MOSI_PIN), PAL_PAD(ST7565_MOSI_PIN), PAL_MODE_ALTERNATIVE_2);
palSetPadMode(PAL_PORT(ST7565_SCLK_PIN), PAL_PAD(ST7565_SCLK_PIN), PAL_MODE_ALTERNATIVE_2);
spiInit(); spiInit();
spiStart(&SPID1, &spi1config); spiStart(&SPID1, &spi1config);
release_bus(g); release_bus(g);
} }
static GFXINLINE void post_init_board(GDisplay *g) { static GFXINLINE void post_init_board(GDisplay *g) { (void)g; }
(void) g;
}
static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) { static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
(void) g; (void)g;
if (state) { writePin(ST7565_RST_PIN, !state);
palClearPad(ST7565_GPIOPORT, ST7565_RST_PIN);
}
else {
palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN);
}
} }
static GFXINLINE void enter_data_mode(GDisplay *g) { static GFXINLINE void write_cmd(GDisplay *g, gU8 cmd) {
palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN); (void)g;
writePinLow(ST7565_A0_PIN);
spiSend(&SPID1, 1, &cmd);
} }
static GFXINLINE void enter_cmd_mode(GDisplay *g) { static GFXINLINE void write_data(GDisplay *g, gU8 *data, gU16 length) {
palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN); (void)g;
} writePinHigh(ST7565_A0_PIN);
static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
(void) g;
spiSend(&SPID1, length, data); spiSend(&SPID1, length, data);
} }

View File

@ -213,7 +213,7 @@ typedef ioline_t pin_t;
# define writePinHigh(pin) palSetLine(pin) # define writePinHigh(pin) palSetLine(pin)
# define writePinLow(pin) palClearLine(pin) # define writePinLow(pin) palClearLine(pin)
# define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin)) # define writePin(pin, level) ((level) ? (writePinHigh(pin)) : (writePinLow(pin)))
# define readPin(pin) palReadLine(pin) # define readPin(pin) palReadLine(pin)

View File

@ -157,14 +157,14 @@ bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t*
(void)animation; (void)animation;
// Read the uGFX documentation for information how to use the displays // Read the uGFX documentation for information how to use the displays
// http://wiki.ugfx.org/index.php/Main_Page // http://wiki.ugfx.org/index.php/Main_Page
gdispClear(White); gdispClear(Black);
// You can use static variables for things that can't be found in the animation // You can use static variables for things that can't be found in the animation
// or state structs, here we use the image // or state structs, here we use the image
// gdispGBlitArea is a tricky function to use since it supports blitting part of the image // gdispGBlitArea is a tricky function to use since it supports blitting part of the image
// if you have full screen image, then just use LCD_WIDTH and LCD_HEIGHT for both source and target dimensions // if you have full screen image, then just use LCD_WIDTH and LCD_HEIGHT for both source and target dimensions
gdispGBlitArea(GDISP, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo); gdispGBlitArea(GDISP, 0, 0, 128, 32, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo);
return false; return false;
} }

View File

@ -16,6 +16,8 @@
#include "resources.h" #include "resources.h"
// clang-format off
// To generate an image array like this // To generate an image array like this
// Ensure the image is 128 x 32 or smaller // Ensure the image is 128 x 32 or smaller
// Convert the bitmap to a C array using a program like http://www.riuson.com/lcd-image-converter/ // Convert the bitmap to a C array using a program like http://www.riuson.com/lcd-image-converter/
@ -23,7 +25,21 @@
// Update array in the source code with the C array produced by the conversion program // Update array in the source code with the C array produced by the conversion program
// The image below is generated from lcd_logo.png // The image below is generated from lcd_logo.png
__attribute__((weak)) const uint8_t resource_lcd_logo[512] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfe, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, __attribute__((weak)) const uint8_t resource_lcd_logo[512] = {
0x00, 0x38, 0x38, 0x38, 0x06, 0x29, 0x41, 0x24, 0x52, 0x24, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x42, 0xaa, 0xaa, 0xaa, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x82, 0x28, 0xaa, 0xae, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x43, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x0a, 0x55, 0x42, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x05, 0x45, 0x42, 0x28, 0x89, 0x4a, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x80, 0x04, 0x45, 0x14, 0xa4, 0x92, 0x83, 0x52, 0x22, 0x22, 0x36, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0xba, 0x84, 0x55, 0x55, 0x57, 0x45, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0xb2, 0x55, 0x55, 0x42, 0x65, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x56, 0x65, 0x42, 0x45, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x54, 0x45, 0x42, 0x45, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x04, 0x48, 0xa2, 0x4a, 0x89, 0x06, 0x24, 0x42, 0x41, 0x36, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFE, 0xEE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xEE, 0xF0, 0x01, 0xC6, 0x0D, 0x8C, 0x1F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFE, 0xEE, 0xFE, 0x03, 0xE7, 0x1D, 0x9C, 0x1F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xEE, 0xF0, 0x06, 0x37, 0x1D, 0xB8, 0x18, 0x0B, 0x59, 0xC8, 0x09, 0xE5, 0x9E, 0x00,
0x00, 0x1E, 0xEE, 0xF0, 0x06, 0x37, 0xBD, 0xF0, 0x18, 0x6F, 0x7F, 0xEC, 0x9B, 0x37, 0xB3, 0x00, 0x00, 0xFE, 0xEE, 0xFE, 0x06, 0x37, 0xBD, 0xE0, 0x1F, 0x6C, 0x66, 0x6D, 0xD8, 0x36, 0x33, 0x00,
0x00, 0x1E, 0xEE, 0xF0, 0x06, 0x36, 0xED, 0xF0, 0x1F, 0x6C, 0x66, 0x6D, 0x59, 0xF6, 0x3E, 0x00, 0x00, 0x1F, 0x6D, 0xF0, 0x06, 0x36, 0xED, 0xB8, 0x18, 0x6C, 0x66, 0x67, 0x73, 0x36, 0x30, 0x00,
0x00, 0xFF, 0x83, 0xFE, 0x03, 0xE6, 0x4D, 0x9C, 0x18, 0x6C, 0x66, 0x67, 0x73, 0x36, 0x1F, 0x00, 0x00, 0x1F, 0xEF, 0xF0, 0x01, 0xC6, 0x0D, 0x8C, 0x18, 0x6C, 0x66, 0x62, 0x21, 0xD6, 0x0E, 0x00,
0x00, 0xFF, 0xEF, 0xFE, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xF0, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 B

After

Width:  |  Height:  |  Size: 271 B

View File

@ -58,12 +58,14 @@ ULIBS += -lm
endif endif
ifeq ($(strip $(LCD_ENABLE)), yes) ifeq ($(strip $(LCD_ENABLE)), yes)
SRC += $(VISUALIZER_DIR)/lcd_backlight.c SRC += $(VISUALIZER_DIR)/lcd_keyframes.c
SRC += $(VISUALIZER_DIR)/lcd_keyframes.c ifeq ($(strip $(LCD_BACKLIGHT_ENABLE)), yes)
SRC += $(VISUALIZER_DIR)/lcd_backlight_keyframes.c OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
SRC += $(VISUALIZER_DIR)/lcd_backlight.c
SRC += $(VISUALIZER_DIR)/lcd_backlight_keyframes.c
endif
# Note, that the linker will strip out any resources that are not actually in use # Note, that the linker will strip out any resources that are not actually in use
SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c
OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
$(eval $(call ADD_DRIVER,LCD)) $(eval $(call ADD_DRIVER,LCD))
endif endif