Skip to content

Thermometer #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions editor.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<!--
.:://++++++//:-.
Expand Down Expand Up @@ -68,9 +68,9 @@
<link rel="icon" href="static/img/favicon.ico">
</head>
<body>
<iframe id="sim-iframe" src="about:blank" width="810px" height="310px" frameborder="0" scrolling="no" style="position: absolute; bottom: 20px; right: 20px; z-index: 10;"></iframe>
<iframe id="sim-iframe" src="about:blank" frameborder="0" scrolling="no"></iframe>
<script type="application/javascript">
<!-- VERSION INFORMATION -->
// VERSION INFORMATION
VERSION = "0.1.0";
</script>
<script id="load-template" type="x-tmpl-mustache">
Expand Down Expand Up @@ -361,7 +361,7 @@ <h2><i class="fa fa-unlock-alt"></i> <strong>{{ title }}</strong></h2>
}
},
'flags': {
'blocks': true,
'blocks': false,
'snippets': true,
'share': true,
'experimental': false,
Expand Down
2 changes: 1 addition & 1 deletion lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],

Expand Down
58 changes: 43 additions & 15 deletions lib/skulpt/microbit/__init__.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var compass = function(name) {
});

return mod;
};
}; // END compass

var accelerometer = function(name) {

Expand Down Expand Up @@ -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]];
Expand Down Expand Up @@ -925,7 +925,7 @@ var display = function(name) {


return mod;
}
} // END display



Expand Down Expand Up @@ -1389,6 +1389,25 @@ var $builtinmodule = function (name) {
html += '<div class="mb_led mb_led_row_' + y + ' mb_led_col_' + x + '"></div>';
}
}

var pinTp = '';
for (var i = 0; i < 21; i++)
{
switch (i)
{
case 0: case 1: case 2:
pinTp = 'tch';
break;
case 3: case 4: case 10:
pinTp = 'anlg';
break;
default:
pinTp = 'dgtl';
break;
}

html += '<div id="mb_pin_' + i + '" class="mb_pin mb_pin_' + pinTp + '"></div>';
}
html += '</div>';
PythonIDE.python.output(html, true);
$('#mb_btn_radio_send').button().click(function() {
Expand Down Expand Up @@ -1497,7 +1516,7 @@ var $builtinmodule = function (name) {
}
}
function updatePinSpinner(pinNumber) {
var pinType = undefined;
var pinType = undefined, pTC = undefined;
var pin = undefined;
var html = '';
function sliderChange(event, ui) {
Expand All @@ -1508,7 +1527,7 @@ var $builtinmodule = function (name) {
case 0:
case 1:
case 2:
pinType = "Touch";
pinType = "Touch"; pTC = 'Touch';
pin = mod['pin' + pinNumber];
html = '<button id="mb_btn_pin_touch">Touch</button>';
$('#mb_pin_detail').html(html);
Expand All @@ -1521,12 +1540,13 @@ var $builtinmodule = function (name) {
case 3:
case 4:
case 10:
pinType = "Analog";
pinType = "Analog"; pTC = 'Analog';
pin = mod['pin' + pinNumber];
html = 'Value: <span id="mb_pin_analog_value">' + pin.value + '</span><div class="mb_slider" id="mb_pin_analog"></div> PWM period: ' + pin.period_us / 1000 + 'ms';
$('#mb_pin_detail').html(html);
$('#mb_pin_analog').slider({
value: pin.value,
orientation: 'vertical',
min: 0,
max: 1023,
step: 1,
Expand All @@ -1546,10 +1566,10 @@ var $builtinmodule = function (name) {
case 16:
case 19:
case 20:
pinType = "Digital";
pinType = "Digital"; pTC = 'Digital';
pin = mod['pin' + pinNumber];

html = 'Currently switched: <button id="mb_btn_pin_digital">' + (pin.value? 'On' : 'Off') + '</button>';
html = 'Currently switched:<br/> <button id="mb_btn_pin_digital">' + (pin.value? 'On' : 'Off') + '</button>';

$('#mb_pin_detail').html(html);
$('#mb_btn_pin_digital').button().click(function() {
Expand All @@ -1558,18 +1578,23 @@ var $builtinmodule = function (name) {
});
break;
default:
pinType = "+3v";
pinType = "+3v"; pTC = 'threeVolts';
$('#mb_pin_detail').html(html);
break;

}


$('#mb_pin_type').text('Type: ' + pinType);
$('#mb_pin_type').html('Type: <strong class="' + pTC + '">' + pinType + '</strong>');
}
$('#mb_pin_num').spinner({
spin: function(event, ui) {
updatePinSpinner(ui.value);

$('.mb_pin').each(function() {
$(this).animate({opacity: '0'}, 500);
});

if(ui.value < 0) {
$('#mb_pin_num').spinner("value", 20 );
return false;
Expand All @@ -1578,6 +1603,8 @@ var $builtinmodule = function (name) {
$('#mb_pin_num').spinner("value", 0 );
return false;
}

$('#mb_pin_' + ui.value).animate({opacity: '1'}, 500);
}
});
$('#mb_pin_num').spinner("value", 0);
Expand Down Expand Up @@ -1641,16 +1668,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({
Expand Down
136 changes: 121 additions & 15 deletions lib/skulpt/microbit/mb.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#mb_tabs {
font-size:10pt;
}
#mb_pin_num {
font-size: 0.8em;
}

#microbit {
width: 300px;
Expand Down Expand Up @@ -36,21 +33,21 @@
}

.mb_help_link {
font-size: small;
background-color: #FFF;
border-radius: 10px;
padding: 10px;
color: #000;
width: 100%;
display: block;
font-size: 10px;
color: #000000;
background-color: #FFFFFF;
background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.6) 5%, rgba(255, 255, 255, 0.6) 95%, rgba(255, 255, 255, 0) 100%);
text-align: center;
transition: all 0.5s;
margin: 5px;
border-style: solid;
border-width: 1px;
border-color: #000;
display:inline-block;

margin: 2px 0;
padding: 10px 0;
}

.mb_help_link:hover {
background-color: #F00;
background: linear-gradient(90deg, rgba(255, 46, 46, 0) 0%, rgba(255, 46, 46, 0.6) 5%, rgba(255, 46, 46, 0.6) 95%, rgba(255, 46, 46, 0) 100%);
}
.mb_led_brightness_0 { background-color: #000; }
.mb_led_brightness_1 { background-color: #300; }
Expand Down Expand Up @@ -127,7 +124,7 @@
}
.mb_current_gesture {
color: #F00;
margin; 1em;
margin: 1em;
}
.mb_active_gesture_down {
transform: rotate(180deg);
Expand Down Expand Up @@ -162,4 +159,113 @@
.mb_active_gesture_8g {
animation-name: shake;
animation-duration: 0.1s;
}

/* Thermometer */
#mb_therm_slider
{
height: 320px; width: 12px;
position: absolute;
left: 320px;
bottom: 0;
float: right;
background: linear-gradient(180deg, rgba(255, 0, 0, 1) 0%, rgba(255, 255, 255, 1) 66%, rgba(0, 255, 255, 1) 100%);
}

.mb_pin {
position: absolute;
bottom: -8px;
background-color: green;
height: 34px;
border-radius: 0 0 3px 3px;
opacity: 0;
}
.mb_pin_dgtl {
width: 5px;
background: linear-gradient(0deg, rgb(3, 231, 3) 0%, rgba(3, 231, 3, 1) 30%, rgba(3, 231, 3, 0) 100%);
}
.mb_pin_anlg {
width: 5px;
background: linear-gradient(0deg, rgb(7, 7, 207) 0%, rgba(7, 7, 207, 1) 30%, rgba(7, 7, 207, 0) 100%)
}
.mb_pin_tch {
width: 24px;
background: linear-gradient(0deg, rgb(255, 17, 17) 0%, rgba(255, 17, 17, 1) 30%, rgba(255, 17, 17, 0) 100%)
}


#mb_pin_num {
font-size: 0.8em;
}

#mb_pin_analog {
height: 240px; width: 12px;
left: 320px; bottom: 0;
float: left;
border: none;
background: rgb(3, 3, 121);
}

#mb_pin_analog span {
height: 20px; width: 30px;
position: absolute;
left: -18px;
border: none;
border-radius: 10px 0 0 10px;
background: rgb(7, 7, 207);
cursor: pointer;
}

/* Touch Pins */
#mb_pin_0 { left: 15px; opacity: 1; }
#mb_pin_1 { left: 74px; }
#mb_pin_2 { left: 141px; }

/* Analogue Pins */
#mb_pin_3 { left: 5px; }
#mb_pin_4 { left: 42.5px; }
#mb_pin_10 { left: 117px; }

/* Digital Pins */
#mb_pin_5 { left: 50px; }
#mb_pin_6 { left: 57.5px; }
#mb_pin_7 { left: 65.5px; }
#mb_pin_8 { left: 102px; }
#mb_pin_9 { left: 109px; }
#mb_pin_11 { left: 125px; }
#mb_pin_12 { left: 132px; }
#mb_pin_13 { left: 168.5px; }
#mb_pin_14 { left: 176px; }
#mb_pin_15 { left: 184px; }
#mb_pin_16 { left: 191px; }
#mb_pin_17 { left: 198px; }
#mb_pin_18 { left: 234.5px; }
#mb_pin_19 { left: 242.5px; }
#mb_pin_20 { left: 249px; }


#mb_pin_type {
margin: 10px 0;
padding: 0 0 0 10px;
background-color: rgba(20, 20, 20, 0.4);
}

#mb_pin_type strong { font-weight: 700; }
#mb_pin_type strong.Analog { color: rgb(7, 7, 207); }
#mb_pin_type strong.Digital { color: rgb(3, 231, 3); }
#mb_pin_type strong.Touch { color: #d40d0d; }
#mb_pin_type strong.threeVolts { color: #eed814; }

#mb_btn_pin_touch {
color: #FFFFFF;
background: #d40d0d;
border-radius: 5px;
border: none;
}

#mb_btn_pin_digital {
color: #FFFFFF;
background: rgb(3, 231, 3);
border-radius: 5px;
border: none;
}
2 changes: 1 addition & 1 deletion python-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function pythonEditor(id) {
}

return editor;
};
}; // END func pythonEditor

/*
The following code contains the various functions that connect the behaviour of
Expand Down
2 changes: 1 addition & 1 deletion show.sh
Original file line number Diff line number Diff line change
@@ -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
Loading