Skip to content

Commit

Permalink
delay parameter (useful while using DTR)
Browse files Browse the repository at this point in the history
  • Loading branch information
cTn-dev committed Jul 19, 2013
1 parent 8ad2d25 commit 45b1b94
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
4 changes: 2 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ chrome.app.runtime.onLaunched.addListener(function() {
id: 'main-window',
minWidth: 960,
maxWidth: 960,
minHeight: 550,
maxHeight: 550
minHeight: 570,
maxHeight: 570
}, function(main_window) {
main_window.onClosed.addListener(function() {
// connectionId is passed from the script side through the chrome.runtime.getBackgroundPage refference
Expand Down
2 changes: 1 addition & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ body {
.controls {
padding-top: 10px;

height: 109px;
height: 129px;

overflow: hidden;

Expand Down
20 changes: 13 additions & 7 deletions js/serial_backend.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$(document).ready(function() {
port_picker = $('div#port-picker .port select');
baud_picker = $('div#port-picker #baud');
delay_picker = $('div#port-picker #delay');

$('div#port-picker a.refresh').click(function() {
console.log("Available port list requested.");
Expand Down Expand Up @@ -45,11 +46,14 @@ $(document).ready(function() {
if (clicks) { // odd number of clicks
chrome.serial.close(connectionId, onClosed);

clearTimeout(connection_delay);

$(this).text('Connect');
$(this).removeClass('active');
} else { // even number of clicks
selected_port = String($(port_picker).val());
selected_baud = parseInt(baud_picker.val());
connection_delay = parseInt(delay_picker.val());

console.log('Connecting to: ' + selected_port);

Expand Down Expand Up @@ -94,13 +98,15 @@ function onOpen(openInfo) {
}
});

// start polling
serial_poll = setInterval(readPoll, 10);
plot_poll = setInterval(redraw_plot, 40);
port_usage_poll = setInterval(port_usage, 1000);

// Send over the configuration
send_current_configuration();
connection_delay = setTimeout(function() {
// start polling
serial_poll = setInterval(readPoll, 10);
plot_poll = setInterval(redraw_plot, 40);
port_usage_poll = setInterval(port_usage, 1000);

// Send over the configuration
send_current_configuration();
}, connection_delay * 1000);

console.log('Connection established.');
} else {
Expand Down
16 changes: 16 additions & 0 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@
<option value="300">300</option>
</select>
</dd>
<dt>Delay:</dt>
<dd>
<select id="delay" title="Useful if you have DTR (RESET) pin connected.">
<option value="0">0 sec.</option>
<option value="1">1 sec.</option>
<option value="2">2 sec.</option>
<option value="3">3 sec.</option>
<option value="4">4 sec.</option>
<option value="5">5 sec.</option>
<option value="6">6 sec.</option>
<option value="7">7 sec.</option>
<option value="8">8 sec.</option>
<option value="9">9 sec.</option>
<option value="10">10 sec.</option>
</select>
</dd>
<dt class="port-usage"><dt><dd><a class="connect" href="#" title="">Connect</a></dd>
<dt><dt><dd><a class="refresh" href="#" title="">Refresh</a> </dd>
</dl>
Expand Down

0 comments on commit 45b1b94

Please sign in to comment.