Merge pull request #5 from PaulKlinger/master
Some simple functions for manipulating display buffer/partial updates
Dieser Commit ist enthalten in:
Commit
525ecf6775
22
lcd.c
22
lcd.c
@ -155,8 +155,11 @@ void lcd_init(uint8_t dispAttr){
|
|||||||
lcd_clrscr();
|
lcd_clrscr();
|
||||||
}
|
}
|
||||||
void lcd_gotoxy(uint8_t x, uint8_t y){
|
void lcd_gotoxy(uint8_t x, uint8_t y){
|
||||||
if( x > (DISPLAY_WIDTH/sizeof(FONT[0])) || y > (DISPLAY_HEIGHT/8-1)) return;// out of display
|
|
||||||
x = x * sizeof(FONT[0]);
|
x = x * sizeof(FONT[0]);
|
||||||
|
lcd_goto_xpix_y(x,y);
|
||||||
|
}
|
||||||
|
void lcd_goto_xpix_y(uint8_t x, uint8_t y){
|
||||||
|
if( x > (DISPLAY_WIDTH) || y > (DISPLAY_HEIGHT/8-1)) return;// out of display
|
||||||
cursorPosition.x=x;
|
cursorPosition.x=x;
|
||||||
cursorPosition.y=y;
|
cursorPosition.y=y;
|
||||||
#if defined (SSD1306) || defined (SSD1309)
|
#if defined (SSD1306) || defined (SSD1309)
|
||||||
@ -488,4 +491,21 @@ void lcd_display() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
void lcd_clear_buffer() {
|
||||||
|
for (uint8_t i = 0; i < DISPLAY_HEIGHT/8; i++){
|
||||||
|
memset(displayBuffer[i], 0x00, sizeof(displayBuffer[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint8_t lcd_check_buffer(uint8_t x, uint8_t y) {
|
||||||
|
if( x > DISPLAY_WIDTH-1 || y > (DISPLAY_HEIGHT-1)) return 0; // out of Display
|
||||||
|
return displayBuffer[(y / (DISPLAY_HEIGHT/8))][x] & (1 << (y % (DISPLAY_HEIGHT/8)));
|
||||||
|
}
|
||||||
|
void lcd_display_block(uint8_t x, uint8_t line, uint8_t width) {
|
||||||
|
if (line > (DISPLAY_HEIGHT/8-1) || x > DISPLAY_WIDTH - 1){return;}
|
||||||
|
if (x + width > DISPLAY_WIDTH) { // no -1 here, x alone is width 1
|
||||||
|
width = DISPLAY_WIDTH - x;
|
||||||
|
}
|
||||||
|
lcd_goto_xpix_y(x,line);
|
||||||
|
lcd_data(&displayBuffer[line][x], width);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
5
lcd.h
5
lcd.h
@ -124,6 +124,8 @@ extern "C" {
|
|||||||
void lcd_clrscr(void); // clear screen (and buffer at GRFAICMODE)
|
void lcd_clrscr(void); // clear screen (and buffer at GRFAICMODE)
|
||||||
void lcd_gotoxy(uint8_t x, uint8_t y); // set curser at pos x, y. x means character,
|
void lcd_gotoxy(uint8_t x, uint8_t y); // set curser at pos x, y. x means character,
|
||||||
// y means line (page, refer lcd manual)
|
// y means line (page, refer lcd manual)
|
||||||
|
void lcd_goto_xpix_y(uint8_t x, uint8_t y); // set curser at pos x, y. x means pixel,
|
||||||
|
// y means line (page, refer lcd manual)
|
||||||
void lcd_putc(char c); // print character on screen at TEXTMODE
|
void lcd_putc(char c); // print character on screen at TEXTMODE
|
||||||
// at GRAPHICMODE print character to buffer
|
// at GRAPHICMODE print character to buffer
|
||||||
void lcd_charMode(uint8_t mode); // set size of chars
|
void lcd_charMode(uint8_t mode); // set size of chars
|
||||||
@ -136,6 +138,9 @@ extern "C" {
|
|||||||
void lcd_fillCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color);
|
void lcd_fillCircle(uint8_t center_x, uint8_t center_y, uint8_t radius, uint8_t color);
|
||||||
void lcd_drawBitmap(uint8_t x, uint8_t y, const uint8_t picture[], uint8_t width, uint8_t height, uint8_t color);
|
void lcd_drawBitmap(uint8_t x, uint8_t y, const uint8_t picture[], uint8_t width, uint8_t height, uint8_t color);
|
||||||
void lcd_display(void); // copy buffer to display RAM
|
void lcd_display(void); // copy buffer to display RAM
|
||||||
|
void lcd_clear_buffer(void); // clear display buffer
|
||||||
|
uint8_t lcd_check_buffer(uint8_t x, uint8_t y); // read a pixel value from the display buffer
|
||||||
|
void lcd_display_block(uint8_t x, uint8_t line, uint8_t width); // display (part of) a display line
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren