![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
All tasks complete
Dependencies: mbed MCP23017 mbed-rtos WattBob_TextLCD
assignment3tasks.cpp@1:c4f62ef9b5b7, 2019-03-20 (annotated)
- Committer:
- aingks
- Date:
- Wed Mar 20 16:12:17 2019 +0000
- Revision:
- 1:c4f62ef9b5b7
- Parent:
- 0:0943f040009c
- Child:
- 2:9d6d07c9cc9c
task 1,2,3 complete not tested; cleaned up the code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aingks | 0:0943f040009c | 1 | #include "header.h" |
aingks | 0:0943f040009c | 2 | //definitions of taskss |
aingks | 0:0943f040009c | 3 | //lock and unlock variables in struct whne performing calculations |
aingks | 0:0943f040009c | 4 | |
aingks | 0:0943f040009c | 5 | //pedals |
aingks | 0:0943f040009c | 6 | AnalogIn brake_pedal(pin_analog_1); |
aingks | 0:0943f040009c | 7 | AnalogIn accel_pedal(pin_analog_2); |
aingks | 0:0943f040009c | 8 | |
aingks | 0:0943f040009c | 9 | |
aingks | 0:0943f040009c | 10 | //switches |
aingks | 0:0943f040009c | 11 | DigitalIn ngene(pin_digital_1); |
aingks | 1:c4f62ef9b5b7 | 12 | DigitalIn leftsw(pin_digital_2); |
aingks | 1:c4f62ef9b5b7 | 13 | DigitalIn rightsw(pin_digital_3); |
aingks | 1:c4f62ef9b5b7 | 14 | DigitalIn sidesw(pin_digital_4); |
aingks | 0:0943f040009c | 15 | |
aingks | 0:0943f040009c | 16 | |
aingks | 0:0943f040009c | 17 | //indicators |
aingks | 0:0943f040009c | 18 | DigitalOut ngeneind(pin_LED1); |
aingks | 0:0943f040009c | 19 | DigitalOut leftind(pin_LED2); |
aingks | 0:0943f040009c | 20 | DigitalOut rightind(pin_LED3); |
aingks | 0:0943f040009c | 21 | DigitalOut sideind(pin_LED4); |
aingks | 0:0943f040009c | 22 | |
aingks | 0:0943f040009c | 23 | |
aingks | 0:0943f040009c | 24 | //RED box lights |
aingks | 0:0943f040009c | 25 | DigitalOut brakeind(pin_LED5); |
aingks | 0:0943f040009c | 26 | DigitalOut overspeedind(pin_LED6); |
aingks | 0:0943f040009c | 27 | |
aingks | 0:0943f040009c | 28 | |
aingks | 0:0943f040009c | 29 | void task1readbrake() |
aingks | 0:0943f040009c | 30 | { |
aingks | 1:c4f62ef9b5b7 | 31 | //lock |
aingks | 1:c4f62ef9b5b7 | 32 | speed.brakevalue = brake_pedal.read(); |
aingks | 1:c4f62ef9b5b7 | 33 | //unlock |
aingks | 0:0943f040009c | 34 | } |
aingks | 0:0943f040009c | 35 | |
aingks | 0:0943f040009c | 36 | void task2readaccel() |
aingks | 0:0943f040009c | 37 | { |
aingks | 1:c4f62ef9b5b7 | 38 | //lock |
aingks | 1:c4f62ef9b5b7 | 39 | speed.accelvalue = accel_pedal.read(); |
aingks | 1:c4f62ef9b5b7 | 40 | //unlock |
aingks | 0:0943f040009c | 41 | } |
aingks | 0:0943f040009c | 42 | |
aingks | 0:0943f040009c | 43 | void task3enginestate() |
aingks | 1:c4f62ef9b5b7 | 44 | { |
aingks | 1:c4f62ef9b5b7 | 45 | //lock |
aingks | 1:c4f62ef9b5b7 | 46 | |
aingks | 1:c4f62ef9b5b7 | 47 | uint8_t engineonoff = ngene.read(); |
aingks | 1:c4f62ef9b5b7 | 48 | info->ENGINESTATE = engineonoff;# |
aingks | 1:c4f62ef9b5b7 | 49 | |
aingks | 1:c4f62ef9b5b7 | 50 | //unlock |
aingks | 1:c4f62ef9b5b7 | 51 | |
aingks | 1:c4f62ef9b5b7 | 52 | if(engineonoff == 1){ |
aingks | 1:c4f62ef9b5b7 | 53 | ngeneind = 1; |
aingks | 1:c4f62ef9b5b7 | 54 | } |
aingks | 1:c4f62ef9b5b7 | 55 | else{ |
aingks | 1:c4f62ef9b5b7 | 56 | ngeneind = 0; |
aingks | 1:c4f62ef9b5b7 | 57 | } |
aingks | 0:0943f040009c | 58 | } |
aingks | 0:0943f040009c | 59 | |
aingks | 0:0943f040009c | 60 | void task4average() |
aingks | 0:0943f040009c | 61 | { |
aingks | 0:0943f040009c | 62 | |
aingks | 0:0943f040009c | 63 | } |