test_0429_L3G_ADXL_HMC:11: error: 'Timer' does not name a type
来源:互联网 发布:java开源框架源码解析 编辑:程序博客网 时间:2024/05/06 23:58
Arduino 上使用定时中断,库文件来自Timer.h,把其中的这几个.cpp和.h文件下下来,并放置到library的folder中。
测试的sketch如下:
#include <Wire.h>//#include <HMC5883L.h>#include <ADXL345.h>#include <L3G4200D.h>#include "Event.h"#include "Timer.h"/*Redefine*/L3G4200D GYRO;ADXL345 ACC;Timer task;/*Define*/struct Sensor{ float x; float y; float z; signed long x_sum; signed long y_sum; signed long z_sum; signed short x_offset; signed short y_offset; signed short z_offset;}Gyro,Acc;#define Sensor_offset_times 250#define TRUE 1#define FALSE 0byte Sensor_offset_OK = FALSE;/*Function for initial sensor*/void Sensor_init(void){ GYRO.enableDefault(); //Init GYRO ACC.enableDefault(); //Init ACC}/*Function for update sensor data*/void Sensor_update(void){ GYRO.read(); ACC.read(); if(Sensor_offset_OK){ Gyro.x = GYRO.g.x - Gyro.x_offset; Gyro.y = GYRO.g.y - Gyro.y_offset; Gyro.z = GYRO.g.z - Gyro.z_offset; Acc.x = ACC.a.x - Acc.x_offset; Acc.y = ACC.a.y - Acc.y_offset; Acc.z = ACC.a.z - Acc.z_offset; } else { static int Sensor_offset_count = 0; Gyro.x_sum += GYRO.g.x; Gyro.y_sum += GYRO.g.y; Gyro.z_sum += GYRO.g.z; Acc.x_sum += ACC.a.x; Acc.y_sum += ACC.a.y; Acc.z_sum += ACC.a.z; Sensor_offset_count ++; if(Sensor_offset_count > Sensor_offset_times) { Gyro.x_offset = Gyro.x_sum / 250; Gyro.y_offset = Gyro.y_sum / 250; Gyro.z_offset = Gyro.z_sum / 250; Acc.x_offset = Acc.x_sum / 250; Acc.y_offset = Acc.y_sum / 250; Acc.z_offset = Acc.z_sum / 250; Sensor_offset_OK = TRUE; } }}/*Function for PIT task*/void PIT_5_task(void){ static int PIT_1000_task = 0; Sensor_update();//run every 5 ms ACC.read(); Serial.println(ACC.a.x); /* PIT_1000_task ++; if(PIT_1000_task > 200) { PIT_1000_task = 0; Serial.println(ACC.a.x); } */}/*Function for system setup*/void setup(void){ Serial.begin(19200); Wire.begin(); //start iic This step is very important! //ACC.enableDefault(); Sensor_init(); //MsTimer2::set(5, PIT_5_task); // 500ms period //MsTimer2::start();}void loop(void){ //Serial.println(ACC.a.x); //ACC.read(); //Serial.println(ACC.a.x); delay(100);}
这段代码compiler的时候会出现问题,提示:'Timer' does not name a type
从网上google了很多人的办法都没用,自己就试着改改,我猜是Timer在其他头文件中可能被涉及到了,所以吧Timer的文件全部换个名字,改为Timer3,果然,这个定时中断就通过了。共享~记录~
0 0
- test_0429_L3G_ADXL_HMC:11: error: 'Timer' does not name a type
- error :does not name a type
- error: ‘ptrdiff_t’ does not name a type
- error: 'uid_t' does not name a type
- error: ‘ptrdiff_t’ does not name a type
- error: ‘ptrdiff_t’ does not name a type
- error: 'uint8_t' does not name a type
- error: 'vector' does not name a type
- ERROR:shared_ptr does not name a type
- error: 'vector' does not name a type
- error: '[class name]' does not name a type
- error: ‘string’ does not name a type string name;
- android4.0编译 error: ‘ptrdiff_t’ does not name a type
- C++ - 错误"error: 'off64_t' does not name a type"
- NDK error: 'off_t' does not name a type
- ndk编译错误:error: 'override' does not name a type
- Error: ‘shared_ptr’ in namespace ‘std’ does not name a type
- c++ error: 'map' does not name a type
- 基于C语言的SQLite操作接口函数简介
- 图书销售系统需求规格说明书
- jquery mobile学习笔记——网格布局
- 基于HALCON的模板匹配方法总结
- [codility]MaxProductOfThree
- test_0429_L3G_ADXL_HMC:11: error: 'Timer' does not name a type
- 解决Android与服务器交互大容量数据问题
- C++程序员应聘常见面试题深入剖析
- gcc编译报错:程序中有游离的‘\357’‘\273’‘\277’等
- Problem 15:Lattice paths
- webservice
- c++学习笔记
- 32位64位操作系统基本数据类型字节大小 2014-03-12 09:44
- 梦想