K1Guitar/AT32F403ARCT7_BOOT/device/TM1617/Drv_TM1617_RGB.h

56 lines
2.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Author: CTW
* @Date: 2025-11-07 14:37:14
* @FilePath: \PhoenixSMGT_Testproject\Drivers\TM1617\Drv_TM1617_RGB.h
* @note: 从 STM32 HAL 库移植到 AT32F403A软件模拟时序GPIO 位翻转)
*/
#ifndef __DRV_TM1617_RGB_H
#define __DRV_TM1617_RGB_H
#include <stdint.h>
#include "at32f403a_407.h"
/* TM1617 引脚GPIO 普通推挽输出)
DIO 需要双向读按键时切输入CLK/STB 推挽输出 */
#define DIO_PORT GPIOC
#define DIO_PIN GPIO_PINS_4
#define CLK_PORT GPIOB
#define CLK_PIN GPIO_PINS_0
#define STB_PORT GPIOC
#define STB_PIN GPIO_PINS_15
/* 按键状态枚举仅关注SEG5~SEG8对应按键 */
typedef enum {
KEY_MAIN_D, // SEG5对应按键
KEY_MAIN_C, // SEG6对应按键
KEY_MAIN_B, // SEG7对应按键
KEY_MAIN_A, // SEG8对应按键
KEY_NULL
} KeyStatusTypeDef;
/* RGB颜色宏定义SEG9=R, SEG10=G, SEG11=B对应bit0~bit2 */
#define COLOR_R 0x01 // 仅R亮
#define COLOR_G 0x02 // 仅G亮
#define COLOR_B 0x04 // 仅B亮
#define COLOR_YEL 0x03 // R+G
#define COLOR_CYA 0x06 // G+B
#define COLOR_PUR 0x05 // R+B
#define COLOR_WHT 0x07 // R+G+B
#define COLOR_OFF 0x00 // 全灭
extern uint8_t rgb_color_seq[]; // 颜色流转序列
extern uint8_t color_idx; // 颜色索引
/* --------------------------------------------------------------------------------------------------------- */
void TM1617_GPIO_Init(void); // TM1617 GPIO初始化
uint8_t TM1617_ReadByte(void); // 读1字节数据
void TM1617_WriteByte(uint8_t data); // 写1字节数据低位先行CLK上升沿锁存
void TM1617_Clear(void); // 上电清零(避免乱码)
void TM1617_Init(void); // TM1617 初始化
extern void TM1617_SetRGB(uint8_t color, uint8_t brightness); // TM1617 初始化
extern KeyStatusTypeDef TM1617_ScanFkey(void); // TM1617 按键扫描
extern void RGB_Breath_Flow(void); // RGB呼吸流转7色循环
void RGB_Test_On(uint8_t u8Color); // 最小化测试让RGB灯常亮白色最高辉度
#endif