1313
1414from breadboard import Breadboard
1515
16- from dataCDLT import INPUT , OUTPUT
16+ from dataCDLT import INPUT , OUTPUT , USED
1717
1818MICROCONTROLLER_PINS = {
1919 "Arduino Mega" : {
@@ -117,7 +117,7 @@ def __init__(
117117 "NodeMCU ESP32"
118118 ],
119119 "Ports" : ["Configure Ports" ],
120- "Export" : ["Show Correspondence Table" ],
120+ "Export" : ["Correspondence Table" ],
121121 "Help" : ["Documentation" , "About" ],
122122 }
123123
@@ -344,6 +344,8 @@ def new_file(self):
344344 # Clear the canvas and reset the circuit
345345 self .board .sketcher .clear_board ()
346346 self .board .fill_matrix_1260_pts ()
347+ self .board .draw_blank_board_model ()
348+
347349 print ("New file created." )
348350 messagebox .showinfo ("New File" , "A new circuit has been created." )
349351
@@ -363,6 +365,23 @@ def open_file(self):
363365 x_o , y_o = self .board .sketcher .id_origins ["xyOrigin" ]
364366 self .board .sketcher .circuit (x_o , y_o , model = [])
365367
368+ battery_pos_wire_end = None
369+ battery_neg_wire_end = None
370+
371+ for key , val in circuit_data .items ():
372+ if key == "_battery_pos_wire" :
373+ battery_pos_wire_end = val ['end' ]
374+ elif key == "_battery_neg_wire" :
375+ battery_neg_wire_end = val ['end' ]
376+
377+ # Redraw the blank board model, including the battery with wire positions
378+ self .board .draw_blank_board_model (
379+ x_o ,
380+ y_o ,
381+ battery_pos_wire_end = battery_pos_wire_end ,
382+ battery_neg_wire_end = battery_neg_wire_end ,
383+ )
384+
366385 for key , val in circuit_data .items ():
367386 if "chip" in key :
368387 x , y = val ["XY" ]
@@ -378,7 +397,7 @@ def open_file(self):
378397 ]
379398 self .board .sketcher .circuit (x , y , model = model_chip )
380399
381- elif "wire" in key :
400+ elif "wire" in key and not key . startswith ( "_battery" ) :
382401 model_wire = [
383402 (
384403 self .board .sketcher .draw_wire ,
@@ -433,6 +452,8 @@ def save_file(self):
433452 comp_data ["label" ] = comp_data ["type" ]
434453 if "wire" in key :
435454 comp_data .pop ("XY" , None ) # Remove XY, will be recalculated anyway
455+ if key == "_battery" :
456+ comp_data .pop ("battery_rect" , None )
436457 # Save the data to a JSON file
437458 with open (file_path , "w" , encoding = "utf-8" ) as file :
438459 json .dump (circuit_data , file , indent = 4 )
0 commit comments