<h2 id="code">Code</h2>
<p>The script being discussed in this show is available for download with this show: <a href="https://hackerpublicradio.org/eps/hpr2951/cad-menu.py">cad-menu.py</a></p>
<h2 id="generic-functions">GENERIC FUNCTIONS</h2>
<ul>
<li><code>def get_hpr_que():</code><br />
Goto hacker public stats page and extract the number of days to next free slot turns on blinkstick LED with colour dependent on the number of days to next free slot in HPR queue prints number of days to next free slot to the display</li>
</ul>
<h2 id="generic-blinkstick-functions">GENERIC BLINKSTICK FUNCTIONS</h2>
<ul>
<li><p><code>def bstick_off():</code><br />
Search for all attached blinksticks and turn them all off</p></li>
<li><p><code>def bstick_on(colour):</code><br />
Turn blinkstick on and set led colour to string value stored in var colour. valid colours are, black, silver, gray, white, maroon, red, purple, fuchsia, green, lime, olive, yellow, navy, blue, teal, aqua</p></li>
<li><p><code>def bstick_on_random():</code><br />
Turn blinkstick on colour random</p></li>
<li><p><code>def bstick_blink(colour):</code><br />
Turn blinkstick on with supplied colour</p></li>
</ul>
<h2 id="end-blinkstick-functions">END BLINKSTICK FUNCTIONS</h2>
<ul>
<li><p><code>def run_cmd(cmd):</code><br />
Used to run an external linux command</p></li>
<li><p><code>def get_my_ip():</code><br />
Returns ip address</p></li>
<li><p><code>def get_my_essid():</code><br />
Returns wifi ESSID</p></li>
<li><p><code>def get_my_wifi_strength():</code><br />
Returns wifi signal strength as a percentage</p></li>
<li><p><code>def wait_for_ip():</code><br />
Tries 10 times to get IP address</p></li>
<li><p><code>def show_wifi_info():</code><br />
Show WiFi information on display, shows essid on first line and both the wifi signal strength as a percentage and ip address on the second line.</p></li>
<li><p><code>def custom_bitmaps():</code><br />
Selection of custom bitmaps to use on LCD display</p></li>
<li><p>Article in pifacecad documentation giving details about creating custom bitmaps on the pifacecad<br />
<a href="https://piface.github.io/pifacecad/creating_custom_bitmaps.html" class="uri">https://piface.github.io/pifacecad/creating_custom_bitmaps.html</a></p></li>
<li><p>This tool referenced in the pifacecad documentation link above can help design custom bitmaps. Make sure you select 5x8<br />
<a href="https://www.quinapalus.com/hd44780udg.html" class="uri">https://www.quinapalus.com/hd44780udg.html</a></p></li>
<li><p><code>def writelongstring(longstring):</code><br />
Writes a long string to the piface control and display LCD &amp; scrolls it to the left until the last character appears on the right hand side of the screen</p></li>
</ul>
<pre><code># Local Variables (for function writelongstring)
DisplaySize = 15
# Number of characters  that can be displayed on 1 line of display

StepSize = 4
# Step size when scrolling message on display

ScrollSpeed =   0.55
# Adjusts scroll speed, delay in seconds between scrolls

Scroll = 0
# Default value for scroll, used when string is smaller than display size</code></pre>
<ul>
<li><p><code>def init_display():</code><br/>
# Setup LCD display for selected menu 0 (Podcasts), 1 (Audiobooks), 2 (System)</p></li>
<li><p><code>def display_main_menu(event):</code><br/>
# Clear LCD &amp; dsplays the appropriate main menu message</p></li>
</ul>
