File tree Expand file tree Collapse file tree 4 files changed +22
-24
lines changed
scratch-arduino-extensions/packages/scratch-vm/src/extensions Expand file tree Collapse file tree 4 files changed +22
-24
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,24 @@ class ArduinoUnoQ {
1616 this . _setupConnectionHandlers ( ) ;
1717 }
1818
19+ on ( event , callback ) {
20+ if ( this . io ) {
21+ this . io . on ( event , callback ) ;
22+ console . log ( `Registered event listener for: ${ event } ` ) ;
23+ } else {
24+ console . error ( "Socket.io not initialized" ) ;
25+ }
26+ }
27+
28+ emit ( event , data ) {
29+ if ( this . io && this . isConnected ) {
30+ this . io . emit ( event , data ) ;
31+ console . log ( `Emitted event: ${ event } ` , data ) ;
32+ } else {
33+ console . warn ( `Cannot emit ${ event } : Not connected to Arduino UNO Q` ) ;
34+ }
35+ }
36+
1937 _setupConnectionHandlers ( ) {
2038 this . io . on ( "connect" , ( ) => {
2139 this . isConnected = true ;
@@ -110,25 +128,6 @@ class ArduinoUnoQ {
110128 }
111129
112130 // ===== EVENT HANDLING METHODS =====
113-
114- on ( event , callback ) {
115- if ( this . io ) {
116- this . io . on ( event , callback ) ;
117- console . log ( `Registered event listener for: ${ event } ` ) ;
118- } else {
119- console . error ( "Socket.io not initialized" ) ;
120- }
121- }
122-
123- emit ( event , data ) {
124- if ( this . io && this . isConnected ) {
125- this . io . emit ( event , data ) ;
126- console . log ( `Emitted event: ${ event } ` , data ) ;
127- } else {
128- console . warn ( `Cannot emit ${ event } : Not connected to Arduino UNO Q` ) ;
129- }
130- }
131-
132131}
133132
134133module . exports = ArduinoUnoQ ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/
22const ArgumentType = require (
33 "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type" ,
44) ;
5- const { ArduinoUnoQ} = require ( "../ArduinoUnoQ" ) ;
5+ const { ArduinoUnoQ } = require ( "../ArduinoUnoQ" ) ;
66
77// TODO: add icons
88const iconURI = "" ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ const BlockType = require("../../../../../../scratch-editor/packages/scratch-vm/
22const ArgumentType = require (
33 "../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type" ,
44) ;
5- const { ArduinoUnoQ} = require ( "../ArduinoUnoQ" ) ;
5+ const { ArduinoUnoQ } = require ( "../ArduinoUnoQ" ) ;
66
77// TODO: add icons
88const iconURI = "" ;
Original file line number Diff line number Diff line change @@ -6,13 +6,12 @@ const Video = require("../../../../../../scratch-editor/packages/scratch-vm/src/
66const Rectangle = require ( "../../../../../../scratch-editor/packages/scratch-render/src/Rectangle.js" ) ;
77const StageLayering = require ( "../../../../../../scratch-editor/packages/scratch-vm/src/engine/stage-layering.js" ) ;
88const { Detection, MODEL_LABELS } = require ( "./object_detection" ) ;
9- const { ArduinoUnoQ} = require ( "../ArduinoUnoQ" ) ;
9+ const { ArduinoUnoQ } = require ( "../ArduinoUnoQ" ) ;
1010
11- //TODO add icons
11+ // TODO add icons
1212const iconURI = "" ;
1313const menuIconURI = "" ;
1414
15-
1615/**
1716 * RGB color constants for confidence visualization
1817 */
You can’t perform that action at this time.
0 commit comments