Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 9:899168e14871, committed 2022-04-12
- Comitter:
- DarkFlame
- Date:
- Tue Apr 12 00:39:26 2022 +0000
- Parent:
- 8:4908ba252e9d
- Commit message:
- fit os6.
Changed in this revision
| JY901.cpp | Show annotated file Show diff for this revision Revisions of this file |
| JY901.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/JY901.cpp Fri Apr 23 09:00:33 2021 +0000
+++ b/JY901.cpp Tue Apr 12 00:39:26 2022 +0000
@@ -12,13 +12,13 @@
for(int i = 0; i < 3; i++) gyroZ[i] = 0;
_timer->start();
last_time = 0;
- time = _timer->read();
+ this->time = duration_cast<std::chrono::milliseconds>(_timer->elapsed_time()).count()*1e-3;
}
float JY901::calculateAngleOnlyGyro()
{
last_time = time;
- time = _timer->read();
+ this->time = duration_cast<std::chrono::milliseconds>(_timer->elapsed_time()).count()*1e-3;
for(int i = 2; i > 0; i--)
{
gyroZ[i] = gyroZ[i-1];
@@ -32,7 +32,7 @@
void JY901::reset()
{
- time = _timer->read();
+ this->time = duration_cast<std::chrono::milliseconds>(_timer->elapsed_time()).count()*1e-3;
for(int i = 0; i > 2; i++)
{
gyroZ[i] = 0;
--- a/JY901.h Fri Apr 23 09:00:33 2021 +0000
+++ b/JY901.h Tue Apr 12 00:39:26 2022 +0000
@@ -4,11 +4,17 @@
#include "SoftI2C.h"
#include "mbed.h"
-/*example*************************************
+/*
+JY901
+
+
+・使用例
+==========================================
#include "mbed.h"
-#include "JY901.h"
+#include "JY901_OS6.h"
I2C myi2c(p28, p27);
+SoftI2C
JY901 jy901(&myi2c);
int main()
@@ -18,10 +24,11 @@
while(1)
{
angle = jy901.getZaxisAngle();
- printf("%f\r\n", angle);
+ printf("%d\r\n", angle);
}
}
-**********************************************/
+==========================================
+*/
#define IICADDR 0xa0 // IIC address
#define g 9.80665 // Acceleration of gravity
@@ -147,6 +154,7 @@
/*************************************/
private:
+
char *getdata(char registar);
float s16(int dataL, int dataH);