极品馒头泬19p,国产精品亚洲一区二区三区,狠狠色噜噜狠狠狠7777奇米,国产精品视频一区二区三区无码,国产欧美日韩久久久久

【E836】基于美信MAX32660的OLED智能手表設(shè)計(jì)

2021-09-07 14:17:33      索煒達(dá)電子      1012     

項(xiàng)目編號(hào):E836

文件大小:4.1M

源碼說明:帶中文注釋

開發(fā)環(huán)境:C編譯器

簡(jiǎn)要概述

本代碼主要實(shí)現(xiàn)了顯示時(shí)間,以及對(duì)步數(shù)的記錄。順便加了個(gè)小的下位機(jī),用來修改時(shí)間。

【E836】基于美信MAX32660的OLED智能手表設(shè)計(jì)

硬件連接

#define SPI_CS_Pin PIN_12

#define SPI_CS_GPIO_Port PORT_0

#define SPI_DC_Pin PIN_13

#define SPI_DC_GPIO_Port PORT_0

#define SPI_RES_Pin PIN_4

#define SPI_RES_GPIO_Port PORT_0

#define SPI_DIN_Pin PIN_3

#define SPI_DIN_GPIO_Port PORT_0

#define SPI_CLK_Pin PIN_2

#define SPI_CLK_GPIO_Port PORT_0

image-20210216221845791


時(shí)間顯示

這次還是用了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);

其中畫時(shí)鐘的函數(shù)是我之前有用過,參照的是另外一個(gè)up主的內(nèi)容,程序里有提到。具體的使用可以參照我之前的項(xiàng)目


下面源碼,主要用了簡(jiǎn)單的畫圖函數(shù)。



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;


//時(shí)針

SetRotateValue(center_pos.x,center_pos.y,hours*30+(minute*30)/60+clock_angle,1); //設(shè)定旋轉(zhuǎn)中心,旋轉(zhuǎn)角度,旋轉(zhuǎn)方向

hourspoint=GetRotateXY(center_pos.x,center_pos.y-CLOCK_R+12);         //給出一個(gè)不在中心的點(diǎn),計(jì)算出其旋轉(zhuǎn)后的坐標(biāo)

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);

}

// /*表盤上的數(shù)字*/

// 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);//中心圓點(diǎn)

DrawCircle(center_pos.x,center_pos.y,CLOCK_R);

UpdateScreen();

ClearScreen();

}

步數(shù)記錄

代碼設(shè)計(jì)過程參考了CSDN上的一篇博客


前面是一些基本的濾波以及求峰值,后面才是計(jì)算是否走步。



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: {

//fix

break;

}

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;

}

}

簡(jiǎn)易下位機(jī)

參照我之前的項(xiàng)目,這次的下位機(jī)更加簡(jiǎn)單,沒有頭文件和結(jié)束語句,原因是max的串口我用的不是很明白,所以簡(jiǎn)化了



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;

       

        }

    }

}

上位機(jī)

也是和之前一樣用的python編寫


#-*- coding: UTF-8 -*- 


import serial # pyserial

import datetime


try:

    # 端口:CNU; Linux上的/dev /ttyUSB0等; windows上的COM3等

    portx = "COM3"


    # 波特率,標(biāo)準(zhǔn)值有:50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400,57600,115200

    bps = 115200


    # 超時(shí)設(shè)置,None:永遠(yuǎn)等待操作;

    #         0:立即返回請(qǐng)求結(jié)果;

    #        其他:等待超時(shí)時(shí)間(單位為秒)

    timex = 5


    # 打開串口,并得到串口對(duì)象

    ser = serial.Serial(portx, bps, timeout=timex)


    # 寫數(shù)據(jù)

    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() # 關(guān)閉串口


except Exception as e:

    print("error!", e)


程序流圖以及各個(gè)模塊

【E836】基于美信MAX32660的OLED智能手表設(shè)計(jì)

模塊關(guān)系圖:

【E836】基于美信MAX32660的OLED智能手表設(shè)計(jì)

目錄│文件列表:

 └ max32660_-oled

    │ image-20210216221845791.png

    │ 上位機(jī).py

    └ maxim32660

       │ ~$$邏輯關(guān)系系統(tǒng)框圖‘.~vsdx

       │ 開發(fā)流程.md

       │ 文案.md

       │ 流程圖.vsdx

       │ 流程圖v1.1.png

       │ 邏輯關(guān)系系統(tǒng)框圖.png

       │ 邏輯關(guān)系系統(tǒng)框圖‘.vsdx

       └ maxim32660

          │ GPIO_my.c

          │ GPIO_my.h

          │ I2C_my.c

          │ I2C_my.h

          │ include.h

          │ main.c

          │ TIM_my.c

          │ TIM_my.h

          │ uart_my.c

          │ uart_my.h

          ├ ARM

          │  │ Abstract.txt

          │  │ GPIO.uvguix.張辰

          │  │ GPIO.uvoptx

          │  │ GPIO.uvprojx

          │  ├ Listings

          │  │  │ GPIO_Demo.map

          │  │  └ startup_max32660.lst

          │  ├ Objects

          │  │  │ board.crf

          │  │  │ board.d

          │  │  │ board.o

          │  │  │ clock.crf

          │  │  │ clock.d

          │  │  │ clock.o

          │  │  │ flc.crf

          │  │  │ flc.d

          │  │  │ flc.o

          │  │  │ gpio.crf

          │  │  │ gpio.d

          │  │  │ gpio.o

          │  │  │ gpio_1.crf

          │  │  │ gpio_1.d

          │  │  │ gpio_1.o

          │  │  │ GPIO_Debug.dep

          │  │  │ GPIO_Demo.axf

          │  │  │ GPIO_Demo.build_log.htm

          │  │  │ GPIO_Demo.hex

          │  │  │ GPIO_Demo.htm

          │  │  │ GPIO_Demo.lnp

          │  │  │ GPIO_Demo.sct

          │  │  │ gpio_my.crf

          │  │  │ gpio_my.d

          │  │  │ gpio_my.o

          │  │  │ i2c.crf

          │  │  │ i2c.d

          │  │  │ i2c.o

          │  │  │ i2c_1.crf

          │  │  │ i2c_1.d

          │  │  │ i2c_1.o

          │  │  │ i2c_my.crf

          │  │  │ i2c_my.d

          │  │  │ i2c_my.o

          │  │  │ icc.crf

          │  │  │ icc.d

          │  │  │ icc.o

          │  │  │ led.crf

          │  │  │ led.d

          │  │  │ led.o

          │  │  │ lp.crf

          │  │  │ lp.d

          │  │  │ lp.o

          │  │  │ main.crf

          │  │  │ main.d

          │  │  │ main.o

          │  │  │ mpu6050.crf

          │  │  │ mpu6050.d

          │  │  │ mpu6050.o

          │  │  │ mxc_assert.crf

          │  │  │ mxc_assert.d

          │  │  │ mxc_assert.o

          │  │  │ mxc_delay.crf

          │  │  │ mxc_delay.d

          │  │  │ mxc_delay.o

          │  │  │ mxc_lock.crf

          │  │  │ mxc_lock.d

          │  │  │ mxc_lock.o

          │  │  │ mxc_pins.crf

          │  │  │ mxc_pins.d

          │  │  │ mxc_pins.o

          │  │  │ mxc_sys.crf

          │  │  │ mxc_sys.d

          │  │  │ mxc_sys.o

          │  │  │ nvic_table.crf

          │  │  │ nvic_table.d

          │  │  │ nvic_table.o

          │  │  │ oled_basic.crf

          │  │  │ oled_basic.d

          │  │  │ oled_basic.o

          │  │  │ oled_bmp.crf

          │  │  │ oled_bmp.d

          │  │  │ oled_bmp.o

          │  │  │ oled_buffer.crf

          │  │  │ oled_buffer.d

          │  │  │ oled_buffer.o

          │  │  │ oled_color.crf

          │  │  │ oled_color.d

          │  │  │ oled_color.o

          │  │  │ oled_config.crf

          │  │  │ oled_config.d

          │  │  │ oled_config.o

          │  │  │ oled_debug.crf

          │  │  │ oled_debug.d

          │  │  │ oled_debug.o

          │  │  │ oled_draw.crf

          │  │  │ oled_draw.d

          │  │  │ oled_draw.o

          │  │  │ oled_driver.crf

          │  │  │ oled_driver.d

          │  │  │ oled_driver.o

          │  │  │ oled_font.crf

          │  │  │ oled_font.d

          │  │  │ oled_font.o

          │  │  │ pb.crf

          │  │  │ pb.d

          │  │  │ pb.o

          │  │  │ rtc.crf

          │  │  │ rtc.d

          │  │  │ rtc.o

          │  │  │ spi.crf

          │  │  │ spi.d

          │  │  │ spi.o

          │  │  │ spi17y.crf

          │  │  │ spi17y.d

          │  │  │ spi17y.o

          │  │  │ spimss.crf

          │  │  │ spimss.d

          │  │  │ spimss.o

          │  │  │ startup_max32660.d

          │  │  │ startup_max32660.o

          │  │  │ stdio.crf

          │  │  │ stdio.d

          │  │  │ stdio.o

          │  │  │ system_max32660.crf

          │  │  │ system_max32660.d

          │  │  │ system_max32660.o

          │  │  │ tim_my.crf

          │  │  │ tim_my.d

          │  │  │ tim_my.o

          │  │  │ tmr.crf

          │  │  │ tmr.d

          │  │  │ tmr.o

          │  │  │ tmr_utils.crf

          │  │  │ tmr_utils.d

          │  │  │ tmr_utils.o

          │  │  │ tracer_api.crf

          │  │  │ tracer_api.d

          │  │  │ tracer_api.o

          │  │  │ uart.crf

          │  │  │ uart.d

          │  │  │ uart.o

          │  │  │ uart_my.crf

          │  │  │ uart_my.d

          │  │  └ uart_my.o

          │  └ RTE

          │     ├ Device

          │     │  └ MAX32660

          │     │     │ mxc_config.h

          │     │     │ startup_max32660.s

          │     │     └ system_max32660.c

          │     └ _Debug

          │        └ RTE_Components.h

          ├ CLOCK

          │  │ CLOCK.c

          │  └ CLOCK.h

          ├ IAR

          │  │ GPIO.ewd

          │  └ GPIO.ewp

          ├ MPU6050

          │  │ mpu6050.c

          │  │ mpu6050.c.orig

          │  │ mpu6050.h

          │  └ eMPL

          │     │ dmpKey.h

          │     │ dmpmap.h

TAGMAX32660
  • 2 次
  • 1 分