first commit

This commit is contained in:
TuxMonkey
2026-01-17 14:06:59 +08:00
commit 8c6429f05a
497 changed files with 322072 additions and 0 deletions

46
modules/led/led.c Normal file
View File

@@ -0,0 +1,46 @@
#include "led.h"
#include "stdlib.h"
#include "memory.h"
#include "user_lib.h"
static uint8_t idx;
static LEDInstance *bsp_led_ins[LED_MAX_NUM] = {NULL};
LEDInstance *LEDRegister(LED_Init_Config_s *led_config)
{
LEDInstance *led_ins = (LEDInstance *)zmalloc(sizeof(LEDInstance));
// 剩下的值暂时都被置零
led_ins->led_pwm = PWMRegister(&led_config->pwm_config);
led_ins->led_switch = led_config->init_swtich;
bsp_led_ins[idx++] = led_ins;
return led_ins;
}
void LEDSet(LEDInstance *_led, uint8_t alpha, uint8_t color_value, uint8_t brightness)
{
}
void LEDSwitch(LEDInstance *_led, uint8_t led_switch)
{
if (led_switch == 1)
{
_led->led_switch = 1;
}
else
{
_led->led_switch = 0;
// PWMSetPeriod(_led,0);
}
}
void LEDShow(uint32_t aRGB)
{
// static uint8_t alpha;
// static uint16_t red, green, blue;
// alpha = (aRGB & 0xFF000000) >> 24;
// red = ((aRGB & 0x00FF0000) >> 16) * alpha;
// green = ((aRGB & 0x0000FF00) >> 8) * alpha;
// blue = ((aRGB & 0x000000FF) >> 0) * alpha;
}

33
modules/led/led.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef _LED_H_
#define _LED_H_
#include "stdint.h"
#include "bsp_pwm.h"
#define LED_MAX_NUM 3
typedef struct
{
PWMInstance* led_pwm;
uint8_t led_alpha; // 透明度,通过pwm频率改变
uint8_t led_brightness; // 亮度,通过电压改变(如果可以,使用dac)
uint8_t led_color; // rgb value,0-255
uint8_t led_switch; // 开关,on1 off0
// void (*action_callback)(void); // led动作回调函数
} LEDInstance;
typedef struct
{
PWM_Init_Config_s pwm_config;
uint8_t init_swtich; // 初始化开关
} LED_Init_Config_s;
LEDInstance* LEDRegister(LED_Init_Config_s* led_config);
void LEDSet(LEDInstance *_led,uint8_t alpha,uint8_t color_value,uint8_t brightness);
void LEDSwitch(LEDInstance *_led,uint8_t led_switch);
void LEDShow();
#endif // !_LED_H_

3
modules/led/led.md Normal file
View File

@@ -0,0 +1,3 @@
TO BE DONE
请勿使用