n=0
-# set gpio lines
+# set gpio output lines
def set_line_values(chip_path, line_values):
value_str = {Value.ACTIVE: "Active", Value.INACTIVE: "Inactive"}
# having systemd use SIGINT to avoid CherryPy consuming the kill signal
signal.signal(signal.SIGINT, handler)
-
+
+def sense_armed():
+ with gpiod.request_lines(
+ "/dev/gpiochip0",
+ consumer="get-line-value",
+ config={12: gpiod.LineSettings(direction=Direction.INPUT)},
+ ) as request:
+ value = request.get_value(12)
+ if value == Value.ACTIVE:
+ return 'armed'
+ else:
+ return 'safe'
+
path = os.path.abspath(os.path.dirname(__file__))
config = {
'global' : {
t = str(n) + b
pyro_v = str(n) + ' volts'
batt_v = str(n) + ' volts'
+ armed = sense_armed()
+
return {
'pressure' : p,
'thrust' : t,
'pyro' : pyro_v,
- 'battery' : batt_v
+ 'battery' : batt_v,
+ 'armed' : armed
}
$('#thrust').text(response.thrust);
$('#pyro').text(response.pyro);
$('#battery').text(response.battery);
+ $('#armed').text(response.armed);
});
request.fail(function(jqXHR, textStatus)
{
<div id='pyro'></div>
<h2>Battery</h2>
<div id='battery'></div>
+ <h2>Armed</h2>
+ <div id='armed'></div>
</body>
</html>