![](/media/cache/profiles/1becf26e9f32353e30870060538746e7.50x50_q85.jpg)
Driver for controlling Renishaw RenBuggy
Dependencies: SevenSegmentDisplay DCMotorDrive mbed MotorController
Diff: main.cpp
- Revision:
- 1:919b214c583c
- Parent:
- 0:ae927e3c7264
- Child:
- 2:4180acdfa77a
--- a/main.cpp Tue Dec 24 10:18:37 2013 +0000 +++ b/main.cpp Tue Dec 24 11:06:30 2013 +0000 @@ -10,7 +10,11 @@ uint8_t ui8Tens = 0, ui8Units = 0; -SevenSegmentDisplay segmentled( FADE ); // add + FLASH to flash display, or INSTANT +// Options to instantiate SevenSegmentDisplay are... +// FADE: causes the number changes to fade in smoothly +// INSTANT: causes the an instant number change +// + FLASH: causes the display to flash +SevenSegmentDisplay segmentled( FADE ); void attimeout(); //declare prototype for timeout handler. @@ -18,25 +22,29 @@ int main() { - //segmentled.FlashRate(100); - timeout.attach_us(&attimeout, 500000); // Set up interrupt to call attimeout() every half a second. + //segmentled.FlashRate(100); //Sets the flash rate to every 100ms + //segmentled.FadeMode(FADE + FLASH); //Changes display mode to fade with flash + //segmentled.FadeRate(10); // Sets the fade rate to 10ms intervals - for(;;) { - } + // Set up interrupt to call attimeout() every half a second. + timeout.attach_us(&attimeout, 500000); + + for(;;) {} // Loop forever (all the program uses interrupts. } -void attimeout() //Timer interrupt routine. +void attimeout() { ui8Units ^= 0x80; if ((ui8Units & 0x80) == 0) { - ui8Units++; // This means the same as D_7seg[0] = D_7seg[0] + 1; Increment "units" - if (ui8Units > 36) { // "units" digit should be in the range 0 -> 9 + ui8Units++; // "units" + if (ui8Units > 36) { // cycle through entire range 0 -> 9, A -> Z ui8Units = 0; // Reset the "units" to 0 ui8Tens++; // Increment "tens" digit - if (ui8Tens > 36) { // "tens" digit should be in the range 0 -> 9 + if (ui8Tens > 36) { // cycle through entire range 0 -> 9, A -> Z ui8Tens = 0; // Reset the "tens" to 0 } } } - segmentled.SevenSegmentDisplayChange(ui8Tens, ui8Units); // Keep the displays multiplexed. -} + // Updates display with new values. + segmentled.SevenSegmentDisplayChange(ui8Tens, ui8Units); +} \ No newline at end of file