diff --git a/examples/BasicMoves/BasicMoves.ino b/examples/BasicMoves/BasicMoves.ino new file mode 100644 index 0000000..9c0db44 --- /dev/null +++ b/examples/BasicMoves/BasicMoves.ino @@ -0,0 +1,58 @@ +// This examples shows the Hippie Library used toghether with ESPUI Library by Lukas Bachschwelll on the ESP32 +#include +#include + +const char* ssid = "Hippie"; + +Hippie hippie; + +boolean walk_forward = false; +boolean walk_backward = false; +boolean jump = false; +boolean turn_left = false; +boolean turn_right = false; +boolean shake = false; +boolean swing = false; +boolean tt_swing = false; +boolean jitter = false; +boolean bend = false; +boolean flap = false; +boolean moon = false; +boolean moon_r = false; +boolean cruise = false; +boolean test_pos = false; + +void setup() +{ + Serial.begin(115200); + + /* + This function is used to config Hippie, it has the following parameters + - (int) pin of the upper left servo + - (int) pin of the upper right servo + - (int) pin of the lower left servo + - (int) pin of the lower right servo + */ + hippie.init(25, 13, 26, 16); + +} + +void loop() +{ + if (walk_forward) hippie.new_walk(); + else if (walk_backward) hippie.new_walk(2, 4, 750); + else if (turn_left) hippie.new_turn(); + else if (turn_right) hippie.new_turn(2); + else if (shake) hippie.shakeLeg(); + else if (jump) hippie.jump(); + else if (swing) hippie.swing(); + else if (tt_swing) hippie.tiptoeSwing(); + else if (jitter) hippie.jitter(); + else if (bend) hippie.bend(); + else if (flap) hippie.flapping(); + else if (moon) hippie.moonwalker(); + else if (moon_r) hippie.moonwalker(1, 900, 50, -1); + else if (cruise) hippie.crusaito(); + else if (test_pos) hippie.test_pos(); + else hippie.home(); +} diff --git a/examples/Hippie/Hippie.ino b/examples/Hippie/Hippie.ino deleted file mode 100644 index bbdd34a..0000000 --- a/examples/Hippie/Hippie.ino +++ /dev/null @@ -1,255 +0,0 @@ - - -/************************************************************************************** -* * -* Programa de calibracion de Hippie * -* Javier Isabel, 02/06/2015 * -* * -* En este programa se indica como calibrar a Hippie utilizando * -* la librera diseñada especificamente para el, hippie.h * -* * -**************************************************************************************/ - -#include //Libreria Hippie, disponible en el repositorio de GitHub de Hippie -#include -#include //Librera ArduSnake de Obijuan, en GitHub -#include -#include -#include - -const char* ssid = "Real_Hippie"; - -/************************************************************************************** -* * -* Empezamos por declarar un objeto de la clase Hippie. La clase Hippie * -* contiene funciones para calibrar a Hippie y para crear y ejecutar * -* diversos tipos de movimientos * -* * -**************************************************************************************/ - -Hippie hippie; -int posiciones[] = {90, 90, 90, 90}; - -boolean walk_forward = false; -boolean walk_backward = false; -boolean jump = false; -boolean turn_left = false; -boolean turn_right = false; -boolean shake = false; -boolean swing = false; -boolean tt_swing = false; -boolean jitter = false; -boolean bend = false; -boolean flap = false; -boolean moon = false; -boolean moon_r = false; -boolean cruise = false; -boolean test_pos = false; - -void setup() -{ - - Serial.begin(115200); - WiFi.mode(WIFI_AP); - WiFi.setHostname(ssid); - WiFi.softAP(ssid); - //WiFi.softAP(ssid, password); - Serial.println(""); - Serial.print("IP address: "); - Serial.println(WiFi.softAPIP()); - - - ESPUI.pad("Hips dont Lie", true, &Padle, COLOR_CARROT); - ESPUI.button("TT_Swing Button", &BeerButton,COLOR_PETERRIVER); - ESPUI.button("Swing Button", &BeerButton2,COLOR_PETERRIVER); - ESPUI.button("Angry Button", &BeerButton3,COLOR_PETERRIVER); - ESPUI.button("Jitter Button", &BeerButton4,COLOR_PETERRIVER); - ESPUI.button("Shake Button", &BeerButton5,COLOR_PETERRIVER); - ESPUI.button("Bend Button", &BeerButton6,COLOR_PETERRIVER); - ESPUI.button("Flap Button", &BeerButton7,COLOR_PETERRIVER); - ESPUI.button("Moonwalk Left Button", &BeerButton8,COLOR_PETERRIVER); - ESPUI.button("cruisato Button", &BeerButton9,COLOR_PETERRIVER); - ESPUI.button("Moonwalk Right Button", &BeerButton10,COLOR_PETERRIVER); - - ESPUI.switcher("Test", true, &test, COLOR_CARROT); - - ESPUI.begin("Hippie Control"); - -/************************************************************************************** -* * -* La funcion init sirve para configurar a Hippie, y se le pasan cinco parametros: * -* - (int) pin del servo superior izquierdo * -* - (int) pin del servo superior derecho * -* - (int) pin del servo inferior izquierdo * -* - (int) pin del servo inferior derecho * -* - (boolean) booleano que indica si quieren cargarse los valores de calibracion * -* de la memoria EEPROM (1, true) o no (0, false). Este valor puede omitirse, por * -* defecto sera 0 * -* * -**************************************************************************************/ - - hippie.init(25, 13, 26, 16, false); - //hippie.moveServos(500, posiciones); -} -void test(Control c, int type) { -} -void BeerButton(Control c, int type) { - if (type == B_DOWN) { - tt_swing = true; - } - else { - tt_swing = false; - } -} - -void BeerButton2(Control c, int type) { - if (type == B_DOWN) { - swing = true; - } - else { - swing = false; - } -} - -void BeerButton3(Control c, int type) { - if (type == B_DOWN) { - jump = true; - } - else { - jump = false; - } -} - -void BeerButton4(Control c, int type) { - if (type == B_DOWN) { - jitter = true; - } - else { - jitter = false; - } -} - -void BeerButton5(Control c, int type) { - if (type == B_DOWN) { - shake = true; - } - else { - shake = false; - } -} - -void BeerButton6(Control c, int type) { - if (type == B_DOWN) { - bend = true; - } - else { - bend = false; - } -} - -void BeerButton7(Control c, int type) { - if (type == B_DOWN) { - flap = true; - } - else { - flap = false; - } -} - -void BeerButton8(Control c, int type) { - if (type == B_DOWN) { - moon = true; - } - else { - moon = false; - } -} - -void BeerButton9(Control c, int type) { - if (type == B_DOWN) { - cruise = true; - } - else { - cruise = false; - } -} - -void BeerButton10(Control c, int type) { - if (type == B_DOWN) { - moon_r = true; - } - else { - moon_r = false; - } -} - - -void Padle (Control c, int value) { - switch (value) { - case P_LEFT_DOWN: - turn_left = true; - break; - case P_LEFT_UP: - turn_left = false; - break; - case P_RIGHT_DOWN: - turn_right = true; - break; - case P_RIGHT_UP: - turn_right = false; - break; - case P_FOR_DOWN: - walk_forward = true; - break; - case P_FOR_UP: - walk_forward = false; - break; - case P_BACK_DOWN: - walk_backward = true; - break; - case P_BACK_UP: - walk_backward = false; - break; - case P_CENTER_DOWN: - test_pos = true; - break; - case P_CENTER_UP: - test_pos = false; - break; - } -} - - - -void loop() -{ - - -/************************************************************************************** -* * -* Durante las pruebas utilizaremos la funcion moveServos para poner todos los servos * -* a 90º y comparar su posicion real con la posicion buscada * -* * -**************************************************************************************/ - - //hippie.walk(4,1800); - - if (walk_forward) hippie.new_walk(); - else if (walk_backward) hippie.new_walk(2,4,750); - else if (turn_left) hippie.new_turn(); - else if (turn_right) hippie.new_turn(2); - else if (shake) hippie.shakeLeg(); - else if (jump) hippie.jump(); - else if (swing) hippie.swing(); - else if (tt_swing) hippie.tiptoeSwing(); - else if (jitter) hippie.jitter(); - else if (bend) hippie.bend(); - else if (flap) hippie.flapping(); - else if (moon) hippie.moonwalker(); - else if (moon_r) hippie.moonwalker(1,900,50,-1); - else if (cruise) hippie.crusaito(); - else if (test_pos) hippie.test_pos(); - else hippie.home(); - -} - diff --git a/examples/Webinterface/Webinterface.ino b/examples/Webinterface/Webinterface.ino new file mode 100644 index 0000000..e7cfd68 --- /dev/null +++ b/examples/Webinterface/Webinterface.ino @@ -0,0 +1,212 @@ +// This examples shows the Hippie Library used toghether with ESPUI Library by Lukas Bachschwelll on the ESP32 +#include +#include +#include +#include + + +const char* ssid = "Hippie"; + +Hippie hippie; + +boolean walk_forward = false; +boolean walk_backward = false; +boolean jump = false; +boolean turn_left = false; +boolean turn_right = false; +boolean shake = false; +boolean swing = false; +boolean tt_swing = false; +boolean jitter = false; +boolean bend = false; +boolean flap = false; +boolean moon = false; +boolean moon_r = false; +boolean cruise = false; +boolean test_pos = false; + +void setup() +{ + + Serial.begin(115200); + WiFi.mode(WIFI_AP); + WiFi.setHostname(ssid); + WiFi.softAP(ssid); + Serial.println(""); + Serial.print("IP address: "); + Serial.println(WiFi.softAPIP()); + + + ESPUI.pad("Move", true, &buttonPad, COLOR_CARROT); + ESPUI.button("TT Swing", &ttSwingButton, COLOR_PETERRIVER); + ESPUI.button("Swing", &swingButton, COLOR_PETERRIVER); + ESPUI.button("Angry", &angryButton, COLOR_PETERRIVER); + ESPUI.button("Jitter", &jitterButton, COLOR_PETERRIVER); + ESPUI.button("Shake", &shakeButton, COLOR_PETERRIVER); + ESPUI.button("Bend", &bendButton, COLOR_PETERRIVER); + ESPUI.button("Flap", &flapButton, COLOR_PETERRIVER); + ESPUI.button("Moonwalk Left", &moonLeftButton, COLOR_PETERRIVER); + ESPUI.button("Cruisato", &cruisatoButton, COLOR_PETERRIVER); + ESPUI.button("Moonwalk Right", &moonRightButton, COLOR_PETERRIVER); + + ESPUI.begin("Hippie Control Demo"); + + /* + This function is used to config Hippie, it has the following parameters + - (int) pin of the upper left servo + - (int) pin of the upper right servo + - (int) pin of the lower left servo + - (int) pin of the lower right servo + */ + + hippie.init(25, 13, 26, 16); +} + + +void ttSwingButton(Control c, int type) { + if (type == B_DOWN) { + tt_swing = true; + } + else { + tt_swing = false; + } +} + +void swingButton(Control c, int type) { + if (type == B_DOWN) { + swing = true; + } + else { + swing = false; + } +} + +void angryButton(Control c, int type) { + if (type == B_DOWN) { + jump = true; + } + else { + jump = false; + } +} + +void jitterButton(Control c, int type) { + if (type == B_DOWN) { + jitter = true; + } + else { + jitter = false; + } +} + +void shakeButton(Control c, int type) { + if (type == B_DOWN) { + shake = true; + } + else { + shake = false; + } +} + +void bendButton(Control c, int type) { + if (type == B_DOWN) { + bend = true; + } + else { + bend = false; + } +} + +void flapButton(Control c, int type) { + if (type == B_DOWN) { + flap = true; + } + else { + flap = false; + } +} + +void moonLeftButton(Control c, int type) { + if (type == B_DOWN) { + moon = true; + } + else { + moon = false; + } +} + +void cruisatoButton(Control c, int type) { + if (type == B_DOWN) { + cruise = true; + } + else { + cruise = false; + } +} + +void moonRightButton(Control c, int type) { + if (type == B_DOWN) { + moon_r = true; + } + else { + moon_r = false; + } +} + + +void buttonPad (Control c, int value) { + switch (value) { + case P_LEFT_DOWN: + turn_left = true; + break; + case P_LEFT_UP: + turn_left = false; + break; + case P_RIGHT_DOWN: + turn_right = true; + break; + case P_RIGHT_UP: + turn_right = false; + break; + case P_FOR_DOWN: + walk_forward = true; + break; + case P_FOR_UP: + walk_forward = false; + break; + case P_BACK_DOWN: + walk_backward = true; + break; + case P_BACK_UP: + walk_backward = false; + break; + case P_CENTER_DOWN: + test_pos = true; + break; + case P_CENTER_UP: + test_pos = false; + break; + } +} + + + +void loop() +{ + if (walk_forward) hippie.new_walk(); + else if (walk_backward) hippie.new_walk(2, 4, 750); + else if (turn_left) hippie.new_turn(); + else if (turn_right) hippie.new_turn(2); + else if (shake) hippie.shakeLeg(); + else if (jump) hippie.jump(); + else if (swing) hippie.swing(); + else if (tt_swing) hippie.tiptoeSwing(); + else if (jitter) hippie.jitter(); + else if (bend) hippie.bend(); + else if (flap) hippie.flapping(); + else if (moon) hippie.moonwalker(); + else if (moon_r) hippie.moonwalker(1, 900, 50, -1); + else if (cruise) hippie.crusaito(); + else if (test_pos) hippie.test_pos(); + else hippie.home(); +} diff --git a/library.properties b/library.properties index b386aa8..4302a60 100644 --- a/library.properties +++ b/library.properties @@ -2,8 +2,8 @@ name=HIPPIE version=1.0.0 author=Lars Hinrichs, Anja Stene, Lukas Bachschwell maintainer=Lukas Bachschwell -sentence=ESP32 Movement library for a 4 servo hippless 2 feet robot +sentence=ESP32 Movement library for a 4 servo hippless 2 feet robot paragraph=A library that creates simple commands for complex robotic movements of a 4 servo hippless 2 feet robot when using the ESP32 category=Signal Input/Output url=https://github.com/s00500/HIPPIE -architectures=ESP32 +architectures=* diff --git a/src/Hippie.cpp b/src/Hippie.cpp index 619fb7a..24c02aa 100644 --- a/src/Hippie.cpp +++ b/src/Hippie.cpp @@ -5,7 +5,7 @@ -void Hippie::init(int YL, int YR, int RL, int RR, int Buzzer) { +void Hippie::init(int YL, int YR, int RL, int RR) { servo_pins[0] = YL; servo_pins[1] = YR; @@ -17,12 +17,6 @@ void Hippie::init(int YL, int YR, int RL, int RR, int Buzzer) { for (int i = 0; i < 4; i++) servo_position[i] = 90; - - - //Buzzer & noise sensor pins: - pinBuzzer = Buzzer; - - pinMode(Buzzer,OUTPUT); } /////////////////////////////////////////////////////////////////// diff --git a/src/Hippie.h b/src/Hippie.h index a3aaebf..21d24c1 100644 --- a/src/Hippie.h +++ b/src/Hippie.h @@ -18,7 +18,7 @@ class Hippie public: //-- Hippie initialisation - void init(int YL, int YR, int RL, int RR, int Buzzer=PIN_Buzzer); + void init(int YL, int YR, int RL, int RR); //-- Attach & detach functions void attachServos(); @@ -65,8 +65,6 @@ class Hippie int servo_trim[4]; int servo_position[4]; - int pinBuzzer; - unsigned long final_time; unsigned long partial_time; float increment[4];