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: Input/Switch/Switch.cpp
- Revision:
- 29:44d5454ce8fa
- Parent:
- 22:7d93f79a3686
--- a/Input/Switch/Switch.cpp Thu Oct 03 05:33:48 2019 +0000
+++ b/Input/Switch/Switch.cpp Fri Oct 18 22:33:25 2019 +0000
@@ -11,6 +11,7 @@
DigitalIn(DIP3_PIN),
};
+ /*
DigitalIn limitSw(LS_PIN);
DigitalOut selectPin[] = {
@@ -19,13 +20,29 @@
DigitalOut(SELECT2_PIN),
DigitalOut(SELECT3_PIN),
};
+ */
- DigitalIn limitSw_N[] = {
- DigitalIn(LS_16),
- DigitalIn(LS_17),
- DigitalIn(LS_18),
- DigitalIn(LS_19),
- DigitalIn(LS_20),
+ DigitalIn digitalIn[INPUT_NUM] = {
+ DigitalIn(INPUT0_PIN),
+ DigitalIn(INPUT1_PIN),
+ DigitalIn(INPUT2_PIN),
+ DigitalIn(INPUT3_PIN),
+ DigitalIn(INPUT4_PIN),
+ DigitalIn(INPUT5_PIN),
+ DigitalIn(INPUT6_PIN),
+ DigitalIn(INPUT7_PIN),
+ DigitalIn(INPUT8_PIN),
+ DigitalIn(INPUT9_PIN),
+ DigitalIn(INPUT10_PIN),
+ DigitalIn(INPUT11_PIN),
+ DigitalIn(INPUT12_PIN),
+ DigitalIn(INPUT13_PIN),
+ DigitalIn(INPUT14_PIN),
+ DigitalIn(INPUT15_PIN),
+ DigitalIn(INPUT16_PIN),
+ DigitalIn(INPUT17_PIN),
+ DigitalIn(INPUT18_PIN),
+ DigitalIn(INPUT19_PIN),
};
void DipSw::Initialize() {
@@ -44,39 +61,40 @@
}
void LimitSw::Initialize() {
- for(uint8_t i=0; i<4; i++) selectPin[i] = 0;
- limitSw.mode(PullUp);
+ for(uint8_t i=0; i<INPUT_NUM; i++) {
+ digitalIn[i].mode(PullUp);
+ }
}
bool LimitSw::IsPressed(int index) {
-
+
+ /*
MP_Channel ch;
- bool button;
switch(index){
case 0:
- ch.all = 9;
+ ch.all = 8;
break;
case 1:
- ch.all = 11;
+ ch.all = 9;
break;
case 2:
- ch.all = 13;
+ ch.all = 10;
break;
case 3:
- ch.all = 15;
+ ch.all = 11;
break;
case 4:
- ch.all = 8;
+ ch.all = 12;
break;
case 5:
- ch.all = 10;
+ ch.all = 13;
break;
case 6:
- ch.all = 12;
+ ch.all = 14;
break;
case 7:
- ch.all = 14;
+ ch.all = 15;
break;
case 8:
ch.all = 7;
@@ -102,32 +120,16 @@
case 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;
}
-
selectPin[0] = ch.s0;
selectPin[1] = ch.s1;
selectPin[2] = ch.s2;
selectPin[3] = ch.s3;
wait_us(1);
+ */
- if(index < 16) return limitSw ? false : true;
- else return button ? false : true;
+ return digitalIn[index] ? false : true;
}
}