Skip to content

Commit

Permalink
ArduinoIDE compatible v2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
SebCanet committed Mar 5, 2018
1 parent 9443a16 commit aec60d8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 85 deletions.
22 changes: 8 additions & 14 deletions core_BlocklyArduino/blockly@rduino.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,16 +419,6 @@ BlocklyDuino.Redo = function () {
* Binds functions to each of the buttons, nav links, and related.
*/
BlocklyDuino.bindFunctions = function() {

var IDE_string_param = BlocklyDuino.getStringParamFromUrl('IDE', '');
if (IDE_string_param == '')
{
IDE_string_param = 'off';
}
else
{
IDE_string_param = 'on';
}

$('#clearLink').on("click", BlocklyDuino.clearLocalStorage);

Expand All @@ -443,11 +433,15 @@ BlocklyDuino.bindFunctions = function() {
$('#btn_block_capture').on("click", BlocklyDuino.workspace_capture);
$('#btn_saveXML, #menu_12').on("click", BlocklyDuino.saveXmlFile);
$('#btn_saveArduino').on("click", BlocklyDuino.saveArduinoFile);
if (IDE_string_param == 'on') {
if (BlocklyDuino.getStringParamFromUrl('IDE', '') == 'on') {
$('#btn_verify_local').on("click", BlocklyDuino.verify_local_Click_IDE);
$('#btn_flash_local').on("click", BlocklyDuino.uploadClick_IDE);
$('#btn_pasteIDEArduino').on("click", BlocklyDuino.ArduinoIDEClick_IDE);
} else if (IDE_string_param == 'off') {
$('#local_debug').remove();
$('#debug_arduino').remove();
$('#tab_supervision').remove();
document.getElementById("arduinoCodebender_toggles").style.visibility="hidden";
} else {
$('#btn_verify_local').on("click", BlocklyDuino.verify_local_Click);
$('#btn_flash_local').on("click", BlocklyDuino.uploadClick);
$('#btn_pasteIDEArduino').on("click", BlocklyDuino.ArduinoIDEClick);
Expand Down Expand Up @@ -1163,12 +1157,12 @@ BlocklyDuino.clearLocalStorage = function () {
* Modal first connection -> info
*/
BlocklyDuino.firstBlocklyArduino = function() {
if (BlocklyDuino.getStringParamFromUrl('AIO', '') == 'on') {
if ((BlocklyDuino.getStringParamFromUrl('AIO', '') == 'on')||(BlocklyDuino.getStringParamFromUrl('IDE', '') == 'on')) {
$('#firstModal').addClass('draggable');
//$('#videoFirstModal').prop('src', "https://mediacad.ac-nantes.fr/m/2047/d/i");
//$('#firstModal').modal('show');
$('#btn_videos, #menu_51').on('click', function() {
window.open('http://info.technologiescollege.fr/wiki/doku.php/fr/arduino/blockly_rduino/tutosvideos');
window.open('http://www.libreduc.cc/wiki/doku.php/fr/arduino/blockly_rduino/tutosvideos');
});
} else {
$('#btn_videos, #menu_51').on('click', function() {
Expand Down
84 changes: 19 additions & 65 deletions core_BlocklyArduino/blockly@rduino_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,79 +125,33 @@ BlocklyDuino.verify_local_Click = function() {
*/

BlocklyDuino.ArduinoIDEClick_IDE = function() {
var code = $('#pre_arduino').text();

/*var url = "http://127.0.0.1:5005/openIDE";
var method = "POST";
var async = true;
var request = new XMLHttpRequest();*/
var filename = "leCodeGenere.ino";

var element = document.createElement('a');
element.setAttribute('href', 'data:text/ino;charset=utf-8,' + encodeURIComponent(code)); // put INO in data type to force direct upload to arduino IDE
element.setAttribute('download', filename);
// element.hidden = true;

element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);

/*request.open(method, url, async);
request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
request.send(code); */
if (!window.BlocklyArduinoServer) {
BlocklyArduinoServer = false;
}
var code = $('#pre_arduino').text();
if ((typeof BlocklyArduinoServer) != 'undefined' && BlocklyArduinoServer){
BlocklyArduinoServer.pasteCode(code);
}
};

BlocklyDuino.uploadClick_IDE = function() {
//first change board
var board = "board=" + profile.defaultBoard['upload_arg'];
var url = "http://127.0.0.1:5005/set_board";
var method = "POST";
var async = true;
var request = new XMLHttpRequest();
request.open(method, url, async);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
//Call a function when the state changes.
request.onreadystatechange = function() {
if(request.readyState == 4 && request.status == 200) {
alert(request.responseText);
if (!window.BlocklyArduinoServer) {
BlocklyArduinoServer = false;
}
}
request.send(board);
setTimeout( function() {
//then send code after 1000ms
var code = $('#pre_arduino').text();
url = "http://127.0.0.1:5005/upload";
request.open(method, url, async);
request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
request.send(code);
}, 2000);
var code = $('#pre_arduino').text();
if ((typeof BlocklyArduinoServer) != 'undefined' && BlocklyArduinoServer){
BlocklyArduinoServer.uploadCode(code);
}
};

BlocklyDuino.verify_local_Click_IDE = function() {
//first change board
var board = "board=" + profile.defaultBoard['upload_arg'];
var url = "http://127.0.0.1:5005/set_board";
var method = "POST";
var async = true;
var request = new XMLHttpRequest();
request.open(method, url, async);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
//Call a function when the state changes.
request.onreadystatechange = function() {
if(request.readyState == 4 && request.status == 200) {
alert(request.responseText);
if (!window.BlocklyArduinoServer) {
BlocklyArduinoServer = false;
}
}
request.send(board);
setTimeout( function() {
//then send code after 1000ms
var code = $('#pre_arduino').text();
url = "http://127.0.0.1:5005/compile";
request.open(method, url, async);
request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
request.send(code);
}, 2000);
var code = $('#pre_arduino').text();
if ((typeof BlocklyArduinoServer) != 'undefined' && BlocklyArduinoServer){
BlocklyArduinoServer.verifyCode(code);
}
};


Expand Down
4 changes: 2 additions & 2 deletions core_BlocklyArduino/version.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[release]
version=2.6
version=2.7
[update]
date=21022018
date=05032018
7 changes: 3 additions & 4 deletions index_light.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<script type="text/javascript" src="core_BlocklyArduino/blockly@rduino_tools.js"></script>
<script type="text/javascript" src="core_BlocklyArduino/blockly@rduino_visual.js"></script>
<script type="text/javascript" src="core_BlocklyArduino/compilerflasher.js"></script>
<!--updated online plugin>
<script type="text/javascript" src="http://codebender.cc/embed/compilerflasher.js"></script-->
<!--script type="text/javascript" src="http://codebender.cc/embed/compilerflasher.js"></script-->

<script type="text/javascript" src="core_BlocklyArduino/libs/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="core_BlocklyArduino/libs/jquery-ui.js"></script>
Expand Down Expand Up @@ -432,7 +431,7 @@ <h4 class="modal-title" id="aboutModalLabel"></h4>
<br />
<b><div align="center"><a href="http://framaforms.org/blocklyrduino-utilisateurs-1490560876" target='blank'><font size="12"><span id="span_forms_about" style="font-style: bold;"> </span></font></a></div></b>
<br />
<br /><i>version 27-02-2018 - v2.6 "mini Menus"</i>
<br /><i>version 05-03-2018 - v2.7 "IDE compatible"</i>
<br />
<br />
<!--div align="center" id="paypal_about">
Expand Down Expand Up @@ -701,7 +700,7 @@ <h4 class="modal-title" id="configModalGlobalLabel"></h4>
<input id="toggle-Colors" data-toggle="toggle" data-off="<span id='span_colorBW'> </span>" data-on="<span id='span_colorColors'> </span>" data-onstyle="primary" data-offstyle="default" data-width="120" type="checkbox"/><br />
<br />
<br />
<div style="clear : both;">
<div id="arduinoCodebender_toggles" style="clear : both;">
<a href="http://www.libreduc.cc/wiki/doku.php/fr/arduino/blockly_rduino/configglobale" target='blank'><img src="media/codebenderOUarduino.jpg" height="35px"/></a><br/>
<label id="span_OnOffLine"> </label><br/>
<input id="toggle-WebAccess" data-toggle="toggle" data-on="<span id='toggle-WebAccess-on'> </span>" data-off="<span id='toggle-WebAccess-off'> </span>" data-onstyle="codebender" data-offstyle="arduino" data-width="120" type="checkbox"/><br />
Expand Down
Binary file modified sync.ffs_db
Binary file not shown.

0 comments on commit aec60d8

Please sign in to comment.