109 lines
3.4 KiB
C
109 lines
3.4 KiB
C
/* USER CODE BEGIN Header */
|
||
/**
|
||
******************************************************************************
|
||
* @file : bs83b12_capacitive_touch.h
|
||
* @brief : 屏幕显示
|
||
* @version : 1.0
|
||
* @changelog : version 1.0 初始版本 2025.11.13
|
||
******************************************************************************
|
||
* @attention
|
||
*
|
||
* Copyright (c) 2025 Yuwell Software Danyang.Jiangsu.China
|
||
* THIS SOFTWARE is licensed under the Mulan PSL v1.
|
||
* can use this software according to the terms and conditions of the Mulan PSL v1.
|
||
* You may obtain a copy of Mulan PSL v1 at:
|
||
* http://license.coscl.org.cn/MulanPSL
|
||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||
* PURPOSE.
|
||
* See the Mulan PSL v1 for more details.
|
||
*
|
||
******************************************************************************
|
||
*/
|
||
/* USER CODE END Header */
|
||
|
||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||
#ifndef __BS83B12_CAPACITIVE_TOUCH_H
|
||
#define __BS83B12_CAPACITIVE_TOUCH_H
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
|
||
#include <stdint.h>
|
||
#include "fm33lg0xx_fl.h"
|
||
#include "fm33lg0xx_queue.h"
|
||
#include "fm33lg0xx_event.h"
|
||
|
||
|
||
#define ALARM_YELLOW_GPIO_PORT GPIOC
|
||
#define ALARM_YELLOW_GPIO_PIN FL_GPIO_PIN_9
|
||
|
||
|
||
#define ALARM_YELLOW_ON FL_GPIO_SetOutputPin(ALARM_YELLOW_GPIO_PORT, ALARM_YELLOW_GPIO_PIN);
|
||
#define ALARM_YELLOW_OFF FL_GPIO_ResetOutputPin(ALARM_YELLOW_GPIO_PORT, ALARM_YELLOW_GPIO_PIN);
|
||
|
||
|
||
|
||
/*********
|
||
1:iic 通讯
|
||
2:地址 0xA0
|
||
|
||
3:从机发送3个字节
|
||
byte0: 键值
|
||
byte1: 固定0x00
|
||
byte2: ~(byte0+byte1) + 1
|
||
|
||
5:主机发送
|
||
byte0: bit0 = 1
|
||
bit1/bit2=11/00(背光指示灯亮/灭)
|
||
bit4=1/0(蜂鸣器响/灭)
|
||
bit6=1/0(蓝灯指示灯亮/灭)
|
||
bit7(绿灯指示灯亮灭)
|
||
byte1: ~(byte0)+1
|
||
*********/
|
||
#define BS83B12_ADDR 0xA0 // 每隔100ms从该地址读取按键数据
|
||
|
||
#define BS83B12_SCL_GPIO_GROUP GPIOC
|
||
#define BS83B12_SCL_GPIO_PIN FL_GPIO_PIN_7
|
||
#define BS83B12_SDA_GPIO_GROUP GPIOC
|
||
#define BS83B12_SDA_GPIO_PIN FL_GPIO_PIN_8
|
||
|
||
#define BS83B12_SDA_CLEAR() FL_GPIO_ResetOutputPin(BS83B12_SDA_GPIO_GROUP,BS83B12_SDA_GPIO_PIN);
|
||
#define BS83B12_SDA_SET() FL_GPIO_SetOutputPin(BS83B12_SDA_GPIO_GROUP,BS83B12_SDA_GPIO_PIN);
|
||
|
||
#define BS83B12_SCL_CLEAR() FL_GPIO_ResetOutputPin(BS83B12_SCL_GPIO_GROUP,BS83B12_SCL_GPIO_PIN);
|
||
#define BS83B12_SCL_SET() FL_GPIO_SetOutputPin(BS83B12_SCL_GPIO_GROUP,BS83B12_SCL_GPIO_PIN);
|
||
|
||
#define BS83B12_BACK_LIGHT_ON_BYTE0 0x07
|
||
#define BS83B12_BACK_LIGHT_ON_BYTE1 0xF9
|
||
|
||
#define BS83B12_BACK_LIGHT_OFF_BYTE0 0x01
|
||
#define BS83B12_BACK_LIGHT_OFF_BYTE1 0xFF
|
||
|
||
|
||
// 定义触摸三个按键的键值
|
||
#define BS83B12_KEY1_CODE 0xFB
|
||
#define BS83B12_KEY2_CODE 0xFD
|
||
#define BS83B12_KEY3_CODE 0xFE
|
||
#define BS83B12_KEY_NONE 0xFF
|
||
|
||
#define KEY121_TIMEOUT_TICKS (20)
|
||
|
||
|
||
void bs83b12_capacitive_touch_init(void); // 初始化触摸按键及部分灯
|
||
|
||
|
||
void bs83b12_touch_read_task(void); // 每隔100ms执行一次,读取按键状态
|
||
|
||
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif /* __BS83B12_CAPACITIVE_TOUCH_H */
|
||
|
||
/************************ (C) COPYRIGHT Yuwell *****END OF FILE****/
|