From 4436c14ab688ca57fc82c1fd68f2f366fa131de1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 12 Jan 2018 08:29:05 +0100 Subject: add mmsimple driver --- src/driver/mmsimple.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/driver/mmsimple.cc (limited to 'src/driver') diff --git a/src/driver/mmsimple.cc b/src/driver/mmsimple.cc new file mode 100644 index 0000000..d47d10d --- /dev/null +++ b/src/driver/mmsimple.cc @@ -0,0 +1,32 @@ +#include "driver/mmsimple.h" +#include "driver/i2c.h" + +void MicroMoodySimple::sendCmd(unsigned char byte) +{ + txbuf[0] = byte; + i2c.xmit(address, 3, txbuf, 0, txbuf); +} + +void MicroMoodySimple::setBrightness(unsigned char red, unsigned char green) +{ + txbuf[0] = 13; + txbuf[1] = green; + txbuf[2] = red; + i2c.xmit(address, 3, txbuf, 0, txbuf); +} + +void MicroMoodySimple::off() { sendCmd(0); } +void MicroMoodySimple::redOff() { sendCmd(1); } +void MicroMoodySimple::greenOff() { sendCmd(2); } +void MicroMoodySimple::blueOff() { sendCmd(3); } +void MicroMoodySimple::redOn() { sendCmd(4); } +void MicroMoodySimple::greenOn() { sendCmd(5); } +void MicroMoodySimple::blueOn() { sendCmd(6); } +void MicroMoodySimple::toggleRed() { sendCmd(7); } +void MicroMoodySimple::toggleGreen() { sendCmd(8); } +void MicroMoodySimple::toggleBlue() { sendCmd(9); } +void MicroMoodySimple::red() { sendCmd(10); } +void MicroMoodySimple::green() { sendCmd(11); } +void MicroMoodySimple::blue() { sendCmd(12); } + +MicroMoodySimple moody(0x11); -- cgit v1.2.3