The is no need for Wii calibration flag to have its own variable

This commit is contained in:
Kristian Sloth Lauszus 2015-04-20 23:39:57 +02:00
parent 11f80275a5
commit e4c581c991
4 changed files with 8 additions and 11 deletions

View file

@ -393,8 +393,7 @@ void WII::ACLData(uint8_t* l2capinbuf) {
Notify(PSTR("\r\nWii Balance Board connected"), 0x80);
#endif
setReportMode(false, 0x32); // Read the Wii Balance Board extension
wiiBalanceBoardCalibrationComplete = false;
wiiBalanceBoardConnected = true;
wii_set_flag(WII_FLAG_CALIBRATE_BALANCE_BOARD);
}
// Wii Balance Board calibration reports (24 bits in total)
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
Notify(PSTR("\r\nWii Balance Board calibration values read successfully"), 0x80);
#endif
wiiBalanceBoardCalibrationComplete = true;
wii_clear_flag(WII_FLAG_CALIBRATE_BALANCE_BOARD);
wiiBalanceBoardConnected = true;
}
#ifdef DEBUG_USB_HOST
else {
@ -794,7 +794,7 @@ void WII::Run() {
readExtensionType();
unknownExtensionConnected = false;
} else if(stateCounter == 400) {
if(wiiBalanceBoardConnected) {
if(wii_check_flag(WII_FLAG_CALIBRATE_BALANCE_BOARD)) {
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nReading Wii Balance Board calibration values"), 0x80);
#endif

8
Wii.h
View file

@ -24,8 +24,9 @@
#include "controllerEnums.h"
/* Wii event flags */
#define WII_FLAG_MOTION_PLUS_CONNECTED 0x01
#define WII_FLAG_NUNCHUCK_CONNECTED 0x02
#define WII_FLAG_MOTION_PLUS_CONNECTED (1 << 0)
#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_set_flag(flag) (wii_event_flag |= (flag))
@ -294,9 +295,6 @@ public:
uint16_t getWeightRaw(BalanceBoardEnum pos) {
return wiiBalanceBoardRaw[pos];
};
/** Indicates when the calibration of the Wii Balance Board is done. */
bool wiiBalanceBoardCalibrationComplete;
/**@}*/
#ifdef WIICAMERA

View file

@ -34,7 +34,7 @@ void setup() {
}
void loop() {
Usb.Task();
if (Wii.wiiBalanceBoardConnected && Wii.wiiBalanceBoardCalibrationComplete) {
if (Wii.wiiBalanceBoardConnected) {
Serial.print(F("\r\nWeight: "));
for (uint8_t i = 0; i < 4; i++) {
Serial.print(Wii.getWeight((BalanceBoardEnum)i));

View file

@ -270,7 +270,6 @@ nunchuckConnected KEYWORD2
motionPlusConnected KEYWORD2
wiiUProControllerConnected KEYWORD2
wiiBalanceBoardConnected KEYWORD2
wiiBalanceBoardCalibrationComplete KEYWORD2
setRumbleToggle KEYWORD2
getPitch KEYWORD2
getRoll KEYWORD2