久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
基于stm32+fdc2214的手勢識別例程
[打印本頁]
作者:
malingchao
時間:
2019-9-6 17:38
標題:
基于stm32+fdc2214的手勢識別例程
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "oled.h"
#include "fdc2214.h"
#include "key.h"
#include "stm32f10x.h"
#include "exti.h"
void Sys_Init(void);
int key;
int DATA1,DATA2,DATA3,DATA4,DATA5,DATA6,DATA7,DATA8;
int MOD;
float res0,res1,res2,res3;
float temp0,temp1,temp2,temp3;
double shu0,shu1,shu2;
double yi,er,san,si,wu;
int caiquan1,caiquan2=0,caiquan3,huaquan1,huaquan2,huaquan3,huaquan4,huaquan5;
int welcome(void);
int main(void)
{
int i=1;
KEY_Init();
Sys_Init();
KEY_Scan(0);
EXTIX_Init();
while(1)
{
if(MOD==1)//猜拳判決
{
delay_ms(250);
res0 = Cap_Calculate(0);//采集數據(原始數據)
res0 = res0-temp0;//電容接口空載減掉初始值
OLED_Show16x16(30,0,81,0);//猜
OLED_Show16x16(48,0,82,0);//拳
OLED_Show16x16(66,0,87,0);//判
OLED_Show16x16(84,0,88,0);//決
// OLED_Show16x16(0,2,45,0);//數
// OLED_Show16x16(18,2,46,0);//值
// OLED_Show16x16(36,2,18,0);//:
//
//清除上一屏顯示內容
//
// OLED_Show16x16(72,4,0,0);//
// OLED_Show16x16(0,6,0,0);//
// OLED_Show16x16(18,6,0,0);//
// OLED_Show16x16(36,6,0,0);//
// OLED_Show16x16(54,6,0,0);//
// OLED_Show16x16(72,6,0,0);//
// OLED_Show16x16(90,6,0,0);//
// OLED_Show16x16(108,6,0,0);//
// OLED_Show16x16(116,6,0,0);//
//
// Oled_Printf_Float(60,3,res0,0);
//Oled_Printf_Float(32,5,res1,0);
printf("CH0:%3.3f \r\n",res0);
if(res0>5.5)
{
i=1; //布
}
if(res0>1.0&res0<4.0)
{
i=3; //剪刀
}
if(res0>4.70&res0<5.40)
{
i=2; //石頭
}
if(res0<1.00)
{
i=4; //清空
}
switch(i)
{
case 1:led3=0;
led4=1;
led5=1;
OLED_Show16x16(31,2,0,0); //布
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,111,0);
OLED_Show16x16(61,2,112,0);
OLED_Show16x16(47,4,113,0); //布
OLED_Show16x16(61,4,114,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 2:led3=1;
led4=0;
led5=1;
OLED_Show16x16(31,2,95,0);
OLED_Show16x16(47,2,96,0);
OLED_Show16x16(31,4,97,0);
OLED_Show16x16(47,4,98,0);//石
OLED_Show16x16(61,2,99,0);
OLED_Show16x16(77,2,100,0);
OLED_Show16x16(61,4,101,0); //頭
OLED_Show16x16(77,4,102,0);break;
case 3:led3=1;
led4=1;
led5=0;
OLED_Show16x16(31,2,103,0);
OLED_Show16x16(47,2,104,0);
OLED_Show16x16(31,4,105,0);
OLED_Show16x16(47,4,106,0);//剪
OLED_Show16x16(61,2,107,0);
OLED_Show16x16(77,2,108,0);
OLED_Show16x16(61,4,109,0); //刀
OLED_Show16x16(77,4,110,0);break;
case 4:led3=1;
led4=1;
led5=1;
OLED_Show16x16(31,2,0,0); //空
OLED_Show16x16(47,2,0,0);
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,4,0,0);
OLED_Show16x16(61,2,0,0); //空
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(61,4,0,0);
OLED_Show16x16(77,4,0,0);break;
}
}
if(MOD==2)//劃拳判決
{
delay_ms(250);
res0 = Cap_Calculate(0);//采集數據(原始數據)
res0 = res0-temp0;//電容接口空載減掉初始值
OLED_Show16x16(30,0,83,0);//劃
OLED_Show16x16(48,0,84,0);//拳
OLED_Show16x16(66,0,87,0);//判
OLED_Show16x16(84,0,88,0);//決
// OLED_Show16x16(0,2,45,0);//數
// OLED_Show16x16(18,2,46,0);//值
// OLED_Show16x16(36,2,18,0);//:
// Oled_Printf_Float(60,3,res0,0);
// OLED_Show16x16(36,4,56,0);//請
// OLED_Show16x16(54,4,57,0);//將
// OLED_Show16x16(72,4,58,0);//手
// OLED_Show16x16(0,6,59,0);//放
// OLED_Show16x16(18,6,60,0);//在
// OLED_Show16x16(36,6,61,0);//傳
// OLED_Show16x16(54,6,62,0);//感
// OLED_Show16x16(72,6,63,0);//器
// OLED_Show16x16(90,6,64,0);//上
if(res0>2.00&res0<2.60)
{
i=1;
}
if(res0>3.00&res0<3.80)
{
i=2;
}
if(res0>3.90&res0<4.60)
{
i=3;
}
if(res0>5.00&res0<5.80)
{
i=4;
}
if(res0>6.00)
{
i=5;
}
if(res0<2.00)
{
i=6;
}
switch(i)
{
case 1:led3=0;
led4=1;
led5=1;
OLED_Show16x16(31,2,0,0); //一
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,121,0);
OLED_Show16x16(61,2,122,0);
OLED_Show16x16(47,4,123,0);
OLED_Show16x16(61,4,124,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 2:led3=1;
led4=0;
led5=1;
OLED_Show16x16(31,2,0,0); //二
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,125,0);
OLED_Show16x16(61,2,126,0);
OLED_Show16x16(47,4,127,0);
OLED_Show16x16(61,4,128,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 3:led3=1;
led4=1;
led5=0;
OLED_Show16x16(31,2,0,0); //三
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,129,0);
OLED_Show16x16(61,2,130,0);
OLED_Show16x16(47,4,131,0);
OLED_Show16x16(61,4,132,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 4:led3=0;
led4=0;
led5=1;
OLED_Show16x16(31,2,0,0); //四
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,133,0);
OLED_Show16x16(61,2,134,0);
OLED_Show16x16(47,4,135,0);
OLED_Show16x16(61,4,136,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 5:led3=0;
led4=1;
led5=0;
OLED_Show16x16(31,2,0,0); //五
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,137,0);
OLED_Show16x16(61,2,138,0);
OLED_Show16x16(47,4,139,0);
OLED_Show16x16(61,4,140,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 6:led3=1;
led4=1;
led5=1;
OLED_Show16x16(31,2,0,0); //清空
OLED_Show16x16(47,2,0,0);
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,4,0,0);
OLED_Show16x16(61,2,0,0); //清空
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(61,4,0,0);
OLED_Show16x16(77,4,0,0);break;
}
}
if(MOD==3)//猜拳訓練
{
res0 = Cap_Calculate(0);//采集數據(原始數據)
res0 = res0-temp0;//電容接口空載減掉初始值
OLED_Show16x16(30,0,81,0);//猜
OLED_Show16x16(48,0,82,0);//拳
OLED_Show16x16(66,0,52,0);//訓
OLED_Show16x16(84,0,53,0);//練
// OLED_Show16x16(0,2,45,0);//數
// OLED_Show16x16(18,2,46,0);//值
// OLED_Show16x16(36,2,18,0);//:
//
// OLED_Show16x16(0,6,0,0);//
// OLED_Show16x16(18,6,0,0);//
// OLED_Show16x16(36,6,0,0);
// OLED_Show16x16(54,6,0,0);
// OLED_Show16x16(72,6,0,0);//
// OLED_Show16x16(90,6,0,0);//
// OLED_Show16x16(108,6,0,0);//
// OLED_Show16x16(116,6,0,0);//
//
// Oled_Printf_Float(60,3,res0,0);
if(caiquan2>0&caiquan2<21) //石頭
{ static int m=0;
m++;
if(m<21)
{
shu0=shu0+res0;
USART_SendData(USART1,caiquan2);
}
if(m>19)
{
shu0=shu0/20;
// caiquan1=0;
led3=0;
delay_ms(500);
led3=1;
// USART_SendData(USART1,shu0);
m=0;
caiquan2=22;
}
}
if(caiquan2>22&caiquan2<43) //剪刀
{ static int n=0;
n++;
if(n<21)
{
shu1=shu1+res0;
}
if(n>19)
{
shu1=shu1/20;
// caiquan2=0;
led4=0;
delay_ms(500);
led4=1;
// USART_SendData(USART1,shu1);
n=0;
caiquan2=44;
}
}
if(caiquan2>44&caiquan2<65) //布
{ static int p=0;
p++;
if(p<21)
{
shu2=shu2+res0;
// USART_SendData(USART1,shu2);
}
if(p>19)
{
shu2=shu2/20;
//caiquan3=0;
led5=0;
delay_ms(500);
led5=1;
// USART_SendData(USART1,shu2);
p=0;
caiquan2=0;
}
}
}
if(MOD==4)//劃拳訓練
{
res0 = Cap_Calculate(0);//采集數據(原始數據)
res0 = res0-temp0;//電容接口空載減掉初始值
OLED_Show16x16(30,0,70,0);//猜
OLED_Show16x16(48,0,71,0);//拳
OLED_Show16x16(66,0,52,0);//訓
OLED_Show16x16(84,0,53,0);//練
//
// OLED_Show16x16(0,2,45,0);//數
// OLED_Show16x16(18,2,46,0);//值
// OLED_Show16x16(36,2,18,0);//:
//
//
// OLED_Show16x16(0,6,0,0);//
// OLED_Show16x16(18,6,0,0);//
// OLED_Show16x16(36,6,0,0);
// OLED_Show16x16(54,6,0,0);
// OLED_Show16x16(72,6,0,0);//
// OLED_Show16x16(90,6,0,0);//
// OLED_Show16x16(108,6,0,0);//
// OLED_Show16x16(116,6,0,0);//
//
// Oled_Printf_Float(60,3,res0,0);
if(caiquan3>0&caiquan3<21) //一
{ static int a=0;
a++;
if(a<21)
{
yi=yi+res0;
// USART_SendData(USART1,caiquan2);
}
if(a>19)
{
yi=yi/20;
// caiquan1=0;
led3=0;
delay_ms(500);
led3=1;
// USART_SendData(USART1,shu0);
a=0;
caiquan3=22;
}
}
if(caiquan3>22&caiquan3<43) //二
{ static int b=0;
b++;
if(b<21)
{
er=er+res0;
}
if(b>19)
{
er=er/20;
// caiquan2=0;
led4=0;
delay_ms(500);
led4=1;
// USART_SendData(USART1,shu1);
b=0;
caiquan3=44;
}
}
if(caiquan3>44&caiquan3<65) //三
{ static int c=0;
c++;
if(c<21)
{
san=san+res0;
// USART_SendData(USART1,shu2);
}
if(c>19)
{
san=san/20;
//caiquan3=0;
led5=0;
delay_ms(500);
led5=1;
// USART_SendData(USART1,shu2);
c=0;
caiquan3=66;
}
}
if(caiquan3>66&caiquan3<87) //四
{ static int d=0;
d++;
if(d<21)
{
si=si+res0;
// USART_SendData(USART1,shu2);
}
if(d>19)
{
si=si/20;
//caiquan3=0;
led5=0;
delay_ms(500);
led5=1;
// USART_SendData(USART1,shu2);
d=0;
caiquan3=88;
}
}
if(caiquan3>88&caiquan3<109) //五
{ static int e=0;
e++;
if(e<21)
{
wu=wu+res0;
// USART_SendData(USART1,shu2);
}
if(e>19)
{
wu=wu/20;
//caiquan3=0;
led5=0;
delay_ms(500);
led5=1;
// USART_SendData(USART1,shu2);
e=0;
caiquan3=0;
}
}
}
if(MOD==5)//猜拳判決
{
delay_ms(250);
res0 = Cap_Calculate(0);//采集數據(原始數據)
res0 =res0-temp0;//電容接口空載減掉初始值
OLED_Show16x16(30,0,81,0);//猜
OLED_Show16x16(48,0,82,0);//拳
OLED_Show16x16(66,0,87,0);//判
OLED_Show16x16(84,0,88,0);//決
//
// OLED_Show16x16(0,2,45,0);//數
// OLED_Show16x16(18,2,46,0);//值
// OLED_Show16x16(36,2,18,0);//:
//
//
// //清除上一屏顯示內容
// //
// OLED_Show16x16(72,4,0,0);//
// OLED_Show16x16(0,6,0,0);//
// OLED_Show16x16(18,6,0,0);//
// OLED_Show16x16(36,6,0,0);//
// OLED_Show16x16(54,6,0,0);//
// OLED_Show16x16(72,6,0,0);//
// OLED_Show16x16(90,6,0,0);//
// OLED_Show16x16(108,6,0,0);//
// OLED_Show16x16(116,6,0,0);//
//
// Oled_Printf_Float(60,3,res0,0);
//Oled_Printf_Float(32,5,res1,0);
// printf("CH0:%3.3f CH1:%3.3f \r\n",res0,res1);
if(res0>shu2-0.50&res0<shu2+0.50)
{
i=1;
}
if(res0>shu1-0.50&res0<shu1+0.50)
{
i=3;
}
if(res0>shu0-0.50&res0<shu0+0.50)
{
i=2;
}
if(res0<0.50)
{
i=4;
}
switch(i)
{
case 1:led3=0;
led4=1;
led5=1;
OLED_Show16x16(31,2,0,0); //布
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,111,0);
OLED_Show16x16(61,2,112,0);
OLED_Show16x16(47,4,113,0); //布
OLED_Show16x16(61,4,114,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 2:led3=1;
led4=0;
led5=1;
OLED_Show16x16(31,2,95,0);
OLED_Show16x16(47,2,96,0);
OLED_Show16x16(31,4,97,0);
OLED_Show16x16(47,4,98,0);//石
OLED_Show16x16(61,2,99,0);
OLED_Show16x16(77,2,100,0);
OLED_Show16x16(61,4,101,0); //頭
OLED_Show16x16(77,4,102,0);break;
case 3:led3=1;
led4=1;
led5=0;
OLED_Show16x16(31,2,103,0);
OLED_Show16x16(47,2,104,0);
OLED_Show16x16(31,4,105,0);
OLED_Show16x16(47,4,106,0);//剪
OLED_Show16x16(61,2,107,0);
OLED_Show16x16(77,2,108,0);
OLED_Show16x16(61,4,109,0); //刀
OLED_Show16x16(77,4,110,0);break;
case 4:led3=1;
led4=1;
led5=1;
OLED_Show16x16(31,2,0,0); //空
OLED_Show16x16(47,2,0,0);
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,4,0,0);
OLED_Show16x16(61,2,0,0); //空
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(61,4,0,0);
OLED_Show16x16(77,4,0,0);break;
}
}
if(MOD==6)//劃拳判決
{
delay_ms(250);
res0 = Cap_Calculate(0);//采集數據(原始數據)
res0 = res0-temp0;//電容接口空載減掉初始值
OLED_Show16x16(30,0,83,0);//劃
OLED_Show16x16(48,0,84,0);//拳
OLED_Show16x16(66,0,87,0);//判
OLED_Show16x16(84,0,88,0);//決
// OLED_Show16x16(0,2,45,0);//數
// OLED_Show16x16(18,2,46,0);//值
// OLED_Show16x16(36,2,18,0);//:
//
//
// //清除上一屏顯示內容
// //
//
// OLED_Show16x16(0,6,0,0);//
// OLED_Show16x16(18,6,0,0);//
// OLED_Show16x16(36,6,0,0);//
// OLED_Show16x16(54,6,0,0);//
// OLED_Show16x16(72,6,0,0);//
// OLED_Show16x16(90,6,0,0);//
// OLED_Show16x16(108,6,0,0);//
// OLED_Show16x16(116,6,0,0);//
//
//
// Oled_Printf_Float(60,3,res0,0);
//Oled_Printf_Float(32,5,res1,0);
printf("CH0:%3.3f CH1:%3.3f \r\n",res0,res1);
if(res0>yi-0.3&res0<yi+0.3)//2.2 2.4
{
i=1;
}
if(res0>er-0.5&res0<er+0.3)//3.4 3.7
{
i=2;
}
if(res0>san-0.3&res0<san+0.3)//4 4.5
{
i=3;
}
if(res0>si-0.5&res0<si+0.5) // 5.8
{
i=4;
}
if(res0>wu-0.2)//5.8
{
i=5;
}
if(res0<1.0)
{
i=6;
}
switch(i)
{
case 1:led3=0;
led4=1;
led5=1;
OLED_Show16x16(31,2,0,0); //一
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,121,0);
OLED_Show16x16(61,2,122,0);
OLED_Show16x16(47,4,123,0);
OLED_Show16x16(61,4,124,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 2:led3=1;
led4=0;
led5=1;
OLED_Show16x16(31,2,0,0); //二
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,125,0);
OLED_Show16x16(61,2,126,0);
OLED_Show16x16(47,4,127,0);
OLED_Show16x16(61,4,128,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 3:led3=1;
led4=1;
led5=0;
OLED_Show16x16(31,2,0,0); //三
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,129,0);
OLED_Show16x16(61,2,130,0);
OLED_Show16x16(47,4,131,0);
OLED_Show16x16(61,4,132,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 4:led3=0;
led4=0;
led5=1;
OLED_Show16x16(31,2,0,0); //四
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,133,0);
OLED_Show16x16(61,2,134,0);
OLED_Show16x16(47,4,135,0);
OLED_Show16x16(61,4,136,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 5:led3=0;
led4=1;
led5=0;
OLED_Show16x16(31,2,0,0); //五
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,2,137,0);
OLED_Show16x16(61,2,138,0);
OLED_Show16x16(47,4,139,0);
OLED_Show16x16(61,4,140,0);
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(77,4,0,0);break;
case 6:led3=1;
led4=1;
led5=1;
OLED_Show16x16(31,2,0,0); //清空
OLED_Show16x16(47,2,0,0);
OLED_Show16x16(31,4,0,0);
OLED_Show16x16(47,4,0,0);
OLED_Show16x16(61,2,0,0); //清空
OLED_Show16x16(77,2,0,0);
OLED_Show16x16(61,4,0,0);
OLED_Show16x16(77,4,0,0);break;
}
}
}
}
void Sys_Init(void)
{
delay_init();
NVIC_Configuration();
uart_init(115200); //串口波特率115200
LED_Init();
OLED_Init();
// printf("OLED OK\r\n");
OLED_Show16x16(14,0,115,0);
OLED_Show16x16(31,0,116,0);
OLED_Show16x16(48,0,117,0);
OLED_Show16x16(65,0,118,0);
OLED_Show16x16(82,0,119,0);
OLED_Show16x16(99,0,120,0);
delay_ms(1000);
OLED_CLS();
while(FDC2214_Init());
led1=0;
delay_ms(100);
temp0 = Cap_Calculate(0);//讀取初始值
temp1 = Cap_Calculate(1);
}
復制代碼
簡單隊.7z
2019-9-6 19:16 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
212.16 KB, 下載次數: 21, 下載積分: 黑幣 -5
作者:
愛電電子
時間:
2020-1-5 18:13
請問樓主實物咋接線
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
a欧美
|
国产精品国产精品国产专区不卡
|
一区二区三区四区不卡
|
手机av在线
|
国产在线看片
|
精品一区二区三区四区五区
|
精品一二
|
精品国产免费一区二区三区五区
|
国内精品久久久久久影视8 最新黄色在线观看
|
www.国产精
|
欧美在线视频网
|
久久亚洲一区二区
|
国产成人精品一区二区三区四区
|
在线精品观看
|
蜜桃av鲁一鲁一鲁一鲁
|
9191在线播放
|
一区二区在线看
|
国产激情精品视频
|
久久精品毛片
|
成人精品久久日伦片大全免费
|
欧美aⅴ片
|
日日噜噜噜夜夜爽爽狠狠视频,
|
成人久久18免费网站麻豆
|
日日夜夜天天
|
亚洲综合电影
|
一区二区三区四区免费在线观看
|
欧美色999
|
影音先锋中文字幕在线观看
|
av播播
|
成人久草
|
免费在线观看一区二区三区
|
久久一区二区av
|
97国产爽爽爽久久久
|
神马九九
|
久久精彩视频
|
狠狠综合久久av一区二区小说
|
国产精品久久久久久
|
成人在线精品视频
|
久久精品国产99国产
|
中文字幕在线免费视频
|
久久精品91久久久久久再现
|