# eJamar: A Novel Exergame Controller for Upper Limb Motor Rehabilitation
## 3 Materials and Method
### The ejamar GC
#### 3.1.1 Electronic System  
A microprocessor-based system, based on a 32-bit SAMD21 processor (Microchip Technology Inc., Chandler, AZ, USA), manages the different sub-systems of the device, such as IMU, force sensor, push button, haptic feedback, indicator LEDs, and wireless communication. Processor management within the ejamar controller is orchestrated through the following key components and functionalities:  
_IMU Motion Sensor (LSM6 DS3):_ This sensor, equipped with 9 degrees of freedom, predominantly utilizes 3 degrees corresponding to the accelerometer's response along the X-, Y-, and Z-axes. During exergame execution, the controller identifies the specific game being played. Consequently, the microprocessor system selectively transmits solely the pertinent data required by that particular game. This strategic approach avoids superfluous readings, ensuring swifter data transmission.  
_Force reading system:_ Continuous communication between the processor and the HX711 driver linked to the strain gauge enables force assessment. Implementing a software averaging filter helps diminish reading noise, complementing the filtering stage already integrated into the driver library. This system accurately gauges the force exerted by the player on the controller, facilitating rehabilitation exercises and enhancing hand grip for patients undergoing rehabilitation.  
_Push Button:_ The controller integrates a push button mechanism facilitating the activation or deactivation of the exergame pause mode. Additionally, it serves to rouse the controller from sleep mode. The latter mode automatically activates after 5 min of inactivity, conserving energy while not in use.  
_Haptic Feedback:_ Incorporated within the system is a vibration motor generating tactile feedback during exergame execution, triggered by in-game events such as impacts, or specific actions as defined within each game. This feature offers users real-time tactile cues, enhancing their gaming experience. Furthermore, this feature is customizable and can be disabled through individual game configurations.  
_Visual Indicators:_ The controller integrates two LEDs (a red and a green indicator). The red LED illuminates when the pause mode is activated using the push button or when the system enters sleep mode. To revert to normal operation, a press of the push button is required. Meanwhile, the green LED sporadically lights up during gameplay, signaling to the user that the system is functioning correctly.  
Figure 2: Description of the novel ejamar system.  
Bluetooth Communication:The ejamar employs a NINA-W-102 device for seamless communication via Bluetooth, enabling data transmission between nodes. The microprocessor transmits data to the NINA device responsible for relaying this information. Simultaneously, the game interface transmits configuration data to the controller, received by the NINA and forwarded to the processor. This bidirectional communication involves the controller sending grip force values and accelerometer data (X, Y, and/or Z axis), while receiving configuration commands defining game types, modes, and haptic feedback activation. This wireless capability empowers users with increased freedom of movement during gameplay.  
Time Management and Sleep Functionality:Firmware within the system manages time-related operations and sleep functionality. It orchestrates the processing sequence of various elements within the GC and includes a timer mechanism to activate the sleep mode when necessary. Referencing Figure 3, the firmware's flowchart visually delineates the program's processing and management sequence, ensuring efficient utilization of resources and timely activation of sleep mode to conserve energy.