Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#include "encode.h"
|
||||
|
||||
void GEI_BUTTON_CODE(button *bt)
|
||||
{
|
||||
#define t 500 //????(ms)
|
||||
bt->code=0;
|
||||
if(HAL_GPIO_ReadPin(bt->GPIOx,bt->GPIO_Pin)==0)
|
||||
{
|
||||
if(bt->lock==0)
|
||||
{
|
||||
if(HAL_GetTick()<bt->time+t)//??????????
|
||||
{
|
||||
bt->times++;
|
||||
bt->time=HAL_GetTick();
|
||||
bt->lock=1;
|
||||
|
||||
}else
|
||||
{
|
||||
bt->times=1; //??????
|
||||
bt->time=HAL_GetTick();
|
||||
bt->lock=1;
|
||||
}
|
||||
|
||||
}
|
||||
if(bt->lock==1)
|
||||
{
|
||||
if(HAL_GetTick()>bt->time+t)//??????t ms
|
||||
{
|
||||
bt->code=255;
|
||||
bt->times=255;
|
||||
} //????
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(HAL_GPIO_ReadPin(bt->GPIOx,bt->GPIO_Pin)==1)
|
||||
{
|
||||
if(bt->lock==1)
|
||||
{
|
||||
if(bt->code==255)
|
||||
{
|
||||
|
||||
}else
|
||||
{
|
||||
bt->code=bt->times;
|
||||
}
|
||||
bt->lock=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef ENCODER_H_
|
||||
#define ENCODER_H_
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
|
||||
typedef struct button
|
||||
{
|
||||
uint16_t code;
|
||||
uint8_t lock;
|
||||
uint32_t time;
|
||||
uint16_t times;
|
||||
GPIO_TypeDef *GPIOx;
|
||||
uint16_t GPIO_Pin;
|
||||
} button;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int code;
|
||||
uint8_t move_flag:1;
|
||||
} encoder;
|
||||
|
||||
void GEI_BUTTON_CODE(button *bt);
|
||||
|
||||
#endif /* ENCODER_H_ */
|
||||
@@ -5,7 +5,7 @@
|
||||
* Author: wuwen
|
||||
*/
|
||||
#include "mymain.h"
|
||||
#include "hread_interface.h"
|
||||
|
||||
|
||||
#define morse_t1 150
|
||||
#define morse_t2 (morse_t1*3)
|
||||
@@ -166,8 +166,12 @@ char getmorsecode(uint8_t len,uint8_t code)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
button B1;
|
||||
|
||||
void mymain()
|
||||
{
|
||||
int mode=0;
|
||||
uint32_t run_tick=0;
|
||||
char str[16];
|
||||
uint16_t fps=0,fps_=0;
|
||||
@@ -175,24 +179,35 @@ void mymain()
|
||||
OLED_Init();
|
||||
|
||||
HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_3);//启动n通道的pwm
|
||||
MUTE(0);
|
||||
MUTE(1);
|
||||
//add_a_note(1000,50,1000);
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
OLED_Str(0,0,16,"hello",1);
|
||||
switch(mode)
|
||||
{
|
||||
case 0:
|
||||
//启动跳转模式
|
||||
//用于读取系统配置后跳转到其他程序
|
||||
|
||||
OLED_AL(10,20,10,21,1);
|
||||
mode=1;
|
||||
break;
|
||||
case 1:
|
||||
//主界面
|
||||
fps_++;
|
||||
sprintf(str,"FPS:%d",fps);
|
||||
OLED_Str(0,56,8,str,1);
|
||||
break;
|
||||
case 2:
|
||||
//菜单界面
|
||||
break;
|
||||
|
||||
OLED_AL(20,50,20,49,1);
|
||||
}
|
||||
|
||||
|
||||
OLED_AL(20,50,30,50,1);
|
||||
|
||||
OLED_AL(50,30,30,30,1);
|
||||
|
||||
fps_++;
|
||||
sprintf(str,"FPS:%d",fps);
|
||||
OLED_Str(0,56,8,str,1);
|
||||
|
||||
OLED_Cache_to_hardware();//刷新屏幕
|
||||
buzzer_play_server();
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
#include "main.h"
|
||||
#include "oled.h"
|
||||
#include "buzzer.h"
|
||||
|
||||
#include "encode.h"
|
||||
#include "hread_interface.h"
|
||||
struct morsecode
|
||||
{
|
||||
uint8_t len;
|
||||
|
||||
@@ -138,10 +138,10 @@ void OLED_Cache_to_hardware()
|
||||
if(b==0){b=1;OLED_Set_Pos(x,y);}
|
||||
OLED_WrDat(OLED_buff[y][x]);
|
||||
OLED_speedup[y][x]=OLED_buff[y][x];
|
||||
OLED_buff[y][x]=0x00;
|
||||
|
||||
}else
|
||||
{b=0;}
|
||||
|
||||
OLED_buff[y][x]=0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1033,10 +1033,15 @@ void OLED_VL(unsigned char x,unsigned char y,unsigned char size,unsigned char do
|
||||
void OLED_AL(int sx,int sy,int ex,int ey,unsigned char dot_type)
|
||||
{
|
||||
|
||||
int dx,dy;
|
||||
int dx,dy,absx,absy;
|
||||
|
||||
//计算差
|
||||
dx=ex-sx;
|
||||
dy=ey-sy;
|
||||
//取绝对值 就是轴长
|
||||
absx=dx<0?0-dx:dx;
|
||||
absy=dy<0?0-dy:dy;
|
||||
|
||||
|
||||
if(dx==0)
|
||||
{
|
||||
@@ -1046,7 +1051,7 @@ void OLED_AL(int sx,int sy,int ex,int ey,unsigned char dot_type)
|
||||
{
|
||||
OLED_set_dot(sx,y,dot_type);
|
||||
}
|
||||
}
|
||||
}else
|
||||
if(dy<0)
|
||||
{
|
||||
for(int y=ey;y<sy;y++)
|
||||
@@ -1066,7 +1071,7 @@ void OLED_AL(int sx,int sy,int ex,int ey,unsigned char dot_type)
|
||||
{
|
||||
OLED_set_dot(x,sy,dot_type);
|
||||
}
|
||||
}
|
||||
}else
|
||||
if(dx<0)
|
||||
{
|
||||
for(int x=ex;x<sx;x++)
|
||||
@@ -1086,6 +1091,19 @@ void OLED_AL(int sx,int sy,int ex,int ey,unsigned char dot_type)
|
||||
}
|
||||
|
||||
|
||||
/*画方框*/
|
||||
void OLED_square(int Start_x, int Start_y, int End_x, int End_y, char type)
|
||||
{
|
||||
if(Start_x > End_x){int i1 = Start_x; Start_x = End_x; End_x=i1;}
|
||||
if(Start_y > End_y){int i1 = Start_y; Start_y = End_y; End_y=i1;}
|
||||
for(; Start_x < End_x ; Start_x++)
|
||||
{
|
||||
for(int y2 = Start_y ; y2 < End_y ; y2++)
|
||||
{
|
||||
OLED_set_dot(Start_x, y2, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,4 +28,6 @@ void OLED_Ascii(unsigned char x,unsigned char y,unsigned char size,char chr,unsi
|
||||
void OLED_Str(unsigned char x,unsigned char y,unsigned char size,char *str,unsigned char type);
|
||||
|
||||
void OLED_AL(int sx,int sy,int ex,int ey,unsigned char dot_type);
|
||||
|
||||
void OLED_square(int Start_x, int Start_y, int End_x, int End_y, char type);
|
||||
#endif /* OLED_H_ */
|
||||
|
||||
Reference in New Issue
Block a user