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: EthernetInterface LM75B mbed-rtos mbed
Setup.cpp@3:fbf3c92f10ee, 2018-03-16 (annotated)
- Committer:
- RobinMechele
- Date:
- Fri Mar 16 16:11:17 2018 +0000
- Revision:
- 3:fbf3c92f10ee
- Parent:
- 2:ecc0c5c14bc1
- Child:
- 5:665ba017d54e
Alles werkt nu zoals het moet, nog juist de comments btw fzo;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobinMechele | 0:29eeb74e55c6 | 1 | #include "setup.h" |
RobinMechele | 0:29eeb74e55c6 | 2 | #include "lcdcontrol.h" |
RobinMechele | 0:29eeb74e55c6 | 3 | |
RobinMechele | 0:29eeb74e55c6 | 4 | BusIn joy(p15,p12,p13,p16); |
RobinMechele | 0:29eeb74e55c6 | 5 | DigitalIn fire(p14); |
RobinMechele | 0:29eeb74e55c6 | 6 | |
RobinMechele | 0:29eeb74e55c6 | 7 | LcdControl lcd; |
RobinMechele | 0:29eeb74e55c6 | 8 | |
RobinMechele | 0:29eeb74e55c6 | 9 | Setup::Setup() |
RobinMechele | 3:fbf3c92f10ee | 10 | :tempID("100"), partOfIP("192.168.0.") |
RobinMechele | 0:29eeb74e55c6 | 11 | { |
RobinMechele | 0:29eeb74e55c6 | 12 | //Constructor |
RobinMechele | 0:29eeb74e55c6 | 13 | } |
RobinMechele | 0:29eeb74e55c6 | 14 | |
RobinMechele | 0:29eeb74e55c6 | 15 | int Setup::chooseID() |
RobinMechele | 0:29eeb74e55c6 | 16 | { |
RobinMechele | 0:29eeb74e55c6 | 17 | int setID = 100; |
RobinMechele | 0:29eeb74e55c6 | 18 | lcd.lcdReset(); |
RobinMechele | 0:29eeb74e55c6 | 19 | lcd.printID(setID); |
RobinMechele | 0:29eeb74e55c6 | 20 | while(fire==0) |
RobinMechele | 0:29eeb74e55c6 | 21 | { |
RobinMechele | 0:29eeb74e55c6 | 22 | if(joy.read() == 1) |
RobinMechele | 0:29eeb74e55c6 | 23 | { |
RobinMechele | 0:29eeb74e55c6 | 24 | lcd.lcdReset(); |
RobinMechele | 0:29eeb74e55c6 | 25 | if(setID == 110){ |
RobinMechele | 0:29eeb74e55c6 | 26 | setID = 100; |
RobinMechele | 0:29eeb74e55c6 | 27 | } |
RobinMechele | 1:db9b9bec0133 | 28 | else{ |
RobinMechele | 0:29eeb74e55c6 | 29 | setID++; |
RobinMechele | 0:29eeb74e55c6 | 30 | } |
RobinMechele | 0:29eeb74e55c6 | 31 | lcd.printID(setID); |
RobinMechele | 0:29eeb74e55c6 | 32 | wait(0.3); |
RobinMechele | 0:29eeb74e55c6 | 33 | } |
RobinMechele | 0:29eeb74e55c6 | 34 | if(joy.read() == 2) |
RobinMechele | 0:29eeb74e55c6 | 35 | { |
RobinMechele | 0:29eeb74e55c6 | 36 | lcd.lcdReset(); |
RobinMechele | 0:29eeb74e55c6 | 37 | if(setID == 100){ |
RobinMechele | 0:29eeb74e55c6 | 38 | setID = 110; |
RobinMechele | 0:29eeb74e55c6 | 39 | } |
RobinMechele | 1:db9b9bec0133 | 40 | else{ |
RobinMechele | 0:29eeb74e55c6 | 41 | setID--; |
RobinMechele | 0:29eeb74e55c6 | 42 | } |
RobinMechele | 0:29eeb74e55c6 | 43 | lcd.printID(setID); |
RobinMechele | 0:29eeb74e55c6 | 44 | wait(0.3); |
RobinMechele | 0:29eeb74e55c6 | 45 | } |
RobinMechele | 0:29eeb74e55c6 | 46 | } while(fire != 0){} |
RobinMechele | 0:29eeb74e55c6 | 47 | return setID; |
RobinMechele | 0:29eeb74e55c6 | 48 | } |
RobinMechele | 0:29eeb74e55c6 | 49 | |
RobinMechele | 0:29eeb74e55c6 | 50 | int Setup::chooseMode() |
RobinMechele | 0:29eeb74e55c6 | 51 | { |
RobinMechele | 0:29eeb74e55c6 | 52 | lcd.printMode(); |
RobinMechele | 0:29eeb74e55c6 | 53 | lcd.printSlave(); |
RobinMechele | 0:29eeb74e55c6 | 54 | while(fire != 0){} |
RobinMechele | 0:29eeb74e55c6 | 55 | while(fire == 0){ |
RobinMechele | 0:29eeb74e55c6 | 56 | if(joy.read() == 8) { |
RobinMechele | 0:29eeb74e55c6 | 57 | if(mode == 1){ |
RobinMechele | 0:29eeb74e55c6 | 58 | mode=0; |
RobinMechele | 0:29eeb74e55c6 | 59 | lcd.printMode(); |
RobinMechele | 0:29eeb74e55c6 | 60 | lcd.printSlave(); |
RobinMechele | 0:29eeb74e55c6 | 61 | } |
RobinMechele | 0:29eeb74e55c6 | 62 | } |
RobinMechele | 0:29eeb74e55c6 | 63 | else if(joy.read() == 4) { |
RobinMechele | 0:29eeb74e55c6 | 64 | if(mode == 0){ |
RobinMechele | 0:29eeb74e55c6 | 65 | mode=1; |
RobinMechele | 0:29eeb74e55c6 | 66 | lcd.printMode(); |
RobinMechele | 0:29eeb74e55c6 | 67 | lcd.printMaster(); |
RobinMechele | 0:29eeb74e55c6 | 68 | } |
RobinMechele | 0:29eeb74e55c6 | 69 | } |
RobinMechele | 0:29eeb74e55c6 | 70 | } |
RobinMechele | 1:db9b9bec0133 | 71 | return mode; |
RobinMechele | 0:29eeb74e55c6 | 72 | } |
RobinMechele | 0:29eeb74e55c6 | 73 | |
RobinMechele | 0:29eeb74e55c6 | 74 | char* Setup::convertToIP(int ID) |
RobinMechele | 0:29eeb74e55c6 | 75 | { |
RobinMechele | 0:29eeb74e55c6 | 76 | sprintf(tempID,"%ld",ID); |
RobinMechele | 3:fbf3c92f10ee | 77 | return strcat(partOfIP,tempID); |
RobinMechele | 0:29eeb74e55c6 | 78 | } |