All tasks complete
Dependencies: mbed MCP23017 mbed-rtos WattBob_TextLCD
Revision 18:65c51c80a165, committed 2019-04-03
- Comitter:
- aingks
- Date:
- Wed Apr 03 20:06:28 2019 +0000
- Parent:
- 17:6b4d94f9c77a
- Commit message:
- clean code; removed alternative code
Changed in this revision
| assignment3tasks.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/assignment3tasks.cpp Wed Apr 03 14:52:07 2019 +0000
+++ b/assignment3tasks.cpp Wed Apr 03 20:06:28 2019 +0000
@@ -254,62 +254,12 @@
while(true){
- /* int turnleft = leftsw;
- int turnright = rightsw;
-
-
- carstateXS.lock();
-
- (turnleft == 1)? info.leftind = 1 :info.leftind = 0;
- (turnright == 1)? info.rightind = 1 :info.rightind = 0;
-
- carstateXS.unlock();
-
-
-
-
- //hazard and other lights
-
- float left_period = 1.0;
- float right_period = 1.0;
- float left_pulswidth = 0.0;
- float right_pulswidth = 0.0;*/
-
- /*if (turnleft != 0)
- {
- left_period = (1/TASKFREQ9);
- left_pulswidth = (1/(2*TASKFREQ9));
- }
- if (turnright!= 0)
- {
- right_period = (1/TASKFREQ9);
- right_pulswidth = (1/TASKFREQ9);
- }
- if (turnleft != 0 && turnright != 0)
- {
- left_period = left_period / 2;
- left_pulswidth = left_pulswidth / 2;
- right_period = right_period / 2;
- right_pulswidth = right_pulswidth / 2;
- }
-
-
- leftind.period(left_period);
- leftind.pulsewidth(left_pulswidth);
- rightind.period(right_period);
- rightind.pulsewidth(right_pulswidth);
- */
-
-
-
- //float delay = 1000 / TASKFREQ9S2;
- //Thread::wait((int)delay);
-
- // Counter ensure everything works off of 2Hz loop
count++;
leftind = leftsw;
rightind = rightsw;
+ (leftsw==1)? info.leftind = 1: info.leftind = 0;
+ (rightsw==1)? info.rightind = 1: info.rightind = 0;
if (leftsw == 1 && rightsw == 1){
carstateXS.lock();
@@ -366,49 +316,4 @@
-}
-////////////////////////////////////
-/*void IndicatorsCheck(){
- LeftIndicatorLight = LeftIndicatorSwitch;
- RightIndicatorLight = RightIndicatorSwitch;
-}
-// Flash respective indicator every 1 second// linked from above
-void IndicatorFlash(){
- Global_Sem.wait();
- if (LeftIndicatorLight == 1 && RightIndicatorLight == 0){
- LeftIndicatorLight = 0;
- }
- else if (RightIndicatorLight == 1 && LeftIndicatorLight == 0){
- RightIndicatorLight = 0;
- }
- else if (LeftIndicatorLight == 0 && RightIndicatorLight == 0){
- }
- Global_Sem.release();
-}
-// Flash hazards every o.5 seconds
-void HazardLights(){
- Global_Sem.wait();
- if (LeftIndicatorSwitch == 1 && RightIndicatorSwitch == 1){
- LeftIndicatorLight = 0;
- RightIndicatorLight = 0;
- }
- Global_Sem.release();
-}
-void TwoHzLoop(){
- while(true){
-
- count++; // Counter ensure everything works off of 2Hz loop
- Display();
- IndicatorsCheck();
- HazardLights();
- if (count == 2||count == 4){ // flash indicators every second
- IndicatorFlash();
- }
- if (count == 4){ // send data every 2 seconds
- SendData();
- count = 0;
- }
- Thread::wait(500);
- }
-}
- */
\ No newline at end of file
+}
\ No newline at end of file