demo project
Dependencies: AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL
Utils/ControllerIo.cpp@33:8b9dcbf6d8ec, 2016-02-04 (annotated)
- Committer:
- henryrawas
- Date:
- Thu Feb 04 20:10:33 2016 +0000
- Revision:
- 33:8b9dcbf6d8ec
- Parent:
- 19:2f0ec9ac1238
update libs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
henryrawas | 19:2f0ec9ac1238 | 1 | // Copyright (c) Microsoft. All rights reserved. |
henryrawas | 19:2f0ec9ac1238 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
henryrawas | 19:2f0ec9ac1238 | 3 | |
henryrawas | 10:9b21566a5ddb | 4 | #include "mbed.h" |
henryrawas | 10:9b21566a5ddb | 5 | #include "rtos.h" |
henryrawas | 10:9b21566a5ddb | 6 | |
henryrawas | 10:9b21566a5ddb | 7 | DigitalOut greenLed(LED_GREEN); |
henryrawas | 10:9b21566a5ddb | 8 | DigitalOut redLed(LED_RED); |
henryrawas | 10:9b21566a5ddb | 9 | DigitalOut blueLed(LED_BLUE); |
henryrawas | 10:9b21566a5ddb | 10 | |
henryrawas | 13:ffeff9b5e513 | 11 | DigitalOut buzzer(D2, 1); |
henryrawas | 13:ffeff9b5e513 | 12 | |
henryrawas | 13:ffeff9b5e513 | 13 | |
henryrawas | 13:ffeff9b5e513 | 14 | int BuzzStopMs = 0; |
henryrawas | 10:9b21566a5ddb | 15 | |
henryrawas | 10:9b21566a5ddb | 16 | void ShowLedColor(int col) |
henryrawas | 10:9b21566a5ddb | 17 | { |
henryrawas | 10:9b21566a5ddb | 18 | greenLed = 1; |
henryrawas | 10:9b21566a5ddb | 19 | redLed = 1; |
henryrawas | 10:9b21566a5ddb | 20 | blueLed = 1; |
henryrawas | 10:9b21566a5ddb | 21 | |
henryrawas | 10:9b21566a5ddb | 22 | if (col == 1) |
henryrawas | 10:9b21566a5ddb | 23 | greenLed = 0; |
henryrawas | 10:9b21566a5ddb | 24 | else if (col == 2) |
henryrawas | 10:9b21566a5ddb | 25 | redLed = 0; |
henryrawas | 10:9b21566a5ddb | 26 | else if (col == 3) |
henryrawas | 10:9b21566a5ddb | 27 | blueLed = 0; |
henryrawas | 10:9b21566a5ddb | 28 | } |
henryrawas | 10:9b21566a5ddb | 29 | |
henryrawas | 10:9b21566a5ddb | 30 | void ShowLedGreen() |
henryrawas | 10:9b21566a5ddb | 31 | { |
henryrawas | 10:9b21566a5ddb | 32 | ShowLedColor(1); |
henryrawas | 10:9b21566a5ddb | 33 | } |
henryrawas | 10:9b21566a5ddb | 34 | |
henryrawas | 10:9b21566a5ddb | 35 | void ShowLedRed() |
henryrawas | 10:9b21566a5ddb | 36 | { |
henryrawas | 10:9b21566a5ddb | 37 | ShowLedColor(2); |
henryrawas | 10:9b21566a5ddb | 38 | } |
henryrawas | 13:ffeff9b5e513 | 39 | |
henryrawas | 10:9b21566a5ddb | 40 | void ShowLedBlue() |
henryrawas | 10:9b21566a5ddb | 41 | { |
henryrawas | 10:9b21566a5ddb | 42 | ShowLedColor(3); |
henryrawas | 10:9b21566a5ddb | 43 | } |
henryrawas | 13:ffeff9b5e513 | 44 | |
henryrawas | 13:ffeff9b5e513 | 45 | void BuzzerStart() |
henryrawas | 13:ffeff9b5e513 | 46 | { |
henryrawas | 13:ffeff9b5e513 | 47 | buzzer = 0; |
henryrawas | 13:ffeff9b5e513 | 48 | } |
henryrawas | 13:ffeff9b5e513 | 49 | |
henryrawas | 13:ffeff9b5e513 | 50 | void BuzzerStop() |
henryrawas | 13:ffeff9b5e513 | 51 | { |
henryrawas | 13:ffeff9b5e513 | 52 | buzzer = 1; |
henryrawas | 13:ffeff9b5e513 | 53 | } |
henryrawas | 13:ffeff9b5e513 | 54 | |
henryrawas | 13:ffeff9b5e513 | 55 | void BuzzerStartMs(int nowMs, int durationMs) |
henryrawas | 13:ffeff9b5e513 | 56 | { |
henryrawas | 13:ffeff9b5e513 | 57 | BuzzStopMs = nowMs + durationMs; |
henryrawas | 13:ffeff9b5e513 | 58 | BuzzerStart(); |
henryrawas | 13:ffeff9b5e513 | 59 | } |
henryrawas | 13:ffeff9b5e513 | 60 | |
henryrawas | 13:ffeff9b5e513 | 61 | void BuzzerPoll(int nowMs) |
henryrawas | 13:ffeff9b5e513 | 62 | { |
henryrawas | 13:ffeff9b5e513 | 63 | if (BuzzStopMs != 0) |
henryrawas | 13:ffeff9b5e513 | 64 | { |
henryrawas | 13:ffeff9b5e513 | 65 | if (nowMs >= BuzzStopMs) |
henryrawas | 13:ffeff9b5e513 | 66 | { |
henryrawas | 13:ffeff9b5e513 | 67 | BuzzStopMs = 0; |
henryrawas | 13:ffeff9b5e513 | 68 | BuzzerStop(); |
henryrawas | 13:ffeff9b5e513 | 69 | } |
henryrawas | 13:ffeff9b5e513 | 70 | } |
henryrawas | 13:ffeff9b5e513 | 71 | } |