-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
98 lines (74 loc) · 2.71 KB
/
main.cpp
File metadata and controls
98 lines (74 loc) · 2.71 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <Arduino.h>
#include "RBCX.h"
void clear(){
rb::Manager::get().oled().fill(rb::Oled::Black);
rb::Manager::get().oled().updateScreen();
}
void waitToNextTest() {
delay(3000);
clear();
}
void setup() {
printf("RB3204-RBCX\n");
delay(500);
printf("Init manager\n");
auto& man = rb::Manager::get();
man.install();
man.leds().red(true);
auto& oled = rb::Manager::get().oled();
oled.init(rb::Oled::Oled_128x64, true, false);
// oled.init(rb::Oled::Oled_128x32, true, false);
while (true) {
///////// fill ////////////////////////
printf("fill\n");
oled.fill(rb::Oled::White);
oled.updateScreen();
delay(1000);
oled.fill(rb::Oled::Black);
oled.updateScreen();
delay(1000);
///////// drawPixel ////////////////////////
printf("drawPixel\n");
for(int i = 0; i<500; i++) {
oled.drawPixel(random(0,oled.getWidth()), random(0, oled.getHeight()), rb::Oled::White);
}
oled.updateScreen();
waitToNextTest();
///////// setCursor ////////////////////////
///////// writeString ////////////////////////
printf("setCursor + writeString\n");
oled.setCursor(45, 0);
oled.writeString("OLED", rb::Oled::Font_11x18, rb::Oled::White);
oled.setCursor(5, oled.getHeight()/2);
String text = "OLED w:" + String(oled.getWidth()) + " | h:" + String(oled.getHeight());
oled.writeString(text.c_str(), rb::Oled::Font_7x10, rb::Oled::White);
oled.updateScreen();
waitToNextTest();
///////// drawLine ////////////////////////
printf("drawLine\n");
oled.drawLine(0, 0, oled.getWidth(), oled.getHeight(), rb::Oled::White);
oled.drawLine(0, oled.getHeight(), oled.getWidth(), 0, rb::Oled::White);
oled.updateScreen();
waitToNextTest();
///////// drawArc ////////////////////////
printf("drawArc\n");
oled.drawArc(oled.getWidth()/2, oled.getHeight()/2, 15, 20, 270, rb::Oled::White);
oled.updateScreen();
waitToNextTest();
///////// drawCircle ////////////////////////
printf("drawCircle\n");
for(uint32_t delta = 0; delta < 5; delta ++) {
oled.drawCircle(20* delta+30, 15, 10, rb::Oled::White);
}
oled.updateScreen();
waitToNextTest();
///////// drawRectangle ////////////////////////
printf("drawRectangle\n");
for(int i = 5; i< oled.getWidth(); i+=5) {
oled.drawRectangle(i, 0, i+i, oled.getHeight()-1, rb::Oled::White);
}
oled.updateScreen();
waitToNextTest();
}
}
void loop() {}