aboutsummaryrefslogtreecommitdiffstats
path: root/usr/space_light/src/space_light.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/space_light/src/space_light.c')
-rw-r--r--usr/space_light/src/space_light.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/usr/space_light/src/space_light.c b/usr/space_light/src/space_light.c
index f1a0373..ebf0d26 100644
--- a/usr/space_light/src/space_light.c
+++ b/usr/space_light/src/space_light.c
@@ -20,6 +20,56 @@ static inline uint16_t get_led_frequency(const uint8_t value,
return (uint16_t)pow((float)value / 255.0f, gamma) * max_freq + 0.5;
}
+// Complete hacky command which will be removed shortly
+// this is just to shorten the developemnt cycle
+void setPWM(uint8_t *values, size_t len) {
+ // at least try something ^^
+
+ switch (values[0]) {
+ case 0x01: // initialzie
+ {
+ if (len < 5) {
+ return;
+ }
+ uint8_t pwm = values[1];
+ uint16_t frequency = values[2] << 8 | values[3];
+ uint8_t duty = values[4];
+ bk_pwm_initialize(pwm, frequency, duty);
+ break;
+ }
+ case 0x02: // start
+ {
+ if (len < 2) {
+ return;
+ }
+ uint8_t pwm = values[1];
+ bk_pwm_start(pwm);
+ break;
+ }
+ case 0x03: // stop
+ {
+ if (len < 2) {
+ return;
+ }
+ uint8_t pwm = values[1];
+ bk_pwm_stop(pwm);
+ break;
+ }
+ case 0x04: // update param
+ {
+ if (len < 5) {
+ return;
+ }
+ uint8_t pwm = values[1];
+ uint16_t frequency = values[2] << 8 | values[3];
+ uint8_t duty = values[4];
+ bk_pwm_update_param(pwm, frequency, duty);
+ }
+ default:
+ return;
+ }
+}
+
void setRGBCW(struct RGBCW *rgbcw) {
if (rgbcw->r) {
bk_pwm_initialize(RED, get_led_frequency(rgbcw->r, 2.8), 10);
@@ -76,6 +126,38 @@ void setRGBCW(struct RGBCW *rgbcw) {
}
}
+// FIXME: this is where we want to shut down everything exept ble
+void power_save_mode() {
+ // FIXME: this is as it is stupid and bad but it works this way..
+ // TODO: figure out how to just disable pwm without setting defaults first ^^
+ // TODO: update pwm also is not working like it should
+ bk_pwm_stop(RED);
+ bk_pwm_stop(GREEN);
+ bk_pwm_stop(BLUE);
+ bk_pwm_stop(COLD);
+ bk_pwm_stop(WARM);
+
+ bk_pwm_initialize(RED, 100, 50);
+ bk_pwm_start(RED);
+ bk_pwm_initialize(GREEN, 100, 50);
+ bk_pwm_start(GREEN);
+ bk_pwm_initialize(BLUE, 100, 50);
+ bk_pwm_start(BLUE);
+ // FIXME: laser is still a puzzle to me
+ bk_pwm_initialize(COLD, 100, 50);
+ bk_pwm_start(COLD);
+ bk_pwm_initialize(WARM, 1000, 50);
+ bk_pwm_start(WARM);
+
+ // FIXME: doing this will start all leds to full color ^^
+ // TODO: figgure out how to reverse the level in the configuration of each PWM
+ // bk_pwm_stop(RED);
+ // bk_pwm_stop(GREEN);
+ // bk_pwm_stop(BLUE);
+ // bk_pwm_stop(COLD);
+ // bk_pwm_stop(WARM);
+}
+
void init_led_thread(void *arg) {
// FIXME: this is as it is stupid and bad but it works this way..
// TODO: figure out how to just disable pwm without setting defaults first ^^