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: RemoteIR m3pi mbed-rtos mbed
Controller.cpp@1:76cff32344d1, 2017-05-09 (annotated)
- Committer:
- Kristof@LAPTOP-FT09DA9V.home
- Date:
- Tue May 09 23:02:13 2017 +0200
- Revision:
- 1:76cff32344d1
- Child:
- 7:1d77c7e0208c
added communication
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 1 | // |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 2 | // Created by Kristof on 5/9/2017. |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 3 | // |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 4 | |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 5 | #include "Controller.h" |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 6 | |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 7 | Controller::Controller() { |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 8 | //constructor once to initialise |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 9 | static LightCommunication lightCommunication; |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 10 | car = new m3pi(); |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 11 | receiveThread.start(&LightCommunication::receiveData); |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 12 | ir_rx = new ReceiverIR(p21); |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 13 | } |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 14 | |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 15 | Controller::~Controller() { |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 16 | |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 17 | } |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 18 | |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 19 | int Controller::run() { |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 20 | |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 21 | LightCommunication::mut.lock(); |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 22 | if (LightCommunication::needsToStop()){ |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 23 | car->stop(); |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 24 | LightCommunication::mut.unlock(); |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 25 | }else { |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 26 | current_left = LightCommunication::getLeft(current_left); |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 27 | current_right = LightCommunication::getRight(current_right); |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 28 | LightCommunication::mut.unlock(); |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 29 | car->left_motor(current_left) ; |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 30 | car->right_motor(current_right) ; |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 31 | } |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 32 | return 0; |
| Kristof@LAPTOP-FT09DA9V.home | 1:76cff32344d1 | 33 | } |
