Skip to content

Commit

Permalink
stop button tweaks; atmega reset feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Hechenberger committed Feb 17, 2013
1 parent 310ec92 commit d828746
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
8 changes: 7 additions & 1 deletion backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from wsgiref.simple_server import WSGIRequestHandler, make_server
from bottle import *
from serial_manager import SerialManager
from flash import flash_upload
from flash import flash_upload, reset_atmega
from filereaders import read_svg, read_dxf


Expand Down Expand Up @@ -381,6 +381,12 @@ def flash_firmware_handler(firmware_file=FIRMWARE):
return ''.join(ret)


@route('/reset_atmega')
def reset_atmega_handler():
reset_atmega(HARDWARE)
return '1'


# @route('/gcode/:gcode_line')
# def gcode_handler(gcode_line):
# if SerialManager.is_connected():
Expand Down
29 changes: 28 additions & 1 deletion backend/flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,31 @@ def trigger_reset():
return subprocess.call(command, shell=True)



def reset_atmega(hardware=''):
if hardware == 'beaglebone':
try:
fw = file("/sys/class/gpio/export", "w")
fw.write("%d" % (71))
fw.close()
except IOError:
pass
fw = file("/sys/class/gpio/gpio71/direction", "w")
fw.write("out")
fw.close()
fw = file("/sys/class/gpio/gpio71/value", "w")
fw.write("0")
fw.flush()
time.sleep(0.2)
fw.write("1")
fw.flush()
fw.close()
elif hardware == 'raspberrypi':
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM) # use chip pin number
pinReset = 2
GPIO.setup(pinReset, GPIO.OUT)
GPIO.output(pinReset, GPIO.LOW)
time.sleep(0.2)
GPIO.output(pinReset, GPIO.HIGH)
else:
print "ERROR: forced reset only possible on beaglebone and raspberrypi"
5 changes: 3 additions & 2 deletions frontend/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
<div class="btn-group pull-right">
<button id="go_to_origin" class="btn" type="submit" title="move to origin">(0,0)</i></button>
<button id="homing_cycle" class="btn" type="submit" title="run homing cycle, find table origin"><i class="icon-home"></i></button>
<button id="cancel_btn" class="btn" type="submit">Stop</button>
<button id="cancel_btn" class="btn" type="submit" title="stop and purge job"><i class="icon-stop"></i></button>
</div>
<button id="pause_btn" class="btn pull-right" type="submit"><i class="icon-pause"></i></button>
<button id="pause_btn" class="btn pull-right" type="submit" title="pause/continue"><i class="icon-pause"></i></button>
<a class="brand" href="#" style="color:#666666"><img src="/img/lasersaur-dino-brand.png" style="margin-right:6px">LasaurApp</a>
<div class="nav-collapse">
<ul class="nav">
Expand All @@ -59,6 +59,7 @@
<li><a href="flash_firmware">Flash Firmware (DriveBoard v13.01)</a>
<li><a href="flash_firmware/LasaurGrbl-ls.hex">Flash Firmware (LasaurShield v13.01-ls, testing)</a>
<li><a href="flash_firmware/LasaurGrbl-v12.08f.hex">Flash Firmware (LasaurShield v12.08f, stable)</a>
<li><a id="reset_atmega" href="reset_atmega">Reset Atmega (restarts firmware)</a>
</ul>
</li>

Expand Down
15 changes: 14 additions & 1 deletion frontend/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ $(document).ready(function(){
hardware_ready_state = true;
$("#connect_btn").html("Ready");
} else {
$("#connect_btn").html("Busy");
hardware_ready_state = false;
}

Expand Down Expand Up @@ -426,6 +427,7 @@ $(document).ready(function(){
}
);

$("#pause_btn").tooltip({placement:'bottom', delay: {show:500, hide:100}});
$("#pause_btn").click(function(e){
if (pause_btn_state == true) { // unpause
$.get('/pause/0', function(data) {
Expand Down Expand Up @@ -456,7 +458,7 @@ $(document).ready(function(){
//\\\\\\ serial connect and pause button \\\\\\\\



$("#cancel_btn").tooltip({placement:'bottom', delay: {show:500, hide:100}});
$("#cancel_btn").click(function(e){
var gcode = '!\n' // ! is enter stop state char
$().uxmessage('notice', gcode.replace(/\n/g, '<br>'));
Expand Down Expand Up @@ -495,5 +497,16 @@ $(document).ready(function(){
send_gcode(gcode, "Going to origin ...", false);
e.preventDefault();
});

$("#reset_atmega").click(function(e){
$.get('/reset_atmega', function(data) {
if (data != "") {
$().uxmessage('success', "Atmega restarted!");
} else {
$().uxmessage('error', "Atmega restart failed!");
}
});
e.preventDefault();
});

}); // ready

0 comments on commit d828746

Please sign in to comment.