Skip to content

Commit

Permalink
issue OpenRoberta#887: add arduino circuit visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
pretodev committed Aug 30, 2020
1 parent a8cc67a commit 3ea0c38
Show file tree
Hide file tree
Showing 9 changed files with 33,884 additions and 2 deletions.
2,618 changes: 2,618 additions & 0 deletions OpenRobertaServer/staticResources/blockly/media/robots/arduino_mega.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,495 changes: 3,495 additions & 0 deletions OpenRobertaServer/staticResources/blockly/media/robots/arduino_uno.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,495 changes: 3,495 additions & 0 deletions OpenRobertaServer/staticResources/blockly/media/robots/arduino_unowifirev2.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24,247 changes: 24,247 additions & 0 deletions OpenRobertaServer/staticResources/blockly/plugins/circuit_visualization.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -1,9 +1,10 @@
define([ 'exports', 'log', 'util', 'comm', 'message', 'guiState.controller', 'blockly', 'configuration.model', 'jquery', 'jquery-validate' ], function(exports,
define([ 'exports', 'log', 'util', 'comm', 'message', 'guiState.controller', 'blockly', 'configuration.model', 'jquery', 'jquery-validate', 'blockly.confvis' ], function(exports,
LOG, UTIL, COMM, MSG, GUISTATE_C, Blockly, CONFIGURATION, $) {

var $formSingleModal;

var bricklyWorkspace;
var confVis;
var listenToBricklyEvents = true;
seen = false;

Expand Down Expand Up @@ -71,6 +72,7 @@ define([ 'exports', 'log', 'util', 'comm', 'message', 'guiState.controller', 'bl
UTIL.annotateBlocks(bricklyWorkspace, GUISTATE_C.confAnnos);
delete GUISTATE_C.confAnnos;
}
confVis.refresh();
}, 'tabConfiguration clicked');

$('#tabConfiguration').on('hide.bs.tab', function(e) {
Expand Down Expand Up @@ -340,7 +342,20 @@ define([ 'exports', 'log', 'util', 'comm', 'message', 'guiState.controller', 'bl
}
exports.reloadView = reloadView;

function changeArduinoRobot(){
bricklyWorkspace.setDevice({
group : GUISTATE_C.getRobotGroup(),
robot : GUISTATE_C.getRobot()
});
confVis.resetRobot();
}
exports.changeArduinoRobot = changeArduinoRobot;

function resetView() {
if(confVis){
confVis.dispose();
confVis = null;
}
bricklyWorkspace.setDevice({
group : GUISTATE_C.getRobotGroup(),
robot : GUISTATE_C.getRobot()
Expand All @@ -362,7 +377,11 @@ define([ 'exports', 'log', 'util', 'comm', 'message', 'guiState.controller', 'bl
bricklyWorkspace.clear();
Blockly.svgResize(bricklyWorkspace);
var dom = Blockly.Xml.textToDom(xml, bricklyWorkspace);
Blockly.Xml.domToWorkspace(dom, bricklyWorkspace);
if(bricklyWorkspace.device === 'arduino'){
confVis = CircuitVisualization.domToWorkspace(dom, bricklyWorkspace);
} else {
Blockly.Xml.domToWorkspace(dom, bricklyWorkspace);
}
bricklyWorkspace.setVersion(dom.getAttribute('xmlversion'));
var name = xml == GUISTATE_C.getConfigurationConf() ? GUISTATE_C.getRobotGroup().toUpperCase() + "basis" : '';
GUISTATE_C.setConfigurationName(name);
Expand Down
Expand Up @@ -334,6 +334,7 @@ define([ 'exports', 'util', 'log', 'message', 'guiState.controller', 'guiState.m
PROGRAM_C.resetView();
} else {
GUISTATE_C.setRobot(robot, result);
if(GUISTATE_C.findGroup(robot) === 'arduino') CONFIGURATION_C.changeArduinoRobot();
}
if (GUISTATE_C.getView() == 'tabConfList') {
$('#confList>.bootstrap-table').find('button[name="refresh"]').trigger('click');
Expand Down
5 changes: 5 additions & 0 deletions OpenRobertaServer/staticResources/js/main.js
Expand Up @@ -3,6 +3,7 @@ require.config({
paths: {
'codeflask': 'codeflask/codeflask.min',
'blockly': '../../blockly/blockly_compressed',
'blockly.confvis': '../../blockly/plugins/circuit_visualization',
'bootstrap': 'bootstrap/bootstrap-3.3.1-dist/dist/js/bootstrap.min',
'bootstrap-table': 'bootstrap/bootstrap-3.3.1-dist/dist/js/bootstrap-table.min',
'bootstrap-tagsinput': 'bootstrap/bootstrap-3.3.1-dist/dist/js/bootstrap-tagsinput.min',
Expand Down Expand Up @@ -101,6 +102,10 @@ require.config({
'blockly': {
exports: 'Blockly'
},
'blockly.confvis' : {
deps : [ 'blockly' ],
exports : 'CircuitVisualization'
},

'volume-meter': {
exports: "Volume",
Expand Down

0 comments on commit 3ea0c38

Please sign in to comment.