diff --git a/app/src/routes/peripherals/servo/servos.svelte b/app/src/routes/peripherals/servo/servos.svelte index e48a991..a3c54cb 100644 --- a/app/src/routes/peripherals/servo/servos.svelte +++ b/app/src/routes/peripherals/servo/servos.svelte @@ -1,75 +1,86 @@ - {#snippet icon()} - - {/snippet} - {#snippet title()} - Servo - {/snippet} - {pwm} - + {#snippet icon()} + + {/snippet} + {#snippet title()} + Servo + {/snippet} + {pwm} + - {#if isLoading} - - {:else} -
-

General servo configuration

- - - - - -
- {/if} + {#if isLoading} + + {:else} +
+

General servo configuration

+ + + + + + + + + + + + +
+ {/if}
diff --git a/esp32/lib/ESP32-sveltekit/peripherals/servo_controller.h b/esp32/lib/ESP32-sveltekit/peripherals/servo_controller.h index 3683fed..5b68a33 100644 --- a/esp32/lib/ESP32-sveltekit/peripherals/servo_controller.h +++ b/esp32/lib/ESP32-sveltekit/peripherals/servo_controller.h @@ -74,9 +74,15 @@ class ServoController : public StatefulService { void servoEvent(JsonObject &root, int originId) { control_state = SERVO_CONTROL_STATE::PWM; - uint8_t servo_id = root["servo_id"]; - int pwm = root["pwm"].as(); - pcaWrite(servo_id, pwm); + int8_t servo_id = root["servo_id"]; + uint16_t pwm = root["pwm"].as(); + if (servo_id < 0) { + uint16_t pwms[12]; + std::fill_n(pwms, 12, pwm); + _pca.setMultiplePWM(pwms, 12); + } else { + _pca.setPWM(servo_id, 0, pwm); + } ESP_LOGI("SERVO_CONTROLLER", "Setting servo %d to %d", servo_id, pwm); }