Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:79522b611923, committed 2020-10-08
- Comitter:
- sink
- Date:
- Thu Oct 08 10:09:55 2020 +0000
- Parent:
- 0:d83a0eaeb1d9
- Commit message:
- test;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Oct 05 10:37:51 2020 +0000
+++ b/main.cpp Thu Oct 08 10:09:55 2020 +0000
@@ -15,10 +15,12 @@
DigitalIn sw9(D9);
DigitalIn sw10(D10);
-AnalogIn joyR_x(A6);
-AnalogIn joyR_y(A5);
-AnalogIn joyL_x(A4);
-AnalogIn joyL_y(A3);
+AnalogIn joyL_x(A6);
+AnalogIn joyL_y(A5);
+AnalogIn joyR_x(A4);
+AnalogIn joyR_y(A3);
+
+char global_x = 0, global_y = 0, global_rot = 0, global_buttons = 0b00000000;
bool per_rotR, pre_rotL, pre_up, pre_down, pre_handR, pre_handL, pre_other;
@@ -50,11 +52,17 @@
if(sw_in(handL,pre_handL)) buttons |= 0b00001000;
if(sw_in(other,pre_other)) buttons |= 0b00010000;
+ if(d_joyx < 132 && d_joyx > 122) d_joyx = 127;
+ if(d_joyy < 132 && d_joyy > 122) d_joyy = 127;
+
char joyx = char(int(255.0 * d_joyx));
char joyy = char(int(255.0 * d_joyy));
char rot = char(127 + 100*sw_in(rotR,per_rotR)- 100*sw_in(rotL,pre_rotL));
- pc.printf("%c%c%c%c\n",joyx,joyy,rot,buttons);
+ global_x = joyx;
+ global_y = joyy;
+ global_rot = rot;
+ global_buttons = buttons;
Master.putc(joyx);
Master.putc(joyy);
@@ -76,5 +84,8 @@
timer.attach(&timer_warikomi,INT_TIME);
- while(true) {}
+ while(true) {
+ pc.printf("%d%d%d%d\n",global_x,global_y,global_rot,global_buttons);
+ wait(0.02);
+ }
}