🫏 Adds getter for state

This commit is contained in:
Rune Harlyk
2024-11-23 12:54:15 +01:00
parent 852ff91b7d
commit 8792c06e8a
8 changed files with 49 additions and 48 deletions
@@ -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();
}
@@ -97,8 +97,8 @@ class Peripherals : public StatefulService<PeripheralsConfiguration> {
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<PeripheralsConfiguration> {
char output[150];
JsonDocument doc;
JsonObject root = doc.to<JsonObject>();
root["sda"] = _state.sda;
root["scl"] = _state.scl;
root["sda"] = state().sda;
root["scl"] = state().scl;
JsonArray addresses = root["addresses"].to<JsonArray>();
for (auto &address : addressList) {
addresses.add(address);
@@ -96,7 +96,7 @@ class ServoController : public StatefulService<ServoSettings> {
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) {