add dlpf option to ino
This commit is contained in:
parent
f6fcd8c3cd
commit
84ebc9826a
1 changed files with 12 additions and 5 deletions
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <Wire.h>
|
||||
|
||||
#define ENABLE_LPF false
|
||||
#define addr 0x68
|
||||
|
||||
#define FIFO_EN 0x23
|
||||
|
|
@ -27,6 +28,7 @@
|
|||
#define PWR_MGMT_1 0x6B
|
||||
#define FIFO_COUNTH 0x72
|
||||
#define FIFO_COUNTL 0x73
|
||||
#define CONFIG 0x1A
|
||||
#define SETREG(REG, VAL) Wire.beginTransmission(addr); Wire.write(REG); Wire.write(VAL); Wire.endTransmission(true);
|
||||
|
||||
void setup() {
|
||||
|
|
@ -40,17 +42,22 @@ void setup() {
|
|||
|
||||
Serial.begin(8000000); // be fast. we are transmitting csv which is inefficient as fuck
|
||||
|
||||
delay(3000);
|
||||
delay(2000);
|
||||
SETREG(PWR_MGMT_1, 0b10000000); // reset
|
||||
delay(200);
|
||||
delay(500);
|
||||
SETREG(USER_CTRL, 0b00000100); // reset fifo
|
||||
delay(100);
|
||||
SETREG(ACCEL_CONFIG, 0b00000000); // +-2g
|
||||
SETREG(PWR_MGMT_1, 0); // all on
|
||||
SETREG(SMPRT_DIV, 7); // 8kHz / (1 + 7) = 1kHz
|
||||
SETREG(ACCEL_CONFIG, 0b00000000); // +-2g
|
||||
if (ENABLE_LPF) {
|
||||
SETREG(CONFIG, 6); // DLPF strength 2
|
||||
} else {
|
||||
SETREG(SMPRT_DIV, 7); // 8kHz / (1 + 7) = 1kHz
|
||||
}
|
||||
delay(1000);
|
||||
SETREG(FIFO_EN, 0b00001000); // only accel bit
|
||||
SETREG(USER_CTRL, 0b01000000); // only FIFO_EN bit
|
||||
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
Wire.setClock(2500000);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue