Basketball robot mainboard firmware

Dependencies:   USBDevice mbed

Committer:
Reiko
Date:
Mon Sep 10 15:24:08 2018 +0000
Revision:
0:88887cfb2b04
Mainboard firmware for basketball robot

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Reiko 0:88887cfb2b04 1 #include "RGBLed.hpp"
Reiko 0:88887cfb2b04 2
Reiko 0:88887cfb2b04 3 RGBLed::RGBLed(PinName rPin, PinName gPin, PinName bPin) :
Reiko 0:88887cfb2b04 4 r(rPin),
Reiko 0:88887cfb2b04 5 g(gPin),
Reiko 0:88887cfb2b04 6 b(bPin)
Reiko 0:88887cfb2b04 7 {
Reiko 0:88887cfb2b04 8 set(false, false, false);
Reiko 0:88887cfb2b04 9 }
Reiko 0:88887cfb2b04 10
Reiko 0:88887cfb2b04 11 bool RGBLed::getRed()
Reiko 0:88887cfb2b04 12 {
Reiko 0:88887cfb2b04 13 return !r.read();
Reiko 0:88887cfb2b04 14 }
Reiko 0:88887cfb2b04 15
Reiko 0:88887cfb2b04 16 bool RGBLed::getGreen()
Reiko 0:88887cfb2b04 17 {
Reiko 0:88887cfb2b04 18 return !g.read();
Reiko 0:88887cfb2b04 19 }
Reiko 0:88887cfb2b04 20
Reiko 0:88887cfb2b04 21 bool RGBLed::getBlue()
Reiko 0:88887cfb2b04 22 {
Reiko 0:88887cfb2b04 23 return !b.read();
Reiko 0:88887cfb2b04 24 }
Reiko 0:88887cfb2b04 25
Reiko 0:88887cfb2b04 26 RGBLed::Color RGBLed::get()
Reiko 0:88887cfb2b04 27 {
Reiko 0:88887cfb2b04 28 return Color(getRed() | (getGreen() << 1) | (getBlue() << 2));
Reiko 0:88887cfb2b04 29 }
Reiko 0:88887cfb2b04 30
Reiko 0:88887cfb2b04 31 RGBLed& RGBLed::setRed(bool value)
Reiko 0:88887cfb2b04 32 {
Reiko 0:88887cfb2b04 33 r = !value;
Reiko 0:88887cfb2b04 34 return *this;
Reiko 0:88887cfb2b04 35 }
Reiko 0:88887cfb2b04 36
Reiko 0:88887cfb2b04 37 RGBLed& RGBLed::setGreen(bool value)
Reiko 0:88887cfb2b04 38 {
Reiko 0:88887cfb2b04 39 g = !value;
Reiko 0:88887cfb2b04 40 return *this;
Reiko 0:88887cfb2b04 41 }
Reiko 0:88887cfb2b04 42
Reiko 0:88887cfb2b04 43 RGBLed& RGBLed::setBlue(bool value)
Reiko 0:88887cfb2b04 44 {
Reiko 0:88887cfb2b04 45 b = !value;
Reiko 0:88887cfb2b04 46 return *this;
Reiko 0:88887cfb2b04 47 }
Reiko 0:88887cfb2b04 48
Reiko 0:88887cfb2b04 49 RGBLed& RGBLed::set(bool rValue, bool gValue, bool bValue)
Reiko 0:88887cfb2b04 50 {
Reiko 0:88887cfb2b04 51 return setRed(rValue).setGreen(gValue).setBlue(bValue);
Reiko 0:88887cfb2b04 52 }
Reiko 0:88887cfb2b04 53
Reiko 0:88887cfb2b04 54 RGBLed& RGBLed::set(RGBLed::Color color)
Reiko 0:88887cfb2b04 55 {
Reiko 0:88887cfb2b04 56 return set(color & 1, color & 2, color & 4);
Reiko 0:88887cfb2b04 57 }