Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MCP23017 TCS3472_I2C WattBob_TextLCD mbed
Block.h
00001 /* 00002 * Block.h 00003 * 00004 * Created on: 16 Nov 2015 00005 * Author: Chandan Siyag 00006 * 00007 * Defines two classes: 00008 * - Colour: is a colour object used for saving/retriving data from sensor. Can also do simple manipulations. 00009 * - Block: class to save a block data, any new block that passes through, or hazardous block. 00010 */ 00011 00012 #ifndef _block_h_ 00013 #define _block_h_ 00014 00015 class Colour{ 00016 public: 00017 Colour(); 00018 Colour(float components[4]); 00019 Colour(const Colour& rhs); 00020 virtual ~Colour(); 00021 void printDescription(); 00022 00023 enum Components {Red = 0, Blue = 1, Green = 2, Alpha = 3}; 00024 00025 float components [4]; 00026 00027 float getAlpha() const { 00028 return components[Alpha]; 00029 } 00030 00031 void setAlpha(float alpha) { 00032 this->components[Alpha] = alpha; 00033 } 00034 00035 float getBlue() const { 00036 return components[Blue]; 00037 } 00038 00039 void setBlue(float blue) { 00040 this->components[Blue] = blue; 00041 } 00042 00043 float getGreen() const { 00044 return components[Green]; 00045 } 00046 00047 void setGreen(float green) { 00048 this->components[Green] = green; 00049 } 00050 00051 float getRed() const { 00052 return components[Red]; 00053 } 00054 00055 void setRed(float red) { 00056 this->components[Red] = red; 00057 } 00058 }; 00059 00060 class Block { 00061 public: 00062 // ENUM to help make code readable and reduce mistakes. 00063 enum Size {Small = 0, Big = 1}; 00064 enum BlockColour {Wrong = -1, Red = 0, White = 1, Blue = 2, Green = 3, Orange = 4, Yellow = 5, Black = 6}; 00065 00066 Block(); 00067 Block(Size size); 00068 Block(Size size, BlockColour blockColour); 00069 Block(Size size, Colour minColour, Colour maxColour, Colour averageColour); 00070 Block(const Block& rhs); 00071 virtual ~Block(); 00072 00073 Size size; 00074 Colour minColour; 00075 Colour maxColour; 00076 Colour averageColour; 00077 BlockColour colour; 00078 00079 void printDescription(); 00080 private: 00081 00082 }; 00083 00084 #endif /* _block_h_ */
Generated on Sat Jul 16 2022 16:49:56 by
1.7.2