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.
Diff: Control.cpp
- Revision:
- 2:8dd5298ca3a0
- Parent:
- 1:9c7744271d72
--- 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);
}
}