Grenade Drone Controller
Dependencies: mbed
GranadeSwitch.cpp@2:915533cf5d94, 2018-08-20 (annotated)
- Committer:
- halusis
- Date:
- Mon Aug 20 03:08:50 2018 +0000
- Revision:
- 2:915533cf5d94
- Parent:
- 1:d2b6491e52fd
Grenade Drone Switch
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
halusis | 0:02ed82ccad9f | 1 | #include "mbed.h" |
halusis | 0:02ed82ccad9f | 2 | #include "PinAssign.h" |
halusis | 0:02ed82ccad9f | 3 | #include "GlobalVars.h" |
halusis | 0:02ed82ccad9f | 4 | #include "SwitchFn.h" |
halusis | 0:02ed82ccad9f | 5 | |
halusis | 0:02ed82ccad9f | 6 | Timeout SndStateReq; |
halusis | 0:02ed82ccad9f | 7 | |
halusis | 0:02ed82ccad9f | 8 | bool fReq=1; |
halusis | 0:02ed82ccad9f | 9 | |
halusis | 0:02ed82ccad9f | 10 | void Req_isr(void) {fReq=1;} |
halusis | 0:02ed82ccad9f | 11 | |
halusis | 0:02ed82ccad9f | 12 | int main() |
halusis | 0:02ed82ccad9f | 13 | { |
halusis | 0:02ed82ccad9f | 14 | pc.baud(115200); |
halusis | 0:02ed82ccad9f | 15 | Snd2Crr.baud(9600); |
halusis | 0:02ed82ccad9f | 16 | |
halusis | 0:02ed82ccad9f | 17 | Sw1.mode(PullUp); |
halusis | 0:02ed82ccad9f | 18 | Sw2.mode(PullUp); |
halusis | 0:02ed82ccad9f | 19 | Sw3.mode(PullUp); |
halusis | 0:02ed82ccad9f | 20 | Sw4.mode(PullUp); |
halusis | 0:02ed82ccad9f | 21 | Sw5.mode(PullUp); |
halusis | 0:02ed82ccad9f | 22 | Sw6.mode(PullUp); |
halusis | 0:02ed82ccad9f | 23 | Sw7.mode(PullUp); |
halusis | 0:02ed82ccad9f | 24 | Sw8.mode(PullUp); |
halusis | 0:02ed82ccad9f | 25 | Sw14.mode(PullUp); |
halusis | 0:02ed82ccad9f | 26 | Sw58.mode(PullUp); |
halusis | 0:02ed82ccad9f | 27 | SwAll.mode(PullUp); |
halusis | 0:02ed82ccad9f | 28 | |
halusis | 0:02ed82ccad9f | 29 | myled1=0; |
halusis | 0:02ed82ccad9f | 30 | myled2=0; |
halusis | 0:02ed82ccad9f | 31 | myled3=0; |
halusis | 0:02ed82ccad9f | 32 | myled4=0; |
halusis | 0:02ed82ccad9f | 33 | |
halusis | 0:02ed82ccad9f | 34 | while(1) |
halusis | 0:02ed82ccad9f | 35 | { |
halusis | 0:02ed82ccad9f | 36 | if(fReq==1) |
halusis | 0:02ed82ccad9f | 37 | { |
halusis | 0:02ed82ccad9f | 38 | fReq=0; |
halusis | 0:02ed82ccad9f | 39 | SndStateReq.attach(&Req_isr, 1); |
halusis | 0:02ed82ccad9f | 40 | |
halusis | 0:02ed82ccad9f | 41 | Send2Crr(); |
halusis | 0:02ed82ccad9f | 42 | |
halusis | 1:d2b6491e52fd | 43 | |
halusis | 0:02ed82ccad9f | 44 | if(SigBit==RcvBit) |
halusis | 0:02ed82ccad9f | 45 | { |
halusis | 0:02ed82ccad9f | 46 | pc.printf("Good Status\n"); |
halusis | 0:02ed82ccad9f | 47 | Led9=1; |
halusis | 0:02ed82ccad9f | 48 | } |
halusis | 0:02ed82ccad9f | 49 | else |
halusis | 0:02ed82ccad9f | 50 | { |
halusis | 0:02ed82ccad9f | 51 | pc.printf("Signal Lost\n"); |
halusis | 0:02ed82ccad9f | 52 | Led9=0; |
halusis | 0:02ed82ccad9f | 53 | } |
halusis | 0:02ed82ccad9f | 54 | RcvStat(); |
halusis | 2:915533cf5d94 | 55 | |
halusis | 2:915533cf5d94 | 56 | pc.printf("%x %x\n",SigBit,RcvBit); |
halusis | 0:02ed82ccad9f | 57 | RcvBit=0; |
halusis | 0:02ed82ccad9f | 58 | } |
halusis | 0:02ed82ccad9f | 59 | if(Sw1==0) Sw1Fn(); |
halusis | 0:02ed82ccad9f | 60 | if(Sw2==0) {Sw2Fn();} |
halusis | 0:02ed82ccad9f | 61 | if(Sw3==0) Sw3Fn(); |
halusis | 0:02ed82ccad9f | 62 | if(Sw4==0) Sw4Fn(); |
halusis | 0:02ed82ccad9f | 63 | if(Sw5==0) Sw5Fn(); |
halusis | 0:02ed82ccad9f | 64 | if(Sw6==0) Sw6Fn(); |
halusis | 0:02ed82ccad9f | 65 | if(Sw7==0) Sw7Fn(); |
halusis | 0:02ed82ccad9f | 66 | if(Sw8==0) Sw8Fn(); |
halusis | 0:02ed82ccad9f | 67 | if(Sw14==0) Sw14Fn(); |
halusis | 0:02ed82ccad9f | 68 | if(Sw58==0) Sw58Fn(); |
halusis | 0:02ed82ccad9f | 69 | if(SwAll==0) {SwAllFn();} |
halusis | 0:02ed82ccad9f | 70 | |
halusis | 0:02ed82ccad9f | 71 | if(Snd2Crr.readable()) ProcCrr(); |
halusis | 0:02ed82ccad9f | 72 | } |
halusis | 0:02ed82ccad9f | 73 | } |