3rd year group project. Electronic and Electrical Engineering. Heriot-Watt University. This is the code for the mbed for the Automatic Little Object Organiser (ALOO).

Dependencies:   MCP23017 TCS3472_I2C WattBob_TextLCD mbed

globals.h

Committer:
dreamselec
Date:
2015-11-28
Revision:
23:db91aaa43a9e
Parent:
20:4e0f0944f28f
Child:
25:792540d69c49

File content as of revision 23:db91aaa43a9e:




#ifndef _globals_h_
#define _globals_h_

#include "Block.h"
#include "mbed.h"
//#include "MCP23017.h"
//#include "fpga.h"

class FPGA;
class TCS3472_I2C;
class MCP23017;
class WattBob_TextLCD;

extern mbed::Serial pc;
extern MCP23017 *i2cport;
extern int kDefaultBaudRate;
extern WattBob_TextLCD *lcd;
//extern SerialBase gParity;
extern int gStopBits;
extern bool connectedToPC;
extern bool runServoTest;
extern bool runBreakBeamTest;

const int kCommandBufferSize = 80;
const int kSmallBufferSize = 5;
const float kServoWait = 0.25;

#define FOREVER for(;;)

const char CommandTypeValue [3] = {'!', '?', ':'};
const char kCommandTerminator = ';';
enum CommandTypeRaw { InvalidType = -1, Set = 0, Query = 1, Reply = 2 };

const float kMinRedBlock[4] = {4.812, 2.286, 1.316, 1};
const float kMaxRedBlock[4] = {4.812, 2.286, 1.316, 1};
const float kAverageRedBlock[4] = {5.25134482758621, 2.85965517241379, 1.35858620689655, 1};
const float kMinError[3] = { 0.0836632980714298, 0.200602918123719, 0.0313459732480518};
const float kMaxError[3] = { 0.0423996480376129, 0.0857952490051849, 0.051828726617427};

extern Block defaultHazBlock;
extern Block _HazBlock;
extern FPGA *fpga;

extern TCS3472_I2C rgbSensor;

enum Servos {Stopping = 1, Sorting = 2};
enum StoppingServoPositions {Stop = 0, Go = 1};
enum SortingServoPositions {NonHaz = 0, Haz = 1};
enum Controls { Start = 0, Pause = 1};
enum PCModes { None = -1, Normal = 0, Maintanence = 1};

extern PCModes currentMode;
extern Controls currentState;
void DefaultHazBlock();

int readSwitches();
bool displayAbortDialog();
void displayPCStatus();

void connectToPC(CommandTypeRaw typeRaw=Set);
void disconnectToPC(CommandTypeRaw typeRaw=Set);
void hazBlock(CommandTypeRaw typeRaw);
void getCurrentBlock(CommandTypeRaw typeRaw=Query);

void setIntegrationTimeTo(float integrationTime);
void previewOnPC(bool on);
void readColourSensor ();

void testServos(Controls state);
void resetServos();

void getPortInfo();
void setPortBaudRate(int baudRate);
void setPortParity(int parity);

void testBreakBeams(Controls state);

#endif