File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1+ #include " doctest.h"
2+ #include " util/colors_rgb565.hh"
3+
4+ TEST_CASE (" Basic usage" ) {
5+
6+ RGB565 c1;
7+ RGB565 c2{};
8+ RGB565 c3{(uint8_t )0x80 , 0x40 , 0x20 };
9+ RGB565 c4{0 .5f , 0 .25f , 0 .125f };
10+ RGB565 c5{0x804020 };
11+
12+ CHECK (c1.raw () == 0 );
13+ CHECK (c2.raw () == 0 );
14+ CHECK (c3.raw () == 0x8204 );
15+ CHECK (c4.raw () == 0x8204 );
16+ CHECK (c5.raw () == 0x8204 );
17+
18+ CHECK (c5.red () == 0x80 );
19+ CHECK (c5.green () == 0x40 );
20+ CHECK (c5.blue () == 0x20 );
21+
22+ c1 = 0x2334 ;
23+ CHECK (c1.raw () == 0x2334 );
24+ CHECK ((uint16_t )c1 == 0x2334 );
25+ }
Original file line number Diff line number Diff line change 55
66struct RGB565 {
77 // msb> rrrrr gggggg bbbbb <lsb
8- uint16_t b : 5 ;
9- uint16_t g : 6 ;
10- uint16_t r : 5 ;
8+ uint16_t b : 5 {} ;
9+ uint16_t g : 6 {} ;
10+ uint16_t r : 5 {} ;
1111
12- constexpr RGB565 () {
12+ constexpr RGB565 ()
13+ : b{0 }
14+ , g{0 }
15+ , r{0 } {
1316 }
1417
1518 constexpr RGB565 (uint8_t red, uint8_t green, uint8_t blue)
You can’t perform that action at this time.
0 commit comments