Compare commits

..

No commits in common. "master" and "b4261874cfa472c4d947d73bd1a3629ec9f4a4d5" have entirely different histories.

2 changed files with 4 additions and 52 deletions

View File

@ -1,24 +1,5 @@
#include "st7789_lcd.h"
uint8_t st7789_init_seq_zjy_320_240[] = {
0x05, 0xB2, 0x0C, 0x0C, 0x00, 0x33, 0x33, // Porch Setting
0x01, 0xB7, 0x35, // Gate Control
0x01, 0xBB, 0x32, // VCOM Setting // Factory 0x19 -> 0.725V
0x01, 0xC0, 0x2C, // LCM Control
0x01, 0xC2, 0x01, // VDV and VRH Command Enable
0x01, 0xC3, 0x15, // VRH Set // Factory 12H
0x01, 0xC4, 0x20, // VDV Set
0x01, 0xC6, 0x0F, // Frame Rate Control in Normal Mode
0x02, 0xD0, 0xA4, 0xA1, // Power Control 1
0x0E, 0xE0, 0xD0, 0x08, 0x0E, 0x09, 0x09, 0x05,
0x31, 0x33, 0x48, 0x17, 0x14, 0x15, 0x31,
0x34, // Positive Voltage Gamma Control
0x0E, 0xE1, 0xD0, 0x08, 0x0E, 0x09, 0x09, 0x15,
0x31, 0x33, 0x48, 0x17, 0x14, 0x15, 0x31,
0x34, // Negative Voltage Gamma Control
0x00, 0x21, // Inversion On
};
uint8_t st7789_init_seq_zjy_240_240[] = {
0x05, 0xB2, 0x0C, 0x0C, 0x00, 0x33, 0x33, // Porch Setting
0x01, 0xB7, 0x35, // Gate Control
@ -86,12 +67,12 @@ st7789_ret_t _st7789_window(st7789_lcd_t *lcd, uint16_t x_start, uint16_t x_end,
y_offset = PANEL_X_OFFSET;
break;
case ST7789_DIR_180:
x_offset = 240 - (PANEL_X_OFFSET + PANEL_X_WIDTH);
y_offset = 320 - (PANEL_Y_OFFSET + PANEL_Y_WIDTH);
x_offset = 0;
y_offset = 80;
break;
case ST7789_DIR_270:
x_offset = 320 - (PANEL_Y_OFFSET + PANEL_Y_WIDTH);
y_offset = 240 - (PANEL_X_OFFSET + PANEL_X_WIDTH);
x_offset = 80;
y_offset = 0;
break;
default:
x_offset = 0;
@ -130,13 +111,10 @@ st7789_ret_t _st7789_reset(st7789_lcd_t *lcd) {
}
st7789_ret_t st7789_lcd_init(st7789_lcd_t *lcd) {
if(_st7789_reset(lcd) != ST7789_OK) return ST7789_ERROR;
if(_st7789_init_seq(lcd) != ST7789_OK) return ST7789_ERROR;
if(st7789_lcd_config(lcd, &lcd->config) != ST7789_OK) return ST7789_ERROR;
if(st7789_lcd_sleep(lcd, 0) != ST7789_OK) return ST7789_ERROR;
if(st7789_lcd_display(lcd, 1) != ST7789_OK) return ST7789_ERROR;
return ST7789_OK;
}
st7789_ret_t st7789_lcd_load(st7789_lcd_t *lcd, uint8_t *data, uint16_t x_start,
@ -167,11 +145,6 @@ st7789_ret_t st7789_lcd_load(st7789_lcd_t *lcd, uint8_t *data, uint16_t x_start,
return ST7789_ERROR;
}
uint8_t command = 0x2C; // Memory Write
if(lcd->cb.write_cmd_cb(lcd->user_data, &command, 0x01) != ST7789_OK) {
return ST7789_ERROR;
}
// Write pixel data
if(lcd->cb.write_data_cb(lcd->user_data, data, data_len) != ST7789_OK) {
return ST7789_ERROR;
@ -194,12 +167,6 @@ st7789_ret_t st7789_lcd_display(st7789_lcd_t *lcd, uint8_t display_on) {
if(lcd->cb.write_cmd_cb(lcd->user_data, &command, 0x01) != ST7789_OK) {
return ST7789_ERROR;
}
if(lcd->cb.backlight_cb(lcd->user_data, display_on) != ST7789_OK) {
return ST7789_ERROR;
}
return ST7789_OK;
}
st7789_ret_t st7789_lcd_config(st7789_lcd_t *lcd, st7789_config_t *config) {

View File

@ -24,7 +24,6 @@ typedef enum {
typedef struct {
st7789_ret_t (*reset_cb)(void *handle);
st7789_ret_t (*backlight_cb)(void *handle, uint8_t on);
st7789_ret_t (*write_cmd_cb)(void *handle, uint8_t *cmd, uint8_t len);
st7789_ret_t (*write_data_cb)(void *handle, uint8_t *data, uint32_t len);
} st7789_cb_t;
@ -45,33 +44,19 @@ typedef struct {
#ifdef ST7789_PANEL_ZJY_240
#define ST7789_PANEL_SELECTION st7789_init_seq_zjy_240_240
#define PANEL_X_WIDTH 240
#define PANEL_Y_WIDTH 240
#define PANEL_X_OFFSET 0
#define PANEL_Y_OFFSET 0
#elif ST7789_PANEL_ZJY_135
#define ST7789_PANEL_SELECTION st7789_init_seq_zjy_240_135
#define PANEL_X_WIDTH 240
#define PANEL_Y_WIDTH 135
#define PANEL_X_OFFSET 53
#define PANEL_Y_OFFSET 40
#elif ST7789_PANEL_ZJY_320
#define ST7789_PANEL_SELECTION st7789_init_seq_zjy_320_240
#define PANEL_X_WIDTH 240
#define PANEL_Y_WIDTH 320
#define PANEL_X_OFFSET 0
#define PANEL_Y_OFFSET 0
#else
#warning "Panel not defined, using default."
#define ST7789_PANEL_SELECTION st7789_init_seq_zjy_240_240
#define PANEL_X_WIDTH 240
#define PANEL_Y_WIDTH 240
#define PANEL_X_OFFSET 0
#define PANEL_Y_OFFSET 0