diff --git a/raspberry/roberto/views/frontend/templates/index.html b/raspberry/roberto/views/frontend/templates/index.html index 09034bc..fe11dff 100644 --- a/raspberry/roberto/views/frontend/templates/index.html +++ b/raspberry/roberto/views/frontend/templates/index.html @@ -23,6 +23,12 @@ position: relative; z-index: 1; } + #message { + position: absolute; + z-index: 1; + top: 20px; + right: 50px + } @@ -34,7 +40,10 @@
- +
+ + +
@@ -148,6 +157,11 @@ socket.on('data', (data) => { ctx.font = "24px Arial"; ctx.fillStyle = "blue"; //ctx.fillText("Hello World", canvas.width/3, 30); + + $('form#message').submit(function(event) { + gp_socket.emit('text', {data: $('#message_data').val()}); + return false; + }); }; diff --git a/raspberry/roberto/views/websocket/routes.py b/raspberry/roberto/views/websocket/routes.py index d2e0bce..d345e1a 100644 --- a/raspberry/roberto/views/websocket/routes.py +++ b/raspberry/roberto/views/websocket/routes.py @@ -53,6 +53,15 @@ def applyDeadZone(value, threshold): new_value = new_value * -1 return new_value +@socketio.on('text', namespace='/gamepad') +def display_text(text): + print("display_text()") + print(text['data']) + if isinstance(text['data'], str): + if len(text['data']) < 250: + from roberto import serial + command = 'T '+str(text['data']) + serial.write(bytes(command, "utf8")) # https://pfertyk.me/2020/03/webrtc-a-working-example/ diff --git a/trigorilla/src/main.cpp b/trigorilla/src/main.cpp index 0b936d8..e9d331b 100644 --- a/trigorilla/src/main.cpp +++ b/trigorilla/src/main.cpp @@ -158,6 +158,11 @@ void loop() Serial.print(values[2]); Serial.print(", "); Serial.print(values[3]); Serial.print("\n"); } + } else if (command.charAt(0) == 'T') { + String message = command.substring(3); + char* text = message.c_str(); + lcd.setCursor(0,2); + lcd.print(text); } }