Skip to content

Commit 161abc8

Browse files
authored
Merge pull request #92 from Team-Arduino-Logique/battery-implementation
Battery implementation
2 parents 76c193b + bb22b38 commit 161abc8

File tree

6 files changed

+398
-18
lines changed

6 files changed

+398
-18
lines changed

.github/workflows/pylint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
sudo apt-get update
3232
sudo apt-get install -y python3-tk
3333
python -m pip install --upgrade pip
34-
pip install pylint
34+
pip install pylint pillow
3535
python -m pip install mypy
3636
3737
- name: Analysing the code with pylint

Assets/Icons/battery.png

6.62 KB
Loading

arduino_logique.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def main():
2222
# Creating main window
2323
win = tk.Tk()
2424
win.title("Laboratoire virtuel de circuit logique - GIF-1002")
25-
win.geometry("1400x800") # Initial window size
25+
win.geometry("1700x800") # Initial window size
2626
win.resizable(False, False) # Disabling window resizing
2727
win.configure(bg="#333333") # Setting consistent background color
2828

breadboard.py

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

1920

@@ -156,7 +157,7 @@ def draw_matrix_points(self, scale=1): # used to debug the matrix
156157
radius = 2 * scale # Adjust size as needed
157158
self.canvas.create_oval(x - radius, y - radius, x + radius, y + radius, fill=color, outline="")
158159

159-
def draw_blank_board_model(self, x_origin: int = 50, y_origin: int = 10):
160+
def draw_blank_board_model(self, x_origin: int = 50, y_origin: int = 10, battery_pos_wire_end=None, battery_neg_wire_end=None):
160161
"""
161162
Draws a blank breadboard model on the canvas.
162163
"""
@@ -223,3 +224,24 @@ def draw_blank_board_model(self, x_origin: int = 50, y_origin: int = 10):
223224
(self.sketcher.go_xy, 1, {"line": 0, "column": 0, "id_origin": "circTest"}),
224225
]
225226
self.sketcher.circuit(x_origin, y_origin, scale=self.sketcher.scale_factor, model=blank_board_model)
227+
228+
battery_x = x_origin + 1200 # Adjust as needed for proper positioning
229+
battery_y = y_origin + 300 # Adjust as needed for proper positioning
230+
231+
# Reset all matrix elements' states to FREE
232+
for key in self.sketcher.matrix:
233+
self.sketcher.matrix[key]['state'] = FREE
234+
235+
self.sketcher.draw_battery(
236+
battery_x,
237+
battery_y,
238+
pos_wire_end=battery_pos_wire_end,
239+
neg_wire_end=battery_neg_wire_end,
240+
)
241+
if battery_pos_wire_end:
242+
allowed_positions = self.sketcher.get_power_line_last_pins()
243+
nearest_point, nearest_point_coord = self.sketcher.find_nearest_allowed_grid_point(battery_pos_wire_end[0], battery_pos_wire_end[1], allowed_positions)
244+
col, line = nearest_point_coord
245+
self.sketcher.matrix[f'{col},{line}']['state'] = USED
246+
247+

0 commit comments

Comments
 (0)