標題: 基于STM32f103c8t6的姿態(tài)解算程序(0.96寸OLED屏顯示) [打印本頁]

作者: ZZZZZ134679    時間: 2023-7-30 16:07
標題: 基于STM32f103c8t6的姿態(tài)解算程序(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姿態(tài)檢測”
        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, 下載次數(shù): 28)





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1