Skip to content

Commit

Permalink
fix prev/next mode for RGBW
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Mullins committed Apr 23, 2017
1 parent 217ca8f commit bf44b70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/MiLight/RgbwPacketFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ void RgbwPacketFormatter::modeSpeedUp() {
}

void RgbwPacketFormatter::nextMode() {
command(RGBW_DISCO_MODE, 0);
lastMode = (lastMode + 1) % RGBW_NUM_MODES;
updateMode(lastMode);
}

void RgbwPacketFormatter::previousMode() {
lastMode = (lastMode - 1) % RGBW_NUM_MODES;
updateMode(lastMode);
}

void RgbwPacketFormatter::updateMode(uint8_t mode) {
Expand Down
8 changes: 7 additions & 1 deletion lib/MiLight/RgbwPacketFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ enum MiLightRgbwButton {
#define RGBW_COMMAND_INDEX 5
#define RGBW_BRIGHTNESS_GROUP_INDEX 4
#define RGBW_COLOR_INDEX 3
#define RGBW_NUM_MODES 9

class RgbwPacketFormatter : public PacketFormatter {
public:
RgbwPacketFormatter()
: PacketFormatter(7)
: PacketFormatter(7),
lastMode(0)
{ }

virtual void updateStatus(MiLightStatus status, uint8_t groupId);
Expand All @@ -55,10 +57,14 @@ class RgbwPacketFormatter : public PacketFormatter {
virtual void modeSpeedDown();
virtual void modeSpeedUp();
virtual void nextMode();
virtual void previousMode();
virtual void updateMode(uint8_t mode);
virtual void enableNightMode();

virtual void initializePacket(uint8_t* packet);

protected:
uint8_t lastMode;
};

#endif

0 comments on commit bf44b70

Please sign in to comment.