135def parse_args(raw_args):
136 """Parses the args into ready to write register_data."""
137
138 parser = argparse.ArgumentParser()
139 parser.add_argument("--pin", type=str, default="P22",
140 help="Pin: P22, P23, P24, P25 default P22")
141 parser.add_argument("--output", type=str, default="-1",
142 help="Providing this puts the pin in output mode instead of input mode. Output: 0, 1")
143 parser.add_argument("-t", "--test", action="store_true",
144 help="Print JSON of register_data")
145 args = parser.parse_args(raw_args)
146
147
148 register_data['pin'] = 6
149 if (args.pin == 'P22'):
150 register_data['pin'] = 6
151 if (args.pin == 'P23'):
152 register_data['pin'] = 13
153 if (args.pin == 'P24'):
154 register_data['pin'] = 19
155 if (args.pin == 'P25'):
156 register_data['pin'] = 26
157
158
159 register_data['output'] = -1
160 if (args.output == '0'):
161 register_data['output'] = 0
162 if (args.output == '1'):
163 register_data['output'] = 1
164
165
166 if args.test:
167 output_json()
168 exit()
169
170
171
172
173