Skip to content

Commit 2ccc83c

Browse files
committed
version de la prez
1 parent fba4522 commit 2ccc83c

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

arduino_logique.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def main():
3030
win = tk.Tk()
3131
win.title("Laboratoire virtuel de circuit logique - GIF-1002")
3232
win.geometry("1500x800") # Initial window size
33-
win.minsize(1500, 800) # Set minimal window size
33+
win.minsize(3456, 2234) # Set minimal window size 3456 × 2234) 1500,800
3434
win.resizable(True, True) # Disabling window resizing
3535
win.configure(bg="#333333") # Setting consistent background color
3636

menus.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import subprocess
1313
import platform
1414
import serial.tools.list_ports # type: ignore
15+
import time
1516

1617
from breadboard import Breadboard
1718
from component_sketch import ComponentSketcher
@@ -92,7 +93,12 @@ class SerialPort:
9293
def connect(self):
9394
"""Open the serial connection."""
9495
try:
95-
self.connection = serial.Serial(port=self.com_port, baudrate=self.baud_rate, timeout=self.timeout)
96+
self.connection = serial.Serial(port=self.com_port,
97+
baudrate=self.baud_rate,
98+
parity=serial.PARITY_NONE,
99+
stopbits=serial.STOPBITS_ONE,
100+
bytesize=serial.EIGHTBITS,
101+
timeout=self.timeout)
96102
print(f"Serial port {self.com_port} opened successfully.")
97103
except serial.SerialException as e:
98104
print(f"Error opening port {self.com_port}: {e}")
@@ -143,8 +149,8 @@ def __init__(
143149

144150
self.menu_bar = tk.Frame(parent, bg="#333333")
145151
"""The frame containing the menu bar buttons."""
146-
147-
self.serial_port = SerialPort(None, 115200, 1, None)
152+
153+
self.serial_port = SerialPort(None, 9600, 1, None)
148154
"""The serial port configuration."""
149155

150156
self.open_file_path: str | None = None
@@ -685,6 +691,10 @@ def send_data(self, data):
685691
# Convertir la chaîne en bytes et l'envoyer
686692
self.serial_port.connection.write(data.encode('utf-8'))
687693
print(f"Données envoyées: {data}")
694+
#time.sleep(0.5)
695+
#if self.serial_port.connection.in_waiting > 0: # Vérifie s'il y a des données disponibles
696+
data = self.serial_port.connection.readline().decode('utf-8').strip()
697+
print(f"réponse: {data} à {self.serial_port.baud_rate} bauds")
688698
except serial.SerialException as e:
689699
print(f"Erreur lors de l'envoi des données: {e}")
690700
else:
@@ -702,7 +712,7 @@ def download_script(self):
702712
self.checkCircuit()
703713
self.serial_port.connect()
704714
self.send_data(self.script)
705-
self.close_port()
715+
#self.close_port()
706716

707717
def is_linked_to(self, dest, src):
708718
res = False
@@ -785,7 +795,7 @@ def decodeFunc(self,inVar, funcName):
785795
iset = f"{inVar[2]['iset']}"
786796
rst = f"!{inVar[1]['irst']}"
787797
sT =f"T{self.varTempNum} = "
788-
sT += "((" + inVar[0]['J'] + f" & !T{self.varTempNum}_precedant) | (!{K} & T{self.varTempNum}_precedant)) & {set} & {rst} & CLK | {iset} "
798+
sT += "((" + inVar[0]['J'] + f" & !T{self.varTempNum}_precedent) | (!{K} & T{self.varTempNum}_precedent)) & {set} & {rst} & CLK | {iset} "
789799
sT += " ); "
790800
s = inVar[0]['numO']*" !" + f"T{self.varTempNum} "
791801
self.varTempNum +=1
@@ -800,22 +810,22 @@ def decodeFunc(self,inVar, funcName):
800810
D1 = inVar[1]["val"]
801811
D2 = inVar[0]["val"]
802812
D3 = inVar[0]["val"]
803-
sT = f"T{self.varTempNum} = clk & {CE} & {iL} & !T{self.varTempNum}_precedant | !{iL} & {D0} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedant; "
813+
sT = f"T{self.varTempNum} = clk & {CE} & {iL} & !T{self.varTempNum}_precedent | !{iL} & {D0} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedent; "
804814
self.numTemp += [self.varTempNum]
805815
self.varTempNum +=1
806816
self.varScript += [sT]
807-
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-1}_precedant | !T{self.varTempNum}_precedant) & " \
808-
+ f"({CE} & T{self.varTempNum - 1}_precedant | T{self.varTempNum}_precedant ) & {iL} & clk | !{iL} & {D1} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedant; "
817+
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-1}_precedent | !T{self.varTempNum}_precedent) & " \
818+
+ f"({CE} & T{self.varTempNum - 1}_precedent | T{self.varTempNum}_precedent ) & {iL} & clk | !{iL} & {D1} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedent; "
809819
self.numTemp += [self.varTempNum]
810820
self.varTempNum +=1
811821
self.varScript += [sT]
812-
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-2}_precedant | !T{self.varTempNum-1}_precedant | !T{self.varTempNum}_precedant) & clk & " \
813-
+ f"({CE} & T{self.varTempNum - 2}_precedant & T{self.varTempNum - 1}_precedant | T{self.varTempNum}_precedant ) & {iL} & clk | !{iL} & {D2} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedant; "
822+
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-2}_precedent | !T{self.varTempNum-1}_precedent | !T{self.varTempNum}_precedent) & clk & " \
823+
+ f"({CE} & T{self.varTempNum - 2}_precedent & T{self.varTempNum - 1}_precedent | T{self.varTempNum}_precedent ) & {iL} & clk | !{iL} & {D2} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedent; "
814824
self.numTemp += [self.varTempNum]
815825
self.varTempNum +=1
816826
self.varScript += [sT]
817-
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-3}_precedant | !T{self.varTempNum-2}_precedant | !T{self.varTempNum-1}_precedant | !T{self.varTempNum}_precedant) & " \
818-
+ f"({CE} & T{self.varTempNum - 3}_precedant & T{self.varTempNum - 2}_precedant & T{self.varTempNum - 1}_precedant | T{self.varTempNum}_precedant ) & {iL} & clk | !{iL} & {D3} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedant; "
827+
sT = f"T{self.varTempNum} = (!{CE} | !T{self.varTempNum-3}_precedent | !T{self.varTempNum-2}_precedent | !T{self.varTempNum-1}_precedent | !T{self.varTempNum}_precedent) & " \
828+
+ f"({CE} & T{self.varTempNum - 3}_precedent & T{self.varTempNum - 2}_precedent & T{self.varTempNum - 1}_precedent | T{self.varTempNum}_precedent ) & {iL} & clk | !{iL} & {D3} & clk | !{CE} & {iL} & clk & T{self.varTempNum}_precedent; "
819829
self.numTemp += [self.varTempNum]
820830
self.varTempNum +=1
821831
self.varScript += [sT]
@@ -1749,7 +1759,7 @@ def io_position(io):
17491759
self.script += s
17501760
self.varScript = []
17511761
self.script += f"O{no+1}" + " = "
1752-
self.script += f"{script}; "
1762+
self.script += f"{script}; \n"
17531763
print(f"script temp : {self.script}")
17541764
else: print(f"le circuit est ouvert sur la sortie {ioOut}")
17551765

@@ -1772,3 +1782,7 @@ def io_position(io):
17721782
print(f"chip_in_enable_inv : {chip_in_enable_inv}")
17731783
print(f"map pin mcu : {self.mcu_pin}")
17741784
print(f"script final : {self.script}")
1785+
if self.script:
1786+
messagebox.showinfo("Script du circuit", f"Circuit= {self.script}")
1787+
else:
1788+
messagebox.showinfo("Script du circuit", f"Le circuit présente au moins un défaut et ne peut être téléversé.")

sidebar.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
from dataCDLT import FREE, USED
1919
from object_model.circuit_object_model import Chip, get_all_available_chips, get_chip_modification_times
2020

21-
if (os.name in ("posix", "darwin")) and "linux" not in platform.platform().lower():
22-
from tkinter import messagebox, font
23-
from tkmacosx import Button # type: ignore
24-
else:
25-
from tkinter import Button, messagebox, font
21+
# if (os.name in ("posix", "darwin")) and "linux" not in platform.platform().lower():
22+
# from tkinter import messagebox, font
23+
# from tkmacosx import Button # type: ignore
24+
# else:
25+
# from tkinter import Button, messagebox, font
2626

27+
from tkinter import Button, messagebox, font
2728

2829
@dataclass
2930
class SidebarGrid:

0 commit comments

Comments
 (0)