static void taskPrintXYZ(void *) {
int16_t x, y, z;
printf("* X:%5d, Y:%5d, Z:%5d\n", x, y, z);
} else {
printf("* Gyro is turned off.\n");
}
}
void setup() {
Serial.begin(115200);
Serial.printf("\n*** [nRF52-DK] MMA8452Q 3-axis accelerometer ***\n");
printf(
"* Gyro ODR: 0x%X\n", acc.
getODR());
acc.
setODR(MMA8452Q::ODR_100Hz);
timerPrintXYZ.
onFired(taskPrintXYZ, NULL);
}
Public driver declarations and configuration constants.
MMA8452Q accelerometer register driver with optional interrupt GPIOs. Initialize the I2C bus before b...
Definition MMA8452Q.hpp:50
void begin(TwoWire &wire, uint8_t addr, int8_t pinInt1=-1, int8_t pinInt2=-1)
Bind the bus/address and attach falling-edge interrupt handlers.
void setODR(ODR_t val)
Set the output data rate, temporarily entering standby if needed.
uint8_t readSensorId()
Return the WHO_AM_I register byte.
bool isActive()
Return the ACTIVE bit from the control register.
void readXYZ(int16_t *x, int16_t *y, int16_t *z)
Read and assemble signed axis register values without conversion to g.
void setActive()
Set the ACTIVE bit to enable measurements.
ODR_t getODR()
Return the configured output data rate.
Timer는 일정 시간 이후에 1회 실행될 작업, 매 일정 시간마다 실행될 작업 등을 위한 기능입니다.
Definition Timer.hpp:61
bool startPeriodic(uint32_t millis, bool interrupt=false)
작업함수를 매 millis 밀리초 주기로 반복하여 실행합니다.
void onFired(void(*func)(void *), void *args=nullptr)
타이머 만료시 실행시킬 작업함수를 지정합니다.