Added ST7735_RED144_JAYCAR screen

This commit is contained in:
Jack Massey 2019-02-28 09:04:33 +10:00
parent 7a7b030e2a
commit cbc18d15e9
3 changed files with 35 additions and 13 deletions

View File

@ -16,10 +16,11 @@ enum ST7735_DISPLAY_TYPE {
ST7735_RED_18_GREENTAB,
ST7735_RED_18_REDTAB,
ST7735_RED_18_BLACKTAB,
ST7735_RED144_GREENTAB
ST7735_RED144_GREENTAB,
ST7735_RED144_JAYCAR
};
static const enum ST7735_DISPLAY_TYPE st7735_type = ST7735_RED_18_BLACKTAB;
static const enum ST7735_DISPLAY_TYPE st7735_type = ST7735_RED144_JAYCAR;
// ST7735 commands

4
spi.c
View File

@ -2,10 +2,10 @@
void spi_init(void) {
// Set MOSI and SCK, SS/CS output, all others input
DDRB = (1<<PB3) | (1<<PB5) | (1<<PB2);
DDRB = (1<<PB3) | (1<<PB5) | (1<<PB2) | (1<<PB0);
// Enable SPI, Master, set clock rate fck/4, mode 0
SPCR = (1<<SPE) | (1<<MSTR);
// Set SS/CS
PORTB |= (1 << PB2);
PORTB |= (1 << PB2) | (1 << PB0);
}

View File

@ -132,12 +132,13 @@ void st7735_init() {
break;
case ST7735_RED144_GREENTAB:
st7735_height = st7735_default_height_144;
st7735_column_start = 2;
st7735_row_start = 3;
case ST7735_RED144_JAYCAR:
st7735_run_command_list(st7735_red_init1);
st7735_run_command_list(st7735_red_init_green1442);
st7735_run_command_list(st7735_red_init3);
st7735_height = st7735_default_height_144;
st7735_column_start = 2;
st7735_row_start = 3;
st7735_width = st7735_default_width;
st7735_height = st7735_default_height_144;
break;
@ -168,11 +169,18 @@ void st7735_set_orientation(enum ST7735_ORIENTATION orientation) {
st7735_width = st7735_default_width;
if(st7735_type == ST7735_RED144_GREENTAB) {
st7735_height = st7735_default_height_144;
if(
st7735_type == ST7735_RED144_GREENTAB ||
st7735_type == ST7735_RED144_JAYCAR
) {
st7735_height = st7735_default_height_144;
} else {
st7735_height = st7735_default_height_18;
}
}
if(st7735_type == ST7735_RED144_JAYCAR) {
st7735_row_start = 32;
}
break;
@ -183,13 +191,20 @@ void st7735_set_orientation(enum ST7735_ORIENTATION orientation) {
st7735_write_data(MADCTL_MY | MADCTL_MV | MADCTL_BGR);
}
if(st7735_type == ST7735_RED144_GREENTAB) {
if(
st7735_type == ST7735_RED144_GREENTAB ||
st7735_type == ST7735_RED144_JAYCAR
) {
st7735_width = st7735_default_height_144;
}
else {
st7735_width = st7735_default_height_18;
}
if(st7735_type == ST7735_RED144_JAYCAR) {
st7735_column_start = 32;
}
st7735_height = st7735_default_width;
break;
@ -202,7 +217,10 @@ void st7735_set_orientation(enum ST7735_ORIENTATION orientation) {
st7735_width = st7735_default_width;
if(st7735_type == ST7735_RED144_GREENTAB) {
if(
st7735_type == ST7735_RED144_GREENTAB ||
st7735_type == ST7735_RED144_JAYCAR
) {
st7735_height = st7735_default_height_144;
} else {
st7735_height = st7735_default_height_18;
@ -216,7 +234,10 @@ void st7735_set_orientation(enum ST7735_ORIENTATION orientation) {
st7735_write_data(MADCTL_MX | MADCTL_MV | MADCTL_BGR);
}
if (st7735_type == ST7735_RED144_GREENTAB) {
if(
st7735_type == ST7735_RED144_GREENTAB ||
st7735_type == ST7735_RED144_JAYCAR
) {
st7735_width = st7735_default_height_144;
} else {
st7735_width = st7735_default_height_18;