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.cpp
- Committer:
- dreamselec
- Date:
- 2015-11-16
- Revision:
- 9:dc8f155b71c8
- Parent:
- 8:e1da2ae62885
- Child:
- 10:16ba52f8e025
File content as of revision 9:dc8f155b71c8:
#include "globals.h" #include "Block.h" #include "fpga.h" int kDefaultBaudRate = 19200; //SerialBase gParity = SerialBase::None; int gStopBits = 1; Block _HazBlock = Block(kDefaultHazBlock); bool connectedToPC = false; void connectToPC(CommandTypeRaw typeRaw){ pc.printf("pc told to connect\n"); connectedToPC = true; } void disconnectToPC(CommandTypeRaw typeRaw){ pc.printf("pc told to disconnect\n"); connectedToPC = false; } void hazBlock(CommandTypeRaw typeRaw){ if (typeRaw == Set) { pc.printf("setting new haz block.\n"); pc.printf("Send 'y' when block is inserted.\n"); int lowerBeam = 0; char readyChar = '\0'; do{ readyChar = pc.getc(); lowerBeam = fpga->checkForBlock(); if (readyChar == 'y' && lowerBeam == 0){ pc.printf("No block detected by beam\nTry again."); } } while (readyChar != 'y' || lowerBeam != 0); int higherBeam = 0; higherBeam = fpga->checkForSize(); _HazBlock = Block(); if (higherBeam == 1) _HazBlock.size = Block::Big; else if (higherBeam == 0) _HazBlock.size = Block::Small; }else if (typeRaw == Query){ pc.printf( "HazBlock:\n \t Size:%i\n \t Min Colour:%i,%i,%i,%i\n \t Max Colour:TBA\n ", _HazBlock.size, _HazBlock.minColour.components[Colour::Red], _HazBlock.minColour.components[Colour::Blue], _HazBlock.minColour.components[Colour::Green], _HazBlock.minColour.components[Colour::Alpha]); } } void getCurrentBlock(CommandTypeRaw typeRaw){ pc.printf("getting current block readings\n"); } void setIntegrationTime(int integrationTime){ pc.printf("setting i-time to %i.\n", integrationTime); } void previewOnPC(bool on){ pc.printf("setting preview on pc to %i.\n", on); } void testServos(){ pc.printf("testing servos.\n"); } void resetServos(){ pc.printf("resetting servos.\n"); } void getPortInfo(){ pc.printf("getting port info.\n"); } void setPortBaudRate(int baudRate){ pc.printf("setting port baudrate to: %i\n", baudRate); }