From aefa067ab4f7b9a9d58bee6fc4dccac3c11ac7c2 Mon Sep 17 00:00:00 2001 From: dgjames <1943357252@qq.com> Date: Sat, 15 Mar 2025 16:07:17 +0800 Subject: [PATCH] matrix --- applications/indicator_led.c | 255 ++++++++++++------------ applications/indicator_led.h | 22 +- applications/mytest.c | 8 +- applications/sensor.c | 132 ++++++------ applications/status.c | 25 ++- applications/status.h | 1 + board/ports/led_matrix/drv_matrix_led.c | 12 ++ board/ports/led_matrix/drv_matrix_led.h | 26 ++- 8 files changed, 264 insertions(+), 217 deletions(-) diff --git a/applications/indicator_led.c b/applications/indicator_led.c index 1cab1b4..754473c 100644 --- a/applications/indicator_led.c +++ b/applications/indicator_led.c @@ -1,66 +1,62 @@ #include "indicator_led.h" #include "rtdevice.h" -#define ADC_DEV_NAME "adc1" /* ADC 设备名称 */ -#define ADC_DEV_CHANNEL 5 /* ADC 通道 */ -#define REFER_VOLTAGE 330 /* 参考电压 3.3V,数据精度乘以100保留2位小数*/ -#define CONVERT_BITS (1 << 12) /* 转换位数为12位 */ +#define LED_BREATH_PERIOD 4000 +#define LED_BREATH_MDELAY 20 +#define LED_BREATH_HALF_TIMES (LED_BREATH_PERIOD / LED_BREATH_MDELAY / 2) +const uint8_t gamma_table[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, + 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, + 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, + 18, 18, 19, 19, 20, 20, 21, 21, 22, 23, 23, 24, 24, 25, 26, 26, + 27, 28, 28, 29, 30, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 38, + 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 48, 49, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 84, 85, 86, + 87, 89, 90, 91, 92, 94, 95, 96, 98, 99,100,102,103,104,106,107, + 109,110,112,113,114,116,117,119,120,122,123,125,126,128,130,131, + 133,134,136,138,139,141,143,144,146,148,149,151,153,154,156,158, + 160,161,163,165,167,169,170,172,174,176,178,180,182,183,185,187, + 189,191,193,195,197,199,201,203,205,207,209,211,213,215,218,220, + 222,224,226,228,230,233,235,237,239,241,244,246,248,250,253,255, +}; -#define LED_NUM 24 // LED灯珠个数 rt_thread_t led_blink_thread = RT_NULL; rt_thread_t led_breath_thread = RT_NULL; +rt_thread_t led_reflash_thread = RT_NULL; // 灯是否处于特定颜色还是闪烁状态 -uint8_t LED_Blink_State[LED_NUM] = {LED_NOT_BLINKING}; -// 呼吸灯是否开启 -uint8_t LED_Breath_State = LED_BREATH_OFF; +uint8_t LED_State[LED_NUM] = {LED_NOT_BLINKING}; // 灯闪烁颜色缓存 -RGBColor_TypeDef LED_Blink_Color[LED_NUM] = {0}; -const RGBColor_TypeDef LED_OFF = {0, 0, 0}; -const RGBColor_TypeDef LED_ON = {255, 255, 255}; -/** - * @brief 设置呼吸LED的开关 - * @param LedBreath_state 开/关 LED_BREATH_ON/LED_BREATH_OFF - */ -void LED_BreathTurn(uint8_t LedBreath_state) -{ - LED_Breath_State = LedBreath_state; - // if (LedBreath_state == LED_BREATH_OFF) - // { - // // rt_thread_suspend(led_breath_thread); - // LED_SetMore(LED_BREATH_ID(1), LED_BREATH_ID(12), LED_OFF); - // } - // else if (LedBreath_state == LED_BREATH_ON) - // { - // // rt_thread_resume(led_breath_thread); - // } -} +RGBColor_TypeDef LED_Color[LED_NUM] = {0}; +// 灯闪烁(呼吸)颜色当前值 +RGBColor_TypeDef LED_Tmp_Color = {0}; + /** * @brief 设置特定LED的颜色或开关 - * @param LedId LED的序号(0~LED_NUM-1) + * @param LedId LED的序号(0~LED_NUM-1) * @param Color 颜色/开关 LED_RED,LED_BLUE,LED_OFF,LED_ON(白色)…… */ void LED_Set(uint16_t LedId, RGBColor_TypeDef Color) { - LedId=LED_CHARGE_ID(LedId); - LED_Blink_State[LedId] = 0; + LED_State[LedId] = LED_NOT_BLINKING; Set_LEDColor(LedId, Color); RGB_Reflash(); } /** * @brief 设置连续多个特定LED的颜色或开关 - * @param LedId_begin LED的序号(0~LED_NUM-1)开始 - * @param LedId_end LED的序号(0~LED_NUM-1)结束 + * @param LedId_begin LED的序号(0~LED_NUM-1)开始 + * @param LedId_end LED的序号(0~LED_NUM-1)结束 * @param Color 颜色/开关 LED_RED,LED_BLUE,LED_OFF,LED_ON(白色)…… */ void LED_SetMore(uint16_t LedId_begin, uint16_t LedId_end, RGBColor_TypeDef Color) { - LedId_begin=LED_CHARGE_ID(LedId_begin); - LedId_end=LED_CHARGE_ID(LedId_end); for (int LedId = LedId_begin; LedId <= LedId_end; LedId++) { - LED_Blink_State[LedId] = 0; + LED_State[LedId] = LED_NOT_BLINKING; Set_LEDColor(LedId, Color); } RGB_Reflash(); @@ -68,163 +64,166 @@ void LED_SetMore(uint16_t LedId_begin, uint16_t LedId_end, RGBColor_TypeDef Colo /** * @brief 设置特定LED的闪烁 - * @param LedId LED的序号(0~LED_NUM-1) + * @param LedId LED的序号(0~LED_NUM-1) * @param Color 颜色 LED_RED,LED_BLUE…… */ void LED_Blink(uint16_t LedId, RGBColor_TypeDef Color) { - LedId=LED_CHARGE_ID(LedId); - LED_Blink_State[LedId] = 1; - LED_Blink_Color[LedId] = Color; + LED_State[LedId] = LED_IS_BLINKING; + LED_Color[LedId] = Color; } /** * @brief 设置连续多个特定LED的闪烁 - * @param LedId_begin LED的序号(0~LED_NUM-1)开始 - * @param LedId_end LED的序号(0~LED_NUM-1)结束 + * @param LedId_begin LED的序号(0~LED_NUM-1)开始 + * @param LedId_end LED的序号(0~LED_NUM-1)结束 * @param Color 颜色 LED_RED,LED_BLUE…… */ void LED_BlinkMore(uint16_t LedId_begin, uint16_t LedId_end, RGBColor_TypeDef Color) { - LedId_begin=LED_CHARGE_ID(LedId_begin); - LedId_end=LED_CHARGE_ID(LedId_end); for (int LedId = LedId_begin; LedId <= LedId_end; LedId++) { - LED_Blink_State[LedId] = 1; - LED_Blink_Color[LedId] = Color; + LED_State[LedId] = LED_IS_BLINKING; + LED_Color[LedId] = Color; } } /** - * @brief 每0.5s判断各盏灯是否要翻转 + * @brief 设置特定LED的呼吸 + * @param LedId LED的序号(0~LED_NUM-1) + * @param Color 颜色 LED_RED,LED_BLUE…… + */ +void LED_Breath(uint16_t LedId, RGBColor_TypeDef Color) +{ + LED_State[LedId] = LED_IS_BREATHING; + LED_Color[LedId] = Color; +} +/** + * @brief 设置连续多个特定LED的呼吸 + * @param LedId_begin LED的序号(0~LED_NUM-1)开始 + * @param LedId_end LED的序号(0~LED_NUM-1)结束 + * @param Color 颜色 LED_RED,LED_BLUE…… + */ +void LED_BreathMore(uint16_t LedId_begin, uint16_t LedId_end, RGBColor_TypeDef Color) +{ + for (int LedId = LedId_begin; LedId <= LedId_end; LedId++) + { + LED_State[LedId] = LED_IS_BREATHING; + LED_Color[LedId] = Color; + } +} +/** + * @brief 灯的闪烁,每0.5s判断各盏灯是否要翻转 */ void led_blink_entry(void *parameter) { - uint8_t LED_Blink_ON = 1; + (void)parameter; + uint16_t LED_Blink_ON = 1, cnt_blink = 0; while (1) { + cnt_blink = 0; for (int LedId = 0; LedId < LED_NUM; LedId++) { - if (LED_Blink_State[LedId] == LED_IS_BLINKING) + if (LED_State[LedId] == LED_IS_BLINKING) { + cnt_blink++; if (LED_Blink_ON) { - Set_LEDColor(LedId, LED_Blink_Color[LedId]); + Set_LEDColor(LedId, LED_Color[LedId]); } else { - Set_LEDColor(LedId, LED_OFF); + Set_LEDColor(LedId, LEDI_OFF); } } } LED_Blink_ON = !LED_Blink_ON; - RGB_Reflash(); + if (cnt_blink) + RGB_Reflash(); rt_thread_mdelay(500); } } -/** - * @brief 流水灯 - */ +void breath_add(float *LED_Breath_Percentage) +{ + static int breath_cnt = 0; + if(breath_cnt<=LED_BREATH_HALF_TIMES) + { + *LED_Breath_Percentage =gamma_table[(uint8_t)256.0*breath_cnt/LED_BREATH_HALF_TIMES]; + } + else + { + *LED_Breath_Percentage =gamma_table[(uint8_t)256.0*(LED_BREATH_HALF_TIMES*2-breath_cnt)/LED_BREATH_HALF_TIMES]; + if (breath_cnt>=LED_BREATH_HALF_TIMES*2) + { + breath_cnt=0; + } + + } + breath_cnt++; +} + void led_breath_entry(void *parameter) { - int count = 0; + (void)parameter; + float LED_Breath_Percentage = 255; + uint16_t LED_Breath_ON = 1, breath_num=0; while (1) { - for (int i = LED_BREATH_ID(1); i <= LED_BREATH_ID(12); i++) + breath_num = 0; + for (int LedId = 0; LedId < LED_NUM; LedId++) { - if (LED_Breath_State==LED_BREATH_OFF) + if (LED_State[LedId] == LED_IS_BREATHING) { - rt_thread_mdelay(100); - i = LED_BREATH_ID(1); - continue; + breath_num++; + LED_Tmp_Color.G = (uint8_t)LED_Color[LedId].G * LED_Breath_Percentage/255; + LED_Tmp_Color.R = (uint8_t)LED_Color[LedId].R * LED_Breath_Percentage/255; + LED_Tmp_Color.B = (uint8_t)LED_Color[LedId].B * LED_Breath_Percentage/255; + Set_LEDColor(LedId, LED_Tmp_Color); } - - switch (count) - { - case 0: - Set_LEDColor(i, LED_RED); - break; - case 1: - Set_LEDColor(i, LED_GREEN); - break; - case 2: - Set_LEDColor(i, LED_BLUE); - break; - default: - return; - break; - } - RGB_Reflash(); - rt_thread_delay(40); } - count = (count + 1) % 3; + breath_add(&LED_Breath_Percentage); + if (breath_num) + RGB_Reflash(); + rt_thread_mdelay(LED_BREATH_MDELAY); } } -#define BORAD_NOT_CORRECT 25 -#define BORAD_CORRECT_VOL 250 - -/** - * @brief 检测一下当前接入的是否是正确的板 -*/ -static int borad_check(void) +void led_reflash_entry(void *parameter) { - rt_adc_device_t adc_dev; - rt_uint32_t value, vol; - rt_err_t ret = RT_EOK; - - /* 查找设备 */ - adc_dev = (rt_adc_device_t)rt_device_find(ADC_DEV_NAME); - if (adc_dev == RT_NULL) + (void)parameter; + while (1) { - rt_kprintf("adc sample run failed! can't find %s device!\n", ADC_DEV_NAME); - return RT_ERROR; + RGB_Reflash(); + rt_thread_mdelay(500); } - - /* 使能设备 */ - ret = rt_adc_enable(adc_dev, ADC_DEV_CHANNEL); - - /* 读取采样值 */ - value = rt_adc_read(adc_dev, ADC_DEV_CHANNEL); - - /* 转换为对应电压值 */ - vol = value * REFER_VOLTAGE / CONVERT_BITS; - if(vol>=BORAD_CORRECT_VOL) - { - rt_kprintf("NOT correct borad!\n"); - rt_kprintf("the value is :%d \n", value); - rt_kprintf("the voltage is :%d.%02d \n", vol / 100, vol % 100); - return BORAD_NOT_CORRECT; - } - /* 关闭通道 */ - ret = rt_adc_disable(adc_dev, ADC_DEV_CHANNEL); - - return ret; } -/* 导出到 msh 命令列表中 */ -MSH_CMD_EXPORT(borad_check, adc voltage convert sample); - /** * @brief LED的初始化 -*/ + */ int led_init(void) { - if (borad_check()==BORAD_NOT_CORRECT) - { - return 0; - } - led_blink_thread = rt_thread_create("led blink control thread", led_blink_entry, RT_NULL, 1024, 20, 20); + + led_blink_thread = rt_thread_create("ledblT", led_blink_entry, RT_NULL, 1024, 20, 20); if (led_blink_thread == RT_NULL) { rt_kprintf("led blink control thread creat failed!\n"); return 0; } - led_breath_thread = rt_thread_create("led breath control thread", led_breath_entry, RT_NULL, 1024, 20, 20); + rt_thread_startup(led_blink_thread); + + led_breath_thread = rt_thread_create("ledbrT", led_breath_entry, RT_NULL, 1024, 20, 20); if (led_breath_thread == RT_NULL) { rt_kprintf("led breath control thread creat failed!\n"); return 0; } - rt_thread_mdelay(200); // avoid multi-thread on LED matrix transmit. - rt_thread_startup(led_blink_thread); rt_thread_startup(led_breath_thread); + + led_reflash_thread = rt_thread_create("ledreT", led_reflash_entry, RT_NULL, 1024, 20, 20); + if (led_reflash_thread == RT_NULL) + { + rt_kprintf("led reflash control thread creat failed!\n"); + return 0; + } + rt_thread_startup(led_reflash_thread); + return 0; } \ No newline at end of file diff --git a/applications/indicator_led.h b/applications/indicator_led.h index 823e59e..b24816e 100644 --- a/applications/indicator_led.h +++ b/applications/indicator_led.h @@ -1,20 +1,22 @@ #include #include +#define LED_NUM 19 // LED灯珠个数 + #define LED_IS_BLINKING 1 #define LED_NOT_BLINKING 0 #define LED_BREATH_ON 1 #define LED_BREATH_OFF 0 +#define LED_BREATH_OFF_LASTING 2 +#define LED_IS_BREATHING 6 #define LED_CHARGE_ID(i) (i+12-1) //电源指示灯序号(1-12) -#define LED_BREATH_ID(i) (i-1) //呼吸灯序号(1-12) +#define LED_BREATH_ID(i) (i-12) //呼吸灯序号(1-12) -extern void LED_Set(uint16_t LedId, RGBColor_TypeDef Color); -extern void LED_SetMore(uint16_t LedId_begin,uint16_t LedId_end, RGBColor_TypeDef Color); -extern void LED_Blink(uint16_t LedId, RGBColor_TypeDef Color); -extern void LED_BlinkMore(uint16_t LedId_begin, uint16_t LedId_end, RGBColor_TypeDef Color); -extern void LED_BreathTurn(uint8_t LedBreath_state); -extern int led_init(void); - -extern const RGBColor_TypeDef LED_OFF; -extern const RGBColor_TypeDef LED_ON; \ No newline at end of file +void LED_Set(uint16_t LedId, RGBColor_TypeDef Color); +void LED_SetMore(uint16_t LedId_begin,uint16_t LedId_end, RGBColor_TypeDef Color); +void LED_Blink(uint16_t LedId, RGBColor_TypeDef Color); +void LED_BlinkMore(uint16_t LedId_begin, uint16_t LedId_end, RGBColor_TypeDef Color); +void LED_Breath(uint16_t LedId, RGBColor_TypeDef Color); +void LED_BreathMore(uint16_t LedId_begin, uint16_t LedId_end, RGBColor_TypeDef Color); +int led_init(void); \ No newline at end of file diff --git a/applications/mytest.c b/applications/mytest.c index 55ad932..fbb44e9 100644 --- a/applications/mytest.c +++ b/applications/mytest.c @@ -15,11 +15,11 @@ void ledblinkm(int argc, char **argv){ } } MSH_CMD_EXPORT_ALIAS(ledblinkm,LEDB, "BLINKS LedId Color"); -void ledbreath(int argc, char **argv){ +// void ledbreath(int argc, char **argv){ - LED_BreathTurn(atoi(argv[1])); -} -MSH_CMD_EXPORT_ALIAS(ledbreath,LEDBR, "BLINKS LedId Color"); +// LED_BreathTurn(atoi(argv[1])); +// } +// MSH_CMD_EXPORT_ALIAS(ledbreath,LEDBR, "BLINKS LedId Color"); void ledsetm(int argc, char **argv){ int LedId_begin = atoi(argv[2]); diff --git a/applications/sensor.c b/applications/sensor.c index 3152175..b172f25 100644 --- a/applications/sensor.c +++ b/applications/sensor.c @@ -1,7 +1,7 @@ #define ADC_DEV_NAME "adc1" /* ADC 设备名称 */ #define ADC_CHANNEL_AIR 5 /* ADC 通道 */ #define ADC_CHANNEL_PM25 1 /* ADC 通道 */ -#define ADC_CHANNEL_PRESS 6 /* ADC 通道 */ +#define ADC_CHANNEL_PRESS 6 /* ADC 通道 */ #define REFER_VOLTAGE 330 /* 参考电压 3.3V,数据精度乘以100保留2位小数*/ #define CONVERT_BITS (1 << 12) /* 转换位数为12位 */ #include @@ -16,8 +16,8 @@ rt_thread_t Sensor_Thread = RT_NULL; #define THREAD_STACK_SIZE 4096 #define THREAD_TIMESLICE 5 -#define PM25_READ_TIMES 20 -#define GPIO_PIN GET_PIN(G, 5) +#define PM25_READ_TIMES 20 +#define GPIO_PIN GET_PIN(G, 5) #define LOG_TAG "sensor" #define DBG_LVL DBG_LOG @@ -52,25 +52,25 @@ float Air_Read() } float MQ2_GetData_PPM(void) { - - float tempData = 0; - - for (uint8_t i = 0; i < MQ2_READ_TIMES; i++) - { - tempData += Air_Read();; - rt_thread_mdelay(5);; - } - tempData /= MQ2_READ_TIMES; - - float Vol = (tempData*5/4096); - float RS = (5-Vol)/(Vol*0.5); - float R0=6.64; - - float ppm = pow(11.5428*R0/RS, 0.6549f); - - return ppm; + float tempData = 0; + for (uint8_t i = 0; i < MQ2_READ_TIMES; i++) + { + tempData += Air_Read(); + ; + rt_thread_mdelay(5); + ; + } + tempData /= MQ2_READ_TIMES; + + float Vol = (tempData * 5 / 4096); + float RS = (5 - Vol) / (Vol * 0.5); + float R0 = 6.64; + + float ppm = pow(11.5428 * R0 / RS, 0.6549f); + + return ppm; } float PM25_Read() { @@ -100,75 +100,83 @@ float Pressure_Read() } float PM25_GetData(void) { - int ADCVal; - int dustVal = 0; - float Voltage; - - rt_pin_write(GPIO_PIN, PIN_HIGH);//置1 开启内部LED - - rt_hw_us_delay(280); - ADCVal = PM25_Read(); - rt_hw_us_delay(25); - rt_pin_write(GPIO_PIN, PIN_LOW); //置0 关闭内部LED - rt_hw_us_delay(9680); //需要脉宽比0.32ms/10ms的PWM信号驱动传感器中的LED - - Voltage = 3.3f * ADCVal / 4096.f * 2; //获得AO输出口的电压值 - - dustVal = (0.17*Voltage-0.1)*1000; //乘以1000单位换成ug/m3// + int ADCVal; + int dustVal = 0; + float Voltage; - if (dustVal < 0) - dustVal = 0; //限位// + rt_pin_write(GPIO_PIN, PIN_HIGH); // 置1 开启内部LED - if (dustVal>500) - dustVal=500; + rt_hw_us_delay(280); + ADCVal = PM25_Read(); + rt_hw_us_delay(25); + rt_pin_write(GPIO_PIN, PIN_LOW); // 置0 关闭内部LED + rt_hw_us_delay(9680); // 需要脉宽比0.32ms/10ms的PWM信号驱动传感器中的LED - return dustVal; + Voltage = 3.3f * ADCVal / 4096.f * 2; // 获得AO输出口的电压值 + + dustVal = (0.17 * Voltage - 0.1) * 1000; // 乘以1000单位换成ug/m3// + + if (dustVal < 0) + dustVal = 0; // 限位// + + if (dustVal > 500) + dustVal = 500; + + return dustVal; } /** - * @brief 平均值滤波法 - * @param 无 - * @retval 返回滤波后的数据 - */ + * @brief 平均值滤波法 + * @param 无 + * @retval 返回滤波后的数据 + */ float Get_PM25_Average_Data(void) { - float temp_val=0; - float t; - for(t=0;t max) { - LOG5("%s's value:%f is too high\n",str, value); + LOG5("%s's value:%f is too high\n", str, value); danger_status(); + return 1; } + return 0; } static void sensor_thread(void *parameter) { while (1) { - ADC_air = MQ2_GetData_PPM(); // 空气质量传感器数值 0-4095 表示从差到优秀 + ADC_air = MQ2_GetData_PPM(); // 空气质量传感器数值 0-4095 表示从差到优秀 ADC_PM25 = Get_PM25_Average_Data(); // PM2.5传感器数值0-500 表示从优秀到查差 - ADC_pressure = Pressure_Read(); // 压力传感器数值 0-4095 表示从差到优秀 + ADC_pressure = Pressure_Read(); // 压力传感器数值 0-4095 表示从差到优秀 // LOG5("ADC_air:%f,ADC_PM25:%f,ADC_pressure:%f", ADC_air, ADC_PM25, ADC_pressure); - warning_range("air", ADC_air, 0, 6.8); - warning_range("PM25", ADC_PM25, 0, 260); - warning_range("pressure", ADC_pressure, 3500, 4095); + int cnt_warning = 0; + cnt_warning += warning_range("air", ADC_air, 0, 6.8); + cnt_warning += warning_range("PM25", ADC_PM25, 0, 260); + cnt_warning += warning_range("pressure", ADC_pressure, 3500, 4095); + if (cnt_warning == 0) + { + normal_status(); + } rt_thread_mdelay(500); } } diff --git a/applications/status.c b/applications/status.c index 856fe0d..8f429c3 100644 --- a/applications/status.c +++ b/applications/status.c @@ -5,6 +5,7 @@ #include #include #include +#include "indicator_led.h" #define THREAD_PRIORITY 25 @@ -28,14 +29,6 @@ #define PIN_LED_B GET_PIN(E, 12) #define LED_ON PIN_HIGH #define LED_OFF PIN_LOW -void danger_status(void) -{ - char *str = "aa"; - serial_send(str); - sim_call("17318112360"); -} -MSH_CMD_EXPORT_ALIAS(danger_status, danger, show danger_status); - void fan_on(void) { LOG3("fan on!"); @@ -60,4 +53,20 @@ void light_off(void) LOG3("light off!"); rt_pin_mode(PIN_LED_B, PIN_MODE_OUTPUT); rt_pin_write(PIN_LED_B, LED_OFF); +} +void danger_status(void) +{ + char *str = "aa"; + serial_send(str); + sim_call("17318112360"); + fan_on(); + light_on(); + LED_BreathMore(0,LED_NUM-1,LED_RED); +} +MSH_CMD_EXPORT_ALIAS(danger_status, danger, show danger_status); +void normal_status(void) +{ + fan_off(); + light_off(); + LED_SetMore(0,LED_NUM-1,LEDI_OFF); } \ No newline at end of file diff --git a/applications/status.h b/applications/status.h index 71b4d93..7d36a3d 100644 --- a/applications/status.h +++ b/applications/status.h @@ -1,4 +1,5 @@ void danger_status(void); +void normal_status(void); void fan_on(void); void fan_off(void); void light_on(void); diff --git a/board/ports/led_matrix/drv_matrix_led.c b/board/ports/led_matrix/drv_matrix_led.c index 93f26fa..2b4a60b 100644 --- a/board/ports/led_matrix/drv_matrix_led.c +++ b/board/ports/led_matrix/drv_matrix_led.c @@ -50,12 +50,24 @@ const RGBColor_TypeDef LED_GREEN = {255, 0, 0}; const RGBColor_TypeDef LED_RED = {0, 255, 0}; const RGBColor_TypeDef LED_BLUE = {0, 0, 255}; const RGBColor_TypeDef LED_WHITE = {255, 255, 255}; + + const RGBColor_TypeDef LT_RED = {0, 32, 0}; const RGBColor_TypeDef LT_GREEN = {32, 0, 0}; const RGBColor_TypeDef LT_BLUE = {0, 0, 32}; const RGBColor_TypeDef LT_WHITE = {16, 16, 16}; +const RGBColor_TypeDef LT_PURPLE = {0,32,32}; +const RGBColor_TypeDef LT_YELLOW = {256/8, 256/8, 0}; +const RGBColor_TypeDef LLT_RED = {0, 8, 0}; +const RGBColor_TypeDef LLT_GREEN = {8, 0, 0}; +const RGBColor_TypeDef LLT_BLUE = {0, 0, 8}; +const RGBColor_TypeDef LLT_WHITE = {4, 4, 4}; +const RGBColor_TypeDef LLT_PURPLE = {0,8,8}; +const RGBColor_TypeDef LLT_YELLOW = {8, 8, 0}; +const RGBColor_TypeDef LEDI_OFF = {0, 0, 0}; +const RGBColor_TypeDef LEDI_ON = {255, 255, 255}; // 灯颜色缓存 diff --git a/board/ports/led_matrix/drv_matrix_led.h b/board/ports/led_matrix/drv_matrix_led.h index b278b6e..f48e8d1 100644 --- a/board/ports/led_matrix/drv_matrix_led.h +++ b/board/ports/led_matrix/drv_matrix_led.h @@ -15,11 +15,27 @@ typedef struct RGBColor_TypeDef // // 灯闪烁颜色缓存 // extern RGBColor_TypeDef LED_Blink_Color[LED_NUM] = {0}; -extern const RGBColor_TypeDef LED_DARK; -extern const RGBColor_TypeDef LED_GREEN; -extern const RGBColor_TypeDef LED_RED; -extern const RGBColor_TypeDef LED_BLUE; -extern const RGBColor_TypeDef LED_WHITE; +extern const RGBColor_TypeDef LED_DARK ; +extern const RGBColor_TypeDef LED_GREEN; +extern const RGBColor_TypeDef LED_RED ; +extern const RGBColor_TypeDef LED_BLUE ; +extern const RGBColor_TypeDef LED_WHITE ; + +extern const RGBColor_TypeDef LT_RED ; +extern const RGBColor_TypeDef LT_GREEN ; +extern const RGBColor_TypeDef LT_BLUE ; +extern const RGBColor_TypeDef LT_WHITE ; +extern const RGBColor_TypeDef LT_PURPLE; +extern const RGBColor_TypeDef LT_YELLOW; +extern const RGBColor_TypeDef LLT_RED ; +extern const RGBColor_TypeDef LLT_GREEN; +extern const RGBColor_TypeDef LLT_BLUE ; +extern const RGBColor_TypeDef LLT_WHITE; +extern const RGBColor_TypeDef LLT_PURPLE; +extern const RGBColor_TypeDef LLT_YELLOW; + +extern const RGBColor_TypeDef LEDI_OFF ; +extern const RGBColor_TypeDef LEDI_ON ; extern void Set_LEDColor(uint16_t LedId, RGBColor_TypeDef Color); extern void RGB_Reflash(void);