Driver for controlling Renishaw RenBuggy

Dependencies:   SevenSegmentDisplay DCMotorDrive mbed MotorController

main.cpp

Committer:
jf1452
Date:
2013-12-24
Revision:
0:ae927e3c7264
Child:
1:919b214c583c

File content as of revision 0:ae927e3c7264:

/*******************************************************************************
* 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;

SevenSegmentDisplay segmentled( FADE ); // add + FLASH to flash display, or INSTANT 

void attimeout();            //declare prototype for timeout handler.

Ticker timeout;             //Create an instance of class Ticker called timeout.

int main()
{
    //segmentled.FlashRate(100);
    timeout.attach_us(&attimeout, 500000); // Set up interrupt to call attimeout() every half a second.

    for(;;) {
    }
}

void attimeout()              //Timer interrupt routine.
{
    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 = 0;       // Reset the "units" to 0
            ui8Tens++;          // Increment "tens" digit
            if (ui8Tens > 36) {  // "tens" digit should be in the range 0 -> 9
                ui8Tens = 0;    // Reset the "tens" to 0
            }
        }
    }
    segmentled.SevenSegmentDisplayChange(ui8Tens, ui8Units); // Keep the displays multiplexed.
}