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 2:8dd5298ca3a0, committed 2020-01-04
- Comitter:
- takedayuya
- Date:
- Sat Jan 04 04:24:19 2020 +0000
- Parent:
- 1:9c7744271d72
- Commit message:
- roboconAsyudou
Changed in this revision
| Control.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Control.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Control.cpp Sat Dec 28 06:18:27 2019 +0000
+++ b/Control.cpp Sat Jan 04 04:24:19 2020 +0000
@@ -44,44 +44,38 @@
mt4.move(pwm[3]/130.0f);
}
+int control::CheckButton(int status,int button)
+{
+ if(status == 1) {
+ pre_button[button] = 1;
+ if(pre_button[button] == 0) {
+ return 1;
+ }
+ } else {
+ pre_button[button] = 0;
+ }
+ return 0;
+}
void control::SolenoidControl()
{
- if(sb.PS3_R1_bit()==1) {
- if(sb.PS3_CIRCLE_bit() == 1&&pre_PS3_R1_bit==0) {
- if(pre_button_circle[0]==0/*&&sb.PS3_R1_bit()==1*/) {
- sol.write(0,1);
- } else {
- pre_button_circle[0]=1;//sb.PS3_R1_bit()==0;
- sol.write(0,0);
- }
- }
- if(sb.PS3_TRIANGLE_bit() == 1&&pre_PS3_R1_bit==0) {
- if(pre_button_triangle[0]==0/*&&sb.PS3_R1_bit()==1*/) {
- sol.write(1,1);
- } else {
- pre_button_triangle[0]=1;//sb.PS3_R1_bit()==0;
- sol.write(1,0);
- }
- if(sb.PS3_SQUARE_bit() == 1&&pre_PS3_R1_bit==0) {
- if(pre_button_square[0]==0/*&&sb.PS3_R1_bit()==1*/) {
- sol.write(2,1);
- } else {
- pre_button_square[0]=1;//sb.PS3_R1_bit()==0;
- sol.write(2,0);
-
- }
- if(sb.PS3_CROSS_bit() == 1&&pre_PS3_R1_bit==0) {
- if(pre_button_cross[0]==0) {
- sol.write(3,1);
- } else {
- pre_button_cross[0]=1;//;sb.PS3_R1_bit()==0;
- sol.write(3,0);
- }
- }
- pre_PS3_R1_bit=1;
- }else{
- pre_PS3_R1_bit=0;
- }
- }
+ if(CheckButton(sb.PS3_CIRCLE_bit(),CIRCLE)) {
+ sol.write(0,1);
+ } else {
+ sol.write(0,0);
+ }
+ if(CheckButton(sb.PS3_SQUARE_bit(),SQUARE)) {
+ sol.write(1,1);
+ } else {
+ sol.write(1,0);
+ }
+ if(CheckButton(sb.PS3_CROSS_bit(),CROSS)) {
+ sol.write(2,1);
+ } else {
+ sol.write(2,0);
+ }
+ if(CheckButton(sb.PS3_TRIANGLE_bit(),TRIANGLE)) {
+ sol.write(3,1);
+ } else {
+ sol.write(3,0);
}
}
--- a/Control.h Sat Dec 28 06:18:27 2019 +0000
+++ b/Control.h Sat Jan 04 04:24:19 2020 +0000
@@ -7,6 +7,18 @@
void run();
private:
+ #define L1 0
+ #define L2 1
+ #define R1 2
+ #define R2 3
+ #define TRIANGLE 4
+ #define CIRCLE 5
+ #define CROSS 6
+ #define SQUARE 7
+ #define UP 8
+ #define DOWN 9
+ #define LEFT 10
+ #define RIGHT 11
void OmniControl();
void ModuleControl(int num,int direction);
void SolenoidControl();
@@ -18,10 +30,11 @@
int pre_button[4];
int PS3_R1_bit();
int pre_PS3_R1_bit;
- int pre_button_circle[];
- int pre_button_triangle[];
- int pre_button_square[];
- int pre_button_cross[];
+ int pre_button_circle;
+ int pre_button_triangle;
+ int pre_button_square;
+ int pre_button_cross;
+ int CheckButton(int status,int button);
};
#endif
\ No newline at end of file