#!/usr/bin/python import gpiod import time message="0123456789" PIN_Signals = [ ("0" ,(1,1,1,1,1,1,0,0)), ("1" ,(0,1,1,0,0,0,0,0)), ("2" ,(1,1,0,1,1,0,1,0)), ("3" ,(1,1,1,1,0,0,1,0)), ("4" ,(0,1,1,0,0,1,1,0)), ("5" ,(1,0,1,1,0,1,1,0)), ("6" ,(1,0,1,1,1,1,1,0)), ("7" ,(1,1,1,0,0,0,0,0)), ("8" ,(1,1,1,1,1,1,1,0)), ("9" ,(1,1,1,1,0,1,1,0)), ] select_chip0 = gpiod.Chip("gpiochip0") select_chip2 = gpiod.Chip("gpiochip2") line_Dig4 = select_chip2.get_line( 6) # P8_45 line_Dig3 = select_chip2.get_line( 8) # P8_43 line_Dig2 = select_chip2.get_line(12) # P8_39 line_Dig1 = select_chip2.get_line(10) # P8_41 line_LedOna = select_chip2.get_line(11) # P8_42 line_LedOnb = select_chip2.get_line(17) # P8_34 line_LedOnc = select_chip2.get_line(16) # P8_36 line_LedOnd = select_chip2.get_line(15) # P8_38 line_LedOne = select_chip2.get_line(13) # P8_40 line_LedOnf = select_chip0.get_line(11) # P8_32 line_LedOng = select_chip2.get_line( 9) # P8_44 line_LedOnp = select_chip2.get_line( 7) # P8_46 line_Dig4.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_Dig3.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_Dig2.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_Dig1.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_LedOnp.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_LedOng.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_LedOnf.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_LedOne.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_LedOnd.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_LedOnc.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_LedOnb.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_LedOna.request( consumer="7SEGDEMO", type=gpiod.LINE_REQ_DIR_OUT, default_vals=[0] ) line_Dig1.set_value(1) # 1桁目選択 while True : for ch in message: sigs = [value for key, value in PIN_Signals if key == ch] for sw in sigs: line_LedOna.set_value(sw[0]) line_LedOnb.set_value(sw[1]) line_LedOnc.set_value(sw[2]) line_LedOnd.set_value(sw[3]) line_LedOne.set_value(sw[4]) line_LedOnf.set_value(sw[5]) line_LedOng.set_value(sw[6]) line_LedOnp.set_value(sw[7]) time.sleep(1)