1717
1818from breadboard import Breadboard
1919
20- from dataCDLT import INPUT , OUTPUT , USED
20+ from dataCDLT import INPUT , OUTPUT , USED , CLOCK
2121
2222MICROCONTROLLER_PINS = {
2323 "Arduino Mega" : {
@@ -193,11 +193,17 @@ def show_correspondence_table(self):
193193 # Gather pin_io objects from current_dict_circuit
194194 pin_ios = [value for key , value in self .current_dict_circuit .items () if key .startswith ("_io_" )]
195195
196- # Separate pin_ios into inputs and outputs
196+ # Separate pin_ios into inputs, outputs, and clocks
197197 input_pin_ios = [pin for pin in pin_ios if pin ["type" ] == INPUT ]
198198 output_pin_ios = [pin for pin in pin_ios if pin ["type" ] == OUTPUT ]
199+ clock_pin_ios = [pin for pin in pin_ios if pin ["type" ] == CLOCK ]
199200
200- # Check if we have more pin_ios than available pins
201+ # Ensure only one CLOCK type
202+ if len (clock_pin_ios ) > 1 :
203+ messagebox .showerror ("Clock Error" , "Only one CLOCK is allowed." )
204+ return
205+
206+ # Check pin counts
201207 if len (input_pin_ios ) > len (input_pins ):
202208 messagebox .showerror (
203209 "Too Many Inputs" ,
@@ -216,21 +222,21 @@ def show_correspondence_table(self):
216222 # Create a new window for the correspondence table
217223 table_window = tk .Toplevel (self .parent )
218224 table_window .title ("Correspondence Table" )
219- table_window .geometry ("400x300 " )
225+ table_window .geometry ("500x350 " )
220226
221227 # Create a Treeview widget for the table
222- tree = ttk .Treeview (table_window , columns = ("ID" , "Type" , "MCU Pin" ), show = "headings" , height = 10 )
228+ tree = ttk .Treeview (table_window , columns = ("ID" , "Type" , "MCU Pin" ), show = "headings" , height = 15 )
223229 tree .pack (expand = True , fill = "both" , padx = 10 , pady = 10 )
224230
225231 # Define columns and headings
226232 tree .column ("ID" , anchor = "center" , width = 120 )
227- tree .column ("Type" , anchor = "center" , width = 80 )
233+ tree .column ("Type" , anchor = "center" , width = 120 )
228234 tree .column ("MCU Pin" , anchor = "center" , width = 120 )
229235 tree .heading ("ID" , text = "Pin IO ID" )
230236 tree .heading ("Type" , text = "Type" )
231237 tree .heading ("MCU Pin" , text = "MCU Pin" )
232238
233- # Populate the table with input and output pin mappings
239+ # Populate the table with input, output, and clock pin mappings
234240 for idx , pin_io in enumerate (input_pin_ios ):
235241 mcu_pin = input_pins [idx ]
236242 pin_number = pin_io ["id" ].split ("_" )[- 1 ]
@@ -241,6 +247,11 @@ def show_correspondence_table(self):
241247 pin_number = pin_io ["id" ].split ("_" )[- 1 ]
242248 tree .insert ("" , "end" , values = (pin_number , "Output" , mcu_pin ))
243249
250+ if clock_pin_ios :
251+ clock_pin = pin_mappings ["clock_pin" ]
252+ pin_number = clock_pin_ios [0 ]["id" ].split ("_" )[- 1 ]
253+ tree .insert ("" , "end" , values = (pin_number , "clk input" , clock_pin ))
254+
244255 # Add a scrollbar if the list gets too long
245256 scrollbar = ttk .Scrollbar (table_window , orient = "vertical" , command = tree .yview )
246257 tree .configure (yscroll = scrollbar .set )
0 commit comments