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

Committer:
dreamselec
Date:
Thu Dec 17 17:23:24 2015 +0100
Revision:
32:9a4046224b11
Parent:
29:9c0339e3c593
Comments and clean up.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreamselec 6:98fe30430194 1 /*
dreamselec 6:98fe30430194 2 * Block.h
dreamselec 6:98fe30430194 3 *
dreamselec 6:98fe30430194 4 * Created on: 16 Nov 2015
dreamselec 32:9a4046224b11 5 * Author: Chandan Siyag
dreamselec 32:9a4046224b11 6 *
dreamselec 32:9a4046224b11 7 * Defines two classes:
dreamselec 32:9a4046224b11 8 * - Colour: is a colour object used for saving/retriving data from sensor. Can also do simple manipulations.
dreamselec 32:9a4046224b11 9 * - Block: class to save a block data, any new block that passes through, or hazardous block.
dreamselec 6:98fe30430194 10 */
dreamselec 6:98fe30430194 11
dreamselec 6:98fe30430194 12 #ifndef _block_h_
dreamselec 6:98fe30430194 13 #define _block_h_
dreamselec 6:98fe30430194 14
dreamselec 6:98fe30430194 15 class Colour{
dreamselec 6:98fe30430194 16 public:
dreamselec 6:98fe30430194 17 Colour();
dreamselec 20:4e0f0944f28f 18 Colour(float components[4]);
dreamselec 6:98fe30430194 19 Colour(const Colour& rhs);
dreamselec 6:98fe30430194 20 virtual ~Colour();
dreamselec 26:bbcc25418ffa 21 void printDescription();
dreamselec 6:98fe30430194 22
dreamselec 6:98fe30430194 23 enum Components {Red = 0, Blue = 1, Green = 2, Alpha = 3};
dreamselec 6:98fe30430194 24
dreamselec 20:4e0f0944f28f 25 float components [4];
dreamselec 6:98fe30430194 26
dreamselec 20:4e0f0944f28f 27 float getAlpha() const {
dreamselec 6:98fe30430194 28 return components[Alpha];
dreamselec 6:98fe30430194 29 }
dreamselec 6:98fe30430194 30
dreamselec 20:4e0f0944f28f 31 void setAlpha(float alpha) {
dreamselec 6:98fe30430194 32 this->components[Alpha] = alpha;
dreamselec 6:98fe30430194 33 }
dreamselec 6:98fe30430194 34
dreamselec 20:4e0f0944f28f 35 float getBlue() const {
dreamselec 6:98fe30430194 36 return components[Blue];
dreamselec 6:98fe30430194 37 }
dreamselec 6:98fe30430194 38
dreamselec 20:4e0f0944f28f 39 void setBlue(float blue) {
dreamselec 6:98fe30430194 40 this->components[Blue] = blue;
dreamselec 6:98fe30430194 41 }
dreamselec 6:98fe30430194 42
dreamselec 20:4e0f0944f28f 43 float getGreen() const {
dreamselec 6:98fe30430194 44 return components[Green];
dreamselec 6:98fe30430194 45 }
dreamselec 6:98fe30430194 46
dreamselec 20:4e0f0944f28f 47 void setGreen(float green) {
dreamselec 6:98fe30430194 48 this->components[Green] = green;
dreamselec 6:98fe30430194 49 }
dreamselec 6:98fe30430194 50
dreamselec 20:4e0f0944f28f 51 float getRed() const {
dreamselec 6:98fe30430194 52 return components[Red];
dreamselec 6:98fe30430194 53 }
dreamselec 6:98fe30430194 54
dreamselec 20:4e0f0944f28f 55 void setRed(float red) {
dreamselec 6:98fe30430194 56 this->components[Red] = red;
dreamselec 6:98fe30430194 57 }
dreamselec 6:98fe30430194 58 };
dreamselec 6:98fe30430194 59
dreamselec 7:b6e31bfdb2af 60 class Block {
dreamselec 7:b6e31bfdb2af 61 public:
dreamselec 32:9a4046224b11 62 // ENUM to help make code readable and reduce mistakes.
dreamselec 7:b6e31bfdb2af 63 enum Size {Small = 0, Big = 1};
dreamselec 29:9c0339e3c593 64 enum BlockColour {Wrong = -1, Red = 0, White = 1, Blue = 2, Green = 3, Orange = 4, Yellow = 5, Black = 6};
dreamselec 29:9c0339e3c593 65
dreamselec 7:b6e31bfdb2af 66 Block();
dreamselec 7:b6e31bfdb2af 67 Block(Size size);
dreamselec 29:9c0339e3c593 68 Block(Size size, BlockColour blockColour);
dreamselec 20:4e0f0944f28f 69 Block(Size size, Colour minColour, Colour maxColour, Colour averageColour);
dreamselec 7:b6e31bfdb2af 70 Block(const Block& rhs);
dreamselec 7:b6e31bfdb2af 71 virtual ~Block();
dreamselec 7:b6e31bfdb2af 72
dreamselec 7:b6e31bfdb2af 73 Size size;
dreamselec 7:b6e31bfdb2af 74 Colour minColour;
dreamselec 7:b6e31bfdb2af 75 Colour maxColour;
dreamselec 20:4e0f0944f28f 76 Colour averageColour;
dreamselec 29:9c0339e3c593 77 BlockColour colour;
dreamselec 26:bbcc25418ffa 78
dreamselec 26:bbcc25418ffa 79 void printDescription();
dreamselec 26:bbcc25418ffa 80 private:
dreamselec 26:bbcc25418ffa 81
dreamselec 7:b6e31bfdb2af 82 };
dreamselec 7:b6e31bfdb2af 83
dreamselec 6:98fe30430194 84 #endif /* _block_h_ */