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
Diff: globals.h
- Revision:
- 32:9a4046224b11
- Parent:
- 31:16e056b9f9e0
--- a/globals.h Thu Dec 03 15:50:14 2015 +0000 +++ b/globals.h Thu Dec 17 17:23:24 2015 +0100 @@ -1,19 +1,22 @@ - - +// +// globals.h +// Created by Chandan Siyag on 13/11/2015. +// +// Includes all the functions, variables, objects that need to be accessed accross the classes/files. #ifndef _globals_h_ #define _globals_h_ #include "Block.h" #include "mbed.h" -//#include "MCP23017.h" -//#include "fpga.h" +// Forward declared classes class FPGA; class TCS3472_I2C; class MCP23017; class WattBob_TextLCD; +// External global variables extern mbed::Serial pc; extern MCP23017 *i2cport; extern int kDefaultBaudRate; @@ -32,19 +35,23 @@ extern int hazReadingCount; extern bool setNewHazBlock; +// Constants const int kCommandBufferSize = 80; const int kSmallBufferSize = 5; const float kServoWait = 0.20; +// More external globals vars extern float currentMinError[3]; extern float currentMaxError[3]; extern bool pcModeChanged; #define FOREVER for(;;) +// More constants and enums const char CommandTypeValue [3] = {'!', '?', ':'}; const char kCommandTerminator = ';'; enum CommandTypeRaw { InvalidType = -1, Set = 0, Query = 1, Reply = 2 }; +// Red block values const float kMinRedBlock[4] = {4.812, 2.286, 1.316, 1}; const float kMaxRedBlock[4] = {5.474, 3.105, 1.429, 1}; const float kAverageRedBlock[4] = {5.25134482758621, 2.85965517241379, 1.35858620689655, 1}; @@ -82,20 +89,25 @@ { 0, 0, 0, 1 } }; +// External global objects extern Block defaultHazBlock; extern Block _HazBlock; extern FPGA *fpga; extern TCS3472_I2C rgbSensor; +// Enums to help make code more readable and easier to edit 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}; +// External variables extern PCModes currentMode; extern Controls currentState; + +// Global functions void DefaultHazBlock(); int readSwitches();