the_software_build_and_test
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
the_software_build_and_test [2017/01/22 19:48] – walkeradmin | the_software_build_and_test [2023/03/09 22:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 24: | Line 24: | ||
==== Working Clock Code ==== | ==== Working Clock Code ==== | ||
\\ | \\ | ||
- | This is the final version of code that was used. It has the support for the flashing dots time separator. If cutting and pasting isn't working well for you, download the python file {{ :working_new.zip |here:}} | + | This is the final version of code that was used. It has the support for the flashing dots time separator. If cutting and pasting isn't working well for you, download the python file {{ :7segmentledclock_v1.0.zip |Here}}. |
- | <file> | + | <sxh [py][; options for SyntaxHighlighter]> |
#! / | #! / | ||
- | # code modified, tweaked and tailored from code by bertwert | + | # Python Script to run a 7 Segment Common Anode LED as a clock. |
- | # on RPi forum thread topic 91796 | + | # Version 1.0 |
import RPi.GPIO as GPIO | import RPi.GPIO as GPIO | ||
import time | import time | ||
Line 72: | Line 72: | ||
try: | try: | ||
while True: | while True: | ||
- | | + | |
- | s = str(n).rjust(4) | + | |
for digit in range(4): | for digit in range(4): | ||
+ | #select digit to display | ||
GPIO.output(gpioDigits[digit], | GPIO.output(gpioDigits[digit], | ||
- | | + | #set required segments on |
- | GPIO.output(gpioSegments[segment], | + | |
+ | GPIO.output(gpioSegments[segment], | ||
+ | #check to see if we are on segment 3 of digit 2(LTR) | ||
if ((digit==1) and (segment==2)): | if ((digit==1) and (segment==2)): | ||
- | if (colon_counter< | + | #when colon counter gets to set value flip colon display mode between TRUE (visible) and False (NOT.visible) |
+ | if (colon_counter< | ||
+ | #count value not reached turn colon ON or OFF based on current setting of colon_visible | ||
if colon_visible==True: | if colon_visible==True: | ||
GPIO.output(13, | GPIO.output(13, | ||
else: | else: | ||
GPIO.output(13, | GPIO.output(13, | ||
+ | #colon counter set value reached so flip colon display mode and reset colon counter | ||
else: | else: | ||
colon_counter = 0 | colon_counter = 0 | ||
colon_visible = not colon_visible | colon_visible = not colon_visible | ||
+ | #display all selected segments for a short time | ||
time.sleep(0.005) | time.sleep(0.005) | ||
- | | + | #turn-off All segments |
- | for segment in (gpioSegments): | + | for segment in range(0,8): |
- | GPIO.output(segment, | + | GPIO.output(gpioSegments[segment], |
- | + | #turn-off current digit selector pin | |
- | | + | GPIO.output(gpioDigits[digit], GPIO.LOW) |
- | | + | #advance colon counter |
colon_counter=colon_counter+1 | colon_counter=colon_counter+1 | ||
finally: | finally: | ||
- | | + | |
- | </file> | + | </sxh> |
\\ | \\ | ||
\\ | \\ | ||
Line 106: | Line 110: | ||
\\ | \\ | ||
==== Here is the original code, unedited ==== | ==== Here is the original code, unedited ==== | ||
- | <file> | + | <sxh [py][; options for SyntaxHighlighter]> |
# code modified, tweaked and tailored from code by bertwert | # code modified, tweaked and tailored from code by bertwert | ||
# on RPi forum thread topic 91796 | # on RPi forum thread topic 91796 | ||
Line 157: | Line 161: | ||
finally: | finally: | ||
GPIO.cleanup() | GPIO.cleanup() | ||
- | + | </sxh> | |
- | </file> | + |
the_software_build_and_test.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1