Driver for controlling Renishaw RenBuggy
Dependencies: SevenSegmentDisplay DCMotorDrive mbed MotorController
main.cpp@0:ae927e3c7264, 2013-12-24 (annotated)
- Committer:
- jf1452
- Date:
- Tue Dec 24 10:18:37 2013 +0000
- Revision:
- 0:ae927e3c7264
- Child:
- 1:919b214c583c
Seven Segment Display driver test program for RenBED
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jf1452 | 0:ae927e3c7264 | 1 | /******************************************************************************* |
jf1452 | 0:ae927e3c7264 | 2 | * This program demonstrates how to drive the seven segment display * |
jf1452 | 0:ae927e3c7264 | 3 | * * |
jf1452 | 0:ae927e3c7264 | 4 | * Jon Fuge * |
jf1452 | 0:ae927e3c7264 | 5 | * V1.0 24/12/2013 First issue of code * |
jf1452 | 0:ae927e3c7264 | 6 | *******************************************************************************/ |
jf1452 | 0:ae927e3c7264 | 7 | |
jf1452 | 0:ae927e3c7264 | 8 | #include "mbed.h" |
jf1452 | 0:ae927e3c7264 | 9 | #include "SevenSegmentDisplay.h" |
jf1452 | 0:ae927e3c7264 | 10 | |
jf1452 | 0:ae927e3c7264 | 11 | uint8_t ui8Tens = 0, ui8Units = 0; |
jf1452 | 0:ae927e3c7264 | 12 | |
jf1452 | 0:ae927e3c7264 | 13 | SevenSegmentDisplay segmentled( FADE ); // add + FLASH to flash display, or INSTANT |
jf1452 | 0:ae927e3c7264 | 14 | |
jf1452 | 0:ae927e3c7264 | 15 | void attimeout(); //declare prototype for timeout handler. |
jf1452 | 0:ae927e3c7264 | 16 | |
jf1452 | 0:ae927e3c7264 | 17 | Ticker timeout; //Create an instance of class Ticker called timeout. |
jf1452 | 0:ae927e3c7264 | 18 | |
jf1452 | 0:ae927e3c7264 | 19 | int main() |
jf1452 | 0:ae927e3c7264 | 20 | { |
jf1452 | 0:ae927e3c7264 | 21 | //segmentled.FlashRate(100); |
jf1452 | 0:ae927e3c7264 | 22 | timeout.attach_us(&attimeout, 500000); // Set up interrupt to call attimeout() every half a second. |
jf1452 | 0:ae927e3c7264 | 23 | |
jf1452 | 0:ae927e3c7264 | 24 | for(;;) { |
jf1452 | 0:ae927e3c7264 | 25 | } |
jf1452 | 0:ae927e3c7264 | 26 | } |
jf1452 | 0:ae927e3c7264 | 27 | |
jf1452 | 0:ae927e3c7264 | 28 | void attimeout() //Timer interrupt routine. |
jf1452 | 0:ae927e3c7264 | 29 | { |
jf1452 | 0:ae927e3c7264 | 30 | ui8Units ^= 0x80; |
jf1452 | 0:ae927e3c7264 | 31 | if ((ui8Units & 0x80) == 0) { |
jf1452 | 0:ae927e3c7264 | 32 | ui8Units++; // This means the same as D_7seg[0] = D_7seg[0] + 1; Increment "units" |
jf1452 | 0:ae927e3c7264 | 33 | if (ui8Units > 36) { // "units" digit should be in the range 0 -> 9 |
jf1452 | 0:ae927e3c7264 | 34 | ui8Units = 0; // Reset the "units" to 0 |
jf1452 | 0:ae927e3c7264 | 35 | ui8Tens++; // Increment "tens" digit |
jf1452 | 0:ae927e3c7264 | 36 | if (ui8Tens > 36) { // "tens" digit should be in the range 0 -> 9 |
jf1452 | 0:ae927e3c7264 | 37 | ui8Tens = 0; // Reset the "tens" to 0 |
jf1452 | 0:ae927e3c7264 | 38 | } |
jf1452 | 0:ae927e3c7264 | 39 | } |
jf1452 | 0:ae927e3c7264 | 40 | } |
jf1452 | 0:ae927e3c7264 | 41 | segmentled.SevenSegmentDisplayChange(ui8Tens, ui8Units); // Keep the displays multiplexed. |
jf1452 | 0:ae927e3c7264 | 42 | } |