aboutsummaryrefslogtreecommitdiffstats
path: root/usr/space_light/src/device.c
diff options
context:
space:
mode:
authorBernhard Guillon <Bernhard.Guillon@begu.org>2025-01-01 18:22:14 +0100
committerBernhard Guillon <Bernhard.Guillon@begu.org>2025-01-01 18:22:14 +0100
commitf70b052b789dbac68651591031aabc0b372db8ec (patch)
tree8d6fb9aa274200849251328d4aa1dbc71b06a014 /usr/space_light/src/device.c
parentb917dc4fa5a400141c75c81164f442dd43b23a28 (diff)
downloadwb3s-ble-nebula-galaxy-f70b052b789dbac68651591031aabc0b372db8ec.tar.gz
wb3s-ble-nebula-galaxy-f70b052b789dbac68651591031aabc0b372db8ec.zip
space_light: finished the pwm stuff
Using a logic analyzer and a multimeter to figguer out why the things did't do what I expected ^^ I wrote a long explanation on the set_rgbcw on how this space light is connected and how it is supposed to work. Also used a work arround for the PWM.
Diffstat (limited to 'usr/space_light/src/device.c')
-rw-r--r--usr/space_light/src/device.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/usr/space_light/src/device.c b/usr/space_light/src/device.c
index 30bcf9e..8b87879 100644
--- a/usr/space_light/src/device.c
+++ b/usr/space_light/src/device.c
@@ -1,3 +1,28 @@
+/*
+ * The BLE code and the stripped down version of the SDK was taken and modified
+ * from here
+ * https://www.elektroda.com/rtvforum/topic3989434.html#20742145
+ *
+ * Copyright (C) 2023 jitsirakowsk (Alex)
+ *
+ * The original code was taken modified and used for this project by
+ * Copyright (C) 2025 Bernhard Guillon <Bernhard.Guillon@begu.org>
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * SPDX: GPL-3.0
+ *
+ */
#include "ble.h"
#include "ble_api.h"
@@ -20,10 +45,6 @@
#include "mcu_ps_pub.h"
#include "start_type_pub.h"
-#include "FreeRTOS.h"
-#include "task.h"
-#include "timers.h"
-
#include "space_light.h"
#define ATT_DB_LENGTH 5
@@ -73,10 +94,6 @@ bk_attm_desc_t btl_att_db[ATT_DB_LENGTH] = {
beken_semaphore_t app_sema = NULL;
beken_semaphore_t ext_init_sema = NULL;
-TimerHandle_t xOneShotTimer;
-
-static void oneShotTimerCallback(TimerHandle_t xTimer) { power_save_mode(); }
-
static void ble_event_callback(ble_event_t event, void *param) {
switch (event) {
case BLE_STACK_OK:
@@ -165,11 +182,14 @@ static void ble_event_callback(ble_event_t event, void *param) {
static void ble_write_callback(write_req_t *write_req) {
switch (write_req->value[0]) {
case 0x1: {
+ if (write_req->len != 6) {
+ return;
+ }
struct RGBCW rgbcw = {
write_req->value[1], write_req->value[2], write_req->value[3],
write_req->value[4], write_req->value[5],
};
- setRGBCW(&rgbcw);
+ set_rgbcw(&rgbcw);
break;
}
case 0x2:
@@ -177,11 +197,7 @@ static void ble_write_callback(write_req_t *write_req) {
return;
}
uint16_t seconds = write_req->value[1] << 8 | write_req->value[2];
- xOneShotTimer = xTimerCreate("OneShot", seconds * 1000, pdFALSE, 0,
- oneShotTimerCallback);
- if ((xOneShotTimer != NULL)) {
- xTimerStart(xOneShotTimer, 0);
- }
+ set_timer(seconds);
break;
case 0xFF:
setPWM(&write_req->value[1], write_req->len - 1);