diff --git a/esp32/lib/ESP32-sveltekit/ap_service.cpp b/esp32/lib/ESP32-sveltekit/ap_service.cpp index b1b68d8..2cac12b 100644 --- a/esp32/lib/ESP32-sveltekit/ap_service.cpp +++ b/esp32/lib/ESP32-sveltekit/ap_service.cpp @@ -29,7 +29,7 @@ void APService::status(JsonObject &root) { APNetworkStatus APService::getAPNetworkStatus() { WiFiMode_t currentWiFiMode = WiFi.getMode(); bool apActive = currentWiFiMode == WIFI_AP || currentWiFiMode == WIFI_AP_STA; - if (apActive && _state.provisionMode != AP_MODE_ALWAYS && WiFi.status() == WL_CONNECTED) { + if (apActive && state().provisionMode != AP_MODE_ALWAYS && WiFi.status() == WL_CONNECTED) { return APNetworkStatus::LINGERING; } return apActive ? APNetworkStatus::ACTIVE : APNetworkStatus::INACTIVE; @@ -55,8 +55,8 @@ void APService::loop() { void APService::manageAP() { WiFiMode_t currentWiFiMode = WiFi.getMode(); - if (_state.provisionMode == AP_MODE_ALWAYS || - (_state.provisionMode == AP_MODE_DISCONNECTED && WiFi.status() != WL_CONNECTED) || _recoveryMode) { + if (state().provisionMode == AP_MODE_ALWAYS || + (state().provisionMode == AP_MODE_DISCONNECTED && WiFi.status() != WL_CONNECTED) || _recoveryMode) { if (_reconfigureAp || currentWiFiMode == WIFI_OFF || currentWiFiMode == WIFI_STA) { startAP(); } @@ -68,9 +68,10 @@ void APService::manageAP() { } void APService::startAP() { - ESP_LOGI(TAG, "Starting software access point: %s", _state.ssid.c_str()); - WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask); - WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), _state.channel, _state.ssidHidden, _state.maxClients); + ESP_LOGI(TAG, "Starting software access point: %s", state().ssid.c_str()); + WiFi.softAPConfig(state().localIP, state().gatewayIP, state().subnetMask); + WiFi.softAP(state().ssid.c_str(), state().password.c_str(), state().channel, state().ssidHidden, + state().maxClients); #if CONFIG_IDF_TARGET_ESP32C3 WiFi.setTxPower(WIFI_POWER_8_5dBm); // https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi #endif diff --git a/esp32/lib/ESP32-sveltekit/peripherals/camera_service.cpp b/esp32/lib/ESP32-sveltekit/peripherals/camera_service.cpp index 253856f..43ffddb 100644 --- a/esp32/lib/ESP32-sveltekit/peripherals/camera_service.cpp +++ b/esp32/lib/ESP32-sveltekit/peripherals/camera_service.cpp @@ -168,30 +168,30 @@ void CameraService::updateCamera() { safe_sensor_return(); return; } - s->set_pixformat(s, _state.pixformat); - s->set_framesize(s, _state.framesize); - s->set_brightness(s, _state.brightness); - s->set_contrast(s, _state.contrast); - s->set_saturation(s, _state.saturation); - s->set_sharpness(s, _state.sharpness); - s->set_denoise(s, _state.denoise); - s->set_gainceiling(s, _state.gainceiling); - s->set_quality(s, _state.quality); - s->set_colorbar(s, _state.colorbar); - s->set_awb_gain(s, _state.awb_gain); - s->set_wb_mode(s, _state.wb_mode); - s->set_aec2(s, _state.aec2); - s->set_ae_level(s, _state.ae_level); - s->set_aec_value(s, _state.aec_value); - s->set_agc_gain(s, _state.agc_gain); - s->set_bpc(s, _state.bpc); - s->set_wpc(s, _state.wpc); - s->set_special_effect(s, _state.special_effect); - s->set_raw_gma(s, _state.raw_gma); - s->set_lenc(s, _state.lenc); - s->set_hmirror(s, _state.hmirror); - s->set_vflip(s, _state.vflip); - s->set_dcw(s, _state.dcw); + s->set_pixformat(s, state().pixformat); + s->set_framesize(s, state().framesize); + s->set_brightness(s, state().brightness); + s->set_contrast(s, state().contrast); + s->set_saturation(s, state().saturation); + s->set_sharpness(s, state().sharpness); + s->set_denoise(s, state().denoise); + s->set_gainceiling(s, state().gainceiling); + s->set_quality(s, state().quality); + s->set_colorbar(s, state().colorbar); + s->set_awb_gain(s, state().awb_gain); + s->set_wb_mode(s, state().wb_mode); + s->set_aec2(s, state().aec2); + s->set_ae_level(s, state().ae_level); + s->set_aec_value(s, state().aec_value); + s->set_agc_gain(s, state().agc_gain); + s->set_bpc(s, state().bpc); + s->set_wpc(s, state().wpc); + s->set_special_effect(s, state().special_effect); + s->set_raw_gma(s, state().raw_gma); + s->set_lenc(s, state().lenc); + s->set_hmirror(s, state().hmirror); + s->set_vflip(s, state().vflip); + s->set_dcw(s, state().dcw); safe_sensor_return(); } diff --git a/esp32/lib/ESP32-sveltekit/peripherals/peripherals.h b/esp32/lib/ESP32-sveltekit/peripherals/peripherals.h index c600512..672cfa7 100644 --- a/esp32/lib/ESP32-sveltekit/peripherals/peripherals.h +++ b/esp32/lib/ESP32-sveltekit/peripherals/peripherals.h @@ -97,8 +97,8 @@ class Peripherals : public StatefulService { Wire.end(); } - if (_state.sda != -1 && _state.scl != -1) { - Wire.begin(_state.sda, _state.scl, _state.frequency); + if (state().sda != -1 && state().scl != -1) { + Wire.begin(state().sda, state().scl, state().frequency); i2c_active = true; } } @@ -107,8 +107,8 @@ class Peripherals : public StatefulService { char output[150]; JsonDocument doc; JsonObject root = doc.to(); - root["sda"] = _state.sda; - root["scl"] = _state.scl; + root["sda"] = state().sda; + root["scl"] = state().scl; JsonArray addresses = root["addresses"].to(); for (auto &address : addressList) { addresses.add(address); diff --git a/esp32/lib/ESP32-sveltekit/peripherals/servo_controller.h b/esp32/lib/ESP32-sveltekit/peripherals/servo_controller.h index 5bf952f..178d8b7 100644 --- a/esp32/lib/ESP32-sveltekit/peripherals/servo_controller.h +++ b/esp32/lib/ESP32-sveltekit/peripherals/servo_controller.h @@ -96,7 +96,7 @@ class ServoController : public StatefulService { void updateServoState() { for (int i = 0; i < 12; i++) { angles[i] = lerp(angles[i], target_angles[i], 0.2); - auto &servo = _state.servos[i]; + auto &servo = state().servos[i]; float angle = servo.direction * angles[i] + servo.centerAngle; uint16_t pwm = angle * servo.conversion + servo.centerPwm; if (pwm < 125 || pwm > 600) { diff --git a/esp32/lib/ESP32-sveltekit/template/stateful_endpoint.h b/esp32/lib/ESP32-sveltekit/template/stateful_endpoint.h index 91d43e4..284731a 100644 --- a/esp32/lib/ESP32-sveltekit/template/stateful_endpoint.h +++ b/esp32/lib/ESP32-sveltekit/template/stateful_endpoint.h @@ -1,7 +1,7 @@ #pragma once #include -#include