diff --git a/antennapi.py b/antennapi.py index 59e7dec..59a780f 100644 --- a/antennapi.py +++ b/antennapi.py @@ -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')) diff --git a/templates/index.html b/templates/index.html index 4c60b4b..2a8da4d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,18 +4,16 @@
-
- - X200 -
-
- - 20m Dipol -
-
- - 40-20-10 Windom -
+ + + + + + + + + +