add 'pause'

This commit is contained in:
philippe44
2020-02-27 18:23:00 -08:00
parent 5fb4b14e87
commit 876ae491a1
3 changed files with 20 additions and 4 deletions

View File

@@ -39,6 +39,7 @@ static void Update( struct GDS_Device* Device ) {
// not sure the compiler does not have to redo all calculation in for loops, so local it is
int width = Device->Width, rows = Device->Height / 8;
uint8_t *optr = Device->Shadowbuffer, *iptr = Device->Framebuffer;
int CurrentRow = -1, FirstCol = -1, LastCol = -1;
// by row, find first and last columns that have been updated
for (int r = 0; r < rows; r++) {
@@ -53,8 +54,22 @@ static void Update( struct GDS_Device* Device ) {
// now update the display by "byte rows"
if (first--) {
SetColumnAddress( Device, first, last );
SetPageAddress( Device, r, r);
// only set column when useful, saves a fair bit of CPU
if (first > FirstCol && first <= FirstCol + 4 && last < LastCol && last >= LastCol - 4) {
first = FirstCol;
last = LastCol;
} else {
SetColumnAddress( Device, first, last );
FirstCol = first;
LastCol = last;
}
// Set row only when needed, otherwise let auto-increment work
if (r != CurrentRow) SetPageAddress( Device, r, Device->Height / 8 - 1 );
CurrentRow = r + 1;
// actual write
Device->WriteData( Device, Device->Shadowbuffer + r*width + first, last - first + 1);
}
}

View File

@@ -289,13 +289,14 @@ void displayer_metadata(char *artist, char *album, char *title) {
/****************************************************************************************
*
*/
void displayer_scroll(char *string, int speed) {
void displayer_scroll(char *string, int speed, int pause) {
// need a display!
if (!display) return;
xSemaphoreTake(displayer.mutex, portMAX_DELAY);
if (speed) displayer.speed = speed;
if (pause) displayer.pause = pause;
displayer.offset = 0;
strncpy(displayer.string, string, SCROLLABLE_SIZE);
displayer.string[SCROLLABLE_SIZE] = '\0';

View File

@@ -42,7 +42,7 @@ enum displayer_time_e { DISPLAYER_ELAPSED, DISPLAYER_REMAINING };
enum display_bus_cmd_e { DISPLAY_BUS_TAKE, DISPLAY_BUS_GIVE };
bool (*display_bus)(void *from, enum display_bus_cmd_e cmd);
void displayer_scroll(char *string, int speed);
void displayer_scroll(char *string, int speed, int pause);
void displayer_control(enum displayer_cmd_e cmd, ...);
void displayer_metadata(char *artist, char *album, char *title);
void displayer_timer(enum displayer_time_e mode, int elapsed, int duration);