Test PS3 - Dribbler

Dependencies:   SerialArduino RCJESC

Files at this revision

API Documentation at this revision

Comitter:
piroro4560
Date:
Fri Jun 17 02:54:39 2022 +0000
Commit message:
Test PS3 - Dribbler

Changed in this revision

lib/RCJESC.lib Show annotated file Show diff for this revision Revisions of this file
lib/SerialArduino.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/RCJESC.lib	Fri Jun 17 02:54:39 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Quadrifoglio/code/RCJESC/#5f1959f9d2db
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/SerialArduino.lib	Fri Jun 17 02:54:39 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Quadrifoglio/code/SerialArduino/#a591557e4771
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 17 02:54:39 2022 +0000
@@ -0,0 +1,63 @@
+
+
+#if 1
+#include "mbed.h"
+#include "esc.h"
+#include "SerialArduino.h"
+
+RCJESC esc(PC_9);
+DigitalIn myb(PC_3);
+DigitalOut led(LED1);
+SerialArduino mini(A0, A1, 115200);
+
+uint8_t h1,h2;
+bool    b[12]= {};
+uint8_t st[4]= {};
+uint8_t tr[2]= {};
+
+void PS3get(bool flag_PS3print);
+
+int main()
+{
+    esc.setspeed(0.0);
+    thread_sleep_for(1200);
+    
+    while (1) {
+        PS3get(false);
+//        if(myb) esc.setspeed(0.7);
+//        else esc.setspeed(0.0);
+//        led = myb;
+        if(b[2]) esc.setspeed(0.7);
+        else esc.setspeed(0.0);
+        led = b[2];
+    }
+}
+
+void PS3get(bool flag_PS3print)
+{
+    h1 = mini.getHedder1();
+    h2 = mini.getHedder2();
+    for(int i=0; i<12; i++) {
+        b[i] = mini.getButton(i);
+    }
+    for(int i=0; i<2; i++) {
+        tr[i] = mini.getTrigger(i);
+    }
+    for(int i=0; i<4; i++) {
+        st[i] = mini.getStick(i);
+    }
+    if (flag_PS3print) {
+        for(int i=0; i<12; i++) printf("%d ",b[i]);
+        printf("|");
+        for(int i=0; i<2; i++) printf("%3d ",tr[i]);
+        printf("|");
+        for(int i=0; i<4; i++) printf("%3d ",st[i]);
+        if(mini.getState()) printf("ok");
+        else printf("bad");
+        printf("\r\n");
+    } else {
+        mini.getState();
+    }
+}
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h	Fri Jun 17 02:54:39 2022 +0000
@@ -0,0 +1,45 @@
+#ifndef MAIN_H
+#define MAIN_H
+
+#include "mbed.h"
+
+#define RobotNumberIsOne
+
+#define PI 3.141592653//5897932
+
+#define US1trig PC_8
+#define US1echo PC_6
+#define US2trig PC_5
+#define US2echo PA_12
+#define US3trig PA_11
+#define US3echo PB_12
+#define US4trig PB_2
+#define US4echo PB_1
+#define jyscl   PA_8
+#define jysda   PB_4
+#define IR      PC_2
+
+#ifdef RobotNumberIsOne
+#define Pin_motor_0 PA_6
+#define Pin_motor_1 PA_15
+#define Pin_motor_2 PB_6
+#define Pin_motor_3 PA_7
+#else
+#define Pin_motor_0 PA_15
+#define Pin_motor_1 PA_7
+#define Pin_motor_2 PB_6
+#define Pin_motor_3 PA_6
+#endif
+
+#define Pin_Kicker   PA_10
+#define Pin_Dribbler PC_9
+
+#define Pin_lcdscl  PB_8
+#define Pin_lcdsda  PB_9
+
+#define Pin_button   PC_3
+#define Pin_toggle_0 PA_9
+#define Pin_toggle_1 PB_10
+#define Pin_toggle_2 PB_5
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Jun 17 02:54:39 2022 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#b1796dedeb8accde1cbaecf136fab96895e23d81