added status indicator

This commit is contained in:
Michael Clemens 2019-09-13 05:53:12 +01:00
parent 4558b9d6f4
commit c7fb16979d
2 changed files with 44 additions and 16 deletions

View File

@ -11,25 +11,55 @@ GPIO.setwarnings(False)
RELAIS_1_GPIO = 0
RELAIS_2_GPIO = 1
enabled = '#bbffbb'
disabled = '#eeeeee'
def b1():
coax1 = GPIO.input(RELAIS_1_GPIO)
coax2 = GPIO.input(RELAIS_2_GPIO)
if coax1 == 0 and coax2 == 1:
return enabled
else:
return disabled
def b2():
coax1 = GPIO.input(RELAIS_1_GPIO)
coax2 = GPIO.input(RELAIS_2_GPIO)
if coax1 == 1 and coax2 == 0:
return enabled
else:
return disabled
def b3():
coax1 = GPIO.input(RELAIS_1_GPIO)
coax2 = GPIO.input(RELAIS_2_GPIO)
if coax1 == 1 and coax2 == 1:
return enabled
else:
return disabled
GPIO.setup(RELAIS_1_GPIO, GPIO.OUT)
GPIO.setup(RELAIS_2_GPIO, GPIO.OUT)
@app.route('/')
def start():
return render_template('index.html')
return render_template('index.html', bc1=b1(), bc2=b2(), bc3=b3())
@app.route('/index',methods = ['POST', 'GET'])
def index():
if request.method == 'POST':
if request.form['ant_button'] == 'Antenna 1':
if request.form['ant_button'] == 'ant1':
GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
GPIO.output(RELAIS_1_GPIO, GPIO.LOW)
return redirect(url_for('start'))
if request.form['ant_button'] == 'Antenna 2':
if request.form['ant_button'] == 'ant2':
GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
GPIO.output(RELAIS_2_GPIO, GPIO.LOW)
return redirect(url_for('start'))
if request.form['ant_button'] == 'Antenna 3':
if request.form['ant_button'] == 'ant3':
GPIO.output(RELAIS_1_GPIO, GPIO.HIGH)
GPIO.output(RELAIS_2_GPIO, GPIO.HIGH)
return redirect(url_for('start'))

View File

@ -4,18 +4,16 @@
</head>
<body>
<form action = "/index" method = "post">
<div>
<input type ="submit" name="ant_button" value="Antenna 1">
X200
</div>
<div>
<input type ="submit" name="ant_button" value="Antenna 2">
20m Dipol
</div>
<div>
<input type ="submit" name="ant_button" value="Antenna 3">
40-20-10 Windom
</div>
<table>
<tr>
<td><button type ="submit" name="ant_button" style="background-color:{{ bc1 }};color:black;width:200px;height:40px;" value="ant1">X200</button></td>
</tr>
<tr>
<td><button type ="submit" name="ant_button" style="background-color:{{ bc2 }};color:black;width:200px;height:40px;" value="ant2">20m Dipol</button></td>
</tr>
<tr>
<td><button type ="submit" name="ant_button" style="background-color:{{ bc3 }};color:black;width:200px;height:40px;" value="ant3">40-20-10m Windom</button></td>
</tr>
</form>
</body>
</html>