mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Moved things around and change a couple of names
This commit is contained in:
parent
3acafa2634
commit
1cb937b2a1
2 changed files with 44 additions and 40 deletions
40
Wii.cpp
40
Wii.cpp
|
@ -914,15 +914,15 @@ uint8_t WII::getAnalogHat(AnalogHat a) {
|
|||
|
||||
#ifdef WIICAMERA
|
||||
|
||||
void WII::IRinitialize(){ //Turns on and initialises the IR camera
|
||||
void WII::IRinitialize(){ // Turns on and initialises the IR camera
|
||||
|
||||
EnableIRCamera1();
|
||||
enableIRCamera1();
|
||||
#ifdef DEBUG
|
||||
Notify(PSTR("\r\nEnable IR Camera1 Complete"));
|
||||
#endif
|
||||
delay(80);
|
||||
|
||||
EnableIRCamera2();
|
||||
enableIRCamera2();
|
||||
#ifdef DEBUG
|
||||
Notify(PSTR("\r\nEnable IR Camera2 Complete"));
|
||||
#endif
|
||||
|
@ -934,23 +934,23 @@ void WII::IRinitialize(){ //Turns on and initialises the IR camera
|
|||
#endif
|
||||
delay(80);
|
||||
|
||||
WriteSensitivityBlock1();
|
||||
writeSensitivityBlock1();
|
||||
#ifdef DEBUG
|
||||
Notify(PSTR("\r\nWrote Sensitivity Block 1"));
|
||||
#endif
|
||||
delay(80);
|
||||
|
||||
WriteSensitivityBlock2();
|
||||
writeSensitivityBlock2();
|
||||
#ifdef DEBUG
|
||||
Notify(PSTR("\r\nWrote Sensitivity Block 2"));
|
||||
#endif
|
||||
delay(80);
|
||||
|
||||
uint8_t mode_num[] = {0x03};
|
||||
setWIIModeNumber(mode_num); //change input for whatever mode you want i.e. 0x01, 0x03, or 0x05
|
||||
uint8_t mode_num = 0x03;
|
||||
setWiiModeNumber(mode_num); // Change input for whatever mode you want i.e. 0x01, 0x03, or 0x05
|
||||
#ifdef DEBUG
|
||||
Notify(PSTR("\r\nSet Wii Mode Number To 0x"));
|
||||
PrintHex<uint8_t>(mode_num[0]);
|
||||
PrintHex<uint8_t>(mode_num);
|
||||
#endif
|
||||
delay(80);
|
||||
|
||||
|
@ -960,8 +960,8 @@ void WII::IRinitialize(){ //Turns on and initialises the IR camera
|
|||
#endif
|
||||
delay(80);
|
||||
|
||||
setReportMode(false, 0x33); //note wiiMotePitch won't return values anymore because it uses output report 0x31 or 0x35
|
||||
//setReportMode(false, 0x3f); //for full reporting mode, doesn't work
|
||||
setReportMode(false, 0x33); // Note wiiMotePitch won't return values anymore because it uses output report 0x31 or 0x35
|
||||
//setReportMode(false, 0x3f); // For full reporting mode, doesn't work yet
|
||||
#ifdef DEBUG
|
||||
Notify(PSTR("\r\nSet Report Mode to 0x33"));
|
||||
#endif
|
||||
|
@ -969,23 +969,23 @@ void WII::IRinitialize(){ //Turns on and initialises the IR camera
|
|||
Notify(PSTR("\r\nIR enabled and Initialized"));
|
||||
}
|
||||
|
||||
void WII::EnableIRCamera1(){
|
||||
void WII::enableIRCamera1(){
|
||||
uint8_t cmd_buf[3];
|
||||
cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02)
|
||||
cmd_buf[1] = 0x13; //output report 13
|
||||
cmd_buf[1] = 0x13; // Output report 13
|
||||
cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01); // Keep the rumble bit and sets bit 2
|
||||
HID_Command(cmd_buf, 3);
|
||||
}
|
||||
|
||||
void WII::EnableIRCamera2(){
|
||||
void WII::enableIRCamera2(){
|
||||
uint8_t cmd_buf[3];
|
||||
cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02)
|
||||
cmd_buf[1] = 0x1A; //output report 1A
|
||||
cmd_buf[1] = 0x1A; // Output report 1A
|
||||
cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01); // Keep the rumble bit and sets bit 2
|
||||
HID_Command(cmd_buf, 3);
|
||||
}
|
||||
|
||||
void WII::WriteSensitivityBlock1(){
|
||||
void WII::writeSensitivityBlock1(){
|
||||
uint8_t buf[9];
|
||||
buf[0] = 0x00;
|
||||
buf[1] = 0x00;
|
||||
|
@ -1000,7 +1000,7 @@ void WII::WriteSensitivityBlock1(){
|
|||
writeData(0xB00000, 9, buf);
|
||||
}
|
||||
|
||||
void WII::WriteSensitivityBlock2(){
|
||||
void WII::writeSensitivityBlock2(){
|
||||
uint8_t buf[2];
|
||||
buf[0] = 0x40;
|
||||
buf[1] = 0x00;
|
||||
|
@ -1009,11 +1009,11 @@ void WII::WriteSensitivityBlock2(){
|
|||
}
|
||||
|
||||
void WII::write0x08Value(){
|
||||
uint8_t Value[]={0x08};
|
||||
writeData(0xb00030, 1, Value);
|
||||
uint8_t cmd = 0x08;
|
||||
writeData(0xb00030, 1, &cmd);
|
||||
}
|
||||
|
||||
void WII::setWIIModeNumber(uint8_t* mode_number){ //mode_number in hex i.e. 0x03 for mode extended mode
|
||||
writeData(0xb00033,1,mode_number);
|
||||
void WII::setWiiModeNumber(uint8_t mode_number){ //mode_number in hex i.e. 0x03 for mode extended mode
|
||||
writeData(0xb00033,1,&mode_number);
|
||||
}
|
||||
#endif
|
42
Wii.h
42
Wii.h
|
@ -186,27 +186,13 @@ public:
|
|||
|
||||
void statusRequest();
|
||||
|
||||
/* These are functions for the IR camera */
|
||||
#ifdef WIICAMERA
|
||||
void IRinitialize(); //Initialises the camera as per the steps from http://wiibrew.org/wiki/Wiimote#IR_Camera
|
||||
void EnableIRCamera1(); //Sets bit 2 of output report 13
|
||||
void EnableIRCamera2(); //Sets bit 2 of output report 1A
|
||||
void WriteSensitivityBlock1();
|
||||
void WriteSensitivityBlock2();
|
||||
void write0x08Value();
|
||||
void setWIIModeNumber(uint8_t* mode_number);
|
||||
/* These are functions for the IR camera */
|
||||
void IRinitialize(); // Initialises the camera as per the steps from http://wiibrew.org/wiki/Wiimote#IR_Camera
|
||||
|
||||
int8_t IR_state; //stores the value in l2capinbuf[12] (0x08 means IR enabled)
|
||||
int16_t IR_object_x1; // IR x position data 10 bits
|
||||
int16_t IR_object_y1; //IR y position data 10 bits
|
||||
int8_t IR_object_s1; // IR size value
|
||||
int16_t IR_object_x2;
|
||||
int16_t IR_object_y2;
|
||||
int8_t IR_object_s2;
|
||||
|
||||
int16_t getIRx1() { return IR_object_x1; }; //IR object 1 x position (0-1023)
|
||||
int16_t getIRy1() { return IR_object_y1; }; //IR object 1 y position (0-767)
|
||||
int8_t getIRs1() { return IR_object_s1; }; //IR object 1 size (0-15)
|
||||
int16_t getIRx1() { return IR_object_x1; }; // IR object 1 x position (0-1023)
|
||||
int16_t getIRy1() { return IR_object_y1; }; // IR object 1 y position (0-767)
|
||||
int8_t getIRs1() { return IR_object_s1; }; // IR object 1 size (0-15)
|
||||
|
||||
int16_t getIRx2() { return IR_object_x2; };
|
||||
int16_t getIRy2() { return IR_object_y2; };
|
||||
|
@ -266,5 +252,23 @@ private:
|
|||
bool activateNunchuck;
|
||||
bool motionValuesReset; // This bool is true when the gyro values has been reset
|
||||
unsigned long timer;
|
||||
|
||||
#ifdef WIICAMERA
|
||||
/* Private function and variables for the readings from teh IR Camera */
|
||||
void enableIRCamera1(); // Sets bit 2 of output report 13
|
||||
void enableIRCamera2(); // Sets bit 2 of output report 1A
|
||||
void writeSensitivityBlock1();
|
||||
void writeSensitivityBlock2();
|
||||
void write0x08Value();
|
||||
void setWiiModeNumber(uint8_t mode_number);
|
||||
|
||||
int8_t IR_state; //stores the value in l2capinbuf[12] (0x08 means IR enabled)
|
||||
int16_t IR_object_x1; // IR x position data 10 bits
|
||||
int16_t IR_object_y1; //IR y position data 10 bits
|
||||
int8_t IR_object_s1; // IR size value
|
||||
int16_t IR_object_x2;
|
||||
int16_t IR_object_y2;
|
||||
int8_t IR_object_s2;
|
||||
#endif
|
||||
};
|
||||
#endif
|
Loading…
Reference in a new issue