work in progress for partial area scroll
This commit is contained in:
parent
a51bb1bf5f
commit
d96a491d32
2 changed files with 55 additions and 19 deletions
24
console.c
24
console.c
|
@ -84,7 +84,7 @@ msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t x1
|
||||||
|
|
||||||
/* calculate the size of the console in characters */
|
/* calculate the size of the console in characters */
|
||||||
console->sx = (x1-x0);
|
console->sx = (x1-x0);
|
||||||
console->sy = ((int16_t)((y1-y0)/console->fy))*console->fy;
|
console->sy = (((int16_t)((y1-y0)/console->fy))-1)*console->fy;
|
||||||
|
|
||||||
console->cx = 0;
|
console->cx = 0;
|
||||||
console->cy = 0;
|
console->cy = 0;
|
||||||
|
@ -102,13 +102,10 @@ msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t x1
|
||||||
console->font = font;
|
console->font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_t lcdConsoleUpdate(GLCDConsole *console) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_t lcdConsolePut(GLCDConsole *console, char c) {
|
msg_t lcdConsolePut(GLCDConsole *console, char c) {
|
||||||
uint8_t width;
|
uint8_t width;
|
||||||
bool_t redraw = FALSE;
|
bool_t newline = FALSE;
|
||||||
|
|
||||||
|
|
||||||
if(c == '\n') {
|
if(c == '\n') {
|
||||||
/* clear the text at the end of the line */
|
/* clear the text at the end of the line */
|
||||||
|
@ -123,19 +120,26 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) {
|
||||||
} else {
|
} else {
|
||||||
width = lcdMeasureChar(c, console->font);
|
width = lcdMeasureChar(c, console->font);
|
||||||
if((console->cx + width) >= console->sx) {
|
if((console->cx + width) >= console->sx) {
|
||||||
|
chprintf(&SD1, "[1] ");
|
||||||
console->cx = 0;
|
console->cx = 0;
|
||||||
console->cy += console->fy;
|
console->cy += console->fy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((console->cy + console->fy) >= console->sy) {
|
if(
|
||||||
|
(console->cy > console->sy)) {
|
||||||
|
chprintf(&SD1, "[2] ");
|
||||||
|
if(newline)
|
||||||
|
chprintf(&SD1, "* ");
|
||||||
lcdVerticalScroll(console->x0, console->y0, console->x0 + console->sx,
|
lcdVerticalScroll(console->x0, console->y0, console->x0 + console->sx,
|
||||||
console->y0 + console->sy, console->fy);
|
console->y0 + console->sy, console->fy);
|
||||||
/* reset the cursor */
|
/* reset the cursor */
|
||||||
console->cx = 0;
|
console->cx = 0;
|
||||||
while((console->cy) >= console->sy)
|
console->cy = console->sy;
|
||||||
console->cy -= console->fy;
|
} else if(newline) {
|
||||||
|
chprintf(&SD1, "[3] ");
|
||||||
|
console->cy += console->fy;
|
||||||
}
|
}
|
||||||
|
//chprintf(&SD1, "'%c' at [%d, %d]\r\n", c, console->x0 + console->cx, console->y0 + console->cy);
|
||||||
lcdDrawChar(console->x0 + console->cx, console->y0 + console->cy, c,
|
lcdDrawChar(console->x0 + console->cx, console->y0 + console->cy, c,
|
||||||
console->font, console->color, console->bkcolor, solid);
|
console->font, console->color, console->bkcolor, solid);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ uint8_t orientation;
|
||||||
uint16_t DeviceCode;
|
uint16_t DeviceCode;
|
||||||
extern uint16_t lcd_width, lcd_height;
|
extern uint16_t lcd_width, lcd_height;
|
||||||
|
|
||||||
|
/* TODO: use max(height, width) */
|
||||||
|
static uint16_t buf[SCREEN_HEIGHT];
|
||||||
|
|
||||||
#ifdef LCD_USE_GPIO
|
#ifdef LCD_USE_GPIO
|
||||||
static __inline void lld_lcdWriteIndex(uint16_t index) {
|
static __inline void lld_lcdWriteIndex(uint16_t index) {
|
||||||
Clr_RS;
|
Clr_RS;
|
||||||
|
@ -131,6 +134,21 @@ __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) {
|
||||||
for(i = 0; i < size; i++)
|
for(i = 0; i < size; i++)
|
||||||
LCD_RAM = buffer[i];
|
LCD_RAM = buffer[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__inline void lld_lcdReadStreamStart(void) {
|
||||||
|
LCD_REG = 0x0022;
|
||||||
|
}
|
||||||
|
|
||||||
|
__inline void lld_lcdReadStreamStop(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
__inline void lld_lcdReadStream(uint16_t *buffer, size_t size) {
|
||||||
|
uint16_t i;
|
||||||
|
for(i = 0; i < size; i++) {
|
||||||
|
buffer[i] = LCD_RAM;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LCD_USE_SPI
|
#ifdef LCD_USE_SPI
|
||||||
|
@ -336,17 +354,31 @@ uint16_t lld_lcdGetWidth(void) {
|
||||||
|
|
||||||
#include "chprintf.h"
|
#include "chprintf.h"
|
||||||
|
|
||||||
|
/* a positive lines value shifts the screen up, negative down */
|
||||||
void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines) {
|
void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines) {
|
||||||
|
uint16_t row0, row1;
|
||||||
|
uint16_t i;
|
||||||
lld_lcdSetWindow(x0, y0, x1, y1);
|
lld_lcdSetWindow(x0, y0, x1, y1);
|
||||||
|
|
||||||
/* if negative shift, then subtract from the height of the area */
|
for(i = 0; i < ((y1-y0) - abs(lines)); i++) {
|
||||||
lines = (lines < 0) ? ((y1-y0) + lines) : lines;
|
if(lines > 0) {
|
||||||
|
row0 = y0 + i + lines;
|
||||||
|
row1 = y0 + i;
|
||||||
|
} else {
|
||||||
|
row0 = (y1 - i - 1) + lines;
|
||||||
|
row1 = (y1 - i - 1);
|
||||||
|
}
|
||||||
|
/* read row0 into the buffer and then write at row1*/
|
||||||
|
lld_lcdSetWindow(x0, row0, x1, row0);
|
||||||
|
lld_lcdReadStreamStart();
|
||||||
|
lld_lcdReadStream(buf, x1-x0);
|
||||||
|
lld_lcdReadStreamStop();
|
||||||
|
|
||||||
/* driver accepts only 9 bit line value */
|
lld_lcdSetWindow(x0, row1, x1, row1);
|
||||||
lld_lcdWriteReg(0x0041, (uint16_t)lines & 0x01FF);
|
lld_lcdWriteStreamStart();
|
||||||
|
lld_lcdWriteStream(buf, x1-x0);
|
||||||
/* enable the scroll */
|
lld_lcdWriteStreamStop();
|
||||||
lld_lcdWriteReg(0x0007, (0x0001 << 9) | 0x0133);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue