My Project 1
Yet another Wii Balance Board Driver
|
Core file for the YAWiiBBD application, facilitating interaction with a Wii Balance Board. More...
#include "YAWiiBBessentials.h"
Functions | |
void | main_loop (WiiBalanceBoard *board) |
Main loop of the application. More... | |
int | main (int argc, char *argv[]) |
Main entry point of the application. More... | |
Variables | |
const LogLevel | debug_level = DEBUG |
Default logging level for output verbosity, dependent on compilation mode. More... | |
Core file for the YAWiiBBD application, facilitating interaction with a Wii Balance Board.
This file contains the main functionality of the application, including setup for Bluetooth connections, the primary loop for data handling, and thread management. The compilation flags control debug levels, which influence logging and application status reporting.
The application scans for the Wii Balance Board and attempts to establish two L2CAP connections: one for command transmission and one for receiving responses. Once connected, it enters a loop to process and output data continuously as long as the board remains active.
The main loop can be exited by pressing Enter in the terminal or by pressing the power button on the Wii Balance Board.
Compile the application using the following commands based on the intended configuration:
YAWiiBBessentials.c
. int main | ( | int | argc, |
char * | argv[] | ||
) |
Main entry point of the application.
This function initializes the WiiBalanceBoard
, checks the validity of the provided MAC address, and establishes a Bluetooth connection to the Balance Board. If a valid MAC address is detected, a message is displayed to the user, suggesting a command line format for establishing an immediate connection on subsequent runs:
A background thread is started to handle user input. Currently, this thread only supports program termination commands, allowing the user to end the main loop. However, in future versions, this thread could be expanded to accept additional commands, such as status requests or calibration triggers, by setting corresponding flags in the WiiBalanceBoard
object.
The main loop operates as long as the is_running
flag remains set to true
. Upon termination, the function performs cleanup by releasing all resources and closing the Bluetooth connection to the Balance Board.
argc | Number of arguments passed to the program at startup. |
argv | Array of strings containing the arguments passed. |
void main_loop | ( | WiiBalanceBoard * | board | ) |
Main loop of the application.
This function executes the core operations of the application, performing various actions based on the flags set within the WiiBalanceBoard
object. These actions include status checks, calibration, activation, and toggling the LED on or off. The received data from the Balance Board is processed and handled within this loop.
The loop includes a 10-millisecond delay to reduce CPU load and ensure efficient processing of data. It runs continuously until a termination signal is received.
board | A pointer to the WiiBalanceBoard object containing current status information and control flags. |
Default logging level for output verbosity, dependent on compilation mode.
The debug_level
constant controls the verbosity of output logging for the Wii Balance Board.
YAWIIBB_EXTENDED
flag, the logging level is set to the only available option RAW
, limiting output to raw, uninterpreted data.YAWIIBB_EXTENDED
flag, the logging level defaults to DEBUG
, allowing the selection between multiple verbosity levels (RAW
, DECODE
, DEBUG
, and optionally VERBOSE
).