Skip to content

Commit

Permalink
Adding display of RAM use in the converter
Browse files Browse the repository at this point in the history
it is the maximum use estimate
  • Loading branch information
gg64du02 committed May 25, 2018
1 parent c98d826 commit 8cf8eef
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 13 deletions.
10 changes: 6 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

# TODO: add a score number to notify the user that his script is to long,
therefore not be able to run on the DigiSpark!!!
w/ proper stylesheet ?

# TODO:Add an info button next to it when the RAM usage guess is RED.

# TODO: Make it deployment friendly for a website (I don't know if it currently works)

Expand Down Expand Up @@ -74,7 +73,10 @@ is fine
# DONE: See the memory threshold when it happens.
use: https://stackoverflow.com/questions/4009756/how-to-count-string-occurrence-in-string


# TODO: add a score number to notify the user that his script is to long,
therefore not be able to run on the DigiSpark!!!
w/ proper stylesheet ?

# =============================================================

# DON'T/CAN'T DO IT: multiOS script on 7 would change back the keyboard layout settings to the primary one set in 7
Expand Down
4 changes: 2 additions & 2 deletions duckSpark.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
<i class="fa fa-play"></i>
Compile
</a>
<a class="left dl-but disabled">
Download sketch !
<a class="left RAM-info disabled" id="RAM-info">
RAM used (raw guess):
</a>
<!--
<a class="left dl-but disabled">
Expand Down
24 changes: 18 additions & 6 deletions duckSpark.js_files/duckSpark.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Dckuinojs {
this.keyMap = keyMap;
this.commandMap = commandMap;
this.comboMap = comboMap;
this.numbers_of_character;
}

toArduino(inputCode)
Expand Down Expand Up @@ -128,18 +129,29 @@ class Dckuinojs {
console.log("setup:"+"1");
console.log("pinmode:"+"2");

var count = (parsedDucky.match(/DigiKeyboard.delay/g) || []).length;
console.log("delay:"+count);
var count_delay = (parsedDucky.match(/DigiKeyboard.delay/g) || []).length;
console.log("delay:"+count_delay);
var count_delay_corrected = count_delay+1;

var count = (parsedDucky.match(/DigiKeyboard.sendKeyStroke/g) || []).length;
console.log("sendKeyStroke:"+count);
var count_sendKeyStroke = (parsedDucky.match(/DigiKeyboard.sendKeyStroke/g) || []).length;
console.log("sendKeyStroke:"+count_sendKeyStroke);

var count = (parsedDucky.match(/DigiKeyboard.println/g) || []).length;
console.log("println:"+count);
var count_println = (parsedDucky.match(/DigiKeyboard.println/g) || []).length;
console.log("println:"+count_println);


console.log("numbers_of_character (println):"+numbers_of_character);

var test_RAM_used = 88 + 0 * count_delay_corrected + 0* count_sendKeyStroke;
//test_RAM_used += 2* count_println + 1* numbers_of_character;
test_RAM_used += 0* count_println + 1* numbers_of_character;
console.log("test_RAM_used:"+test_RAM_used)
this.numbers_of_character = test_RAM_used;


//$(".RAM-inf").val("duckSpark.js" + "lol");
//document.getElementById('RAM-inf').innerHTML = 'John Doe';


return '/*\n'
+ ' * Generated with <3 by Dckuino.js, an open source project ! Please check the Nurrl github, and style sheet from Seytonic`s website Modified by gg64du02\n'
Expand Down
22 changes: 21 additions & 1 deletion duckSpark.js_files/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,36 @@ jQuery(function() { // Wait for jQuery
// Compile button
$(".compile-but").click(function(e) {
var duckOutput = Duck.toArduino($(".duckyscript").val());

var numbers_of_character_lol = Duck.numbers_of_character;
console.log("numbers_of_character_lol:"+numbers_of_character_lol);

//document.getElementById("dl-but").innerHTML = "Hello JavaScript!";
//document.getElementById("dl-but").innerHTML = "RAM used:" + numbers_of_character_lol + "bytes (about)";
document.getElementById("RAM-info").innerHTML = "RAM used:" + numbers_of_character_lol + "bytes (raw guess)";

if(numbers_of_character_lol>460){
document.getElementById("RAM-info").style.color = "#ff0000";
}
else{
document.getElementById("RAM-info").style.color = "#000000";

}



if (duckOutput !== false)
{
$(".arduino").val(duckOutput);
if (isFileSaverSupported)
enableDl(500); // Enable download button
//$(".dl-but").val('test');
}
else {
$(".arduino").val('An error occured, the compiler returned undefined content !');

//$(".RAM-inf").val("duckSpark.js" + "lol");
disableDl(500); // Disable download button
//$(".dl-but").val('test');
}
});

Expand Down
62 changes: 62 additions & 0 deletions temp_Use_of_RAM/estimated_versus_ide.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
ide:
Les variables globales utilisent 1414 octets de m�moire dynamique.
test_RAM_used:1476

var test_RAM_used = 88 + 0 * count_delay_corrected + 0* count_sendKeyStroke;
test_RAM_used += 2* count_println + 1* numbers_of_character;
================

Les variables globales utilisent 1414 octets de m�moire dynamique.
test_RAM_used:1452

var test_RAM_used = 88 + 0 * count_delay_corrected + 0* count_sendKeyStroke;
test_RAM_used += 1* count_println + 1* numbers_of_character;
=================
Les variables globales utilisent 1414 octets de m�moire dynamique.
var test_RAM_used = 88 + 0 * count_delay_corrected + 0* count_sendKeyStroke;
test_RAM_used += 0* count_println + 1* numbers_of_character;

count:2
main.js:16 DigiKeyboard.h:1
main.js:16 setup:1
main.js:16 pinmode:2
main.js:16 delay:6
main.js:16 sendKeyStroke:26
main.js:16 println:24
main.js:16 numbers_of_character (println):1340
main.js:16 test_RAM_used:1428


=========================

Le croquis utilise 3380 octets (56%) de l'espace de stockage de programmes. Le maximum est de 6012 octets.
Les variables globales utilisent 232 octets de m�moire dynamique.

count:2
main.js:16 DigiKeyboard.h:1
main.js:16 setup:1
main.js:16 pinmode:2
main.js:16 delay:7
main.js:16 sendKeyStroke:7
main.js:16 println:6
main.js:16 numbers_of_character (println):137
main.js:16 test_RAM_used:225

var test_RAM_used = 88 + 0 * count_delay_corrected + 0* count_sendKeyStroke;
test_RAM_used += 0* count_println + 1* numbers_of_character;


=========================


Le croquis utilise 3282 octets (54%) de l'espace de stockage de programmes. Le maximum est de 6012 octets.
Les variables globales utilisent 170 octets de m�moire dynamique.
count:2
main.js:16 DigiKeyboard.h:1
main.js:16 setup:1
main.js:16 pinmode:2
main.js:16 delay:6
main.js:16 sendKeyStroke:6
main.js:16 println:4
main.js:16 numbers_of_character (println):82
main.js:16 test_RAM_used:170

0 comments on commit 8cf8eef

Please sign in to comment.