【max32660】简易智能手表说明文档

news/2025/3/6 2:10:03/

说明文档

文章目录

  • 说明文档
    • 时间显示
    • 步数记录
    • 简易下位机
      • 上位机

项目地址

本代码主要实现了显示时间,以及对步数的记录。顺便加了个小的下位机,用来修改时间。

时间显示

这次还是用了OLED的文字库,用到了显示文字,和画图功能。

DrawNum(0,0,step_cnt,5);SetFontSize(3);DrawChar(30,24,':');DrawNum(0,24,hour,2);DrawNum(42,24,min,2);fresh_g();RoundClock(hour,min,sec);

其中画时钟的函数是我之前有用过,参照的是另外一个up主的内容,程序里有提到。具体的使用可以参照我之前的项目

下面源码,主要用了简单的画图函数。


void RoundClock(int hours ,int minute ,int sec)
{unsigned char i=0;TypeXY hourspoint,minutepoint,secpoint,tmp1,tmp2;center_pos.x = 104;center_pos.y = 39;//时针SetRotateValue(center_pos.x,center_pos.y,hours*30+(minute*30)/60+clock_angle,1); //设定旋转中心,旋转角度,旋转方向hourspoint=GetRotateXY(center_pos.x,center_pos.y-CLOCK_R+12);         //给出一个不在中心的点,计算出其旋转后的坐标DrawLine(center_pos.x,center_pos.y,hourspoint.x,hourspoint.y);//画线//分针SetRotateValue(center_pos.x,center_pos.y,minute*6+(sec*6)/60+clock_angle,1);minutepoint=GetRotateXY(center_pos.x,center_pos.y-CLOCK_R+6);DrawLine(center_pos.x,center_pos.y,minutepoint.x,minutepoint.y);	//秒针SetRotateValue(center_pos.x,center_pos.y,sec*6+clock_angle,1);secpoint=GetRotateXY(center_pos.x,center_pos.y-CLOCK_R+2);DrawLine(center_pos.x,center_pos.y,secpoint.x,secpoint.y);//表盘for(i=0;i<12;i++){SetRotateValue(center_pos.x,center_pos.y,i*30+clock_angle,1);tmp1=GetRotateXY(center_pos.x,center_pos.y-CLOCK_R+1);tmp2=GetRotateXY(center_pos.x,center_pos.y-CLOCK_R+1+CLOCK_LEN);DrawLine(tmp1.x,tmp1.y,tmp2.x,tmp2.y);}
//		/*表盘上的数字*/
//		SetRotateValue(60,30,i*30+clock_angle,1);
//		if(i==0)
//		{
//			tmp3=GetRotateXY(center_pos.x,center_pos.y-num_pos);
//			SetFontSize(1);
//			DrawNum(tmp3.x,tmp3.y,12,2);
//		}
//		else if(i<7)
//		{
//			SetRotateValue(62,29,i*30+clock_angle,1);
//			tmp3=GetRotateXY(center_pos.x,center_pos.y-num_pos);
//			SetFontSize(1);
//			DrawNum(tmp3.x,tmp3.y,i,1);
//		}
//		else if(i<10)
//		{
//			tmp3=GetRotateXY(center_pos.x,center_pos.y-num_pos);
//			SetFontSize(1);
//			DrawNum(tmp3.x,tmp3.y,i,1);
//		}
//		else if(i<12)
//		{
//			tmp3=GetRotateXY(center_pos.x,center_pos.y-num_pos);
//			SetFontSize(1);
//			DrawNum(tmp3.x,tmp3.y,i,2);
//		}
//	}DrawFillCircle(center_pos.x,center_pos.y,2);//中心圆点DrawCircle(center_pos.x,center_pos.y,CLOCK_R);UpdateScreen();ClearScreen();
}

步数记录

代码设计过程参考了CSDN上的一篇博客

前面是一些基本的滤波以及求峰值,后面才是计算是否走步。

filter_acc();peak_caculate();slid_update(&temp_acc,&mpu);detect_step(&peak_acc,&temp_acc,&mpu);

下面是判断是否走步的代码:


void detect_step(peak_info *peak, slid_reg_t *slid, axis_info *cur_sample)
{char res = is_most_active(peak);switch (res) {case MOST_ACTIVE_NULL: {//fixbreak;}case MOST_ACTIVE_X: {short threshold_x = (peak->max_x + peak->min_x) / 2;if (slid->old_sample.acc_x > threshold_x && slid->new_sample.acc_x < threshold_x) {step_cnt ++;}break;}case MOST_ACTIVE_Y: {short threshold_y = (peak->max_y + peak->min_y) / 2;if (slid->old_sample.acc_y > threshold_y && slid->new_sample.acc_y < threshold_y) {step_cnt ++;}break;}case MOST_ACTIVE_Z: {short threshold_z = (peak->max_z + peak->min_z) / 2;if (slid->old_sample.acc_z > threshold_z && slid->new_sample.acc_z < threshold_z) {step_cnt ++;}break;}default: break;}
}

简易下位机

参照我之前的项目,这次的下位机更加简单,没有头文件和结束语句,原因是max的串口我用的不是很明白,所以简化了


void fresh_s_time(char *temp)
{while(*temp != '\0'){switch(*temp++){case 'h':hour = (*temp-'0')*10 + (*(temp+1)-'0');temp+=2;break;case 'm':min = (*temp-'0')*10 + (*(temp+1)-'0');temp+=2;break;case 's':sec = (*temp-'0')*10 + (*(temp+1)-'0');temp+=2;break;}}
}

上位机

也是和之前一样用的python编写

#-*- coding: UTF-8 -*- import serial # pyserial
import datetimetry:# 端口:CNU; Linux上的/dev /ttyUSB0等; windows上的COM3等portx = "COM3"# 波特率,标准值有:50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400,57600,115200bps = 115200# 超时设置,None:永远等待操作;#         0:立即返回请求结果;#        其他:等待超时时间(单位为秒)timex = 5# 打开串口,并得到串口对象ser = serial.Serial(portx, bps, timeout=timex)# 写数据curr_time = datetime.datetime.now()result = ser.write(datetime.datetime.strftime(curr_time,'h%Hm%Ms%S').encode("gbk"))result = ser.write(datetime.datetime.strftime(curr_time,'s%S').encode("gbk"))ser.close() # 关闭串口except Exception as e:print("error!", e)

curr_time,‘h%Hm%Ms%S’).encode(“gbk”))

result = ser.write(datetime.datetime.strftime(curr_time,'s%S').encode("gbk"))ser.close() # 关闭串口

except Exception as e:
print(“error!”, e)



http://www.ppmy.cn/news/732029.html

相关文章

BPM流程引擎适用于哪些类型企业管理系统

看到标题的童鞋们&#xff0c;估计在搜索办公软件系统时都会留意到BPM&#xff0c;那BPM到底是何方神圣&#xff1f;它与管理系统有什么区别呢&#xff1f;今天我们一一解答。 什么是BPM&#xff1f; BPM&#xff08;即业务流程管理&#xff09;&#xff0c;是企业信息化发展的…

如何用wireshark查看snmpv3报文

编辑->首选项 Protocols 选择SNMP协议&#xff0c;点击编辑 填写账号 加密方式 密码 加密方式 密码 加密的数据可以看见了

Python绘制多条折线图对比

数据 target 20.74 reals [(1,10.684),(3,13.433),(5,14.727),(9,15.671),(15,16.678),(17,17.617),(19,17.402)]我们这里要把这两个数据画在一个这线图里&#xff0c;要求如下&#xff1a; 1.用折线图画在一起&#xff0c;target只需要画一条横线就行&#xff0c;reals每个…

ModaHub魔搭社区:Zilliz Cloud 数据迁移,数据的备份和恢复

目录 01.从 Milvus 到 Zilliz Cloud&#xff0c;轻点鼠标即可实现无缝迁移 02.掌握数据库的备份和恢复&#xff0c;让明天没有意外 01. 从 Milvus 到 Zilliz Cloud&#xff0c;轻点鼠标即可实现无缝迁移 越来越多的用户选择将数据从 Milvus 迁移至 Zilliz Cloud&#xff0c;通…

mac云显卡服务器_重磅!NVIDIA GeForce NOW登陆Mac:云显卡玩吃鸡逆天

未来&#xff0c;只要网络足够好&#xff0c;想玩游戏大作&#xff0c;自己有没有一块顶级显卡&#xff0c;似乎已经不重要了。 近日&#xff0c;NVIDIA宣布&#xff0c;旗下最新的GeForce Now云端游戏服务正式登陆Mac平台&#xff0c;提供Beta版下载。该服务于今年1月份CES消费…

mac云显卡服务器_用苹果Mac也能吃鸡啦!NVIDIA推出云端显卡登陆Mac

用苹果Mac也能吃鸡啦&#xff01;NVIDIA推出云端显卡登陆Mac 2017年10月23日 07:33作者&#xff1a;宋阳编辑&#xff1a;宋阳文章出处&#xff1a;泡泡网原创 分享 对于Mac用户来说&#xff0c;想畅快的玩款大型游戏一直是一个痛点&#xff0c;因为做不到&#xff0c;苹果Mac定…

mac云显卡服务器_NVIDIA GeForce Now登陆Mac:云显卡玩吃鸡

来源&#xff1a;小黑盒 众所周知&#xff0c;苹果Mac是办公、生产力利器&#xff0c;但玩游戏并非强项。一是没有专门对一些游戏大作优化&#xff0c;二是没有足够强大的显卡支持。 NVIDIA最新推出的GeForce Now就是专门为解决这一痛点而研发的。唯一的要求就是你的网络足够好…

mac云显卡服务器_云显卡玩吃鸡逆天!NVIDIA_GeForce_NOW登陆Mac

相信不少人都有这样的经历&#xff0c;大学时代花费了不少时间在玩游戏上面&#xff0c;而一款好的笔记本对于游戏也是很重要的&#xff0c;那么有什么大学生笔记本电脑推荐吗&#xff1f;还有&#xff0c;都说玩游戏需要一块好的显卡&#xff0c;但是在以后&#xff0c;想玩游…