Public Access
Send only the changed dots of a frame to the Nano
Frames were sent as F0 plus one s command per yellow dot (thousands of characters). During scrolling that overran the Nano's serial buffer, and half-received frames redrew the whole screen. showBitmap() now sends two B commands over the changed rectangle (dots off, dots on), or one B command for a full frame, and the pacing counts the characters sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
89001ddbc6
commit
47ef65ee7d
8 files changed
+262
-25
No files matched your search
@@ -23,6 +23,38 @@ void BROSE9323::begin(Stream *s)
|
||||
{
|
||||
stream = s;
|
||||
}
|
||||
|
||||
size_t BROSE9323::showBitmap(const uint8_t *bitmap, bool changes_only, bool instant)
|
||||
{
|
||||
// What the Nano shows now, in drawBitmap format (the buffers keep the bits the other
|
||||
// way around)
|
||||
uint8_t *shown = (uint8_t *)malloc(_buffer_size);
|
||||
if (!shown)
|
||||
return 0;
|
||||
for (uint16_t i = 0; i < _buffer_size; i++)
|
||||
{
|
||||
uint8_t b = _old_buffer[i], r = 0;
|
||||
for (uint8_t k = 0; k < 8; k++)
|
||||
if (b & (1 << k))
|
||||
r |= 0x80 >> k;
|
||||
shown[i] = r;
|
||||
}
|
||||
size_t sent = frameCommands(bitmap, changes_only ? shown : nullptr, width(), height(), instant,
|
||||
[this](const char *text) { stream->print(text); });
|
||||
free(shown);
|
||||
|
||||
for (uint8_t y = 0; y < height(); y++)
|
||||
for (uint8_t x = 0; x < width(); x++)
|
||||
{
|
||||
uint8_t &byte = _new_buffer[y * _buffer_width + x / 8];
|
||||
if (bitmap[y * _buffer_width + x / 8] & (0x80 >> (x & 7)))
|
||||
byte |= 1 << (x & 7);
|
||||
else
|
||||
byte &= ~(1 << (x & 7));
|
||||
}
|
||||
memcpy(_old_buffer, _new_buffer, _buffer_size);
|
||||
return sent;
|
||||
}
|
||||
#else
|
||||
void BROSE9323::begin(void)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user