@@ -10,7 +10,8 @@ import { getGamepadManager } from './gamepad.js';
1010// Global state
1111const state = {
1212 mode : 'virtual' , // 'virtual' or 'gamepad'
13- connected : false
13+ connected : false ,
14+ baudRate : 5250000
1415} ;
1516
1617// Get instances
@@ -29,16 +30,20 @@ const elements = {
2930 gamepadInfo : document . getElementById ( 'gamepadInfo' ) ,
3031 gamepadSelect : document . getElementById ( 'gamepadSelect' ) ,
3132 gamepadStatus : document . getElementById ( 'gamepadStatus' ) ,
33+ baudRateSelect : document . getElementById ( 'baudRateSelect' ) ,
3234 bindBtn : document . getElementById ( 'bindBtn' ) ,
3335 wifiBtn : document . getElementById ( 'wifiBtn' ) ,
3436 resetBtn : document . getElementById ( 'resetBtn' ) ,
35- logPanel : document . getElementById ( 'logPanel' )
37+ logPanel : document . getElementById ( 'logPanel' ) ,
38+ buildCommit : document . getElementById ( 'buildCommit' )
3639} ;
3740
3841// Initialize
3942function init ( ) {
4043 log ( 'Initializing ELRS Web Remote...' ) ;
4144 elements . wifiBtn . title = 'WiFi mode command is not implemented yet' ;
45+ elements . buildCommit . textContent = '5995baf' ;
46+ elements . baudRateSelect . value = String ( state . baudRate ) ;
4247
4348 // Create virtual joystick
4449 joystick = new VirtualJoystick ( 'joystickContainer' ) ;
@@ -125,7 +130,8 @@ function setupUIEvents() {
125130 // Connect button
126131 elements . connectBtn . addEventListener ( 'click' , async ( ) => {
127132 try {
128- await elrs . connect ( 420000 ) ;
133+ log ( `Opening serial port at ${ state . baudRate } baud` ) ;
134+ await elrs . connect ( state . baudRate ) ;
129135 } catch ( error ) {
130136 if ( error . name !== 'NotFoundError' ) {
131137 log ( `Connection failed: ${ error . message } ` ) ;
@@ -155,6 +161,14 @@ function setupUIEvents() {
155161 }
156162 } ) ;
157163
164+ elements . baudRateSelect . addEventListener ( 'change' , ( e ) => {
165+ const baudRate = parseInt ( e . target . value , 10 ) ;
166+ if ( ! Number . isNaN ( baudRate ) ) {
167+ state . baudRate = baudRate ;
168+ log ( `Baud rate set to ${ baudRate } ` ) ;
169+ }
170+ } ) ;
171+
158172 // Bind button
159173 elements . bindBtn . addEventListener ( 'click' , async ( ) => {
160174 if ( state . connected ) {
@@ -211,7 +225,7 @@ function updateConnectionUI(connected) {
211225 elements . connectBtn . disabled = connected ;
212226 elements . disconnectBtn . disabled = ! connected ;
213227 elements . bindBtn . disabled = ! connected ;
214- elements . wifiBtn . disabled = ! connected || ! elrs . supportsWifiMode ( ) ;
228+ elements . wifiBtn . disabled = ! connected ;
215229
216230 if ( connected ) {
217231 // Start sending RC data
0 commit comments