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
Diff: Block.cpp
- Revision:
- 32:9a4046224b11
- Parent:
- 30:c0bc92d009fe
--- a/Block.cpp Thu Dec 03 15:50:14 2015 +0000
+++ b/Block.cpp Thu Dec 17 17:23:24 2015 +0100
@@ -2,7 +2,7 @@
* Block.cpp
*
* Created on: 16 Nov 2015
- * Author: chandansiyag
+ * Author: Chandan Siyag
*/
#include "Block.h"
@@ -18,12 +18,15 @@
}
+/// Create a new colour object from passed array of components.
Colour::Colour(float components[4]){
for (int i = 0; i < sizeof(components)/sizeof(*components); i++){
this->components[i] = components[i];
}
}
+/// Create new colour object from passed colour object.
+/// Copies data, not a new pointer
Colour::Colour(const Colour& rhs){
setRed(rhs.getRed());
setBlue(rhs.getBlue());
@@ -31,6 +34,8 @@
setAlpha(rhs.getAlpha());
}
+/// Sends description to PC about itself.
+/// Cannot be used here since it doesn't know about pc object. Defined in globals.h
void Colour::printDescription(){
// pc.printf("Red: %.3f, Green: %.3f, Blue: %.3f, Clear: %.3f\n", this->component[0], this->component[1], this->component[2], this->component[3]);
}
@@ -41,10 +46,9 @@
this->averageColour = Colour();
this->maxColour = Colour();
this->colour = Block::Red;
-// this->minError = {0, 0, 0, 0};
-// this->maxError = {0, 0, 0, 0};
}
+/// Create new block object from passed size and colour
Block::Block(Size size, BlockColour blockColour){
this->minColour = Colour();
this->averageColour = Colour();
@@ -53,32 +57,29 @@
this->size = size;
}
+/// Create new block with size and default colour
Block::Block(Size size) {
// TODO Auto-generated constructor stub
this->size = size;
this->minColour = Colour();
this->maxColour = Colour();
this->averageColour = Colour();
-// this->minError = {0, 0, 0, 0};
-// this->maxError = {0, 0, 0, 0};
}
+/// Create new block object with passed properties
Block::Block(Size size, Colour minColour, Colour maxColour, Colour averageColour){
this->size = size;
this->minColour = Colour(minColour);
this->maxColour = Colour(maxColour);
this->averageColour = Colour(averageColour);
-// this->minError = {0, 0, 0, 0};
-// this->maxError = {0, 0, 0, 0};
}
+/// Copy block object to a new one.
Block::Block(const Block& rhs){
minColour = Colour(rhs.minColour);
maxColour = Colour(rhs.maxColour);
averageColour = Colour(rhs.averageColour);
size = rhs.size;
-// minError = rhs.minError;
-// maxError = rhs.maxError;
}
Block::~Block() {
