So jetzt Funktioniert es so wie es soll:
Code:
' Wii-Motion-Plus for Bascom
'
' Here I´ve found nearly everything I needed for it:
' http://www.windmeadow.com/node/42
' http://randomhacksofboredom.blogspot...uino-love.html
' http://wiibrew.org/wiki/Wiimote/Exte...ii_Motion_Plus
' https://www.roboternetz.de/phpBB2/vi...c.php?p=389190
'
$regfile = "M8def.dat" ' Mega8
$crystal = 14745600 ' 14.745600 MHz
$baud = 9600 ' Baud 9600
$lib "I2C_TWI.LBX"
Config Scl = Portc.5 ' Ports for I2C-Bus
Config Sda = Portc.4
Config Twi = 100000
I2cinit
Dim Buffer(6) As Byte
On Ovf1 Ontimer
Timsk.toie1 = 1
Tccr1a = &B00000000
Tccr1b = &B00000010
Enable Interrupts
Dim Yaw As Word
Dim Yaw0 As Byte At Yaw + 1 Overlay
Dim Yaw1 As Byte At Yaw Overlay
Dim Roll As Word
Dim Roll0 As Byte At Roll + 1 Overlay
Dim Roll1 As Byte At Roll Overlay
Dim Pitch As Word
Dim Pitch0 As Byte At Pitch + 1 Overlay
Dim Pitch1 As Byte At Pitch Overlay
Gosub Wmp_init
Waitms 1000
Do
Loop
Ontimer:
Timer1 = 28672 '~50 Hz
Gosub Read_data
Printbin Yaw '
Printbin Roll ' Output
Printbin Pitch
Return
Wmp_init:
I2cstart
I2cwbyte &HA6 ' sends memory address
I2cwbyte &HFE ' WM+ activation
I2cwbyte &H04 . ' Now Adress changes to &HA4
I2cstop
Return
Send_zero:
I2cstart
I2cwbyte &HA4 ' sends memory address
I2cwbyte &H00 ' sends zero before receiving
I2cstop
Waitms 1
Return
Read_data:
Gosub Send_zero ' sends zero before receiving
I2creceive &HA4 , Buffer(1) , 0 , 6 ' receive 6 bytes
Yaw1 = Buffer(1)
Roll1 = Buffer(2) ' Low Bytes
Pitch1 = Buffer(3)
Shift Buffer(4) , Right , 2 : Yaw0 = Buffer(4)
Shift Buffer(5) , Right , 2 : Roll0 = Buffer(5) ' High Bytes
Shift Buffer(6) , Right , 2 : Pitch0 = Buffer(6)
Return
Ich hatte auch noch versucht das Nunchuk zu aktivieren, aber dazu muss man offenischtlich die Wii Motion Plus zuvor noch deaktivieren und das hat jetzt noch nicht funktioniert:
Danke nochmal für die Hilfe
Lesezeichen