mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-14 01:27:41 +00:00
it's only (rock &) roll, but we like it
This commit is contained in:
parent
1cbe268abc
commit
7857c3bcb8
@ -163,6 +163,7 @@
|
||||
glRotatef(rotateX, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(rotateY, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(rotateZ, 0.0f, 0.0f, 1.0f);
|
||||
// glRotatef(1.0f, rotateX, rotateY, rotateZ);
|
||||
#else
|
||||
rota += 1;
|
||||
glRotatef(rota, 0.0, 0.5, 0.0);
|
||||
|
@ -111,15 +111,22 @@ static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
|
||||
ay = h;
|
||||
|
||||
// calc
|
||||
int roll = 0;
|
||||
int roll = atan2(ax, ay) * 180 / M_PI;
|
||||
int pitch = atan2(ay, az) * 180 / M_PI;
|
||||
int theta = 0;
|
||||
|
||||
#if 0
|
||||
if (roll >= 90 || roll <= -90) {
|
||||
pitch = 360 - pitch;
|
||||
}
|
||||
// if ( (++counter & 15) == 0)
|
||||
NSLog(@"BT data: %f %f %f: pitch %i, roll %i, yaw %i", ax , ay ,az, pitch, roll, theta);
|
||||
|
||||
// NSLog(@"BT data: %f %f %f: pitch %i, roll %i, yaw %i", ax , ay ,az, pitch, roll, theta);
|
||||
#endif
|
||||
pitch = 0;
|
||||
|
||||
#if 1
|
||||
static int lastPitch;
|
||||
static int lastRoll;
|
||||
|
||||
if (abs(lastPitch - pitch) > 180) {
|
||||
if (pitch > lastPitch) {
|
||||
@ -128,6 +135,14 @@ static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
|
||||
pitch += 360;
|
||||
}
|
||||
}
|
||||
|
||||
if (abs(lastRoll - roll) > 180) {
|
||||
if (roll > lastRoll) {
|
||||
roll -= 360;
|
||||
} else {
|
||||
roll += 360;
|
||||
}
|
||||
}
|
||||
|
||||
// moving average of size SIZE
|
||||
static int pos = 0;
|
||||
@ -154,9 +169,10 @@ static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
|
||||
theta = theta / SIZE;
|
||||
|
||||
lastPitch = pitch;
|
||||
lastRoll = roll;
|
||||
#endif
|
||||
// hack
|
||||
[[theMainApp glView] setRotationX:(-pitch+90) Y:roll Z:0];
|
||||
[[theMainApp glView] setRotationX:(-pitch) Y:roll Z:0];
|
||||
}
|
||||
|
||||
void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||
|
Loading…
x
Reference in New Issue
Block a user