1414
1515from breadboard import Breadboard
1616
17- from dataCDLT import INPUT , OUTPUT , USED
17+ from dataCDLT import INPUT , OUTPUT , USED , CLOCK
1818
1919MICROCONTROLLER_PINS = {
2020 "Arduino Mega" : {
@@ -190,11 +190,17 @@ def show_correspondence_table(self):
190190 # Gather pin_io objects from current_dict_circuit
191191 pin_ios = [value for key , value in self .current_dict_circuit .items () if key .startswith ("_io_" )]
192192
193- # Separate pin_ios into inputs and outputs
193+ # Separate pin_ios into inputs, outputs, and clocks
194194 input_pin_ios = [pin for pin in pin_ios if pin ["type" ] == INPUT ]
195195 output_pin_ios = [pin for pin in pin_ios if pin ["type" ] == OUTPUT ]
196+ clock_pin_ios = [pin for pin in pin_ios if pin ["type" ] == CLOCK ]
196197
197- # Check if we have more pin_ios than available pins
198+ # Ensure only one CLOCK type
199+ if len (clock_pin_ios ) > 1 :
200+ messagebox .showerror ("Clock Error" , "Only one CLOCK is allowed." )
201+ return
202+
203+ # Check pin counts
198204 if len (input_pin_ios ) > len (input_pins ):
199205 messagebox .showerror (
200206 "Too Many Inputs" ,
@@ -213,21 +219,21 @@ def show_correspondence_table(self):
213219 # Create a new window for the correspondence table
214220 table_window = tk .Toplevel (self .parent )
215221 table_window .title ("Correspondence Table" )
216- table_window .geometry ("400x300 " )
222+ table_window .geometry ("500x350 " )
217223
218224 # Create a Treeview widget for the table
219- tree = ttk .Treeview (table_window , columns = ("ID" , "Type" , "MCU Pin" ), show = "headings" , height = 10 )
225+ tree = ttk .Treeview (table_window , columns = ("ID" , "Type" , "MCU Pin" ), show = "headings" , height = 15 )
220226 tree .pack (expand = True , fill = "both" , padx = 10 , pady = 10 )
221227
222228 # Define columns and headings
223229 tree .column ("ID" , anchor = "center" , width = 120 )
224- tree .column ("Type" , anchor = "center" , width = 80 )
230+ tree .column ("Type" , anchor = "center" , width = 120 )
225231 tree .column ("MCU Pin" , anchor = "center" , width = 120 )
226232 tree .heading ("ID" , text = "Pin IO ID" )
227233 tree .heading ("Type" , text = "Type" )
228234 tree .heading ("MCU Pin" , text = "MCU Pin" )
229235
230- # Populate the table with input and output pin mappings
236+ # Populate the table with input, output, and clock pin mappings
231237 for idx , pin_io in enumerate (input_pin_ios ):
232238 mcu_pin = input_pins [idx ]
233239 pin_number = pin_io ["id" ].split ("_" )[- 1 ]
@@ -238,6 +244,11 @@ def show_correspondence_table(self):
238244 pin_number = pin_io ["id" ].split ("_" )[- 1 ]
239245 tree .insert ("" , "end" , values = (pin_number , "Output" , mcu_pin ))
240246
247+ if clock_pin_ios :
248+ clock_pin = pin_mappings ["clock_pin" ]
249+ pin_number = clock_pin_ios [0 ]["id" ].split ("_" )[- 1 ]
250+ tree .insert ("" , "end" , values = (pin_number , "clk input" , clock_pin ))
251+
241252 # Add a scrollbar if the list gets too long
242253 scrollbar = ttk .Scrollbar (table_window , orient = "vertical" , command = tree .yview )
243254 tree .configure (yscroll = scrollbar .set )
0 commit comments