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.
Dependencies: mbed TrapezoidControl QEI Pulse LM61CIZ
Diff: Input/Switch/Switch.cpp
- Revision:
- 22:7d93f79a3686
- Parent:
- 19:96a462583af9
--- a/Input/Switch/Switch.cpp Mon Sep 09 00:19:28 2019 +0000
+++ b/Input/Switch/Switch.cpp Tue Sep 17 04:40:17 2019 +0000
@@ -19,6 +19,14 @@
DigitalOut(SELECT2_PIN),
DigitalOut(SELECT3_PIN),
};
+
+ DigitalIn limitSw_N[] = {
+ DigitalIn(LS_16),
+ DigitalIn(LS_17),
+ DigitalIn(LS_18),
+ DigitalIn(LS_19),
+ DigitalIn(LS_20),
+ };
void DipSw::Initialize() {
for(uint8_t i=0; i < sizeof(dipSw)/sizeof(dipSw[0]); i++) {
@@ -43,55 +51,71 @@
bool LimitSw::IsPressed(int index) {
MP_Channel ch;
+ bool button;
switch(index){
case 0:
- ch.all = 8;
- break;
- case 1:
ch.all = 9;
break;
- case 2:
- ch.all = 10;
- break;
- case 3:
+ case 1:
ch.all = 11;
break;
+ case 2:
+ ch.all = 13;
+ break;
+ case 3:
+ ch.all = 15;
+ break;
case 4:
- ch.all = 6;
+ ch.all = 8;
break;
case 5:
- ch.all = 4;
+ ch.all = 10;
break;
case 6:
- ch.all = 2;
+ ch.all = 12;
break;
case 7:
- ch.all = 0;
+ ch.all = 14;
break;
case 8:
ch.all = 7;
break;
case 9:
- ch.all = 5;
+ ch.all = 4;
break;
case 10:
- ch.all = 3;
+ ch.all = 2;
break;
case 11:
- ch.all = 1;
+ ch.all = 0;
break;
case 12:
- ch.all = 12;
+ ch.all = 6;
break;
case 13:
- ch.all = 13;
+ ch.all = 5;
break;
case 14:
- ch.all = 14;
+ ch.all = 3;
break;
case 15:
- ch.all = 15;
+ ch.all = 1;
+ break;
+ case 16:
+ button = limitSw_N[0];
+ break;
+ case 17:
+ button = limitSw_N[1];
+ break;
+ case 18:
+ button = limitSw_N[2];
+ break;
+ case 19:
+ button = limitSw_N[3];
+ break;
+ case 20:
+ button = limitSw_N[4];
break;
}
@@ -103,6 +127,7 @@
wait_us(1);
- return limitSw ? false : true;
+ if(index < 16) return limitSw ? false : true;
+ else return button ? false : true;
}
}