mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
The is no need for Wii calibration flag to have its own variable
This commit is contained in:
parent
11f80275a5
commit
e4c581c991
4 changed files with 8 additions and 11 deletions
8
Wii.cpp
8
Wii.cpp
|
@ -393,8 +393,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
Notify(PSTR("\r\nWii Balance Board connected"), 0x80);
|
Notify(PSTR("\r\nWii Balance Board connected"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
setReportMode(false, 0x32); // Read the Wii Balance Board extension
|
setReportMode(false, 0x32); // Read the Wii Balance Board extension
|
||||||
wiiBalanceBoardCalibrationComplete = false;
|
wii_set_flag(WII_FLAG_CALIBRATE_BALANCE_BOARD);
|
||||||
wiiBalanceBoardConnected = true;
|
|
||||||
}
|
}
|
||||||
// Wii Balance Board calibration reports (24 bits in total)
|
// Wii Balance Board calibration reports (24 bits in total)
|
||||||
else if(l2capinbuf[13] == 0x00 && l2capinbuf[14] == 0x24 && reportLength == 16) { // First 16-bit
|
else if(l2capinbuf[13] == 0x00 && l2capinbuf[14] == 0x24 && reportLength == 16) { // First 16-bit
|
||||||
|
@ -408,7 +407,8 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nWii Balance Board calibration values read successfully"), 0x80);
|
Notify(PSTR("\r\nWii Balance Board calibration values read successfully"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
wiiBalanceBoardCalibrationComplete = true;
|
wii_clear_flag(WII_FLAG_CALIBRATE_BALANCE_BOARD);
|
||||||
|
wiiBalanceBoardConnected = true;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
else {
|
else {
|
||||||
|
@ -794,7 +794,7 @@ void WII::Run() {
|
||||||
readExtensionType();
|
readExtensionType();
|
||||||
unknownExtensionConnected = false;
|
unknownExtensionConnected = false;
|
||||||
} else if(stateCounter == 400) {
|
} else if(stateCounter == 400) {
|
||||||
if(wiiBalanceBoardConnected) {
|
if(wii_check_flag(WII_FLAG_CALIBRATE_BALANCE_BOARD)) {
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
Notify(PSTR("\r\nReading Wii Balance Board calibration values"), 0x80);
|
Notify(PSTR("\r\nReading Wii Balance Board calibration values"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
|
|
8
Wii.h
8
Wii.h
|
@ -24,8 +24,9 @@
|
||||||
#include "controllerEnums.h"
|
#include "controllerEnums.h"
|
||||||
|
|
||||||
/* Wii event flags */
|
/* Wii event flags */
|
||||||
#define WII_FLAG_MOTION_PLUS_CONNECTED 0x01
|
#define WII_FLAG_MOTION_PLUS_CONNECTED (1 << 0)
|
||||||
#define WII_FLAG_NUNCHUCK_CONNECTED 0x02
|
#define WII_FLAG_NUNCHUCK_CONNECTED (1 << 1)
|
||||||
|
#define WII_FLAG_CALIBRATE_BALANCE_BOARD (1 << 2)
|
||||||
|
|
||||||
#define wii_check_flag(flag) (wii_event_flag & (flag))
|
#define wii_check_flag(flag) (wii_event_flag & (flag))
|
||||||
#define wii_set_flag(flag) (wii_event_flag |= (flag))
|
#define wii_set_flag(flag) (wii_event_flag |= (flag))
|
||||||
|
@ -294,9 +295,6 @@ public:
|
||||||
uint16_t getWeightRaw(BalanceBoardEnum pos) {
|
uint16_t getWeightRaw(BalanceBoardEnum pos) {
|
||||||
return wiiBalanceBoardRaw[pos];
|
return wiiBalanceBoardRaw[pos];
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Indicates when the calibration of the Wii Balance Board is done. */
|
|
||||||
bool wiiBalanceBoardCalibrationComplete;
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
#ifdef WIICAMERA
|
#ifdef WIICAMERA
|
||||||
|
|
|
@ -34,7 +34,7 @@ void setup() {
|
||||||
}
|
}
|
||||||
void loop() {
|
void loop() {
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
if (Wii.wiiBalanceBoardConnected && Wii.wiiBalanceBoardCalibrationComplete) {
|
if (Wii.wiiBalanceBoardConnected) {
|
||||||
Serial.print(F("\r\nWeight: "));
|
Serial.print(F("\r\nWeight: "));
|
||||||
for (uint8_t i = 0; i < 4; i++) {
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
Serial.print(Wii.getWeight((BalanceBoardEnum)i));
|
Serial.print(Wii.getWeight((BalanceBoardEnum)i));
|
||||||
|
|
|
@ -270,7 +270,6 @@ nunchuckConnected KEYWORD2
|
||||||
motionPlusConnected KEYWORD2
|
motionPlusConnected KEYWORD2
|
||||||
wiiUProControllerConnected KEYWORD2
|
wiiUProControllerConnected KEYWORD2
|
||||||
wiiBalanceBoardConnected KEYWORD2
|
wiiBalanceBoardConnected KEYWORD2
|
||||||
wiiBalanceBoardCalibrationComplete KEYWORD2
|
|
||||||
setRumbleToggle KEYWORD2
|
setRumbleToggle KEYWORD2
|
||||||
getPitch KEYWORD2
|
getPitch KEYWORD2
|
||||||
getRoll KEYWORD2
|
getRoll KEYWORD2
|
||||||
|
|
Loading…
Reference in a new issue