Skip to content

Commit

Permalink
use RGB888 for colours not RGB565 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
maks authored Feb 4, 2025
1 parent 5820fe2 commit 4638f33
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/command_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ class CmdBuilder {
case CommandType.CLEAR:
if (_byteBuffer.length == _type!.paramCount) {
final cmd = ClearCmd(
// convert from 565 RGB to 888 RGB
// ref: https://stackoverflow.com/a/9069480/85472
r: (_byteBuffer[0] * 527 + 23) >> 5, // Red component
g: (_byteBuffer[1] * 259 + 33) >> 6, // Green component
b: (_byteBuffer[2] * 527 + 23) >> 5, // Blue component
r: _byteBuffer[0],
g: _byteBuffer[1],
b: _byteBuffer[2],
);
_commandStreamController.add(cmd);
_reset();
Expand All @@ -99,11 +97,9 @@ class CmdBuilder {
case CommandType.SET_COLOUR:
if (_byteBuffer.length == _type!.paramCount) {
final cmd = ColourCmd(
// convert from 565 RGB to 888 RGB
// ref: https://stackoverflow.com/a/9069480/85472
r: (_byteBuffer[0] * 527 + 23) >> 5, // Red component
g: (_byteBuffer[1] * 259 + 33) >> 6, // Green component
b: (_byteBuffer[2] * 527 + 23) >> 5, // Blue component
r: _byteBuffer[0],
g: _byteBuffer[1],
b: _byteBuffer[2],
);
_commandStreamController.add(cmd);
_reset();
Expand Down

0 comments on commit 4638f33

Please sign in to comment.