-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path02_setRGBpixelsQuestionMark.cpp
More file actions
56 lines (47 loc) · 1.85 KB
/
02_setRGBpixelsQuestionMark.cpp
File metadata and controls
56 lines (47 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* File: 02_setRGBpixelsQuestionMark.cpp
* Author: Philippe Latu
* Source: https://github.com/platu/libsensehat-cpp
*
* This example program illustrates the senseSetRGBpixels() function that
* prints all pixels at once.
* One pixel RGB colors are encoded in an array of three bytes defined by the
* rgb_pixel_t type.
* RGB colors of all pixels are stored in a 8x8 array of rgb_pixel_t elements.
* The complete pixel map is defined by the rgb_pixels_t type.
*
* Function prototype:
*
* void senseSetRGBpixels(rgb_pixels_t );
* all pixels map -^
*
* The program prints a red question mark on a white background.
*/
#include <iostream>
#include <iomanip>
#include <console_io.h>
#include <sensehat.h>
using namespace std;
int main() {
const rgb_pixel_t R = {.color = {255, 0, 0}}; // Red
const rgb_pixel_t W = {.color = {255, 255, 255}}; // White
rgb_pixels_t question_mark = {.array = {{W, W, W, R, R, W, W, W},
{W, W, R, W, W, R, W, W},
{W, W, W, W, W, R, W, W},
{W, W, W, W, R, W, W, W},
{W, W, W, R, W, W, W, W},
{W, W, W, R, W, W, W, W},
{W, W, W, W, W, W, W, W},
{W, W, W, R, W, W, W, W}}};
if (senseInit()) {
cout << "-------------------------------" << endl
<< "Sense Hat initialization Ok." << endl;
senseClear();
senseSetPixels(question_mark);
cout << endl << "Waiting for keypress." << endl;
getch();
senseShutdown();
cout << "-------------------------------" << endl
<< "Sense Hat shut down." << endl;
}
return EXIT_SUCCESS;
}