📄 button_api.c
字号:
/*****************************************************************
* 函数库名称:旋转编码器驱动函数库 *
* 版本: v0.01 *
* 作者: I ROBOT *
* 创建日期: Copyright (C) 2008年10月24日 *
*----------------------------------------------------------------*
* [支持库] *
* 支持库名称:USE_Encode_Roll_Driver.h(旋转编码器驱动配置库) *
* 支持库版本:v0.01 *
* 支持库说明:与本文件相应的函数声明 *
*----------------------------------------------------------------*
* [版本更新] *
* 更新: I ROBOT *
* 更新日期: *
* 版本: *
*----------------------------------------------------------------*
* [版本历史] *
* v0.01 创建版本,创建了旋转编码器数据采样的函数 *
*----------------------------------------------------------------*
* [使用说明] *
* 1.直接调用数据采样函数 *
*****************************************************************/
/********************
* 头 文 件 配 置 区 *
********************/
# include "Button_API.h"
/********************
* 系 统 宏 定 义 *
********************/
/*------------------*
* 常 数 宏 定 义 *
*------------------*/
/*------------------*
* 动 作 宏 定 义 *
*------------------*/
/********************
* 模块结构体定义区 *
********************/
/********************
* 函 数 声 明 区 *
********************/
void Creat_Button(Draw_Info *Queue,Button_Info *Button);
void Button_Reverse(Draw_Info *Queue,Button_Info *Button);
void Creat_Button_cn(Draw_Info *Queue,Button_Info *Button,
const UINT8 *Cn_Word,UINT16 *chPos_Buffer,UINT8 chWord_Num);
/********************
* 模块函数声明区 *
********************/
/********************
* 模块变量声明区 *
********************/
/********************
* 全局变量声明区 *
********************/
/******************************************************************
* 函 数 定 义 区 *
******************************************************************/
/****************************************
* 函数说明: Encode_Roll硬件配置函数 *
* 输入 :无 *
* 输出 :无 *
* 调用函数: 无 *
****************************************/
void Creat_Button(Draw_Info *Queue,Button_Info *Button)
{
UINT8 chCounter = 0;
UINT8 Str_Len = 0;
for (chCounter = 0;Button->Str[chCounter] != '\0';chCounter++)
{
Str_Len++;
}
{
UINT8 x0 = Button->chHead_x,y0 = Button->chHead_y,
x1 = Button->chHead_x+(Str_Len*5)+1,y1 = y0,
x2 = x1,y2 = Button->chHead_y-10,
x3 = x0,y3 = y2;
Line_To(Queue,Button->chCur_ID_Draw,x0,y0,x1,y1);
Line_To(Queue,Button->chCur_ID_Draw,x0,y0,x3,y3);
Line_To(Queue,Button->chCur_ID_Draw,x3,y3,x2,y2);
Line_To(Queue,Button->chCur_ID_Draw,x1,y1,x2,y2);
Line_To(Queue,Button->chCur_ID_Draw,x3,(y3-1),(x2+1),(y2-1));
Line_To(Queue,Button->chCur_ID_Draw,(x2+1),(y2-1),(x2+1),y1);
Write_String(Queue,Button->chCur_ID_Draw,
ASCII_Table,Button->Str,Button->chHead_x+1,Button->chHead_y-1);
Button->chEnd_x = x2+1;
Button->chEnd_y = y2-1;
}
}
/****************************************
* 函数说明: Encode_Roll硬件配置函数 *
* 输入 :无 *
* 输出 :无 *
* 调用函数: 无 *
****************************************/
void Button_Reverse(Draw_Info *Queue,Button_Info *Button)
//按钮是静态的,所以不能在移动窗口上,以后必须把类封装好
{
UINT8 chxPixel = 0,chyPixel = 0;
Draw_Info *Draw = &Queue[Button->chCur_ID_Draw-1];
UINT8 chx_Head = Button->chHead_x-Draw->chCur_x;
UINT8 chy_Head = Draw->chCur_y-Button->chHead_y;
UINT8 chx_End = Button->chEnd_x-Draw->chCur_x;
UINT8 chy_End = Draw->chCur_y-Button->chEnd_y;
for (chxPixel = chx_Head+1;chxPixel < chx_End;chxPixel++)
{
for (chyPixel = chy_Head;chyPixel < chy_End;chyPixel++)
{
UINT8 chRow = chyPixel >> 3;
UINT8 chCol = chxPixel;
UINT8 chBit = BIT(chyPixel&7);
UINT8 chScreen_x = Draw->chCur_x+chxPixel;
UINT8 chScreen_y = Draw->chCur_y-chyPixel;
if (Draw->chSelf_Buffer[(chRow*Draw->chx_Pixel+chCol)]&chBit)
{
Clear_Dot(Queue,Draw->ID_Draw,chScreen_x,chScreen_y);
}
else
{
Draw_Dot(Queue,Draw->ID_Draw,chScreen_x,chScreen_y);
}
}
}
}
/****************************************
* 函数说明: Encode_Roll硬件配置函数 *
* 输入 :无 *
* 输出 :无 *
* 调用函数: 无 *
****************************************/
BOOL Button_Is_Down(Button_Info *Button,
Draw_Info *Queue,UINT8 chCur_ID_Draw,
BOOL Down_Flag,UINT8 chx,UINT8 chy)
{
if (!Down_Flag)
{
return FALSE;
//如果没有按键按下我就返回FALSE
}
else
{
if ((chx < Button->chHead_x || chx > Button->chEnd_x)
|| (chy < Button->chEnd_y || chy > Button->chHead_y))
{
return FALSE;
//如果坐标在BUTTON的范围内返回FALSE
}
else
{
UINT8 chCounter = 0;
for (chCounter = chCur_ID_Draw-1;chCounter > ID_MOUSE;chCounter--)
{
Draw_Info *Draw = &Queue[chCounter-1];
UINT8 chxPixel = chx-Draw->chCur_x;
UINT8 chyPixel = Draw->chCur_y-chy;
if (Dot_Inside(Draw,chxPixel,chyPixel))
{
return FALSE;
}
}
//扫描BUTTON寄生的图层上所有的上层图层,如果遮挡了BUTTON
//就返回FALSE
return TRUE;
//否则返回TRUE
}
}
}
/****************************************
* 函数说明: Encode_Roll硬件配置函数 *
* 输入 :无 *
* 输出 :无 *
* 调用函数: 无 *
****************************************/
void Creat_Button_cn(Draw_Info *Queue,Button_Info *Button,
const UINT8 *Cn_Word,UINT16 *chPos_Buffer,UINT8 chWord_Num)
{
{
UINT8 x0 = Button->chHead_x,y0 = Button->chHead_y,
x1 = (UINT8)(Button->chHead_x+(chWord_Num*16)+1),y1 = y0,
x2 = x1,y2 = Button->chHead_y-17,
x3 = x0,y3 = y2;
Line_To(Queue,Button->chCur_ID_Draw,x0,y0,x1,y1);
Line_To(Queue,Button->chCur_ID_Draw,x0,y0,x3,y3);
Line_To(Queue,Button->chCur_ID_Draw,x3,y3,x2,y2);
Line_To(Queue,Button->chCur_ID_Draw,x1,y1,x2,y2);
Line_To(Queue,Button->chCur_ID_Draw,x3,(y3-1),(x2+1),(y2-1));
Line_To(Queue,Button->chCur_ID_Draw,(x2+1),(y2-1),(x2+1),y1);
{
UINT8 chCounter = 0;
UINT8 chTemp_x = Button->chHead_x+1;
UINT8 chTemp_y = Button->chHead_y-1;
for (chCounter = 0;chCounter < chWord_Num;chCounter++)
{
Write_Cn(Queue,Button->chCur_ID_Draw,Cn_Word,
chPos_Buffer[chCounter],
chTemp_x,chTemp_y);
chTemp_x += 16;
}
}
Button->chEnd_x = x2+1;
Button->chEnd_y = y2-1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -