Browse Source

feat: 灯光控制
1. 增加多路灯光控制
fix: 修复编译失败问题

kindring 1 year ago
parent
commit
ddacfb9cb8
3 changed files with 17 additions and 9 deletions
  1. 2 2
      src/control/btn.c
  2. 6 2
      src/light.c
  3. 9 5
      src/light.h

+ 2 - 2
src/control/btn.c

@@ -2,10 +2,10 @@
 #include "clock.h"
 #include "log.h"
 #include "gpio.h"
-#include "light.h"
 
-#include "btn.h"
 
+#include "btn.h"
+#include "light.h"
 
 uint8 task_btn_id;
 #define KEY_DEMO_ONCE_TIMER      0x0001

+ 6 - 2
src/light.c

@@ -19,19 +19,23 @@ int light_init(){
     int ret = 0;
     // if()
     ret = pwm_light_init(WARM_CH, GPIO_WARM, _light_total, _light_total, 5, PWM_CLK_DIV_16);
-
+    ret = pwm_light_init(WARM_CH, GPIO_WARM2, _light_total, _light_total, 5, PWM_CLK_DIV_16);
     if(ret != 0){
         LOG("[light_init] pwm_light_init warm failed %d \n", ret);
         return ret;
     }
 
     ret = pwm_light_init(COLD_CH, GPIO_COLD, _light_total, _light_total, 5, PWM_CLK_DIV_16);
-
+    ret = pwm_light_init(COLD_CH, GPIO_COLD2, _light_total, _light_total, 5, PWM_CLK_DIV_16);
     if(ret != 0){
         LOG("[light_init] pwm_light_init cold failed  %d \n", ret);
         return ret;
     }
 
+    // 拉低 warm2 与 cold2 的电平
+
+    // hal_gpio_pull_set(GPIO_WARM2, PULL_DOWN);
+    // hal_gpio_pull_set(GPIO_COLD2, PULL_DOWN);
     return ret;
 }
 

+ 9 - 5
src/light.h

@@ -3,9 +3,11 @@
 
 // 暖光 pwm脚
 #define GPIO_WARM P18
+#define GPIO_WARM2 P15
 #define WARM_CH 0
 // 冷光 pwm脚
 #define GPIO_COLD P20
+#define GPIO_COLD2 P31
 #define COLD_CH 1
 
 // 风扇 pwm
@@ -19,6 +21,13 @@
 // adc 电源监测脚
 #define GPIO_POWER P28
 
+// 灯光数据 色温, 亮度
+typedef struct {
+    int temp;
+    int light;
+} light_data_t;
+
+extern light_data_t light_data;
 extern int light_init(void);
 
 extern int light_ch_set(uint8_t ch, uint16_t val);
@@ -31,10 +40,5 @@ extern int temp_set(int temp);
 
 
 
-// 灯光数据 色温, 亮度
-typedef struct {
-    int temp;
-    int light;
-} light_data_t;
 
 #endif