terry LAI / Mbed 2 deprecated ESDC2014-pwm

Dependencies:   mbed

Fork of ESDC2014 by terry LAI

main.cpp

Committer:
TonyYI
Date:
2014-07-03
Revision:
3:4306d042af6f
Parent:
2:442902ec3aa1
Child:
4:a377ecb9364f

File content as of revision 3:4306d042af6f:

/******************************************************

****┏┓          ┏┓
**┏┛┻━━━━━━┛┻┓
**┃                 ┃
**┃      ━━━      ┃
**┃  ┳┛       ┗┳ ┃
**┃                 ┃
**┃ '''    ┻   ''' ┃
**┃                 ┃
**┗━━┓       ┏━━┛
*******┃       ┃
*******┃       ┃
*******┃       ┃
*******┃       ┗━━━━━━━━┓
*******┃                      ┃━┓
*******┃      NO BUG          ┏━┛
*******┃                      ┃
*******┗━┓  ┓  ┏━┏━┓  ━┛
***********┃  ┛  ┛    ┃  ┛  ┛
***********┃  ┃  ┃    ┃  ┃  ┃
***********┗━┛━┛     ┗━┛━┛

This part is added by project ESDC2014 of CUHK team.
All the code with this header are under GPL open source license.
This program is running on Mbed Platform 'mbed LPC1768' avaliable in 'http://mbed.org'.
**********************************************************/
#include "mbed.h"
#include "communication.h"
#include "port.h"

int main()
{
    init_PORT();
   
    while(1)
    {
        buzzer.OFF();
        com.parseMessage();
        buzzer.time_out_init();
        if(com.getInfoOK(0) == 1) //car
        {
            printf("main(). Car action starting...\r\n");
            com.forwardMessage();
            com.ACK(&lifter, &camera_platform);
            com.resetInfoOK(0);
            com.resetInfoOK(1);
            printf("main(). Car action ended...\r\n");
        }
        else if(com.getInfoOK(0) == 2) //lifter
        {
            printf("main(). Lifter action starting...\r\n");
            lifter.lifterMove(com.getMoveDis(), com.getMoveDir(), com.getRotateDis(), com.getRotateDir());
            com.ACK(&lifter, &camera_platform);
            com.resetInfoOK(0);
            com.resetInfoOK(1);
            printf("main(). Lifter action ended...\r\n");
        }
        else if(com.getInfoOK(0) == 3) //camera_platform
        {
            printf("main(). camera_platform action starting...\r\n");
            camera_platform.cameraPlatformMove(com.getMoveDis(), com.getMoveDir(), com.getRotateDis(), com.getRotateDir());
            com.ACK(&lifter, &camera_platform);
            com.resetInfoOK(0);
            com.resetInfoOK(1);
            printf("main(). Camera_platform action ended...\r\n");
        }
        else if(com.getInfoOK(0) == 4) //compass
        {
            printf("main(). Compass action starting...\r\n");
            com.ACK(&lifter, &camera_platform);
            com.resetInfoOK(0);
            com.resetInfoOK(1);
            printf("main(). Compass action ended...\r\n");
        }
        else if(com.getInfoOK(0) == 5) //buzzer
        {
            printf("main(). Buzzer action starting...\r\n");
            buzzer.ON();
            wait(0.1);
            buzzer.OFF();
            wait(0.1);
            buzzer.ON();
            wait(0.2);
            buzzer.OFF();
            com.ACK(&lifter, &camera_platform);
            com.resetInfoOK(0);
            com.resetInfoOK(1);
            printf("main(). Buzzer action ended...\r\n");
        }
        
        buzzer.cleanFlag();
    }
}