share simple codes to learn how a sensor works... #6
Unanswered
VUILLEMINYannick
asked this question in
Q&A
Replies: 1 comment 14 replies
-
Hi Yannick, Here is an example with the accelerometer (or see the related branch🔐) : #include <hwAccelerometer.h>
#include <debug_messages.h>
...
uint32_t last_update;
void BBinit() {
last_update = HAL_GetTick();
}
void BBloop() {
if (HAL_GetTick() > last_update + 1000) {
tAccel accelerometer_data;
refreshXYZ(&accelerometer_data);
uint8_t buffer[50];
sprintf((char *) buffer, "%d %d %d", (uint16_t) accelerometer_data.angleX,
(uint16_t) accelerometer_data.angleY, (uint16_t) accelerometer_data.angleZ);
send_debug_message(buffer, strlen((char *) buffer));
last_update = HAL_GetTick();
}
} Regarding the initial orientation @bignouu and @flassabe already experienced with that and can probably answer. For the microphone, you can use this code to retrieve the data and use conditions on the range of frequencies of your choosing or the ones predefined in the library: #include <speaker.h>
#include <microphone.h>
...
uint16_t lvl = hwMIC_Get_Level();
if (lvl > RE/2 && lvl < DO) {
...
} We usually use the microphone as a "tap" sensor. But the accelerometer chip is indeed technically able to detect vibration, tap, an orientation. Regarding the accessibility of such features from the library @flassabe can probably give a more accurate answer. |
Beta Was this translation helpful? Give feedback.
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have explored the codes in the libraries (*.h) but I can't get the different sensors to work like the microphone or the accelerometer.
Is it possible to share simple codes to understand the syntax of the functions?
For examples :
From what I see I have the impression that it is placed in a way not perpendicular to all the faces is it true?
Thanks for sharing ;-)
Beta Was this translation helpful? Give feedback.
All reactions