Driver for controlling Renishaw RenBuggy
Dependencies: SevenSegmentDisplay DCMotorDrive mbed MotorController
main.cpp
- Committer:
- jf1452
- Date:
- 2013-12-24
- Revision:
- 2:4180acdfa77a
- Parent:
- 1:919b214c583c
- Child:
- 3:0dd99309381e
File content as of revision 2:4180acdfa77a:
/******************************************************************************* * This program demonstrates how to drive the seven segment display * * * * Jon Fuge * * V1.0 24/12/2013 First issue of code * *******************************************************************************/ #include "mbed.h" #include "SevenSegmentDisplay.h" uint8_t ui8Tens = 0, ui8Units = 0; // 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. Ticker timeout; //Create an instance of class Ticker called timeout. int main() { //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 // Set up interrupt to call attimeout() every half a second. timeout.attach_us(&attimeout, 500000); for(;;) {} // Loop forever (the program uses interrupts) } void attimeout() { ui8Units ^= 0x80; if ((ui8Units & 0x80) == 0) { 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) { // cycle through entire range 0 -> 9, A -> Z ui8Tens = 0; // Reset the "tens" to 0 } } } // Updates display with new values. segmentled.SevenSegmentDisplayChange(ui8Tens, ui8Units); }