mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 07:43:38 +00:00
try again with WiiMote accel value. Pitch working correctly
This commit is contained in:
parent
998c32acab
commit
1cbe268abc
9
TODO.txt
9
TODO.txt
@ -2,11 +2,18 @@
|
|||||||
|
|
||||||
NEXT:
|
NEXT:
|
||||||
- WiiMote Demo
|
- WiiMote Demo
|
||||||
- upside down is not shown correctly
|
- implement roll
|
||||||
|
- video for YouTube
|
||||||
|
|
||||||
- check/fix BTstack for iPhone 2G
|
- check/fix BTstack for iPhone 2G
|
||||||
|
|
||||||
- figure out how to add BTstack logo to Cydia repository list
|
- figure out how to add BTstack logo to Cydia repository list
|
||||||
- sign BTstack repository
|
- sign BTstack repository
|
||||||
|
|
||||||
|
- add news coverage on wiki
|
||||||
|
- release notes (features and limits)
|
||||||
|
- install instructions with Cydia usage screenshots
|
||||||
|
|
||||||
== Release Version 0.1
|
== Release Version 0.1
|
||||||
|
|
||||||
- figure out how to receive iPhone System Power IONotifications (in BTdaemon) to detect,
|
- figure out how to receive iPhone System Power IONotifications (in BTdaemon) to detect,
|
||||||
|
@ -67,9 +67,9 @@ static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
|
|||||||
float az = z - 128;
|
float az = z - 128;
|
||||||
|
|
||||||
// mini calib
|
// mini calib
|
||||||
az /= 2;
|
// az /= 2;
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
// normalize vector
|
// normalize vector
|
||||||
float length = sqrt( ax*ax + ay*ay + az*az);
|
float length = sqrt( ax*ax + ay*ay + az*az);
|
||||||
ax /= length;
|
ax /= length;
|
||||||
@ -77,6 +77,7 @@ static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
|
|||||||
az /= length;
|
az /= length;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
// cross product between A and (0,0,1)
|
// cross product between A and (0,0,1)
|
||||||
float crossX = ay;
|
float crossX = ay;
|
||||||
float crossY = -ax;
|
float crossY = -ax;
|
||||||
@ -94,7 +95,7 @@ static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
|
|||||||
int pitch = atan2( 2*(omega*crossX), omega*omega - crossX*crossX - crossY*crossY)* 180 / M_PI;
|
int pitch = atan2( 2*(omega*crossX), omega*omega - crossX*crossX - crossY*crossY)* 180 / M_PI;
|
||||||
int roll = atan2( 2*(crossX * crossY), omega*omega + crossX*crossX - crossY*crossY) * 180 / M_PI;
|
int roll = atan2( 2*(crossX * crossY), omega*omega + crossX*crossX - crossY*crossY) * 180 / M_PI;
|
||||||
int theta = 0;
|
int theta = 0;
|
||||||
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
int roll = atan2(ax, sqrt(ay*ay+az*az)) * 180 / M_PI;
|
int roll = atan2(ax, sqrt(ay*ay+az*az)) * 180 / M_PI;
|
||||||
int pitch = atan2(ay, sqrt(ax*ax+az*az)) * 180 / M_PI;
|
int pitch = atan2(ay, sqrt(ax*ax+az*az)) * 180 / M_PI;
|
||||||
@ -104,16 +105,37 @@ static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (++counter & 15) == 0)
|
// sort axes
|
||||||
|
float h = az;
|
||||||
|
az = -ay;
|
||||||
|
ay = h;
|
||||||
|
|
||||||
|
// calc
|
||||||
|
int roll = 0;
|
||||||
|
int pitch = atan2(ay, az) * 180 / M_PI;
|
||||||
|
int theta = 0;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
static int lastPitch;
|
||||||
|
|
||||||
|
if (abs(lastPitch - pitch) > 180) {
|
||||||
|
if (pitch > lastPitch) {
|
||||||
|
pitch -= 360;
|
||||||
|
} else {
|
||||||
|
pitch += 360;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// moving average of size SIZE
|
// moving average of size SIZE
|
||||||
static int pos = 0;
|
static int pos = 0;
|
||||||
static int historyRoll[SIZE];
|
static int historyRoll[SIZE];
|
||||||
static int historyPitch[SIZE];
|
static int historyPitch[SIZE];
|
||||||
static int historyTheta[SIZE];
|
static int historyTheta[SIZE];
|
||||||
|
|
||||||
|
|
||||||
historyRoll[pos] = roll;
|
historyRoll[pos] = roll;
|
||||||
historyPitch[pos] = pitch;
|
historyPitch[pos] = pitch;
|
||||||
historyTheta[pos] = theta;
|
historyTheta[pos] = theta;
|
||||||
@ -130,8 +152,11 @@ static void bt_data_cb(uint8_t x, uint8_t y, uint8_t z){
|
|||||||
roll = roll / SIZE;
|
roll = roll / SIZE;
|
||||||
pitch = pitch / SIZE;
|
pitch = pitch / SIZE;
|
||||||
theta = theta / SIZE;
|
theta = theta / SIZE;
|
||||||
|
|
||||||
|
lastPitch = pitch;
|
||||||
#endif
|
#endif
|
||||||
[[theMainApp glView] setRotationX:-pitch Y:roll Z:0];
|
// hack
|
||||||
|
[[theMainApp glView] setRotationX:(-pitch+90) Y:roll Z:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
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