Add files via upload
parent
4dcb901544
commit
9bdb9d1436
20
main.c
20
main.c
|
@ -13,6 +13,26 @@ int main(void) {
|
|||
spi_init();
|
||||
st7735_init();
|
||||
|
||||
st7735_set_orientation(ST7735_LANDSCAPE);
|
||||
st7735_fill_rect(0, 0, 160, 128, ST7735_COLOR_RED);
|
||||
|
||||
_delay_ms(1000);
|
||||
|
||||
st7735_set_orientation(ST7735_PORTRAIT);
|
||||
st7735_fill_rect(0, 0, 128, 160, ST7735_COLOR_BLUE);
|
||||
|
||||
_delay_ms(1000);
|
||||
|
||||
st7735_set_orientation(ST7735_LANDSCAPE_INV);
|
||||
st7735_fill_rect(0, 0, 160, 128, ST7735_COLOR_YELLOW);
|
||||
|
||||
_delay_ms(1000);
|
||||
|
||||
st7735_set_orientation(ST7735_PORTRAIT_INV);
|
||||
st7735_fill_rect(0, 0, 128, 160, ST7735_COLOR_GREEN);
|
||||
|
||||
_delay_ms(1000);
|
||||
|
||||
st7735_set_orientation(ST7735_LANDSCAPE);
|
||||
st7735_fill_rect(0, 0, 160, 128, ST7735_COLOR_BLACK);
|
||||
|
||||
|
|
26
st7735.c
26
st7735.c
|
@ -6,6 +6,8 @@
|
|||
#include "spi.h"
|
||||
#include "st7735initcmds.h"
|
||||
|
||||
uint8_t st7735_screen_row_start = 0;
|
||||
uint8_t st7735_screen_column_start = 0;
|
||||
uint8_t st7735_row_start = 0;
|
||||
uint8_t st7735_column_start = 0;
|
||||
uint8_t st7735_width = 0;
|
||||
|
@ -106,8 +108,8 @@ void st7735_init() {
|
|||
st7735_run_command_list(st7735_red_init1);
|
||||
st7735_run_command_list(st7735_red_init_green2);
|
||||
st7735_run_command_list(st7735_red_init3);
|
||||
st7735_column_start = 2;
|
||||
st7735_row_start = 1;
|
||||
st7735_column_start = st7735_screen_column_start = 2;
|
||||
st7735_row_start = st7735_screen_row_start = 1;
|
||||
st7735_width = st7735_default_width;
|
||||
st7735_height = st7735_default_height_18;
|
||||
break;
|
||||
|
@ -133,8 +135,8 @@ void st7735_init() {
|
|||
|
||||
case ST7735_RED144_GREENTAB:
|
||||
st7735_height = st7735_default_height_144;
|
||||
st7735_column_start = 2;
|
||||
st7735_row_start = 3;
|
||||
st7735_column_start = st7735_screen_column_start = 2;
|
||||
st7735_row_start = st7735_screen_row_start = 3;
|
||||
st7735_run_command_list(st7735_red_init1);
|
||||
st7735_run_command_list(st7735_red_init_green1442);
|
||||
st7735_run_command_list(st7735_red_init3);
|
||||
|
@ -143,8 +145,8 @@ void st7735_init() {
|
|||
break;
|
||||
case ST7735_RED144_JAYCAR:
|
||||
st7735_height = st7735_default_height_144;
|
||||
st7735_column_start = 32;
|
||||
st7735_row_start = 0;
|
||||
st7735_column_start = st7735_screen_column_start = 0;
|
||||
st7735_row_start = st7735_screen_row_start = 32;
|
||||
st7735_run_command_list(st7735_red_init1);
|
||||
st7735_run_command_list(st7735_red_init_green1442);
|
||||
st7735_run_command_list(st7735_red_init3);
|
||||
|
@ -187,10 +189,8 @@ void st7735_set_orientation(enum ST7735_ORIENTATION orientation) {
|
|||
st7735_height = st7735_default_height_18;
|
||||
}
|
||||
|
||||
if(st7735_type == ST7735_RED144_JAYCAR) {
|
||||
st7735_column_start = 0;
|
||||
st7735_row_start = 32;
|
||||
}
|
||||
st7735_column_start = st7735_screen_column_start;
|
||||
st7735_row_start = st7735_screen_row_start;
|
||||
break;
|
||||
|
||||
|
||||
|
@ -216,6 +216,8 @@ void st7735_set_orientation(enum ST7735_ORIENTATION orientation) {
|
|||
}
|
||||
|
||||
st7735_height = st7735_default_width;
|
||||
st7735_column_start = st7735_screen_row_start;
|
||||
st7735_row_start = st7735_screen_column_start;
|
||||
break;
|
||||
|
||||
case ST7735_PORTRAIT_INV:
|
||||
|
@ -239,6 +241,8 @@ void st7735_set_orientation(enum ST7735_ORIENTATION orientation) {
|
|||
if(st7735_type == ST7735_RED144_JAYCAR) {
|
||||
st7735_column_start = 0;
|
||||
}
|
||||
st7735_column_start = st7735_screen_column_start;
|
||||
st7735_row_start = st7735_screen_row_start;
|
||||
|
||||
break;
|
||||
|
||||
|
@ -263,6 +267,8 @@ void st7735_set_orientation(enum ST7735_ORIENTATION orientation) {
|
|||
}
|
||||
|
||||
st7735_height = st7735_default_width;
|
||||
st7735_column_start = st7735_screen_row_start;
|
||||
st7735_row_start = st7735_screen_column_start;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue