8000 Add DA217 sensor. · neurodavid/CubeCell-Arduino@e60b066 · GitHub
[go: up one dir, main page]

Skip to content

Commit e60b066

Browse files
committed
Add DA217 sensor.
Add DA217 sensor.
1 parent ee272cf commit e60b066

File tree

5 files changed

+731
-2
lines changed

5 files changed

+731
-2
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
3+
#include "Arduino.h"
4+
#include "da217.h"
5+
6+
#define INT1_PIN GPIO0
7+
#define INT2_PIN GPIO1
8+
bool da217_int1_flag,da217_int2_flag;
9+
10+
DA217 da217;
11+
uint16_t step_num;
12+
da217_step_status_t step_status;
13+
14+
15+
void da217_int1_isr(void)
16+
{
17+
da217_int1_flag =true;
18+
}
19+
void da217_int2_isr(void)
20+
{
21+
da217_int2_flag =true;
22+
}
23+
24+
void setup()
25+
{
26+
Serial.begin(115200);
27+
PINMODE_INPUT_PULLDOWN(INT1_PIN);
28+
PINMODE_INPUT_PULLDOWN(INT2_PIN);
29+
attachInterrupt(INT1_PIN, da217_int1_isr, RISING);
30+
attachInterrupt(INT2_PIN, da217_int2_isr, RISING);
31+
pinMode(Vext,OUTPUT);
32+
digitalWrite(Vext,LOW);//set vext to high
33+
da217.da217_init();
34+
da217.da217_start_up_step_detect(true,true,5);
35+
}
36+
37+
38+
void loop()
39+
{
40+
step_num = da217.da217_read_steps();
41+
step_status = da217.da217_read_step_status();
42+
Serial.printf("step_num = %d step_status =%d\r\n",step_num,step_status);
43+
if( da217_int1_flag )
44+
{
45+
Serial.println("da217_int1_flag");
46+
da217_int1_flag = false;
47+
}
48+
if(da217_int2_flag)
49+
{
50+
Serial.println("da217_int2_flag");
51+
da217_int2_flag = false;
52+
}
53+
delay(3000);
54+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
3+
#include "Arduino.h"
4+
#include "da217.h"
5+
6+
7+
DA217 da217;
8+
uint16_t step_num;
9+
uint16_t x_data,y_data,z_data;
10+
void setup()
11+
{
12+
Serial.begin(115200);
13+
pinMode(Vext,OUTPUT);
14+
digitalWrite(Vext,LOW);//set vext to high
15+
da217.da217_init();
16+
da217.da217_set_odr_rate(DA217_ODR_500HZ);
17+
da217.da217_set_fifo_mode(FIFO_MODE_FIFO);
18+
da217.da217_set_full_scale(FS_FULL_SCALE_2g);
19+
da217.da217_set_resolution(RESOLUTION_14_BIT);
20+
da217.da217_start_xyz_axis(true,true,true);
21+
}
22+
23+
24+
void loop()
25+
{
26+
da217.da217_read_xyz_data(&x_data,&y_data,&z_data);
27+
Serial.printf("x_data=%d y_data=%d z_data=%d\r\n",x_data,y_data,z_data);
28+
delay(3000);
29+
}

libraries/SensorBasic/examples/MultiSensorAutoRecognize/MultiSensorAutoRecognize.ino

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@
2626
#include "HDC1080.h"
2727
#include <MPU9250.h>
2828
#include <CCS811.h>
29+
#include "da217.h"
2930

3031
BH1750 lightMeter;
3132
BMP085 bmp;
3233
HDC1080 hdc1080;
3334
MPU9250 mySensor;
3435
CCS811 ccs;
35-
36+
DA217 da217;
3637
byte address;
3738
float aX, aY, aZ, aSqrt, gX, gY, gZ, mDirection, mX, mY, mZ;
39+
uint16_t x_data,y_data,z_data;
3840

3941
void I2C_Scan()
4042
{
@@ -97,11 +99,20 @@ void setup()
9799

98100
switch(address)
99101
{
102+
case 0x27:
103+
{
104+
da217.da217_init();
105+
da217.da217_set_odr_rate(DA217_ODR_500HZ);
106+
da217.da217_set_fifo_mode(FIFO_MODE_FIFO);
107+
da217.da217_set_full_scale(FS_FULL_SCALE_2g);
108+
da217.da217_set_resolution(RESOLUTION_14_BIT);
109+
da217.da217_start_xyz_axis(true,true,true);
110+
break;
111+
}
100112
case 35: //0x23 -- BH1750 light sensor
101113
{
102114
lightMeter.begin();
103115
Serial.println(F("BH1750 Test begin"));
104-
105116
break;
106117
}
107118

@@ -159,6 +170,12 @@ void loop()
159170
{
160171
switch(address)
161172
{
173+
case 0x27:
174+
{
175+
da217.da217_read_xyz_data(&x_data,&y_data,&z_data);
176+
Serial.printf("x_data=%d y_data=%d z_data=%d\r\n",x_data,y_data,z_data);
177+
break;
178+
}
162179
case 35: //0x23 -- BH1750 light sensor
163180
{
164181
float lux = lightMeter.readLightLevel();

0 commit comments

Comments
 (0)
0