From 10e23f1e56b38e7dbf509a88554a293975dd3337 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 10 Feb 2022 06:50:24 +0100 Subject: [PATCH 1/9] Replace local inclusion via " with < and >. --- examples/Braccio__Template/Braccio__Template.ino | 2 +- examples/LCD_Custom_Menu/LCD_Custom_Menu.ino | 2 +- examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino | 2 +- examples/LCD_Motors/LCD_Motors.ino | 2 +- examples/LearnByDoing/LearnByDoing.ino | 2 +- examples/New_APIs/New_APIs.ino | 2 +- .../01_creating_a_button/01_creating_a_button.ino | 2 +- .../02_designing_the_button/02_designing_the_button.ino | 2 +- .../03_creating_a_menu/03_creating_a_menu.ino | 2 +- .../04_testing_it_out/04_testing_it_out.ino | 2 +- .../05_display_challenge/05_display_challenge.ino | 2 +- .../01_playing_with_the_Joystick.ino | 2 +- .../02_handling_events_in_the_menu.ino | 2 +- .../03_navigate_challenge_I/03_navigate_challenge_I.ino | 2 +- .../04_navigate_challenge_II/04_navigate_challenge_II.ino | 2 +- .../01_playing_with_the_motors/01_playing_with_the_motors.ino | 2 +- .../02_selecting_the_motor_with_the_enter_button.ino | 2 +- .../03_moving_the_motors_with_the_joystick.ino | 2 +- .../04_servo_motors_challenge/04_servo_motors_challenge.ino | 2 +- .../01_playing_with_a_joint_angle_gauge.ino | 2 +- .../02_selecting_the_motor_in_the_LCD_menu.ino | 2 +- .../03_learnings_challenge_I/03_learnings_challenge_I.ino | 2 +- .../04_learnings_challenge_II/04_learnings_challenge_II.ino | 2 +- .../01_aligning_braccio/01_aligning_braccio.ino | 2 +- .../02_waving_with_Braccio/02_waving_with_Braccio.ino | 2 +- .../03_moving_challenge/03_moving_challenge.ino | 2 +- .../01_controlling_manually_Braccio.ino | 2 +- .../02_manual_control_challenge/02_manual_control_challenge.ino | 2 +- .../01_Braccio_learning_mode/01_Braccio_learning_mode.ino | 2 +- .../02_learning_challenge/02_learning_challenge.ino | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/Braccio__Template/Braccio__Template.ino b/examples/Braccio__Template/Braccio__Template.ino index e3c2725..0cf906e 100644 --- a/examples/Braccio__Template/Braccio__Template.ino +++ b/examples/Braccio__Template/Braccio__Template.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include int demo_mode = 0; diff --git a/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino b/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino index 2eff457..b79ef81 100644 --- a/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino +++ b/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define MARGIN_LEFT 0 #define MARGIN_TOP 0 diff --git a/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino b/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino index fba5ae6..1fd0fbd 100644 --- a/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino +++ b/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define MARGIN_LEFT 0 #define MARGIN_TOP 0 diff --git a/examples/LCD_Motors/LCD_Motors.ino b/examples/LCD_Motors/LCD_Motors.ino index 62334fe..2757ae0 100644 --- a/examples/LCD_Motors/LCD_Motors.ino +++ b/examples/LCD_Motors/LCD_Motors.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include int selected_motor = 0; diff --git a/examples/LearnByDoing/LearnByDoing.ino b/examples/LearnByDoing/LearnByDoing.ino index 760218a..e3756fa 100644 --- a/examples/LearnByDoing/LearnByDoing.ino +++ b/examples/LearnByDoing/LearnByDoing.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #include "FlashIAPBlockDevice.h" #include "FATFileSystem.h" diff --git a/examples/New_APIs/New_APIs.ino b/examples/New_APIs/New_APIs.ino index 877ff2c..7ffeee0 100644 --- a/examples/New_APIs/New_APIs.ino +++ b/examples/New_APIs/New_APIs.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include auto elbow = Braccio.get(1); diff --git a/examples/tutorials/lessons/01-programming-the-braccio-display/01_creating_a_button/01_creating_a_button.ino b/examples/tutorials/lessons/01-programming-the-braccio-display/01_creating_a_button/01_creating_a_button.ino index 1cc8416..a3bef7a 100644 --- a/examples/tutorials/lessons/01-programming-the-braccio-display/01_creating_a_button/01_creating_a_button.ino +++ b/examples/tutorials/lessons/01-programming-the-braccio-display/01_creating_a_button/01_creating_a_button.ino @@ -1,4 +1,4 @@ - #include "Braccio++.h" + #include void customMenu() { lv_obj_t * btn1 = lv_btn_create(lv_scr_act()); diff --git a/examples/tutorials/lessons/01-programming-the-braccio-display/02_designing_the_button/02_designing_the_button.ino b/examples/tutorials/lessons/01-programming-the-braccio-display/02_designing_the_button/02_designing_the_button.ino index 8818453..c261fd3 100644 --- a/examples/tutorials/lessons/01-programming-the-braccio-display/02_designing_the_button/02_designing_the_button.ino +++ b/examples/tutorials/lessons/01-programming-the-braccio-display/02_designing_the_button/02_designing_the_button.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include // Arduino Colors #define COLOR_TEAL 0x00878F diff --git a/examples/tutorials/lessons/01-programming-the-braccio-display/03_creating_a_menu/03_creating_a_menu.ino b/examples/tutorials/lessons/01-programming-the-braccio-display/03_creating_a_menu/03_creating_a_menu.ino index 1a4f832..4647025 100644 --- a/examples/tutorials/lessons/01-programming-the-braccio-display/03_creating_a_menu/03_creating_a_menu.ino +++ b/examples/tutorials/lessons/01-programming-the-braccio-display/03_creating_a_menu/03_creating_a_menu.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define MARGIN_LEFT 0 #define MARGIN_TOP 0 diff --git a/examples/tutorials/lessons/01-programming-the-braccio-display/04_testing_it_out/04_testing_it_out.ino b/examples/tutorials/lessons/01-programming-the-braccio-display/04_testing_it_out/04_testing_it_out.ino index 1d4a705..1da4f2f 100644 --- a/examples/tutorials/lessons/01-programming-the-braccio-display/04_testing_it_out/04_testing_it_out.ino +++ b/examples/tutorials/lessons/01-programming-the-braccio-display/04_testing_it_out/04_testing_it_out.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define MARGIN_LEFT 0 #define MARGIN_TOP 0 diff --git a/examples/tutorials/lessons/01-programming-the-braccio-display/05_display_challenge/05_display_challenge.ino b/examples/tutorials/lessons/01-programming-the-braccio-display/05_display_challenge/05_display_challenge.ino index 50e760c..d4fcba7 100644 --- a/examples/tutorials/lessons/01-programming-the-braccio-display/05_display_challenge/05_display_challenge.ino +++ b/examples/tutorials/lessons/01-programming-the-braccio-display/05_display_challenge/05_display_challenge.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define MARGIN_LEFT 0 #define MARGIN_TOP 0 diff --git a/examples/tutorials/lessons/02-navigatting-the-display-menu/01_playing_with_the_Joystick/01_playing_with_the_Joystick.ino b/examples/tutorials/lessons/02-navigatting-the-display-menu/01_playing_with_the_Joystick/01_playing_with_the_Joystick.ino index db53831..70fd320 100644 --- a/examples/tutorials/lessons/02-navigatting-the-display-menu/01_playing_with_the_Joystick/01_playing_with_the_Joystick.ino +++ b/examples/tutorials/lessons/02-navigatting-the-display-menu/01_playing_with_the_Joystick/01_playing_with_the_Joystick.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include String message = ""; diff --git a/examples/tutorials/lessons/02-navigatting-the-display-menu/02_handling_events_in_the_menu/02_handling_events_in_the_menu.ino b/examples/tutorials/lessons/02-navigatting-the-display-menu/02_handling_events_in_the_menu/02_handling_events_in_the_menu.ino index e1c118c..f0f6d88 100644 --- a/examples/tutorials/lessons/02-navigatting-the-display-menu/02_handling_events_in_the_menu/02_handling_events_in_the_menu.ino +++ b/examples/tutorials/lessons/02-navigatting-the-display-menu/02_handling_events_in_the_menu/02_handling_events_in_the_menu.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define MARGIN_LEFT 0 #define MARGIN_TOP 0 diff --git a/examples/tutorials/lessons/02-navigatting-the-display-menu/03_navigate_challenge_I/03_navigate_challenge_I.ino b/examples/tutorials/lessons/02-navigatting-the-display-menu/03_navigate_challenge_I/03_navigate_challenge_I.ino index 8a25ba3..557600a 100644 --- a/examples/tutorials/lessons/02-navigatting-the-display-menu/03_navigate_challenge_I/03_navigate_challenge_I.ino +++ b/examples/tutorials/lessons/02-navigatting-the-display-menu/03_navigate_challenge_I/03_navigate_challenge_I.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define MARGIN_LEFT 0 #define MARGIN_TOP 0 diff --git a/examples/tutorials/lessons/02-navigatting-the-display-menu/04_navigate_challenge_II/04_navigate_challenge_II.ino b/examples/tutorials/lessons/02-navigatting-the-display-menu/04_navigate_challenge_II/04_navigate_challenge_II.ino index f3a9ca9..5754fce 100644 --- a/examples/tutorials/lessons/02-navigatting-the-display-menu/04_navigate_challenge_II/04_navigate_challenge_II.ino +++ b/examples/tutorials/lessons/02-navigatting-the-display-menu/04_navigate_challenge_II/04_navigate_challenge_II.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define MARGIN_LEFT 0 #define MARGIN_TOP 0 diff --git a/examples/tutorials/lessons/03-playing-with-the-motors/01_playing_with_the_motors/01_playing_with_the_motors.ino b/examples/tutorials/lessons/03-playing-with-the-motors/01_playing_with_the_motors/01_playing_with_the_motors.ino index faa1e04..6b7399f 100644 --- a/examples/tutorials/lessons/03-playing-with-the-motors/01_playing_with_the_motors/01_playing_with_the_motors.ino +++ b/examples/tutorials/lessons/03-playing-with-the-motors/01_playing_with_the_motors/01_playing_with_the_motors.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include int motorID= 0; diff --git a/examples/tutorials/lessons/03-playing-with-the-motors/02_selecting_the_motor_with_the_enter_button/02_selecting_the_motor_with_the_enter_button.ino b/examples/tutorials/lessons/03-playing-with-the-motors/02_selecting_the_motor_with_the_enter_button/02_selecting_the_motor_with_the_enter_button.ino index 861dd5b..c3f2270 100644 --- a/examples/tutorials/lessons/03-playing-with-the-motors/02_selecting_the_motor_with_the_enter_button/02_selecting_the_motor_with_the_enter_button.ino +++ b/examples/tutorials/lessons/03-playing-with-the-motors/02_selecting_the_motor_with_the_enter_button/02_selecting_the_motor_with_the_enter_button.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define BUTTON_ENTER 6 diff --git a/examples/tutorials/lessons/03-playing-with-the-motors/03_moving_the_motors_with_the_joystick/03_moving_the_motors_with_the_joystick.ino b/examples/tutorials/lessons/03-playing-with-the-motors/03_moving_the_motors_with_the_joystick/03_moving_the_motors_with_the_joystick.ino index 30ad751..10b5be0 100644 --- a/examples/tutorials/lessons/03-playing-with-the-motors/03_moving_the_motors_with_the_joystick/03_moving_the_motors_with_the_joystick.ino +++ b/examples/tutorials/lessons/03-playing-with-the-motors/03_moving_the_motors_with_the_joystick/03_moving_the_motors_with_the_joystick.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define JOYSTICK_LEFT 1 #define JOYSTICK_RIGHT 2 diff --git a/examples/tutorials/lessons/03-playing-with-the-motors/04_servo_motors_challenge/04_servo_motors_challenge.ino b/examples/tutorials/lessons/03-playing-with-the-motors/04_servo_motors_challenge/04_servo_motors_challenge.ino index 11302ff..04503c1 100644 --- a/examples/tutorials/lessons/03-playing-with-the-motors/04_servo_motors_challenge/04_servo_motors_challenge.ino +++ b/examples/tutorials/lessons/03-playing-with-the-motors/04_servo_motors_challenge/04_servo_motors_challenge.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define JOYSTICK_LEFT 1 #define JOYSTICK_RIGHT 2 diff --git a/examples/tutorials/lessons/04-integration-of-previous-learnings/01_playing_with_a_joint_angle_gauge/01_playing_with_a_joint_angle_gauge.ino b/examples/tutorials/lessons/04-integration-of-previous-learnings/01_playing_with_a_joint_angle_gauge/01_playing_with_a_joint_angle_gauge.ino index bad15f8..53d50ea 100644 --- a/examples/tutorials/lessons/04-integration-of-previous-learnings/01_playing_with_a_joint_angle_gauge/01_playing_with_a_joint_angle_gauge.ino +++ b/examples/tutorials/lessons/04-integration-of-previous-learnings/01_playing_with_a_joint_angle_gauge/01_playing_with_a_joint_angle_gauge.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define JOYSTICK_LEFT 1 #define JOYSTICK_RIGHT 2 diff --git a/examples/tutorials/lessons/04-integration-of-previous-learnings/02_selecting_the_motor_in_the_LCD_menu/02_selecting_the_motor_in_the_LCD_menu.ino b/examples/tutorials/lessons/04-integration-of-previous-learnings/02_selecting_the_motor_in_the_LCD_menu/02_selecting_the_motor_in_the_LCD_menu.ino index 04ad83f..5ecfeff 100644 --- a/examples/tutorials/lessons/04-integration-of-previous-learnings/02_selecting_the_motor_in_the_LCD_menu/02_selecting_the_motor_in_the_LCD_menu.ino +++ b/examples/tutorials/lessons/04-integration-of-previous-learnings/02_selecting_the_motor_in_the_LCD_menu/02_selecting_the_motor_in_the_LCD_menu.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include // Joystick #define JOYSTICK_LEFT 1 diff --git a/examples/tutorials/lessons/04-integration-of-previous-learnings/03_learnings_challenge_I/03_learnings_challenge_I.ino b/examples/tutorials/lessons/04-integration-of-previous-learnings/03_learnings_challenge_I/03_learnings_challenge_I.ino index 517e3da..f9f25b2 100644 --- a/examples/tutorials/lessons/04-integration-of-previous-learnings/03_learnings_challenge_I/03_learnings_challenge_I.ino +++ b/examples/tutorials/lessons/04-integration-of-previous-learnings/03_learnings_challenge_I/03_learnings_challenge_I.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include // Joystick #define JOYSTICK_LEFT 1 diff --git a/examples/tutorials/lessons/04-integration-of-previous-learnings/04_learnings_challenge_II/04_learnings_challenge_II.ino b/examples/tutorials/lessons/04-integration-of-previous-learnings/04_learnings_challenge_II/04_learnings_challenge_II.ino index 3593e5b..a84e5f5 100644 --- a/examples/tutorials/lessons/04-integration-of-previous-learnings/04_learnings_challenge_II/04_learnings_challenge_II.ino +++ b/examples/tutorials/lessons/04-integration-of-previous-learnings/04_learnings_challenge_II/04_learnings_challenge_II.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include // Joystick #define JOYSTICK_LEFT 1 diff --git a/examples/tutorials/projects/p01-moving-braccio/01_aligning_braccio/01_aligning_braccio.ino b/examples/tutorials/projects/p01-moving-braccio/01_aligning_braccio/01_aligning_braccio.ino index bf7f178..bd0c162 100644 --- a/examples/tutorials/projects/p01-moving-braccio/01_aligning_braccio/01_aligning_braccio.ino +++ b/examples/tutorials/projects/p01-moving-braccio/01_aligning_braccio/01_aligning_braccio.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include // Variables // Braccio ++ joints diff --git a/examples/tutorials/projects/p01-moving-braccio/02_waving_with_Braccio/02_waving_with_Braccio.ino b/examples/tutorials/projects/p01-moving-braccio/02_waving_with_Braccio/02_waving_with_Braccio.ino index 57e081a..2bda3b1 100644 --- a/examples/tutorials/projects/p01-moving-braccio/02_waving_with_Braccio/02_waving_with_Braccio.ino +++ b/examples/tutorials/projects/p01-moving-braccio/02_waving_with_Braccio/02_waving_with_Braccio.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define BUTTON_ENTER 6 diff --git a/examples/tutorials/projects/p01-moving-braccio/03_moving_challenge/03_moving_challenge.ino b/examples/tutorials/projects/p01-moving-braccio/03_moving_challenge/03_moving_challenge.ino index 5667946..2999342 100644 --- a/examples/tutorials/projects/p01-moving-braccio/03_moving_challenge/03_moving_challenge.ino +++ b/examples/tutorials/projects/p01-moving-braccio/03_moving_challenge/03_moving_challenge.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define BUTTON_ENTER 6 diff --git a/examples/tutorials/projects/p02-controlling-braccio-manually/01_controlling_manually_Braccio/01_controlling_manually_Braccio.ino b/examples/tutorials/projects/p02-controlling-braccio-manually/01_controlling_manually_Braccio/01_controlling_manually_Braccio.ino index a3adb85..8fc3fc0 100644 --- a/examples/tutorials/projects/p02-controlling-braccio-manually/01_controlling_manually_Braccio/01_controlling_manually_Braccio.ino +++ b/examples/tutorials/projects/p02-controlling-braccio-manually/01_controlling_manually_Braccio/01_controlling_manually_Braccio.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define BUTTON_ENTER 6 diff --git a/examples/tutorials/projects/p02-controlling-braccio-manually/02_manual_control_challenge/02_manual_control_challenge.ino b/examples/tutorials/projects/p02-controlling-braccio-manually/02_manual_control_challenge/02_manual_control_challenge.ino index 557afb6..629c6ab 100644 --- a/examples/tutorials/projects/p02-controlling-braccio-manually/02_manual_control_challenge/02_manual_control_challenge.ino +++ b/examples/tutorials/projects/p02-controlling-braccio-manually/02_manual_control_challenge/02_manual_control_challenge.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include #define BUTTON_ENTER 6 diff --git a/examples/tutorials/projects/p03-learning-mode/01_Braccio_learning_mode/01_Braccio_learning_mode.ino b/examples/tutorials/projects/p03-learning-mode/01_Braccio_learning_mode/01_Braccio_learning_mode.ino index c2b8ab3..16faee9 100644 --- a/examples/tutorials/projects/p03-learning-mode/01_Braccio_learning_mode/01_Braccio_learning_mode.ino +++ b/examples/tutorials/projects/p03-learning-mode/01_Braccio_learning_mode/01_Braccio_learning_mode.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include // Colors #define COLOR_TEAL 0x00878F diff --git a/examples/tutorials/projects/p03-learning-mode/02_learning_challenge/02_learning_challenge.ino b/examples/tutorials/projects/p03-learning-mode/02_learning_challenge/02_learning_challenge.ino index d1eef79..45686cb 100644 --- a/examples/tutorials/projects/p03-learning-mode/02_learning_challenge/02_learning_challenge.ino +++ b/examples/tutorials/projects/p03-learning-mode/02_learning_challenge/02_learning_challenge.ino @@ -1,4 +1,4 @@ -#include "Braccio++.h" +#include // Colors #define COLOR_TEAL 0x00878F From 882a85a05f2c2e01cc3eb0c1058509d608378c68 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 10 Feb 2022 07:18:35 +0100 Subject: [PATCH 2/9] Cleaning up basic Braccio demo (including a rename to Braccio_Basic). --- examples/Braccio_Basic/Braccio_Basic.ino | 88 +++++++++++++++++++ .../Braccio__Template/Braccio__Template.ino | 54 ------------ 2 files changed, 88 insertions(+), 54 deletions(-) create mode 100644 examples/Braccio_Basic/Braccio_Basic.ino delete mode 100644 examples/Braccio__Template/Braccio__Template.ino diff --git a/examples/Braccio_Basic/Braccio_Basic.ino b/examples/Braccio_Basic/Braccio_Basic.ino new file mode 100644 index 0000000..f275daa --- /dev/null +++ b/examples/Braccio_Basic/Braccio_Basic.ino @@ -0,0 +1,88 @@ +/* + * @brief Activating the "MOVE" button by pressing + * the joystick enables a waving motion of the arm. + */ + +/************************************************************************************** + * INCLUDE + **************************************************************************************/ + +#include + +/************************************************************************************** + * GLOBAL CONSTANTS + **************************************************************************************/ + +float const home_position[6] = {SmartServoClass::MAX_ANGLE / 2.0f, + SmartServoClass::MAX_ANGLE / 2.0f, + SmartServoClass::MAX_ANGLE / 2.0f, + SmartServoClass::MAX_ANGLE / 2.0f, + SmartServoClass::MAX_ANGLE / 2.0f, + 90.0f}; +static const char * btnm_map[] = {"Move", "\0"}; + +/************************************************************************************** + * GLOBAL VARIABLES + **************************************************************************************/ + +bool move_joint = false; + +/************************************************************************************** + * FUNCTIONS + **************************************************************************************/ + +static void event_handler(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * obj = lv_event_get_target(e); + if (code == LV_EVENT_CLICKED) + { + uint32_t id = lv_btnmatrix_get_selected_btn(obj); + const char * txt = lv_btnmatrix_get_btn_text(obj, id); + + LV_LOG_USER("%s was pressed\n", txt); + if (Serial) Serial.println(txt); + + if (strcmp(txt, "Move") == 0) + move_joint = !move_joint; + } +} + +void customMenu() +{ + lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act()); + lv_btnmatrix_set_map(btnm1, btnm_map); + lv_btnmatrix_set_btn_ctrl(btnm1, 0, LV_BTNMATRIX_CTRL_CHECKABLE); + lv_obj_align(btnm1, LV_ALIGN_CENTER, 0, 0); + lv_obj_add_event_cb(btnm1, event_handler, LV_EVENT_ALL, NULL); + Braccio.connectJoystickTo(btnm1); +} + +/************************************************************************************** + * SETUP/LOOP + **************************************************************************************/ + +void setup() +{ + Serial.begin(115200); + for (auto const start = millis(); !Serial && ((millis() - start) < 5000); delay(10)) { } + + if (!Braccio.begin(customMenu)) { + if (Serial) Serial.println("Braccio.begin() failed."); + for(;;) { } + } + + Braccio.moveTo(home_position[0], home_position[1], home_position[2], home_position[3], home_position[4], home_position[5]); + delay(1000); +} + +void loop() +{ + if (move_joint) + { + Braccio.move(4).to((SmartServoClass::MAX_ANGLE / 2.0f) - 45.0f).in(1s); + delay(1000); + Braccio.move(4).to((SmartServoClass::MAX_ANGLE / 2.0f) + 45.0f).in(1s); + delay(1000); + } +} diff --git a/examples/Braccio__Template/Braccio__Template.ino b/examples/Braccio__Template/Braccio__Template.ino deleted file mode 100644 index 0cf906e..0000000 --- a/examples/Braccio__Template/Braccio__Template.ino +++ /dev/null @@ -1,54 +0,0 @@ -#include - -int demo_mode = 0; - -static void event_handler(lv_event_t * e) -{ - lv_event_code_t code = lv_event_get_code(e); - lv_obj_t * obj = lv_event_get_target(e); - if (code == LV_EVENT_CLICKED) { - uint32_t id = lv_btnmatrix_get_selected_btn(obj); - const char * txt = lv_btnmatrix_get_btn_text(obj, id); - - LV_LOG_USER("%s was pressed\n", txt); - Serial.println(txt); - if (strcmp(txt, "Demo") == 0) { - demo_mode = 1; - Braccio.pingOff(); - } else { - Braccio.pingOn(); - demo_mode = 0; - } - } -} - - -static const char * btnm_map[] = {"Demo", "Learn", "\n", - "Repeat", "Unlock", "\n", "\0" - }; - -void customMenu() { - lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act()); - lv_btnmatrix_set_map(btnm1, btnm_map); - lv_btnmatrix_set_btn_ctrl(btnm1, 0, LV_BTNMATRIX_CTRL_CHECKABLE); - lv_btnmatrix_set_btn_ctrl(btnm1, 1, LV_BTNMATRIX_CTRL_CHECKABLE); - lv_btnmatrix_set_btn_ctrl(btnm1, 2, LV_BTNMATRIX_CTRL_CHECKABLE); - lv_btnmatrix_set_btn_ctrl(btnm1, 3, LV_BTNMATRIX_CTRL_CHECKABLE); - lv_obj_align(btnm1, LV_ALIGN_CENTER, 0, 0); - lv_obj_add_event_cb(btnm1, event_handler, LV_EVENT_ALL, NULL); - Braccio.connectJoystickTo(btnm1); -} - -void setup() { - // Call Braccio.begin() for default menu or pass a function for custom menu - Braccio.begin(customMenu); -} - -void loop() { - if (demo_mode) { - Braccio.move(4).to(20.0f); - delay(1000); - Braccio.move(4).to(10.0f); - delay(1000); - } -} From fafb8ede56aae035e101be8b5a0fd6b78caa8af2 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 10 Feb 2022 07:20:08 +0100 Subject: [PATCH 3/9] Cleaning up LCD_Custom_Menu. --- examples/LCD_Custom_Menu/LCD_Custom_Menu.ino | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino b/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino index b79ef81..c5c779b 100644 --- a/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino +++ b/examples/LCD_Custom_Menu/LCD_Custom_Menu.ino @@ -1,19 +1,43 @@ +/* + * @brief This sketch demonstrates how to build a very simple and basic custom menu. + */ + +/************************************************************************************** + * INCLUDE + **************************************************************************************/ + #include +/************************************************************************************** + * DEFINE + **************************************************************************************/ + #define MARGIN_LEFT 0 #define MARGIN_TOP 0 +/************************************************************************************** + * CONSTANTS + **************************************************************************************/ + static const char * btnm_map[] = {"Option 1", "\n", "Option 2", "\n", "Option 3", "\n", "\0" }; +/************************************************************************************** + * FUNCTIONS + **************************************************************************************/ + void customMenu(){ lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act()); lv_btnmatrix_set_map(btnm1, btnm_map); lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP); } +/************************************************************************************** + * SETUP/LOOP + **************************************************************************************/ + void setup() { Braccio.begin(customMenu); } From d8b75fe271c7c1d3f73a610b29e766a730048f1f Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 10 Feb 2022 07:20:40 +0100 Subject: [PATCH 4/9] Calling overloaded setTime with only the runtime as parameter automatically defaults to broadcast. --- src/Braccio++.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Braccio++.cpp b/src/Braccio++.cpp index 29ec05f..45d5cde 100644 --- a/src/Braccio++.cpp +++ b/src/Braccio++.cpp @@ -135,7 +135,7 @@ bool BraccioClass::begin(voidFuncPtr custom_menu) lvgl_defaultMenu(); _servos.begin(); - _servos.setTime(SmartServoClass::BROADCAST, SLOW); + _servos.setTime(SLOW); _servos.setPositionMode(PositionMode::IMMEDIATE); _motors_connected_thd.start(mbed::callback(this, &BraccioClass::motorConnectedThreadFunc)); From 996ca8566e466f54393ad9b70572c47d0637cf27 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 10 Feb 2022 07:22:19 +0100 Subject: [PATCH 5/9] Cleaning up LCD_Menu_Joystick. --- .../LCD_Menu_Joystick/LCD_Menu_Joystick.ino | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino b/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino index 1fd0fbd..fdab2fb 100644 --- a/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino +++ b/examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino @@ -1,8 +1,35 @@ +/* + * @brief This sketch demonstrates how to build a very simple + * and basic custom menu interacting with the Braccio++ carriers + * joystick. + */ + +/************************************************************************************** + * INCLUDE + **************************************************************************************/ + #include +/************************************************************************************** + * DEFINE + **************************************************************************************/ + #define MARGIN_LEFT 0 #define MARGIN_TOP 0 +/************************************************************************************** + * CONSTANT + **************************************************************************************/ + +static const char * btnm_map[] = {"Option 1", "Option 2", "\n", + "Option 3", "Option 4", "\n", + "Option 5", "Option 6", "\n", "\0" + }; + +/************************************************************************************** + * FUNCTIONS + **************************************************************************************/ + static void event_handler(lv_event_t * e){ lv_event_code_t code = lv_event_get_code(e); lv_obj_t * obj = lv_event_get_target(e); @@ -15,11 +42,6 @@ static void event_handler(lv_event_t * e){ } } -static const char * btnm_map[] = {"Option 1", "Option 2", "\n", - "Option 3", "Option 4", "\n", - "Option 5", "Option 6", "\n", "\0" - }; - void customMenu(){ lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act()); lv_btnmatrix_set_map(btnm1, btnm_map); @@ -34,6 +56,10 @@ void customMenu(){ Braccio.connectJoystickTo(btnm1); } +/************************************************************************************** + * SETUP/LOOP + **************************************************************************************/ + void setup() { Braccio.begin(customMenu); } From e3fa736a7cc6864f90b6af8984f933ba46fd3724 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 10 Feb 2022 07:23:52 +0100 Subject: [PATCH 6/9] Cleaning up LCD_Motors. --- examples/LCD_Motors/LCD_Motors.ino | 39 ++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/examples/LCD_Motors/LCD_Motors.ino b/examples/LCD_Motors/LCD_Motors.ino index 2757ae0..3fee9b6 100644 --- a/examples/LCD_Motors/LCD_Motors.ino +++ b/examples/LCD_Motors/LCD_Motors.ino @@ -1,7 +1,35 @@ +/* + * @brief This sketch demonstrates how to build a very simple + * and basic custom menu interacting with the Braccio++ carriers + * joystick, allowing to control a specific motor by selecting + * it from the menu. + */ + +/************************************************************************************** + * INCLUDE + **************************************************************************************/ + #include +/************************************************************************************** + * VARIABLES + **************************************************************************************/ + int selected_motor = 0; +/************************************************************************************** + * CONSTANTS + **************************************************************************************/ + +static const char * btnm_map[] = {"Motor 1", "Motor 2", "\n", + "Motor 3", "Motor 4", "\n", + "Motor 5", "Motor 6", "\n", "\0" + }; + +/************************************************************************************** + * FUNCTIONS + **************************************************************************************/ + static void event_handler(lv_event_t * e) { lv_event_code_t code = lv_event_get_code(e); @@ -37,12 +65,6 @@ static void event_handler(lv_event_t * e) } } - -static const char * btnm_map[] = {"Motor 1", "Motor 2", "\n", - "Motor 3", "Motor 4", "\n", - "Motor 5", "Motor 6", "\n", "\0" - }; - void customMenu() { lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act()); lv_btnmatrix_set_map(btnm1, btnm_map); @@ -57,8 +79,11 @@ void customMenu() { Braccio.connectJoystickTo(btnm1); } +/************************************************************************************** + * SETUP/LOOP + **************************************************************************************/ + void setup() { - // Call Braccio.begin() for default menu or pass a function for custom menu Braccio.begin(customMenu); Serial.begin(115200); } From 4863537ed5cdc9c2d08fab2852f4fba9bc9836b0 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 10 Feb 2022 07:24:33 +0100 Subject: [PATCH 7/9] The new APIs documented here are already extensively used in the content teams lessons. --- examples/New_APIs/New_APIs.ino | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 examples/New_APIs/New_APIs.ino diff --git a/examples/New_APIs/New_APIs.ino b/examples/New_APIs/New_APIs.ino deleted file mode 100644 index 7ffeee0..0000000 --- a/examples/New_APIs/New_APIs.ino +++ /dev/null @@ -1,33 +0,0 @@ -#include - -auto elbow = Braccio.get(1); - -void setup() { - Serial.begin(115200); - while (!Serial); - Braccio.begin(); -} - -void loop() { - - if (elbow) { - elbow.move().to(122.7).in(1s); - delay(1000); - elbow.move().to(11.9).in(100ms); - } - Serial.println(elbow.position()); - - // Should move all the motors at once - Braccio.moveTo(10.0, 20.0, 30.0, 40.0, 50.0, 60.0); - - // You can choose the speed beforehand with - Braccio.speed(FAST); // could be MEDIUM or SLOW too - - float a1, a2, a3, a4, a5, a6; - Braccio.positions(a1, a2, a3, a4, a5, a6); - Serial.println("Motor positions are: " + String(a1) + " " + String(a2) + " " + String(a3) + " " + String(a4) + " " + String(a5) + " " + String(a6)); - - // Can also use the more compact notation - float values[6]; - Braccio.positions(values); -} From 72f2bfe293dffc4d30dc753e2f4b90c170d125ba Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 10 Feb 2022 07:25:27 +0100 Subject: [PATCH 8/9] Rename LearnByDoing to Braccio_LearnByDoing. --- .../Braccio_LearnByDoing.ino} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{LearnByDoing/LearnByDoing.ino => Braccio_LearnByDoing/Braccio_LearnByDoing.ino} (100%) diff --git a/examples/LearnByDoing/LearnByDoing.ino b/examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino similarity index 100% rename from examples/LearnByDoing/LearnByDoing.ino rename to examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino From c2d49337449e83ad6a422778cd54ea43a6ac6809 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 10 Feb 2022 07:32:25 +0100 Subject: [PATCH 9/9] Cleaning up Braccio_LearnByDoing. --- .../Braccio_LearnByDoing.ino | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino b/examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino index e3756fa..3015f39 100644 --- a/examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino +++ b/examples/Braccio_LearnByDoing/Braccio_LearnByDoing.ino @@ -1,7 +1,19 @@ +/* + * @brief Learn the arm an movement and replay it. + */ + +/************************************************************************************** + * INCLUDE + **************************************************************************************/ + #include #include "FlashIAPBlockDevice.h" #include "FATFileSystem.h" +/************************************************************************************** + * VARIABLES + **************************************************************************************/ + enum states { LEARN, REPEAT, @@ -14,6 +26,10 @@ float values[10000]; float* idx = values; float* final_idx = 0; +/************************************************************************************** + * FUNCTIONS + **************************************************************************************/ + static void event_handler(lv_event_t * e) { lv_event_code_t code = lv_event_get_code(e); lv_obj_t * obj = lv_event_get_target(e); @@ -95,9 +111,14 @@ void customMenu() { static FlashIAPBlockDevice bd(XIP_BASE + 0x100000, 0x100000); static mbed::FATFileSystem fs("fs"); -void setup() { +/************************************************************************************** + * SETUP/LOOP + **************************************************************************************/ +void setup() +{ Serial.begin(115200); + while (!Serial) { } // Mount file system for load/store movements int err = fs.mount(&bd);