Skip to content

Commit

Permalink
Fixed URL Screen Display
Browse files Browse the repository at this point in the history
  • Loading branch information
markyharris committed Jan 4, 2024
1 parent 9fd926e commit d86f2bb
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 42 deletions.
8 changes: 4 additions & 4 deletions data.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
KFLG
-2
KSEZ
1
60
0
2
0
0
1
1
0
0
18 changes: 3 additions & 15 deletions metar_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@

# Layouts - add new layouts to this list as necessary
layout_list = [layout0,layout1,layout2,layout3,layout4,layout5,layout6,layout7,layout8,layout9] # ,layout6 Add layout routine names here
global startup_flag
startup_flag = 0 # will be reset to 1 once the IP URL is displayed.

# Check for cmdline args and use passed variables instead of the defaults
# example ['/home/pi/metar/metar_main.py', 'metar', 'kabe', '1', '0', '1', '2', '0', '0', '1', '1']
Expand Down Expand Up @@ -83,15 +81,9 @@

def main():
global display,metar,remarks,print_table,use_remarks,use_disp_format,interval,wind_speed_units,cloud_layer_units,visibility_units,temperature_units,pressure_units,layout_list
global startup_flag

# Choose which layout to use.
if startup_flag == 0: #use_disp_format == -3:
disp_ip(display, get_ip_address())
print('---> use_disp_format:',use_disp_format) # debug
print('---> interval:',interval,'\n') # debug

elif use_disp_format == -1:
# Choose which layout to use.
if use_disp_format == -1:
random_layout(display,metar,remarks,print_table,use_remarks,use_disp_format,interval,wind_speed_units,cloud_layer_units,visibility_units,temperature_units,pressure_units,layout_list)

elif use_disp_format == -2:
Expand Down Expand Up @@ -160,12 +152,8 @@ def main():
# The update interval can be selected via cmd line or web iterface
# If Auto Interval is selected, then Flight Category dictates update
# So the worse the weather, the more often it updates.
if startup_flag == 0:
startup_flag = 1
print("sleep 1 min for Admin URL")
time.sleep(60)

elif interval != 0: # if not auto interval selected
if interval != 0: # if not auto interval selected
print("sleep ",interval) # debug
time.sleep(interval) # Sets interval of updates. 3600 = 1 hour

Expand Down
34 changes: 34 additions & 0 deletions metar_startup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from metar_layouts import *
from metar_routines import *
import time

# epd7in5b_V2 = 3-color 7 by 5 display. Change this based on the display used.
# find 'epd = epd7in5b_V2.EPD()' towards bottom and change also if needed.
# These are located in the directory 'waveshare_epd'
from waveshare_epd import epd7in5b_V2


if __name__ == "__main__":
epd = epd7in5b_V2.EPD() # Instantiate instance for display.
epd.init()
epd.Clear()
display = Display() # pass to routines

disp_ip(display, get_ip_address())

# Print to e-Paper - This is setup to display on 7x5 3 color waveshare panel. epd7in5b_V2
print("Updating screen...")
try:
epd.init()
time.sleep(1)
print("Printing METAR Data to E-Paper")
epd.display(epd.getbuffer(display.im_black), epd.getbuffer(display.im_red))
print("Done")
time.sleep(2)

except Exception as e:
print("Printing error", e)

print("------------")
print("Done")

94 changes: 71 additions & 23 deletions templates/metar.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
}
.myDiv span{
text-align: center;
background: #b1cafc;
background: #ffffff;
padding: 6px 6px;
display: block;
width: 400px;
border: 1px solid blue;
width: 120px;
border: 0px solid blue;
margin: 8px auto;
font-family: Arial, Helvetica, sans-serif;
}
Expand Down Expand Up @@ -72,7 +72,7 @@ <h2>METAR E-Paper Display Admin Page</h2>
<table class="table table-bordered">
<tbody>
<tr class="table-warning">
<td>
<td width="50%">
<label for="display"><b>Choose a Function:</b></label><br>
<select name="display" id="display">
<option value="metar" {% if display=="metar" %} selected="selected" {% endif %}>Display METAR Info</option>
Expand All @@ -81,6 +81,48 @@ <h2>METAR E-Paper Display Admin Page</h2>
<option value="powerdown" {% if display=="powerdown" %} selected="selected" {% endif %}>Power Down RPi</option>
</select>
</td>
<td>
<div id="show0" class="myDiv">
<span><p>
<img src="./static/layout0.jpg" width="100"><p><p>
</span>
</div>
<div id="show1" class="myDiv">
<span><p>
<img src="./static/layout1.jpg" width="100"><p><p>
</span>
</div>
<div id="show2" class="myDiv">
<span><p>
<img src="./static/layout2.jpg" width="100"><p><p>
</span>
</div>
<div id="show3" class="myDiv">
<span><p>
<img src="./static/layout3.jpg" width="100"><p><p>
</span>
</div>
<div id="show4" class="myDiv">
<span><p>
<img src="./static/layout4.jpg" width="100"><p><p>
</span>
</div>
<div id="show5" class="myDiv">
<span><p>
<img src="./static/layout5.jpg" width="100"><p><p>
</span>
</div>
<div id="show6" class="myDiv">
<span><p>
<img src="./static/layout6.jpg" width="100"><p><p>
</span>
</div>
<div id="show7" class="myDiv">
<span><p>
<img src="./static/layout7.jpg" width="100"><p><p>
</span>
</div>
</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -200,26 +242,32 @@ <h2>METAR E-Paper Display Admin Page</h2>
</tbody>
</table>
</div>
<button class="btn btn-primary" type="submit">Submit</button>

</form>
<p>


<hr>
<!-- Flash message via flask and jinja to announce what is currently being displayed -->
<div class="flashes">
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class=flashes>
{% for message in messages %}
</div><b class="text-danger">{{ message }}</b>
{% endfor %}
<table class="table table-bordered">
<tbody>
<tr class="table-secondary">
<td width="50%">
<button class="btn btn-primary" type="submit">Submit</button>
</form>
</td>
<td>
<!-- Flash message via flask and jinja to announce what is currently being displayed -->
<div class="flashes">
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class=flashes>
{% for message in messages %}
</div><b class="text-danger">{{ message }}</b>
{% endfor %}
{% endif %}
{% endwith %}
</div>
</td>
</tr>
</tbody>
</table>

{% endif %}
{% endwith %}
</div>
<hr>
<!-- <hr>
<div id="show0" class="myDiv">
<span><p>
Expand Down Expand Up @@ -261,7 +309,7 @@ <h2>METAR E-Paper Display Admin Page</h2>
<img src="./static/layout7.jpg" width="300"><p><p>
</span>
</div>

-->

</div>
</div>
Expand Down

0 comments on commit d86f2bb

Please sign in to comment.