Avoid 0xFF character when writing to MAX7456 in auto-increment mode

The 0xFF character is used as an "escape" character by the MAX7456 when using auto-increment mode. The last byte of the characters used for the logo is the 0xFF character and this was causing the version and CMS instructions to not display.

Changed the logic to avoid the 0xFF character during the auto-increment phase and added a second pass if needed to update those characters in direct addressing mode.
This commit is contained in:
Bruce Luckcuck 2018-05-01 12:02:56 -04:00
parent 02efd46833
commit 932998a33c
1 changed files with 26 additions and 3 deletions

View File

@ -653,18 +653,41 @@ void max7456DrawScreen(void)
static void max7456DrawScreenSlow(void) static void max7456DrawScreenSlow(void)
{ {
bool escapeCharFound;
ENABLE_MAX7456; ENABLE_MAX7456;
// Enable auto-increment mode and update every character in the screenBuffer.
// The "escape" character 0xFF must be skipped as it causes the MAX7456 to exit auto-increment mode.
max7456Send(MAX7456ADD_DMAH, 0); max7456Send(MAX7456ADD_DMAH, 0);
max7456Send(MAX7456ADD_DMAL, 0); max7456Send(MAX7456ADD_DMAL, 0);
max7456Send(MAX7456ADD_DMM, displayMemoryModeReg | 1); max7456Send(MAX7456ADD_DMM, displayMemoryModeReg | 1);
for (int xx = 0; xx < maxScreenSize; ++xx) { for (int xx = 0; xx < maxScreenSize; xx++) {
if (screenBuffer[xx] == END_STRING) {
escapeCharFound = true;
max7456Send(MAX7456ADD_DMDI, ' '); // replace the 0xFF character with a blank in the first pass to avoid terminating auto-increment
} else {
max7456Send(MAX7456ADD_DMDI, screenBuffer[xx]); max7456Send(MAX7456ADD_DMDI, screenBuffer[xx]);
}
shadowBuffer[xx] = screenBuffer[xx]; shadowBuffer[xx] = screenBuffer[xx];
} }
max7456Send(MAX7456ADD_DMDI, 0xFF); max7456Send(MAX7456ADD_DMDI, END_STRING);
max7456Send(MAX7456ADD_DMM, displayMemoryModeReg); max7456Send(MAX7456ADD_DMM, displayMemoryModeReg);
// If we found any of the "escape" character 0xFF, then make a second pass
// to update them with direct addressing
if (escapeCharFound) {
for (int xx = 0; xx < maxScreenSize; xx++) {
if (screenBuffer[xx] == END_STRING) {
max7456Send(MAX7456ADD_DMAH, xx >> 8);
max7456Send(MAX7456ADD_DMAL, xx & 0xFF);
max7456Send(MAX7456ADD_DMDI, END_STRING);
}
}
}
DISABLE_MAX7456; DISABLE_MAX7456;
} }