diff --git a/platformio.ini b/platformio.ini index d2f1814..aaf9a6f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,7 +22,7 @@ framework = arduino board_build.partitions = partitions.csv build_flags = ${usersettings.build_flags} - -DCORE_DEBUG_LEVEL=5 + -DCORE_DEBUG_LEVEL=4 -DCONFIG_SW_COEXIST_ENABLE=1 ; -DBOARD_HAS_PSRAM ; -mfix-esp32-psram-cache-issue diff --git a/platformio_usersettings.ini.sample b/platformio_usersettings.ini.sample index 886e9dc..50131c6 100644 --- a/platformio_usersettings.ini.sample +++ b/platformio_usersettings.ini.sample @@ -12,8 +12,8 @@ build_flags = -DWIFISID='"mywifi"' ; -DUSE_ETHERNET ## use ethernet instead of Wifi ; -DLR_BLEADDRESS='"c4:b9:71:da:19:c7"' ## if you add the device address here we can skip scanning at startup -DROTARY=1 ## use a rotary attached to esp32 - -DROTARY_PIN_A=GPIO_NUM_27 ## pin a (CLK) of the rotary (Fire Beetle D3) - Set to GPIO_NUM_0 if no rotary is connected - -DROTARY_PIN_B=GPIO_NUM_26 ## pin b (DT) of the rotary (Fire Beetle D4) - Set to GPIO_NUM_0 if no rotary is connected + -DROTARY_PIN_A=GPIO_NUM_27 ## pin a (CLK) of the rotary (Fire Beetle D4) - Set to GPIO_NUM_0 if no rotary is connected + -DROTARY_PIN_B=GPIO_NUM_26 ## pin b (DT) of the rotary (Fire Beetle D3) - Set to GPIO_NUM_0 if no rotary is connected -DROTARY_PIN_BUTTON=GPIO_NUM_25 ## input pin of the rotary switch (SW) (Fire Beetle D2) - Set to GPIO_NUM_0 if no rotary is connected ### LONG PRESS Behavior: LONG PRESS on the rotary button is used to switch to the next scene. LONG_PRESS_DELAY defines how long the button must be pressed for the first event. ### LONG_PRESS_INTERVAL defines how long it takes to switch to the next scene diff --git a/src/LukeRobertsBle.cpp b/src/LukeRobertsBle.cpp index 71551a6..c4551fe 100644 --- a/src/LukeRobertsBle.cpp +++ b/src/LukeRobertsBle.cpp @@ -149,7 +149,7 @@ bool BleGattClient::send_queued() { command.on_send(0); } needs_result = true; - yield(); + delay(50); } } // Other pending commands @@ -157,7 +157,7 @@ bool BleGattClient::send_queued() { auto cmd = pending_commands.front(); send(cmd.data, cmd.size); needs_result = true; - yield(); + delay(100); pending_commands.pop(); if (cmd.on_send) { cmd.on_send(0); @@ -231,8 +231,7 @@ BleGattClient::on_complete_callback BleGattClient::on_connect_ = nullptr; BleGattClient::on_complete_callback BleGattClient::on_disconnect_ = nullptr; notify_callback BleGattClient::on_notify_ = nullptr; BleGattClient::on_downlight_callback BleGattClient::on_downlight_notification_ = - nullptr; // [](uint8_t,uint16_t){ log_i("=============== DEFAULT ON DOWN - // ===============");} ; + nullptr; // BleGattClient::ClientCallbacks BleGattClient::client_cb_; @@ -244,7 +243,7 @@ std::vector SceneMapper::brightness_map_ = { std::vector SceneMapper::colortemperature_map_ = { 0, 2700, 4000, 3800, 2800, 4000, 2700, 4000}; // Load the default values -#endif +#endif std::map scenes = {{0, "OFF"}}; diff --git a/src/LukeRobertsBle.h b/src/LukeRobertsBle.h index 8a1ac40..9cbcb5c 100644 --- a/src/LukeRobertsBle.h +++ b/src/LukeRobertsBle.h @@ -64,7 +64,7 @@ class BleGattClient { client = nullptr; return false; } - yield(); + delay(10); } struct BleCommand { @@ -226,9 +226,9 @@ class BleGattClient { pRemoteCharacteristic->getUUID().toString().c_str(), length, length, (char *)pData, (int)pData[0]); - log_d("Client data received len: %d\n", length); + log_v("Client data received len: %d\n", length); for (auto i = 0; i < length; i++) { - log_d("Response byte[%d]: %d (0x%X)", i, pData[i], pData[i]); + log_v("Response byte[%d]: %d (0x%X)", i, pData[i], pData[i]); } if (on_downlight_notification_ != nullptr && diff --git a/src/main.cpp b/src/main.cpp index cd09169..c6b4b38 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -98,7 +98,7 @@ class LR_Ble_Device { 4, false, [&](int) { - if (state().power) { + /*if (true || state().power)*/ { char json[32]; snprintf(json, sizeof(json), "%d", state_.scene); mqtt.queue("stat/" HOSTNAME "/SCENE", json); @@ -114,7 +114,6 @@ class LR_Ble_Device { // Not sure why this doesn't work from constustructor void init() { gatt_client_.set_on_downlight([&](uint8_t brightness, uint16_t kelvin) { - state_.brightness = brightness; state_.kelvin = kelvin; state_.mired = switch_kelvin_mired(state_.kelvin); @@ -254,7 +253,7 @@ class LR_Ble_Device { gatt_client_.cached_commands[kScene].is_dirty |= force_dirty || (state_.scene == 0 || state_.scene != new_scene); state_.scene = new_scene; -#ifdef OLLD +#ifdef OLD // if (state_.brightness == 0) { state_.brightness = SceneMapper::map_brightness(state_.scene); // }