@@ -18,6 +18,15 @@ const stateLine = document.getElementById("state-line");
1818const latestStatus = document . getElementById ( "latest-status" ) ;
1919const scriptPreview = document . getElementById ( "script-preview" ) ;
2020const presetButtons = document . querySelectorAll ( ".preset" ) ;
21+ const buttonModeToggle = document . getElementById ( "button-mode-toggle" ) ;
22+ const textControls = document . getElementById ( "text-controls" ) ;
23+ const buttonControls = document . getElementById ( "button-controls" ) ;
24+ const placeX = document . getElementById ( "place-x" ) ;
25+ const placeY = document . getElementById ( "place-y" ) ;
26+ const placeF = document . getElementById ( "place-f" ) ;
27+ const placeButton = document . getElementById ( "place-button" ) ;
28+ const actionPadButtons = document . querySelectorAll ( "[data-command]" ) ;
29+ const buttonResetState = document . getElementById ( "button-reset-state" ) ;
2130
2231let state = { ...initialState } ;
2332let scriptCommands = [ ] ;
@@ -117,6 +126,30 @@ function reloadScriptCommands() {
117126 renderScriptPreview ( ) ;
118127}
119128
129+ function resetRobotState ( ) {
130+ state = { ...initialState } ;
131+ renderState ( ) ;
132+ renderBoard ( ) ;
133+ setStatusBanner ( "success" , "Command success: Robot state reset" ) ;
134+ appendLog ( {
135+ commandText : "RESET" ,
136+ status : "success" ,
137+ message : "Command success: Robot state reset" ,
138+ reportOutput : null ,
139+ } ) ;
140+ }
141+
142+ function toggleControlMode ( useButtonControls ) {
143+ textControls . classList . toggle ( "hidden-controls" , useButtonControls ) ;
144+ buttonControls . classList . toggle ( "hidden-controls" , ! useButtonControls ) ;
145+ setStatusBanner (
146+ "neutral" ,
147+ useButtonControls
148+ ? "Button mode enabled: use PLACE/LEFT/MOVE/RIGHT/REPORT controls"
149+ : "Text mode enabled: use command or script input" ,
150+ ) ;
151+ }
152+
120153runCommandButton . addEventListener ( "click" , ( ) => {
121154 const commandText = commandInput . value ;
122155 executeCommand ( commandText ) ;
@@ -172,16 +205,7 @@ resetScriptButton.addEventListener("click", () => {
172205} ) ;
173206
174207resetStateButton . addEventListener ( "click" , ( ) => {
175- state = { ...initialState } ;
176- renderState ( ) ;
177- renderBoard ( ) ;
178- setStatusBanner ( "success" , "Command success: Robot state reset" ) ;
179- appendLog ( {
180- commandText : "RESET" ,
181- status : "success" ,
182- message : "Command success: Robot state reset" ,
183- reportOutput : null ,
184- } ) ;
208+ resetRobotState ( ) ;
185209} ) ;
186210
187211scriptInput . addEventListener ( "input" , ( ) => {
@@ -197,6 +221,26 @@ presetButtons.forEach((button) => {
197221 } ) ;
198222} ) ;
199223
224+ buttonModeToggle . addEventListener ( "change" , ( event ) => {
225+ toggleControlMode ( event . target . checked ) ;
226+ } ) ;
227+
228+ placeButton . addEventListener ( "click" , ( ) => {
229+ const command = `PLACE ${ placeX . value } ,${ placeY . value } ,${ placeF . value } ` ;
230+ executeCommand ( command ) ;
231+ } ) ;
232+
233+ actionPadButtons . forEach ( ( button ) => {
234+ button . addEventListener ( "click" , ( ) => {
235+ executeCommand ( button . dataset . command ) ;
236+ } ) ;
237+ } ) ;
238+
239+ buttonResetState . addEventListener ( "click" , ( ) => {
240+ resetRobotState ( ) ;
241+ } ) ;
242+
200243renderState ( ) ;
201244renderBoard ( ) ;
202245reloadScriptCommands ( ) ;
246+ toggleControlMode ( false ) ;
0 commit comments