-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactor of radio/remote config. Add support for FUT089 remote
- Loading branch information
Chris Mullins
committed
Sep 23, 2017
1 parent
c3fde5e
commit 02ce659
Showing
37 changed files
with
528 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
#include <Arduino.h> | ||
|
||
#ifndef _SIZE_H | ||
#define _SIZE_H | ||
|
||
template<typename T, size_t sz> | ||
size_t size(T(&)[sz]) { | ||
return sz; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <FUT089PacketFormatter.h> | ||
#include <V2RFEncoding.h> | ||
#include <Units.h> | ||
|
||
void FUT089PacketFormatter::modeSpeedDown() { | ||
command(FUT089_ON, FUT089_MODE_SPEED_DOWN); | ||
} | ||
|
||
void FUT089PacketFormatter::modeSpeedUp() { | ||
command(FUT089_ON, FUT089_MODE_SPEED_UP); | ||
} | ||
|
||
void FUT089PacketFormatter::updateMode(uint8_t mode) { | ||
command(FUT089_MODE, mode); | ||
} | ||
|
||
void FUT089PacketFormatter::updateBrightness(uint8_t brightness) { | ||
command(FUT089_BRIGHTNESS, brightness); | ||
} | ||
|
||
void FUT089PacketFormatter::updateHue(uint16_t value) { | ||
uint8_t remapped = Units::rescale(value, 255, 360); | ||
updateColorRaw(remapped); | ||
} | ||
|
||
void FUT089PacketFormatter::updateColorRaw(uint8_t value) { | ||
command(FUT089_COLOR, FUT089_COLOR_OFFSET + value); | ||
} | ||
|
||
void FUT089PacketFormatter::updateTemperature(uint8_t value) { | ||
command(FUT089_KELVIN, value); | ||
} | ||
|
||
void FUT089PacketFormatter::updateSaturation(uint8_t value) { | ||
command(FUT089_SATURATION, value); | ||
} | ||
|
||
void FUT089PacketFormatter::updateColorWhite() { | ||
command(FUT089_ON, FUT089_WHITE_MODE); | ||
} | ||
|
||
void FUT089PacketFormatter::enableNightMode() { | ||
uint8_t arg = groupCommandArg(OFF, groupId); | ||
command(FUT089_ON | 0x80, arg); | ||
} | ||
|
||
void FUT089PacketFormatter::parsePacket(const uint8_t *packet, JsonObject& result) { | ||
uint8_t packetCopy[V2_PACKET_LEN]; | ||
memcpy(packetCopy, packet, V2_PACKET_LEN); | ||
V2RFEncoding::decodeV2Packet(packetCopy); | ||
|
||
result["device_id"] = (packetCopy[2] << 8) | packetCopy[3]; | ||
result["group_id"] = packetCopy[7]; | ||
result["device_type"] = "rgb_cct"; | ||
|
||
if (! result.containsKey("state")) { | ||
result["state"] = "ON"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <V2PacketFormatter.h> | ||
|
||
#ifndef _FUT089_PACKET_FORMATTER_H | ||
#define _FUT089_PACKET_FORMATTER_H | ||
|
||
#define FUT089_COLOR_OFFSET 0 | ||
|
||
enum MiLightFUT089Command { | ||
FUT089_ON = 0x01, | ||
FUT089_OFF = 0x01, | ||
FUT089_COLOR = 0x02, | ||
FUT089_BRIGHTNESS = 0x05, | ||
FUT089_MODE = 0x06, | ||
FUT089_KELVIN = 0x07, | ||
FUT089_SATURATION = 0x07 | ||
}; | ||
|
||
enum MiLightFUT089Arguments { | ||
FUT089_MODE_SPEED_UP = 0x12, | ||
FUT089_MODE_SPEED_DOWN = 0x13, | ||
FUT089_WHITE_MODE = 0x14 | ||
}; | ||
|
||
class FUT089PacketFormatter : public V2PacketFormatter { | ||
public: | ||
FUT089PacketFormatter() | ||
: V2PacketFormatter(0x25, 8) | ||
{ } | ||
|
||
virtual void updateBrightness(uint8_t value); | ||
virtual void updateHue(uint16_t value); | ||
virtual void updateColorRaw(uint8_t value); | ||
virtual void updateColorWhite(); | ||
virtual void updateTemperature(uint8_t value); | ||
virtual void updateSaturation(uint8_t value); | ||
virtual void enableNightMode(); | ||
|
||
virtual void modeSpeedDown(); | ||
virtual void modeSpeedUp(); | ||
virtual void updateMode(uint8_t mode); | ||
|
||
virtual void parsePacket(const uint8_t* packet, JsonObject& result); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.