Cleanup GPIO handler, support third tap

This commit is contained in:
Oliver Gugger
2019-08-09 15:34:31 +02:00
parent 48e5efb196
commit fa6fc8dc6a

View File

@@ -20,6 +20,7 @@ r_ch3 = 21
# single tap # single tap
t_large_beer = 6 t_large_beer = 6
t_small_beer = 2 t_small_beer = 2
# double tap # double tap
t_left_tap = 6 t_left_tap = 6
t_right_tap = 6 t_right_tap = 6
@@ -27,8 +28,6 @@ t_right_tap = 6
t_flush = 20 t_flush = 20
# Syntax suger because of negative logic # Syntax suger because of negative logic
S_ON = GPIO.LOW S_ON = GPIO.LOW
S_OFF = GPIO.HIGH S_OFF = GPIO.HIGH
@@ -58,25 +57,24 @@ def cli_args_parser():
) )
parser.add_argument( parser.add_argument(
'-f', '-f1',
'--flush', '--flush1',
action='store_true', action='store_true',
help="Flush tap for 20s!" help="Flush tap 1 for 20s!"
) )
parser.add_argument( parser.add_argument(
'-f2', '-f2',
'--flush2', '--flush2',
action='store_true', action='store_true',
help="Flush tap for 20s!" help="Flush tap 2 for 20s!"
) )
parser.add_argument( parser.add_argument(
'-m', '-f3',
'--memo', '--flush3',
action='store', action='store_true',
dest='memo', help="Flush tap 3 for 20s!"
help="Precise product information"
) )
return parser.parse_args() return parser.parse_args()
@@ -140,12 +138,15 @@ if __name__ == "__main__":
if args.test: if args.test:
print("Test mode enabled") print("Test mode enabled")
gpio_test() gpio_test()
elif args.flush: elif args.flush1:
print("Choice: Flush tap") print("Choice: Flush tap1")
draw_beer(r_ch1, t_flush) draw_beer(r_ch1, t_flush)
elif args.flush2: elif args.flush2:
print("Choice: Flush tap2") print("Choice: Flush tap2")
draw_beer(r_ch2, t_flush) draw_beer(r_ch2, t_flush)
elif args.flush3:
print("Choice: Flush tap3")
draw_beer(r_ch3, t_flush)
elif args.products == "LARGE": elif args.products == "LARGE":
print("Choice: Large beer") print("Choice: Large beer")
draw_beer(r_ch1, t_large_beer) draw_beer(r_ch1, t_large_beer)
@@ -154,9 +155,9 @@ if __name__ == "__main__":
draw_beer(r_ch1, t_small_beer) draw_beer(r_ch1, t_small_beer)
elif args.products == "LEFT_TAP": elif args.products == "LEFT_TAP":
print("Choice: left tap") print("Choice: left tap")
draw_beer(r_ch1,t_left_tap) draw_beer(r_ch1, t_left_tap)
elif args.products == "RIGHT_TAP": elif args.products == "RIGHT_TAP":
print("Choice: right tap") print("Choice: right tap")
draw_beer(r_ch2,t_right_tap) draw_beer(r_ch2, t_right_tap)
else: else:
print("RTFM!") print("RTFM!")