标题: 基于STM32f103c8t6的姿态解算程序(0.96寸OLED屏显示) [打印本页]

作者: ZZZZZ134679    时间: 2023-7-30 16:07
标题: 基于STM32f103c8t6的姿态解算程序(0.96寸OLED屏显示)
接线见源码顶部详述
#include "stm32f10x.h"                 
#include "Delay.h"
#include "OLED.h"
#include "mpu6050.h"
#include "inv_mpu.h"
#include "inv_mpu_dmp_motion_driver.h"

int main (void)
{
        float pitch,roll,yaw;                 //欧拉角
        
        OLED_Init(); //OLED初始化
        OLED_ShowString(1,1,"MPU6050"); OLED_ShowFontString(1,5,0,3);        //“MPU6050姿态检测”
        OLED_ShowFontString(2,1,5,7);   OLED_ShowFont(2,4,14);                        //“俯仰角:”
        OLED_ShowFontString(3,1,8,10);  OLED_ShowFont(3,4,14);                        //“横滚角:”
        OLED_ShowFontString(4,1,11,13); OLED_ShowFont(4,4,14);                        //“航偏角:”
        
        
        while(mpu_dmp_init())        //初始化MPU6050
        {
                Delay_ms(20);
        }
        
        while(1)
        {
                if(mpu_dmp_get_data(&pitch,&roll,&yaw)==0)        //若初始化成功则显示各个角
                {
                        OLED_ShowSignedNum(2,9,pitch,3);OLED_ShowFont(2,7,4);
                        OLED_ShowSignedNum(3,9,roll,3);OLED_ShowFont(3,7,4);
                        OLED_ShowSignedNum(4,9,yaw,3);OLED_ShowFont(4,7,4);
                }
                Delay_ms(20);        //刷新频率
        }
}


原理图:无
程序: 程序.7z (214.11 KB, 下载次数: 28)





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1