-
Notifications
You must be signed in to change notification settings - Fork 245
New-remote/fut100 #908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KaiFassnacht
wants to merge
12
commits into
sidoh:master
Choose a base branch
from
KaiFassnacht:new-remote/fut100
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
New-remote/fut100 #908
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b07ea66
Add WT32-ETH01 board with NRF24 tranceiver support
KaiFassnacht 4d45f9c
WT-ETH01 Ethernet module support
KaiFassnacht 6a5c184
stabilize implementation with wifimanager
KaiFassnacht 51a250d
resolve "UDP servers never initialize on Ethernet-only board"
KaiFassnacht 0779748
resolve issues in main.cpp
KaiFassnacht e45dee3
set SSDP.setName("ESP8266 MiLight Gateway"); again
KaiFassnacht 65acb53
Inconsistent SPI initialization parameters across two locations solved
KaiFassnacht 1cc817d
Duplicate comment block deleted
KaiFassnacht 61d3484
add FUT100 remote
KaiFassnacht 8e82c0e
FUT100 packetformater review and bugfixes
KaiFassnacht 3a67981
fix ip-addr conflicts if ethernet
KaiFassnacht 4e8c7ce
Merge branch 'new-board/WT-ETH01' into new-remote/fut100
KaiFassnacht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -1089,6 +1089,7 @@ components: | |
| - "rgb_cct" | ||
| - "rgb" | ||
| - "fut089" | ||
| - "fut100" | ||
| - "fut091" | ||
| - "fut020" | ||
| example: rgb_cct | ||
|
|
||
This file contains hidden or 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 hidden or 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,166 @@ | ||
| #include <FUT100PacketFormatter.h> | ||
| #include <V2RFEncoding.h> | ||
| #include <Units.h> | ||
| #include <MiLightCommands.h> | ||
|
|
||
| void FUT100PacketFormatter::updateStatus(MiLightStatus status, uint8_t groupId) { | ||
| this->groupId = groupId; | ||
|
|
||
| if (groupId <= 8) { | ||
| // Groups 0-8: Standard V2 logic | ||
| uint8_t arg = groupId + (status == OFF ? 9 : 0); | ||
| command(FUT100_ON_G_LOW, arg); | ||
| } else { | ||
| // Groups 9-100: Extended FUT100 logic | ||
| uint8_t arg = ((groupId - 9) * 2) + (status == ON ? 0 : 1); | ||
| command(FUT100_ON_G_HIGH, arg); | ||
| } | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::modeSpeedDown() { | ||
| command(FUT100_ON_G_LOW, FUT100_MODE_SPEED_DOWN); | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::modeSpeedUp() { | ||
| command(FUT100_ON_G_LOW, FUT100_MODE_SPEED_UP); | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::updateMode(uint8_t mode) { | ||
| command(FUT100_MODE, mode); | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::updateBrightness(uint8_t brightness) { | ||
| command(FUT100_BRIGHTNESS, brightness); | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::updateHue(uint16_t value) { | ||
| uint8_t remapped = Units::rescale(value, 255, 360); | ||
| updateColorRaw(remapped); | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::updateColorRaw(uint8_t value) { | ||
| command(FUT100_COLOR, value); | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::updateTemperature(uint8_t value) { | ||
| const GroupState* ourState = this->stateStore->get(this->deviceId, this->groupId, REMOTE_TYPE_FUT100); | ||
| BulbMode originalBulbMode = BulbMode::BULB_MODE_WHITE; | ||
|
|
||
| if (ourState != NULL) { | ||
| originalBulbMode = ourState->getBulbMode(); | ||
| if (originalBulbMode != BulbMode::BULB_MODE_WHITE) { | ||
| updateColorWhite(); | ||
| } | ||
| } | ||
|
|
||
| command(FUT100_KELVIN, 100 - value); | ||
|
|
||
| if (ourState != NULL && (settings->enableAutomaticModeSwitching) && (originalBulbMode != BulbMode::BULB_MODE_WHITE)) { | ||
| switchMode(*ourState, originalBulbMode); | ||
| } | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::updateSaturation(uint8_t value) { | ||
| const GroupState* ourState = this->stateStore->get(this->deviceId, this->groupId, REMOTE_TYPE_FUT100); | ||
| BulbMode originalBulbMode = BulbMode::BULB_MODE_WHITE; | ||
|
|
||
| if (ourState != NULL) { | ||
| originalBulbMode = ourState->getBulbMode(); | ||
| } | ||
|
|
||
| if (ourState != NULL && (settings->enableAutomaticModeSwitching) && (originalBulbMode != BulbMode::BULB_MODE_COLOR)) { | ||
| updateHue(ourState->getHue()); | ||
| } | ||
|
|
||
| command(FUT100_SATURATION, 100 - value); | ||
|
|
||
| if (ourState != NULL && (settings->enableAutomaticModeSwitching) && (originalBulbMode != BulbMode::BULB_MODE_COLOR)) { | ||
| switchMode(*ourState, originalBulbMode); | ||
| } | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::updateColorWhite() { | ||
| command(FUT100_ON_G_LOW, FUT100_WHITE_MODE); | ||
| } | ||
|
|
||
| void FUT100PacketFormatter::enableNightMode() { | ||
| if (groupId <= 8) { | ||
| uint8_t arg = groupId + 9; | ||
| command(FUT100_ON_G_LOW | 0x80, arg); | ||
| } else { | ||
| uint8_t arg = ((groupId - 9) * 2) + 1; | ||
| command(FUT100_ON_G_HIGH | 0x80, arg); | ||
| } | ||
| } | ||
|
|
||
| BulbId FUT100PacketFormatter::parsePacket(const uint8_t *packet, JsonObject result) { | ||
| if (stateStore == NULL) { | ||
| Serial.println(F("ERROR: stateStore not set. Prepare was not called! **THIS IS A BUG**")); | ||
| BulbId fakeId(0, 0, REMOTE_TYPE_FUT100); | ||
| return fakeId; | ||
| } | ||
|
|
||
| uint8_t packetCopy[V2_PACKET_LEN]; | ||
| memcpy(packetCopy, packet, V2_PACKET_LEN); | ||
| V2RFEncoding::decodeV2Packet(packetCopy); | ||
|
|
||
| BulbId bulbId( | ||
| (packetCopy[2] << 8) | packetCopy[3], | ||
| packetCopy[7], | ||
| REMOTE_TYPE_FUT100 | ||
| ); | ||
|
|
||
| uint8_t rawCmd = packetCopy[V2_COMMAND_INDEX]; | ||
| uint8_t cmd = (rawCmd & 0x7F); | ||
| uint8_t arg = packetCopy[V2_ARGUMENT_INDEX]; | ||
| bool isNightMode = (rawCmd & 0x80) == 0x80; | ||
|
|
||
| // Groups 0-8 logic | ||
| if (cmd == FUT100_ON_G_LOW) { | ||
| if (isNightMode) { | ||
| result[GroupStateFieldNames::COMMAND] = MiLightCommandNames::NIGHT_MODE; | ||
| if (arg >= 9 && arg <= 17) bulbId.groupId = arg - 9; | ||
| } else if (arg == FUT100_MODE_SPEED_DOWN) { | ||
| result[GroupStateFieldNames::COMMAND] = MiLightCommandNames::MODE_SPEED_DOWN; | ||
| } else if (arg == FUT100_MODE_SPEED_UP) { | ||
| result[GroupStateFieldNames::COMMAND] = MiLightCommandNames::MODE_SPEED_UP; | ||
| } else if (arg == FUT100_WHITE_MODE) { | ||
| result[GroupStateFieldNames::COMMAND] = MiLightCommandNames::SET_WHITE; | ||
| } else if (arg <= 8) { | ||
| result[GroupStateFieldNames::STATE] = "ON"; | ||
| bulbId.groupId = arg; | ||
| } else if (arg >= 9 && arg <= 17) { | ||
| result[GroupStateFieldNames::STATE] = "OFF"; | ||
| bulbId.groupId = arg - 9; | ||
| } | ||
| } | ||
| // Groups 9-100 logic | ||
| else if (cmd == FUT100_ON_G_HIGH) { | ||
| bulbId.groupId = (arg / 2) + 9; | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| if (isNightMode) { | ||
| result[GroupStateFieldNames::COMMAND] = MiLightCommandNames::NIGHT_MODE; | ||
| } else { | ||
| result[GroupStateFieldNames::STATE] = ((arg % 2) == 0) ? "ON" : "OFF"; | ||
| } | ||
| } | ||
| else if (cmd == FUT100_COLOR) { | ||
| result[GroupStateFieldNames::HUE] = Units::rescale<uint16_t, uint16_t>(arg, 360, 255.0); | ||
| } else if (cmd == FUT100_BRIGHTNESS) { | ||
| result[GroupStateFieldNames::BRIGHTNESS] = Units::rescale<uint8_t, uint8_t>(constrain(arg, 0, 100), 255, 100); | ||
| } else if (cmd == FUT100_KELVIN) { | ||
| const GroupState* state = stateStore->get(bulbId); | ||
| if (state != NULL && state->getBulbMode() == BULB_MODE_COLOR) { | ||
| result[GroupStateFieldNames::SATURATION] = 100 - constrain(arg, 0, 100); | ||
| } else { | ||
| result[GroupStateFieldNames::COLOR_TEMP] = Units::whiteValToMireds(100 - arg, 100); | ||
| } | ||
| } else if (cmd == FUT100_MODE) { | ||
| result[GroupStateFieldNames::MODE] = arg; | ||
| } else { | ||
| // Fallback for unknown buttons | ||
| result["button_id"] = cmd; | ||
| result["argument"] = arg; | ||
| } | ||
|
|
||
| return bulbId; | ||
| } | ||
This file contains hidden or 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 @@ | ||
| #ifndef _FUT100_PACKET_FORMATTER_H | ||
| #define _FUT100_PACKET_FORMATTER_H | ||
|
|
||
| #include <V2PacketFormatter.h> | ||
|
|
||
|
|
||
| enum MiLightFUT100Command { | ||
| FUT100_ON_G_LOW = 0x01, | ||
| FUT100_COLOR = 0x02, | ||
| FUT100_BRIGHTNESS = 0x05, | ||
| FUT100_MODE = 0x06, | ||
| FUT100_KELVIN = 0x07, | ||
| FUT100_SATURATION = 0x07, | ||
| FUT100_ON_G_HIGH = 0x08 | ||
| }; | ||
|
|
||
| enum MiLightFUT100Arguments { | ||
| FUT100_MODE_SPEED_UP = 0x12, | ||
| FUT100_MODE_SPEED_DOWN = 0x13, | ||
| FUT100_WHITE_MODE = 0x14 | ||
| }; | ||
|
|
||
| class FUT100PacketFormatter : public V2PacketFormatter { | ||
| public: | ||
| FUT100PacketFormatter() | ||
| : V2PacketFormatter(REMOTE_TYPE_FUT100, 0x25, 100) | ||
| { } | ||
|
|
||
| virtual void updateStatus(MiLightStatus status, uint8_t groupId) override; | ||
| virtual void updateBrightness(uint8_t value) override; | ||
| virtual void updateHue(uint16_t value) override; | ||
| virtual void updateColorRaw(uint8_t value) override; | ||
| virtual void updateColorWhite() override; | ||
| virtual void updateTemperature(uint8_t value) override; | ||
| virtual void updateSaturation(uint8_t value) override; | ||
| virtual void enableNightMode() override; | ||
|
|
||
| virtual void modeSpeedDown() override; | ||
| virtual void modeSpeedUp() override; | ||
| virtual void updateMode(uint8_t mode) override; | ||
|
|
||
| virtual BulbId parsePacket(const uint8_t* packet, JsonObject result) override; | ||
| }; | ||
|
|
||
| #endif |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.