Skip to content

Commit 732a93c

Browse files
committed
feat: lessons and projects codes
1 parent 8c60195 commit 732a93c

File tree

30 files changed

+2679
-0
lines changed

30 files changed

+2679
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "Braccio++.h"
2+
3+
void customMenu() {
4+
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
5+
lv_obj_set_size(btn1, 120, 75);
6+
lv_obj_t * label1 = lv_label_create(btn1);
7+
lv_label_set_text(label1, "BTN 1");
8+
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, 0);
9+
lv_obj_center(label1);
10+
}
11+
12+
void setup() {
13+
// put your setup code here, to run once:
14+
Braccio.begin(customMenu);
15+
}
16+
17+
void loop() {
18+
// put your main code here, to run repeatedly:
19+
20+
}
Lines changed: 7 additions & 0 deletions
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
@@ -0,0 +1,39 @@
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+
static lv_style_t style;
13+
lv_style_init(&style);
14+
lv_style_set_bg_color(&style, lv_color_hex(COLOR_WHITE));
15+
lv_style_set_border_color(&style, lv_color_hex(COLOR_TEAL));
16+
lv_style_set_border_width(&style, 5);
17+
lv_style_set_text_color(&style, lv_color_hex(COLOR_ORANGE));
18+
19+
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
20+
lv_obj_set_size(btn1, 120, 75);
21+
22+
lv_obj_t * label1 = lv_label_create(btn1);
23+
lv_label_set_text(label1, "BTN 1");
24+
25+
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, 0);
26+
lv_obj_center(label1);
27+
28+
lv_obj_add_style(btn1, &style, 0);
29+
}
30+
31+
void setup() {
32+
// put your setup code here, to run once:
33+
Braccio.begin(customMenu);
34+
}
35+
36+
void loop() {
37+
// put your main code here, to run repeatedly:
38+
39+
}
Lines changed: 6 additions & 0 deletions
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+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
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(COLOR_WHITE));
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_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
33+
34+
lv_obj_add_style(btnm1, &style_bg, 0);
35+
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
36+
}
37+
38+
void setup() {
39+
// put your setup code here, to run once:
40+
Braccio.begin(customMenu);
41+
}
42+
43+
void loop() {
44+
// put your main code here, to run repeatedly:
45+
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
static lv_style_t style_bg;
18+
lv_style_init(&style_bg);
19+
lv_style_set_bg_color(&style_bg, lv_color_hex(COLOR_LIGHT_TEAL));
20+
21+
static lv_style_t style_btn;
22+
lv_style_init(&style_btn);
23+
lv_style_set_bg_color(&style_btn, lv_color_hex(0xFFFFFF));
24+
lv_style_set_border_color(&style_btn, lv_color_hex(COLOR_YELLOW));
25+
lv_style_set_border_width(&style_btn, 2);
26+
lv_style_set_text_color(&style_btn, lv_color_hex(COLOR_TEAL));
27+
28+
29+
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
30+
lv_btnmatrix_set_map(btnm1, btnm_map);
31+
lv_btnmatrix_set_btn_width(btnm1, 3, 2); // Make "Option 4" twice as wide as "Option 5"
32+
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
33+
34+
lv_obj_add_style(btnm1, &style_bg, 0);
35+
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
36+
}
37+
38+
void setup() {
39+
// put your setup code here, to run once:
40+
Braccio.begin(customMenu);
41+
}
42+
43+
void loop() {
44+
// put your main code here, to run repeatedly:
45+
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include "Braccio++.h"
2+
3+
#define MARGIN_LEFT 0
4+
#define MARGIN_TOP 0
5+
6+
#define COLOR_BG 0xA69F80
7+
#define COLOR_BTN 0xF2C36B
8+
#define COLOR_BORDER 0x591202
9+
#define COLOR_TEXT 0xA65221
10+
11+
static const char * btnm_map[] = {"BTN 1", "\n",
12+
"BTN 2", "BTN 3", "\n",
13+
"BTN 4", "BTN 5", "\0"
14+
};
15+
16+
void customMenu() {
17+
static lv_style_t style_bg;
18+
lv_style_init(&style_bg);
19+
lv_style_set_bg_color(&style_bg, lv_color_hex(COLOR_BG));
20+
21+
static lv_style_t style_btn;
22+
lv_style_init(&style_btn);
23+
lv_style_set_bg_color(&style_btn, lv_color_hex(COLOR_BTN));
24+
lv_style_set_border_color(&style_btn, lv_color_hex(COLOR_BORDER));
25+
lv_style_set_border_width(&style_btn, 2);
26+
lv_style_set_text_color(&style_btn, lv_color_hex(COLOR_TEXT));
27+
28+
29+
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
30+
lv_btnmatrix_set_map(btnm1, btnm_map);
31+
lv_btnmatrix_set_btn_width(btnm1, 1, 2); // Make "Button 2" twice as wide as "Button 3"
32+
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
33+
34+
lv_obj_add_style(btnm1, &style_bg, 0);
35+
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
36+
}
37+
38+
void setup() {
39+
// put your setup code here, to run once:
40+
Braccio.begin(customMenu);
41+
}
42+
43+
void loop() {
44+
// put your main code here, to run repeatedly:
45+
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "Braccio++.h"
2+
3+
String message = "";
4+
5+
String checkJoystick(int input){
6+
String joystick[] = { "",
7+
"Joystick left was moved!",
8+
"Joystick right was moved!",
9+
"Joystick select button was pressed!",
10+
"Joystick up was moved!",
11+
"Joystick down was moved!"};
12+
return joystick[input];
13+
}
14+
15+
void setup() {
16+
Serial.begin(115200);
17+
while(!Serial){}
18+
Braccio.begin();
19+
Serial.println("Press any button or move the joystick.");
20+
}
21+
22+
void loop() {
23+
int joystickPos = Braccio.getKey();
24+
message = checkJoystick(joystickPos);
25+
if(message != ""){
26+
Serial.println(message);
27+
message = "";
28+
}
29+
delay(500);
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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", "\n",
15+
"Option 5", "Option 6", "\0"
16+
};
17+
18+
static void eventHandler(lv_event_t * e){
19+
lv_event_code_t code = lv_event_get_code(e);
20+
lv_obj_t * obj = lv_event_get_target(e);
21+
if (code == LV_EVENT_PRESSED) {
22+
uint32_t id = lv_btnmatrix_get_selected_btn(obj);
23+
const char * txt = lv_btnmatrix_get_btn_text(obj, id);
24+
25+
LV_LOG_USER("%s was selected\n", txt);
26+
Serial.println(String(txt) + " was selected.");
27+
}
28+
}
29+
30+
void customMenu(){
31+
static lv_style_t style_bg;
32+
lv_style_init(&style_bg);
33+
lv_style_set_bg_color(&style_bg, lv_color_hex(COLOR_WHITE));
34+
35+
static lv_style_t style_btn;
36+
lv_style_init(&style_btn);
37+
lv_style_set_bg_color(&style_btn, lv_color_hex(COLOR_YELLOW));
38+
lv_style_set_border_color(&style_btn, lv_color_hex(COLOR_LIGHT_TEAL));
39+
lv_style_set_border_width(&style_btn, 2);
40+
lv_style_set_text_color(&style_btn, lv_color_hex(COLOR_TEAL));
41+
42+
43+
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
44+
lv_btnmatrix_set_map(btnm1, btnm_map);
45+
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
46+
47+
lv_obj_add_style(btnm1, &style_bg, 0);
48+
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
49+
50+
lv_btnmatrix_set_btn_ctrl(btnm1, 0, LV_BTNMATRIX_CTRL_CHECKABLE);
51+
lv_btnmatrix_set_btn_ctrl(btnm1, 1, LV_BTNMATRIX_CTRL_CHECKABLE);
52+
lv_btnmatrix_set_btn_ctrl(btnm1, 2, LV_BTNMATRIX_CTRL_CHECKABLE);
53+
lv_btnmatrix_set_btn_ctrl(btnm1, 3, LV_BTNMATRIX_CTRL_CHECKABLE);
54+
lv_btnmatrix_set_btn_ctrl(btnm1, 4, LV_BTNMATRIX_CTRL_CHECKABLE);
55+
lv_btnmatrix_set_btn_ctrl(btnm1, 5, LV_BTNMATRIX_CTRL_CHECKABLE);
56+
57+
lv_btnmatrix_set_one_checked(btnm1, true);
58+
59+
lv_obj_add_event_cb(btnm1, eventHandler, LV_EVENT_ALL, NULL);
60+
61+
Braccio.connectJoystickTo(btnm1);
62+
}
63+
64+
void setup() {
65+
Braccio.begin(customMenu);
66+
}
67+
68+
void loop() {
69+
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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", "\n",
15+
"Option 5", "Option 6", "\0"
16+
};
17+
18+
static void eventHandler(lv_event_t * e){
19+
lv_event_code_t code = lv_event_get_code(e);
20+
lv_obj_t * obj = lv_event_get_target(e);
21+
if (code == LV_EVENT_PRESSING) {
22+
uint32_t id = lv_btnmatrix_get_selected_btn(obj);
23+
const char * txt = lv_btnmatrix_get_btn_text(obj, id);
24+
25+
LV_LOG_USER("%s is pressed\n", txt);
26+
Serial.println(String(txt) + " is pressed.");
27+
}
28+
}
29+
30+
void customMenu(){
31+
static lv_style_t style_bg;
32+
lv_style_init(&style_bg);
33+
lv_style_set_bg_color(&style_bg, lv_color_hex(COLOR_LIGHT_TEAL));
34+
35+
static lv_style_t style_btn;
36+
lv_style_init(&style_btn);
37+
lv_style_set_bg_color(&style_btn, lv_color_hex(COLOR_WHITE));
38+
lv_style_set_border_color(&style_btn, lv_color_hex(COLOR_YELLOW));
39+
lv_style_set_border_width(&style_btn, 2);
40+
lv_style_set_text_color(&style_btn, lv_color_hex(COLOR_TEAL));
41+
42+
43+
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
44+
lv_btnmatrix_set_map(btnm1, btnm_map);
45+
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
46+
47+
lv_obj_add_style(btnm1, &style_bg, 0);
48+
lv_obj_add_style(btnm1, &style_btn, LV_PART_ITEMS);
49+
50+
lv_btnmatrix_set_btn_ctrl(btnm1, 0, LV_BTNMATRIX_CTRL_CHECKABLE);
51+
lv_btnmatrix_set_btn_ctrl(btnm1, 1, LV_BTNMATRIX_CTRL_CHECKABLE);
52+
lv_btnmatrix_set_btn_ctrl(btnm1, 2, LV_BTNMATRIX_CTRL_CHECKABLE);
53+
lv_btnmatrix_set_btn_ctrl(btnm1, 3, LV_BTNMATRIX_CTRL_CHECKABLE);
54+
lv_btnmatrix_set_btn_ctrl(btnm1, 4, LV_BTNMATRIX_CTRL_CHECKABLE);
55+
lv_btnmatrix_set_btn_ctrl(btnm1, 5, LV_BTNMATRIX_CTRL_CHECKABLE);
56+
57+
lv_btnmatrix_set_one_checked(btnm1, true);
58+
59+
lv_obj_add_event_cb(btnm1, eventHandler, LV_EVENT_ALL, NULL);
60+
61+
Braccio.connectJoystickTo(btnm1);
62+
}
63+
64+
void setup() {
65+
Braccio.begin(customMenu);
66+
}
67+
68+
void loop() {
69+
70+
}

0 commit comments

Comments
 (0)