Skip to content

Commit 5e685d9

Browse files
committed
battery enhancement and bug fixes
1 parent 06ac5b2 commit 5e685d9

File tree

3 files changed

+114
-165
lines changed

3 files changed

+114
-165
lines changed

breadboard.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
HORIZONTAL,
1515
PERSO,
1616
VERTICAL,
17+
USED,
1718
)
1819

1920

@@ -253,9 +254,21 @@ def draw_blank_board_model(self, x_origin: int = 50, y_origin: int = 10, battery
253254

254255
battery_x = x_origin + 1200 # Adjust as needed for proper positioning
255256
battery_y = y_origin + 300 # Adjust as needed for proper positioning
257+
258+
# Reset all matrix elements' states to FREE
259+
for key in self.sketcher.matrix:
260+
self.sketcher.matrix[key]['state'] = FREE
261+
256262
self.sketcher.draw_battery(
257263
battery_x,
258264
battery_y,
259265
pos_wire_end=battery_pos_wire_end,
260266
neg_wire_end=battery_neg_wire_end,
261267
)
268+
if battery_pos_wire_end:
269+
allowed_positions = self.sketcher.get_power_line_last_pins()
270+
nearest_point, nearest_point_coord = self.sketcher.find_nearest_allowed_grid_point(battery_pos_wire_end[0], battery_pos_wire_end[1], allowed_positions)
271+
col, line = nearest_point_coord
272+
self.sketcher.matrix[f'{col},{line}']['state'] = USED
273+
274+

0 commit comments

Comments
 (0)