From 1a6de9e4bba625eaf8c0d70339e694f0856cd3a2 Mon Sep 17 00:00:00 2001 From: TiGBS Date: Wed, 2 May 2018 13:56:02 +0100 Subject: [PATCH 1/2] Thermometer Gotten my head around the code, and made adjustments Added the thermometer slider and made it update live iframe has a seperate class so inline css not necessary; ignore the changes to the flags microbit/__init__.js changes ESSENTIAL for actual functionality and clarity simulator.html changes essential simulator-ui.css, and simulator-ui.js ESSENTIAL style.css changes ESSENTIAL triangle.css changes ESSENTIAL --- editor.html | 8 +++--- lib/lib.js | 2 +- lib/skulpt/microbit/__init__.js | 17 ++++++------ python-main.js | 2 +- show.sh | 2 +- simulator.html | 18 ++++++++---- static/css/simulator-ui.css | 49 +++++++++++++++++++++++++++++++++ static/css/style.css | 14 ++++++++-- static/img/triangle.svg | 2 +- static/js/simulator-ui.js | 21 ++++++++++++++ styles.css | 1 - 11 files changed, 112 insertions(+), 24 deletions(-) create mode 100644 static/css/simulator-ui.css create mode 100644 static/js/simulator-ui.js diff --git a/editor.html b/editor.html index 59b547a0..e15b658b 100644 --- a/editor.html +++ b/editor.html @@ -1,4 +1,4 @@ - + VERSION = "0.1.0"; @@ -361,9 +361,9 @@

{{ title }}

} }, 'flags': { - 'blocks': true, + 'blocks': false, 'snippets': true, - 'share': true + 'share': false }, }); diff --git a/lib/lib.js b/lib/lib.js index 8064790b..e109762b 100644 --- a/lib/lib.js +++ b/lib/lib.js @@ -42,7 +42,7 @@ var PythonIDE = { files: {'mycode.py': decodeURIComponent(window.location.search.substring(6))}, - // functions and data needed for running theh python code + // functions and data needed for running the python code python: { outputListeners: [], diff --git a/lib/skulpt/microbit/__init__.js b/lib/skulpt/microbit/__init__.js index 2bc7cf4c..8a7dfbfa 100644 --- a/lib/skulpt/microbit/__init__.js +++ b/lib/skulpt/microbit/__init__.js @@ -102,7 +102,7 @@ var compass = function(name) { }); return mod; -}; +}; // END compass var accelerometer = function(name) { @@ -162,7 +162,7 @@ var accelerometer = function(name) { }); return mod; -} +} // END accelerometer var display = function(name) { var leds = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]]; @@ -925,7 +925,7 @@ var display = function(name) { return mod; -} +} // END display @@ -1641,16 +1641,17 @@ var $builtinmodule = function (name) { mod.compass.$d.data.heading = ui.value; } - $('.mb_slider').slider({ - value: 0, - min: -1024, - max: 1024, + $('.mb_slider').slider({ + orientation: 'vertical', + value: 23, + min: 0, + max: 100, step: 1, change: sliderChange }).on("slide", sliderChange); $('#mb_therm_slider').slider({ value: 23, - min: 0, + min: -50, max: 100 }); $('.mb_slider_com').slider({ diff --git a/python-main.js b/python-main.js index 3473fbe0..919d23d3 100644 --- a/python-main.js +++ b/python-main.js @@ -207,7 +207,7 @@ function pythonEditor(id) { } return editor; -}; +}; // END func pythonEditor /* The following code contains the various functions that connect the behaviour of diff --git a/show.sh b/show.sh index 0840ca1b..53958aad 100755 --- a/show.sh +++ b/show.sh @@ -1,3 +1,3 @@ #!/bin/bash echo "http://localhost:8000/editor.html" -python3 -m http.server --bind 0.0.0.0 +py -m http.server --bind 0.0.0.0 diff --git a/simulator.html b/simulator.html index 8fc7fdd3..f47ebf0d 100644 --- a/simulator.html +++ b/simulator.html @@ -1,4 +1,4 @@ - + @@ -10,6 +10,7 @@ + @@ -26,13 +27,20 @@ - - - + + + + +
+
+
+

Temperature: Thermometre Value°C

+
+
-
+
+ @@ -34,10 +35,18 @@
-
+ + +
+
+ + +
+
+
diff --git a/static/css/simulator-ui.css b/static/css/simulator-ui.css index aa5fb73c..6dc73ad9 100644 --- a/static/css/simulator-ui.css +++ b/static/css/simulator-ui.css @@ -13,6 +13,9 @@ position: relative; } +.hidden { display: none; } + +/* Thermometer */ #thermometer { min-height: 100%; min-width: 100%; @@ -27,15 +30,10 @@ background: linear-gradient(180deg, rgba(255, 0, 0, 1) 0%, rgba(255, 255, 255, 1) 66%, rgba(0, 255, 255, 1) 100%); } -.value -{ - position: absolute; - bottom: 0; left: 0; -} - #thermometer .value { font-size: 20px; + position: absolute; left: 10px; bottom: 50px; } @@ -45,5 +43,22 @@ font-weight: 600; color: rgba(180, 0, 0, 1); } +/* END Thermometer */ -.hidden { display: none; } \ No newline at end of file +#pins { + min-height: 100%; min-width: 100%; +} + +label[for="mb_pin_num"] { + margin: 0 4px; + padding: 4px 0; +} + +#pins span +{ + border-radius: 2px; + border-color: blue; + border-top: none; + border-left: none; + border-right: none; +} \ No newline at end of file