![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Block.cpp@30:c0bc92d009fe, 2015-12-01 (annotated)
- Committer:
- dreamselec
- Date:
- Tue Dec 01 23:50:29 2015 +0000
- Revision:
- 30:c0bc92d009fe
- Parent:
- 29:9c0339e3c593
- Child:
- 32:9a4046224b11
All functions appear to be ... functioning. Need to test set new haz block mode with hardware.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dreamselec |
6:98fe30430194 | 1 | /* |
dreamselec |
6:98fe30430194 | 2 | * Block.cpp |
dreamselec |
6:98fe30430194 | 3 | * |
dreamselec |
6:98fe30430194 | 4 | * Created on: 16 Nov 2015 |
dreamselec |
6:98fe30430194 | 5 | * Author: chandansiyag |
dreamselec |
6:98fe30430194 | 6 | */ |
dreamselec |
6:98fe30430194 | 7 | |
dreamselec |
6:98fe30430194 | 8 | #include "Block.h" |
dreamselec |
6:98fe30430194 | 9 | |
dreamselec |
6:98fe30430194 | 10 | Colour::Colour(){ |
dreamselec |
6:98fe30430194 | 11 | setRed(0); |
dreamselec |
6:98fe30430194 | 12 | setBlue(0); |
dreamselec |
6:98fe30430194 | 13 | setGreen(0); |
dreamselec |
6:98fe30430194 | 14 | setAlpha(0); |
dreamselec |
6:98fe30430194 | 15 | } |
dreamselec |
6:98fe30430194 | 16 | |
dreamselec |
6:98fe30430194 | 17 | Colour::~Colour(){ |
dreamselec |
6:98fe30430194 | 18 | |
dreamselec |
6:98fe30430194 | 19 | } |
dreamselec |
6:98fe30430194 | 20 | |
dreamselec | 20:4e0f0944f28f | 21 | Colour::Colour(float components[4]){ |
dreamselec | 20:4e0f0944f28f | 22 | for (int i = 0; i < sizeof(components)/sizeof(*components); i++){ |
dreamselec | 20:4e0f0944f28f | 23 | this->components[i] = components[i]; |
dreamselec | 20:4e0f0944f28f | 24 | } |
dreamselec | 20:4e0f0944f28f | 25 | } |
dreamselec | 20:4e0f0944f28f | 26 | |
dreamselec |
6:98fe30430194 | 27 | Colour::Colour(const Colour& rhs){ |
dreamselec |
6:98fe30430194 | 28 | setRed(rhs.getRed()); |
dreamselec |
6:98fe30430194 | 29 | setBlue(rhs.getBlue()); |
dreamselec |
6:98fe30430194 | 30 | setGreen(rhs.getGreen()); |
dreamselec |
6:98fe30430194 | 31 | setAlpha(rhs.getAlpha()); |
dreamselec |
6:98fe30430194 | 32 | } |
dreamselec | 7:b6e31bfdb2af | 33 | |
dreamselec | 26:bbcc25418ffa | 34 | void Colour::printDescription(){ |
dreamselec | 26:bbcc25418ffa | 35 | // pc.printf("Red: %.3f, Green: %.3f, Blue: %.3f, Clear: %.3f\n", this->component[0], this->component[1], this->component[2], this->component[3]); |
dreamselec | 26:bbcc25418ffa | 36 | } |
dreamselec | 26:bbcc25418ffa | 37 | |
dreamselec | 7:b6e31bfdb2af | 38 | Block::Block(){ |
dreamselec | 7:b6e31bfdb2af | 39 | this->size = Small; |
dreamselec | 7:b6e31bfdb2af | 40 | this->minColour = Colour(); |
dreamselec | 20:4e0f0944f28f | 41 | this->averageColour = Colour(); |
dreamselec | 7:b6e31bfdb2af | 42 | this->maxColour = Colour(); |
dreamselec |
29:9c0339e3c593 | 43 | this->colour = Block::Red; |
dreamselec | 26:bbcc25418ffa | 44 | // this->minError = {0, 0, 0, 0}; |
dreamselec | 26:bbcc25418ffa | 45 | // this->maxError = {0, 0, 0, 0}; |
dreamselec | 7:b6e31bfdb2af | 46 | } |
dreamselec |
29:9c0339e3c593 | 47 | |
dreamselec |
29:9c0339e3c593 | 48 | Block::Block(Size size, BlockColour blockColour){ |
dreamselec | 30:c0bc92d009fe | 49 | this->minColour = Colour(); |
dreamselec | 30:c0bc92d009fe | 50 | this->averageColour = Colour(); |
dreamselec | 30:c0bc92d009fe | 51 | this->maxColour = Colour(); |
dreamselec |
29:9c0339e3c593 | 52 | this->colour = blockColour; |
dreamselec |
29:9c0339e3c593 | 53 | this->size = size; |
dreamselec |
29:9c0339e3c593 | 54 | } |
dreamselec |
29:9c0339e3c593 | 55 | |
dreamselec | 7:b6e31bfdb2af | 56 | Block::Block(Size size) { |
dreamselec | 7:b6e31bfdb2af | 57 | // TODO Auto-generated constructor stub |
dreamselec | 7:b6e31bfdb2af | 58 | this->size = size; |
dreamselec | 7:b6e31bfdb2af | 59 | this->minColour = Colour(); |
dreamselec | 7:b6e31bfdb2af | 60 | this->maxColour = Colour(); |
dreamselec | 20:4e0f0944f28f | 61 | this->averageColour = Colour(); |
dreamselec | 26:bbcc25418ffa | 62 | // this->minError = {0, 0, 0, 0}; |
dreamselec | 26:bbcc25418ffa | 63 | // this->maxError = {0, 0, 0, 0}; |
dreamselec | 20:4e0f0944f28f | 64 | } |
dreamselec | 20:4e0f0944f28f | 65 | |
dreamselec | 20:4e0f0944f28f | 66 | Block::Block(Size size, Colour minColour, Colour maxColour, Colour averageColour){ |
dreamselec | 20:4e0f0944f28f | 67 | this->size = size; |
dreamselec | 20:4e0f0944f28f | 68 | this->minColour = Colour(minColour); |
dreamselec | 20:4e0f0944f28f | 69 | this->maxColour = Colour(maxColour); |
dreamselec | 20:4e0f0944f28f | 70 | this->averageColour = Colour(averageColour); |
dreamselec | 26:bbcc25418ffa | 71 | // this->minError = {0, 0, 0, 0}; |
dreamselec | 26:bbcc25418ffa | 72 | // this->maxError = {0, 0, 0, 0}; |
dreamselec | 7:b6e31bfdb2af | 73 | } |
dreamselec | 7:b6e31bfdb2af | 74 | |
dreamselec | 7:b6e31bfdb2af | 75 | Block::Block(const Block& rhs){ |
dreamselec | 7:b6e31bfdb2af | 76 | minColour = Colour(rhs.minColour); |
dreamselec | 7:b6e31bfdb2af | 77 | maxColour = Colour(rhs.maxColour); |
dreamselec | 20:4e0f0944f28f | 78 | averageColour = Colour(rhs.averageColour); |
dreamselec | 7:b6e31bfdb2af | 79 | size = rhs.size; |
dreamselec | 26:bbcc25418ffa | 80 | // minError = rhs.minError; |
dreamselec | 26:bbcc25418ffa | 81 | // maxError = rhs.maxError; |
dreamselec | 7:b6e31bfdb2af | 82 | } |
dreamselec | 7:b6e31bfdb2af | 83 | |
dreamselec | 7:b6e31bfdb2af | 84 | Block::~Block() { |
dreamselec | 7:b6e31bfdb2af | 85 | // TODO Auto-generated destructor stub |
dreamselec | 7:b6e31bfdb2af | 86 | } |
dreamselec | 7:b6e31bfdb2af | 87 | |
dreamselec | 26:bbcc25418ffa | 88 | void Block::printDescription(){ |
dreamselec | 26:bbcc25418ffa | 89 | |
dreamselec | 26:bbcc25418ffa | 90 | } |