forked from mfulz_github/qmk_firmware
faster buffer sending
This commit is contained in:
parent
129df28574
commit
4446a3781c
|
@ -43,6 +43,7 @@ uint16_t fontMapWidth;
|
||||||
#define swap(a, b) { uint8_t t = a; a = b; b = t; }
|
#define swap(a, b) { uint8_t t = a; a = b; b = t; }
|
||||||
|
|
||||||
uint8_t micro_oled_transfer_buffer[20];
|
uint8_t micro_oled_transfer_buffer[20];
|
||||||
|
static uint8_t micro_oled_screen_current[384] = { 0 };
|
||||||
static uint8_t micro_oled_screen_buffer[] = {
|
static uint8_t micro_oled_screen_buffer[] = {
|
||||||
/* LCD Memory organised in 64 horizontal pixel and 6 rows of byte
|
/* LCD Memory organised in 64 horizontal pixel and 6 rows of byte
|
||||||
B B .............B -----
|
B B .............B -----
|
||||||
|
@ -145,7 +146,7 @@ void micro_oled_init(void) {
|
||||||
send_command(0x40);
|
send_command(0x40);
|
||||||
|
|
||||||
send_command(DISPLAYON); //--turn on oled panel
|
send_command(DISPLAYON); //--turn on oled panel
|
||||||
//clear_screen(); // Erase hardware memory inside the OLED controller to avoid random data in memory.
|
clear_screen(); // Erase hardware memory inside the OLED controller to avoid random data in memory.
|
||||||
send_buffer();
|
send_buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,19 +218,30 @@ void set_contrast(uint8_t contrast) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Transfer display buffer.
|
/** \brief Transfer display buffer.
|
||||||
Bulk move the screen buffer to the SSD1306 controller's memory so that images/graphics drawn on the screen buffer will be displayed on the OLED.
|
Sends the updated buffer to the controller - the current status is checked before to save i2c exectution time
|
||||||
*/
|
*/
|
||||||
void send_buffer(void) {
|
void send_buffer(void) {
|
||||||
uint8_t i, j;
|
uint8_t i, j;
|
||||||
|
|
||||||
for (i=0; i<6; i++) {
|
uint8_t page_addr = 0xFF;
|
||||||
set_page_address(i);
|
for (i = 0; i < 6; i++) {
|
||||||
set_column_address(0);
|
uint8_t col_addr = 0xFF;
|
||||||
for (j=0;j<0x40;j++) {
|
for (j = 0; j < 0x40; j++) {
|
||||||
send_data(micro_oled_screen_buffer[i*0x40+j]);
|
if (micro_oled_screen_buffer[i*0x40+j] != micro_oled_screen_current[i*0x40+j]) {
|
||||||
|
if (page_addr != i) {
|
||||||
|
set_page_address(i);
|
||||||
|
}
|
||||||
|
if (col_addr != j) {
|
||||||
|
set_column_address(j);
|
||||||
|
}
|
||||||
|
send_data(micro_oled_screen_buffer[i*0x40+j]);
|
||||||
|
micro_oled_screen_current[i*0x40+j] = micro_oled_screen_buffer[i*0x40+j];
|
||||||
|
col_addr = j + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Draw pixel with color and mode.
|
/** \brief Draw pixel with color and mode.
|
||||||
Draw color pixel in the screen buffer's x,y position with NORM or XOR draw mode.
|
Draw color pixel in the screen buffer's x,y position with NORM or XOR draw mode.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -37,6 +37,7 @@ void send_command(uint8_t command);
|
||||||
void send_data(uint8_t data);
|
void send_data(uint8_t data);
|
||||||
void set_page_address(uint8_t address);
|
void set_page_address(uint8_t address);
|
||||||
void set_column_address(uint8_t address);
|
void set_column_address(uint8_t address);
|
||||||
|
void clear_screen(void);
|
||||||
void clear_buffer(void);
|
void clear_buffer(void);
|
||||||
void send_buffer(void);
|
void send_buffer(void);
|
||||||
void draw_pixel(uint8_t x, uint8_t y, uint8_t color, uint8_t mode);
|
void draw_pixel(uint8_t x, uint8_t y, uint8_t color, uint8_t mode);
|
||||||
|
|
Loading…
Reference in New Issue