TomYumBoys / Mbed 2 deprecated MM2017

Dependencies:   mbed

main.cpp

Committer:
kolanery
Date:
2017-05-13
Revision:
3:4230b82fde43
Parent:
2:619b02232144
Child:
4:73510c7fa316

File content as of revision 3:4230b82fde43:

#include "mbed.h"
#include "drivecontrol.h"
#include "pin_assignment.h"
AnalogIn battery(PA_3);
Serial pc(PA_9, PA_10);

DigitalOut testLed(PB_12);
DigitalOut testLed2(PB_13);
DigitalOut testLed3(PB_14);
DigitalOut testLed4(PB_15);

Serial serial (PA_9, PA_10);

// Define states for debugging the mouse hardware
// const int DRIVE = 1, TURN = 2, DEBUG = 3, STOP = 4;
// Direction of which to turn
// const int LEFT = 0, RIGHT = 1;
// Start and End Pos
const int START_POS = 0, END_POS = 0;

// Terminating condition for the main control loop
bool hasFoundCenter = false;

// Battery Consumption Indicator
void setup() {
    pc.baud(9600);
    if (battery.read() < 0.67f){
        // flash led
        testLed = 1;
        testLed2 = 1;
        testLed3 = 1;
        testLed4 = 1;
    }  
}

// Performs the basic drive control of the mouse
int main() {
    DriveControl * driver = new DriveControl(START_POS, END_POS);
    while(1) {
        setup();

        serial.printf("voltage value is: %3.3f%%\r\n", battery.read()*100.0f);
        serial.printf("normalized: 0x%04X \r\n", battery.read_u16());
        
        testLed2 = 1;
        testLed4 = 1;

        driver->drive_one_forward();
        
        wait(0.5);
        driver->stop();
        wait(3);
    }
}