Skip to content

Commit 196949d

Browse files
committed
fix: old lessons codes
1 parent 8434e1d commit 196949d

File tree

20 files changed

+213
-301
lines changed

20 files changed

+213
-301
lines changed

examples/Platform_Tutorials/lessons/Basic_codes/01-programming-the-braccio-display/01_creating_a_button/01_creating_a_button.ino

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
#include <Braccio++.h>
1+
#include <Braccio++.h>
22

33
void customMenu() {
44
Braccio.lvgl_lock();
5-
65
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
76
lv_obj_set_size(btn1, 120, 75);
87
lv_obj_t * label1 = lv_label_create(btn1);
98
lv_label_set_text(label1, "BTN 1");
109
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, 0);
1110
lv_obj_center(label1);
12-
1311
Braccio.lvgl_unlock();
1412
}
1513

1614
void setup() {
1715
// put your setup code here, to run once:
18-
if (!Braccio.begin(customMenu)) {
19-
if (Serial) Serial.println("Braccio.begin() failed.");
20-
for(;;) { }
21-
}
16+
Braccio.begin(customMenu);
2217
}
2318

2419
void loop() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"cpu": {
3+
"fqbn": "arduino:mbed_nano:nanorp2040connect",
4+
"name": "Arduino Nano RP2040 Connect",
5+
"port": "serial:///dev/ttyACM0"
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,41 @@
1-
#include <Braccio++.h>
2-
3-
// Arduino Colors
4-
#define COLOR_TEAL 0x00878F
5-
#define COLOR_LIGHT_TEAL 0x62AEB2
6-
#define COLOR_ORANGE 0xE47128
7-
#define COLOR_YELLOW 0xE5AD24
8-
#define COLOR_WHITE 0xFFFFFF
9-
10-
11-
void customMenu() {
12-
Braccio.lvgl_lock();
13-
static lv_style_t style;
14-
lv_style_init(&style);
15-
lv_style_set_bg_color(&style, lv_color_hex(COLOR_WHITE));
16-
lv_style_set_border_color(&style, lv_color_hex(COLOR_TEAL));
17-
lv_style_set_border_width(&style, 5);
18-
lv_style_set_text_color(&style, lv_color_hex(COLOR_ORANGE));
19-
20-
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
21-
lv_obj_set_size(btn1, 120, 75);
22-
23-
lv_obj_t * label1 = lv_label_create(btn1);
24-
lv_label_set_text(label1, "BTN 1");
25-
26-
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, 0);
27-
lv_obj_center(label1);
28-
29-
lv_obj_add_style(btn1, &style, 0);
30-
Braccio.lvgl_unlock();
31-
}
32-
33-
void setup() {
34-
// put your setup code here, to run once:
35-
if (!Braccio.begin(customMenu)) {
36-
if (Serial) Serial.println("Braccio.begin() failed.");
37-
for(;;) { }
38-
}
39-
}
40-
41-
void loop() {
42-
// put your main code here, to run repeatedly:
43-
44-
}
1+
#include <Braccio++.h>
2+
3+
// Arduino Colors
4+
#define COLOR_TEAL 0x00878F
5+
#define COLOR_LIGHT_TEAL 0x62AEB2
6+
#define COLOR_ORANGE 0xE47128
7+
#define COLOR_YELLOW 0xE5AD24
8+
#define COLOR_WHITE 0xFFFFFF
9+
10+
11+
void customMenu() {
12+
Braccio.lvgl_lock();
13+
static lv_style_t style;
14+
lv_style_init(&style);
15+
lv_style_set_bg_color(&style, lv_color_hex(COLOR_WHITE));
16+
lv_style_set_border_color(&style, lv_color_hex(COLOR_TEAL));
17+
lv_style_set_border_width(&style, 5);
18+
lv_style_set_text_color(&style, lv_color_hex(COLOR_ORANGE));
19+
20+
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
21+
lv_obj_set_size(btn1, 120, 75);
22+
23+
lv_obj_t * label1 = lv_label_create(btn1);
24+
lv_label_set_text(label1, "BTN 1");
25+
26+
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, 0);
27+
lv_obj_center(label1);
28+
29+
lv_obj_add_style(btn1, &style, 0);
30+
Braccio.lvgl_unlock();
31+
}
32+
33+
void setup() {
34+
// put your setup code here, to run once:
35+
Braccio.begin(customMenu);
36+
}
37+
38+
void loop() {
39+
// put your main code here, to run repeatedly:
40+
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cpu": {
3+
"fqbn": "arduino:mbed_nano:nanorp2040connect",
4+
"port": ""
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,48 @@
1-
#include <Braccio++.h>
2-
3-
#define MARGIN_LEFT 0
4-
#define MARGIN_TOP 0
5-
6-
// Arduino Colors
7-
#define COLOR_TEAL 0x00878F
8-
#define COLOR_LIGHT_TEAL 0x62AEB2
9-
#define COLOR_ORANGE 0xE47128
10-
#define COLOR_YELLOW 0xE5AD24
11-
#define COLOR_WHITE 0xFFFFFF
12-
13-
static const char * btnm_map[] = {"OPTION 1", "OPTION 2", "\n",
14-
"OPTION 3", "OPTION 4", "\0"
15-
};
16-
17-
void customMenu() {
18-
Braccio.lvgl_lock();
19-
20-
static lv_style_t style_bg;
21-
lv_style_init(&style_bg);
22-
lv_style_set_bg_color(&style_bg, lv_color_hex(COLOR_LIGHT_TEAL));
23-
24-
static lv_style_t style_btn;
25-
lv_style_init(&style_btn);
26-
lv_style_set_bg_color(&style_btn, lv_color_hex(COLOR_WHITE));
27-
lv_style_set_border_color(&style_btn, lv_color_hex(COLOR_YELLOW));
28-
lv_style_set_border_width(&style_btn, 2);
29-
lv_style_set_text_color(&style_btn, lv_color_hex(COLOR_TEAL));
30-
31-
32-
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
33-
lv_btnmatrix_set_map(btnm1, btnm_map);
34-
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
35-
36-
lv_obj_add_style(btnm1, &style_bg, 0);
37-
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
38-
39-
Braccio.lvgl_unlock();
40-
}
41-
42-
void setup() {
43-
// put your setup code here, to run once:
44-
if (!Braccio.begin(customMenu)) {
45-
if (Serial) Serial.println("Braccio.begin() failed.");
46-
for(;;) { }
47-
}
48-
}
49-
50-
void loop() {
51-
// put your main code here, to run repeatedly:
52-
53-
}
1+
#include <Braccio++.h>
2+
3+
#define MARGIN_LEFT 0
4+
#define MARGIN_TOP 0
5+
6+
// Arduino Colors
7+
#define COLOR_TEAL 0x00878F
8+
#define COLOR_LIGHT_TEAL 0x62AEB2
9+
#define COLOR_ORANGE 0xE47128
10+
#define COLOR_YELLOW 0xE5AD24
11+
#define COLOR_WHITE 0xFFFFFF
12+
13+
static const char * btnm_map[] = {"OPTION 1", "OPTION 2", "\n",
14+
"OPTION 3", "OPTION 4", "\0"
15+
};
16+
17+
void customMenu() {
18+
Braccio.lvgl_lock();
19+
static lv_style_t style_bg;
20+
lv_style_init(&style_bg);
21+
lv_style_set_bg_color(&style_bg, lv_color_hex(COLOR_LIGHT_TEAL));
22+
23+
static lv_style_t style_btn;
24+
lv_style_init(&style_btn);
25+
lv_style_set_bg_color(&style_btn, lv_color_hex(COLOR_WHITE));
26+
lv_style_set_border_color(&style_btn, lv_color_hex(COLOR_YELLOW));
27+
lv_style_set_border_width(&style_btn, 2);
28+
lv_style_set_text_color(&style_btn, lv_color_hex(COLOR_TEAL));
29+
30+
31+
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
32+
lv_btnmatrix_set_map(btnm1, btnm_map);
33+
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
34+
35+
lv_obj_add_style(btnm1, &style_bg, 0);
36+
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
37+
Braccio.lvgl_unlock();
38+
}
39+
40+
void setup() {
41+
// put your setup code here, to run once:
42+
Braccio.begin(customMenu);
43+
}
44+
45+
void loop() {
46+
// put your main code here, to run repeatedly:
47+
48+
}
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,48 @@
1-
#include <Braccio++.h>
2-
3-
#define MARGIN_LEFT 0
4-
#define MARGIN_TOP 0
5-
6-
// Arduino Colors
7-
#define COLOR_TEAL 0x00878F
8-
#define COLOR_LIGHT_TEAL 0x62AEB2
9-
#define COLOR_ORANGE 0xE47128
10-
#define COLOR_YELLOW 0xE5AD24
11-
12-
static const char * btnm_map[] = {"OPTION 1", "OPTION 2", "OPTION 3", "\n",
13-
"OPTION 4", "OPTION 5", "\0"
14-
};
15-
16-
void customMenu() {
17-
Braccio.lvgl_lock();
18-
19-
static lv_style_t style_bg;
20-
lv_style_init(&style_bg);
21-
lv_style_set_bg_color(&style_bg, lv_color_hex(COLOR_LIGHT_TEAL));
22-
23-
static lv_style_t style_btn;
24-
lv_style_init(&style_btn);
25-
lv_style_set_bg_color(&style_btn, lv_color_hex(0xFFFFFF));
26-
lv_style_set_border_color(&style_btn, lv_color_hex(COLOR_YELLOW));
27-
lv_style_set_border_width(&style_btn, 2);
28-
lv_style_set_text_color(&style_btn, lv_color_hex(COLOR_TEAL));
29-
30-
31-
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
32-
lv_btnmatrix_set_map(btnm1, btnm_map);
33-
lv_btnmatrix_set_btn_width(btnm1, 3, 2); // Make "Option 4" twice as wide as "Option 5"
34-
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
35-
36-
lv_obj_add_style(btnm1, &style_bg, 0);
37-
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
38-
39-
Braccio.lvgl_unlock();
40-
}
41-
42-
void setup() {
43-
// put your setup code here, to run once:
44-
if (!Braccio.begin(customMenu)) {
45-
if (Serial) Serial.println("Braccio.begin() failed.");
46-
for(;;) { }
47-
}
48-
}
49-
50-
void loop() {
51-
// put your main code here, to run repeatedly:
52-
53-
}
1+
#include <Braccio++.h>
2+
3+
#define MARGIN_LEFT 0
4+
#define MARGIN_TOP 0
5+
6+
// Arduino Colors
7+
#define COLOR_TEAL 0x00878F
8+
#define COLOR_LIGHT_TEAL 0x62AEB2
9+
#define COLOR_ORANGE 0xE47128
10+
#define COLOR_YELLOW 0xE5AD24
11+
12+
static const char * btnm_map[] = {"OPTION 1", "OPTION 2", "OPTION 3", "\n",
13+
"OPTION 4", "OPTION 5", "\0"
14+
};
15+
16+
void customMenu() {
17+
Braccio.lvgl_lock();
18+
static lv_style_t style_bg;
19+
lv_style_init(&style_bg);
20+
lv_style_set_bg_color(&style_bg, lv_color_hex(COLOR_LIGHT_TEAL));
21+
22+
static lv_style_t style_btn;
23+
lv_style_init(&style_btn);
24+
lv_style_set_bg_color(&style_btn, lv_color_hex(0xFFFFFF));
25+
lv_style_set_border_color(&style_btn, lv_color_hex(COLOR_YELLOW));
26+
lv_style_set_border_width(&style_btn, 2);
27+
lv_style_set_text_color(&style_btn, lv_color_hex(COLOR_TEAL));
28+
29+
30+
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
31+
lv_btnmatrix_set_map(btnm1, btnm_map);
32+
lv_btnmatrix_set_btn_width(btnm1, 3, 2); // Make "Option 4" twice as wide as "Option 5"
33+
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
34+
35+
lv_obj_add_style(btnm1, &style_bg, 0);
36+
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
37+
Braccio.lvgl_unlock();
38+
}
39+
40+
void setup() {
41+
// put your setup code here, to run once:
42+
Braccio.begin(customMenu);
43+
}
44+
45+
void loop() {
46+
// put your main code here, to run repeatedly:
47+
48+
}

examples/Platform_Tutorials/lessons/Basic_codes/01-programming-the-braccio-display/05_display_challenge/05_display_challenge.ino

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ static const char * btnm_map[] = {"BTN 1", "\n",
1515

1616
void customMenu() {
1717
Braccio.lvgl_lock();
18-
1918
static lv_style_t style_bg;
2019
lv_style_init(&style_bg);
2120
lv_style_set_bg_color(&style_bg, lv_color_hex(COLOR_BG));
@@ -35,16 +34,12 @@ void customMenu() {
3534

3635
lv_obj_add_style(btnm1, &style_bg, 0);
3736
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
38-
3937
Braccio.lvgl_unlock();
4038
}
4139

4240
void setup() {
4341
// put your setup code here, to run once:
44-
if (!Braccio.begin(customMenu)) {
45-
if (Serial) Serial.println("Braccio.begin() failed.");
46-
for(;;) { }
47-
}
42+
Braccio.begin(customMenu);
4843
}
4944

5045
void loop() {

examples/Platform_Tutorials/lessons/Basic_codes/02-navigatting-the-display-menu/01_playing_with_the_Joystick/01_playing_with_the_Joystick.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ String checkJoystick(int input){
1414

1515
void setup() {
1616
Serial.begin(115200);
17-
while (!Serial) {}
17+
while(!Serial){}
1818
Braccio.begin();
1919
Serial.println("Press any button or move the joystick.");
2020
}
2121

2222
void loop() {
2323
int joystickPos = Braccio.getKey();
2424
message = checkJoystick(joystickPos);
25-
if (message != "") {
25+
if(message != ""){
2626
Serial.println(message);
2727
message = "";
2828
}

0 commit comments

Comments
 (0)