Skip to content

Commit bf62d97

Browse files
committed
finishing touch
1 parent aa06e4a commit bf62d97

File tree

7 files changed

+23
-22
lines changed

7 files changed

+23
-22
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Shows the clock channel.
230230
| Parameter | Description |
231231
| --- | --- |
232232
| `clock` | The style of the clock. Accepts a number between 0 and 9. <br/> `0` = Fullscreen, `1` = Rainbow, `2` = Boxed, `3` = Analog square, <br/> `4` = Fullscreen negative, `5` = Analog round, `6` = Widescreen |
233-
| `twentyfour` | Changes between 12h or 24h format. <br/> `0` = 12h, `1` = 24h. Defaults to 24h. |
233+
| `twentyfour` | Changes between 12h or 24h format. <br/> `0` = 12h, `1` = 24h. Defaults to 24h. Doesn't actually change the current time. |
234234
| `weather` | Actives or deactivates showing the weather with `0` or `1`. |
235235
| `temp` | Actives or deactivates showing the temperature with `0` or `1`. |
236236
| `calendar` | Actives or deactivates showing the calendar date with `0` or `1`. |
@@ -330,15 +330,15 @@ MODE keyboard 0
330330
#### MODE light
331331
Shows the light channel.
332332

333-
`MODE light [color] [brightness] [power]`
333+
`MODE light [brightness] [color] [power]`
334334
| Parameter | Description |
335335
| --- | --- |
336-
| `color` | The color of the clock in the typical RGB HEX format. Example: `FF0000` for red. |
337336
| `brightness` | The brightness value between 0 and 100. |
337+
| `color` | The color of the clock in the typical RGB HEX format. Example: `FF0000` for red. |
338338
| `power` | Activates or deactivates powering the LED panel. |
339339

340340
```
341-
MODE light FF0000 100 1
341+
MODE light 100 FF0000 1
342342
```
343343

344344
#### MODE lyrics

src/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
/* TCP Configuration */
1717
#define TCP_PORT 7777
18-
#define TCP_MAX 5
18+
#define TCP_MAX 3
1919

2020
/* MQTT Configuration */
2121
#define MQTT_CLIENT "ESP32-Divoom"

src/divoom/divoom.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ data_commands_t* Divoom::parseMode(char *buffer, size_t size) {
134134
char* content = buffer + offset;
135135
size -= offset;
136136

137-
char* color = nullptr;
138137
uint8_t brightness = 0;
139-
bool power = 0;
138+
char* color = nullptr;
139+
bool power = 1;
140140

141141
char *token = strtok(content, " ");
142-
if (token != NULL) color = token;
142+
if (token != NULL) brightness = strtoul(token, NULL, 10);
143143

144144
token = strtok(NULL, " ");
145-
if (token != NULL) brightness = strtoul(token, NULL, 10);
145+
if (token != NULL) color = token;
146146

147147
token = strtok(NULL, " ");
148148
if (token != NULL) power = strtoul(token, NULL, 10);
@@ -635,7 +635,7 @@ void Divoom::show_light(char* color, uint8_t brightness, bool power) {
635635
}
636636

637637
buffer[index++] = brightness; // brightness
638-
buffer[index++] = color != nullptr ? 0x01 : 0x00; // effect mode
638+
buffer[index++] = color == nullptr ? 0x01 : 0x00; // effect mode
639639
buffer[index++] = power ? 0x01 : 0x00; // power on/off
640640

641641
command(&(commands.command[commands.count++]), buffer, index);
@@ -707,12 +707,12 @@ void Divoom::show_scoreboard(uint8_t version, uint16_t player1, uint16_t player2
707707
buffer[index++] = 0x06; // scoreboard view
708708
buffer[index++] = 0x00;
709709

710-
buffer[index++] = (player1 & 0xff); // player1
711-
buffer[index++] = (player1 >> 8); // player1
712-
713710
buffer[index++] = (player2 & 0xff); // player2
714711
buffer[index++] = (player2 >> 8); // player2
715712

713+
buffer[index++] = (player1 & 0xff); // player1
714+
buffer[index++] = (player1 >> 8); // player1
715+
716716
command(&(commands.command[commands.count++]), buffer, index);
717717
}
718718

@@ -724,12 +724,12 @@ void Divoom::show_scoreboard(uint8_t version, uint16_t player1, uint16_t player2
724724
buffer[index++] = 0x01; // scoreboard tool
725725
buffer[index++] = 0x01; // show it
726726

727-
buffer[index++] = (player1 & 0xff); // player1
728-
buffer[index++] = (player1 >> 8); // player1
729-
730727
buffer[index++] = (player2 & 0xff); // player2
731728
buffer[index++] = (player2 >> 8); // player2
732729

730+
buffer[index++] = (player1 & 0xff); // player1
731+
buffer[index++] = (player1 >> 8); // player1
732+
733733
command(&(commands.command[commands.count++]), buffer, index);
734734
}
735735
}

src/hardware/wifictl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ void WifiHandler::connected(WiFiEvent_t event, WiFiEventInfo_t info) {
102102

103103
MDNS.begin(WIFI_NAME);
104104
MDNS.addService("_divoom_esp32", "_tcp", TCP_PORT);
105-
106-
if (MqttInput::check()) {
107-
MqttInput::update();
108-
}
109105
}
110106

111107
/**

src/input/mqtt.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ void MqttInput::setup() {
3333
void MqttInput::loop() {
3434
if (strlen(MQTT_HOST) == 0) return;
3535

36-
if (getElapsed(timer) > 10000) {
36+
bool isWifiConnected = WifiHandler::check(true);
37+
if (getElapsed(timer) > 15000 || (isWifiConnected && !wasWifiConnected)) {
38+
wasWifiConnected = isWifiConnected;
3739
timer = millis();
3840

3941
if (check()) {
@@ -49,6 +51,7 @@ void MqttInput::loop() {
4951
*/
5052
bool MqttInput::check(void) {
5153
if (strlen(MQTT_HOST) == 0) return false;
54+
if (!wasWifiConnected) return false;
5255

5356
if (mqttClient.connected())
5457
{
@@ -81,6 +84,7 @@ bool MqttInput::check(void) {
8184
*/
8285
void MqttInput::update(void) {
8386
if (strlen(MQTT_HOST) == 0) return;
87+
if (!isConnected) return;
8488

8589
char topicState[strlen(MQTT_TOPIC) + strlen("proxy")];
8690
snprintf(topicState, sizeof( topicState ), MQTT_TOPIC, "proxy");

src/input/mqtt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
private:
2323
inline static bool isConnected;
24+
inline static bool wasWifiConnected;
2425
inline static unsigned long timer;
2526

2627
static void parse(char* topic, uint8_t* payload, size_t size);

src/input/tcp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void TcpInput::setup() {
1414
tcpServer.onClient(connection, &tcpServer);
1515
tcpServer.begin();
1616

17-
parsePacketQueue = xQueueCreate(10, sizeof(data_packet_t));
17+
parsePacketQueue = xQueueCreate(5, sizeof(data_packet_t));
1818
xTaskCreatePinnedToCore(queue, "ParsePacketTask", 4096, NULL, 1, &parsePacketHandle, 1);
1919
}
2020

0 commit comments

Comments
 (0)