Skip to content

Commit 73106a8

Browse files
committed
agregado seleccion de modos
1 parent 4316537 commit 73106a8

4 files changed

Lines changed: 138 additions & 20 deletions

File tree

nw-miniblip/firmwares.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "0.0.1",
55
"author": "victor",
66
"filename": "anim",
7+
"id": 1,
78
"type": "",
89
"image": "yes",
910
"md5": ""
@@ -13,6 +14,7 @@
1314
"version": "0.0.1",
1415
"author": "victor2",
1516
"filename": "serial",
17+
"id": 2,
1618
"type": "firmware",
1719
"image": "yes",
1820
"md5": ""

nw-miniblip/index.html

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
<script>
1313
var editor;
1414
$( document ).ready(function() {
15+
bind_buttons();
1516
get_list_firmwares_local();
1617

1718
editor = ace.edit("editor");
1819
editor.setTheme("ace/theme/monokai");
19-
editor.getSession().setMode("ace/mode/javascript");
20+
editor.getSession().setMode("ace/mode/c_cpp");
2021
editor.setOptions({
2122
fontSize: "15pt"
2223
});
@@ -28,34 +29,56 @@
2829
<div id = "container">
2930
<div id = "toolbar">
3031
<ul>
31-
<li> <i class="fa fa-list fa-2x"></i></li>
32-
<li> <i class="fa fa-terminal fa-2x"></i></li>
33-
<li> <i class="fa fa-code fa-2x"></i></li>
32+
<li id = "list"> <i class="fa fa-list fa-2x"></i></li>
33+
<li id = "console"> <i class="fa fa-terminal fa-2x"></i></li>
34+
<li id = "code"> <i class="fa fa-code fa-2x"></i></li>
3435

3536

3637
</ul>
3738
</div>
3839

3940
<div id = "main">
4041

41-
<div id = "firmwares">
42+
<div id = "firmware-list">
4243

4344
</div>
4445

4546
<div id = "board">
4647
<img src="./images/miniblip_board.png">
4748
</div>
4849

49-
<div id="editor">function foo(items) {
50-
var x = "All this is syntax highlighted";
51-
return x;
52-
}</div>
53-
50+
<div id="editor-container">
51+
<div id = "actions">
52+
<ul>
53+
<li> <i class="fa fa-play-circle fa-2x"></i></li>
54+
<li> <i class="fa fa-stop-circle fa-2x"></i></li>
55+
<li> <i class="fa fa-arrow-circle-right fa-2x"></i></li>
56+
</ul>
57+
</div>
58+
59+
<div id="editor">
5460

61+
void setup() {
62+
// Turn off miniblip buzzer
63+
speaker=0.0;
5564

56-
<div id = "actions">
65+
serial.printf("Hello world!\n");
66+
67+
for (int i = 0; i < TOUCH_N; i++) {
68+
p_touch_io[i] = new DigitalInOut(touch_pin[i]);
69+
p_touch_io[i]->mode(PullDown);
70+
p_touch_io[i]->output();
71+
p_touch_io[i]->write(1);
72+
}
73+
74+
tick.attach(detect, 1.0 / 40.0);
75+
}
5776

77+
</div>
5878
</div>
79+
80+
81+
5982

6083
<div id = "console">
6184
<ul>

nw-miniblip/javascript/main.js

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,30 @@ function detect_board() {
33

44
}
55

6-
7-
function upload_firmware() {
8-
9-
6+
function upload_firmware(path_in, path_out) {
7+
var cmd_dd = "sudo dd if="+path_in+" of="+path_out+" bs=512 seek=4 conv=notrunc";
8+
9+
console.log(cmd_dd);
10+
11+
12+
var execFile = require
13+
('child_process').execFile, child;
14+
15+
child = execFile(cmd_dd,
16+
function(error,stdout,stderr) {
17+
if (error) {
18+
console.log(error.stack);
19+
console.log('Error code: '+ error.code);
20+
console.log('Signal received: '+
21+
error.signal);
22+
}
23+
console.log('Child Process stdout: '+ stdout);
24+
console.log('Child Process stderr: '+ stderr);
25+
});
26+
child.on('exit', function (code) {
27+
console.log('Child process exited '+
28+
'with exit code '+ code);
29+
});
1030
}
1131

1232

@@ -19,6 +39,20 @@ function init_console(div) {
1939
function get_list_firmwares_remote() {
2040

2141

42+
}
43+
44+
function get_local_firmware_path(firmware_name) {
45+
var base = process.cwd() + "/firmwares-prueba/";
46+
47+
var path = base + "firmware_name";
48+
console.log(path);
49+
50+
return path;
51+
}
52+
53+
function get_remote_firmware_url() {
54+
55+
2256
}
2357

2458
function get_list_firmwares_local() {
@@ -29,10 +63,13 @@ function get_list_firmwares_local() {
2963
console.log(data);
3064
var obj = $.parseJSON( data );
3165

32-
for (var i = 0; i < obj.length; i++) {
66+
$.each(obj, function(i, value) {
3367
console.log(obj[i].name);
34-
$("#firmwares").append('<div class="item"><div class="name">' + obj[i].name +'</div><div class="author">'+obj[i].author+'</div></div>');
35-
}
68+
$("#firmware-list").append('<div class="item" id = '+obj[i].id +'><div class="name">' + obj[i].name +'</div><div class="author">'+obj[i].author+'</div></div>');
69+
$("#firmware-list #" + obj[i].id).click(function() {
70+
upload_firmware(get_local_firmware_path(obj[i].id), "/dev/sdb");
71+
});
72+
});
3673
//console.log(obj);
3774
});
3875
}
@@ -42,3 +79,34 @@ function get_list_firmwares_local() {
4279
function download_firmware() {
4380

4481
}
82+
83+
84+
85+
86+
function bind_buttons() {
87+
$("#toolbar #list").click(function() {
88+
hide_all_sections();
89+
$("#main #firmware-list").show();
90+
});
91+
92+
$("#toolbar #console").click(function() {
93+
hide_all_sections();
94+
$("#main #console").show();
95+
});
96+
97+
$("#toolbar #code").click(function() {
98+
hide_all_sections();
99+
$("#main #editor-container").show();
100+
});
101+
}
102+
103+
104+
function hide_all_sections() {
105+
$("#main #editor-container").hide();
106+
107+
}
108+
109+
function show_section() {
110+
111+
112+
}

nw-miniblip/styles/main.less

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,26 @@ body {
8282
position: absolute;
8383
}
8484

85+
#actions {
86+
z-index: 10;
87+
position: absolute;
88+
top: 0;
89+
right: -32px;
90+
background: rgb(255, 223, 0);
91+
padding: 10px;
92+
border-radius: 0px 0px 2px 2px;
93+
box-shadow: 0px 0px 10px black;
94+
color: rgb(95, 91, 10);
95+
96+
97+
li {
98+
padding: 10px;
99+
}
85100

101+
}
86102

87103

88-
89-
#firmwares {
104+
#firmware-list {
90105
float: left;
91106
width: 200px;
92107
background: white;
@@ -100,6 +115,16 @@ body {
100115
.name {
101116
font-weight: bold;
102117
}
118+
119+
.author {
120+
color: gray;
121+
font-style: italic;
122+
font-size: 0.8em;
123+
}
124+
125+
&:hover {
126+
background: rgba(0, 0, 0, 0.08);
127+
}
103128
}
104129
}
105130

0 commit comments

Comments
 (0)