mirror of
https://forge.apps.education.fr/blender-edutech/jumeaux-numeriques.git
synced 2024-01-27 06:56:18 +01:00
Jumelage numérique point d'étape
This commit is contained in:
parent
32003abb32
commit
a3a2c06354
@ -29,7 +29,16 @@ from porcou_lib import * # Bibliothèque portail coulissant
|
||||
###############################################################################
|
||||
|
||||
# Brochage du jumeau réel
|
||||
brochage={'gyr' : 2}
|
||||
brochage={
|
||||
'bp_ext' : [2,'d','i'],
|
||||
'ebp_int' : [3,'d','i'],
|
||||
'fdc_o' : [4,'d','i'],
|
||||
'fdc_f' : [5,'d','i'],
|
||||
'mot_o' : [6,'d','o'],
|
||||
'mot_f' : [7,'d','o'],
|
||||
'gyr' : [8,'d','o'],
|
||||
'ir_emett' : [9,'d','o'],
|
||||
'ir_recept' : [10,'d','i']}
|
||||
|
||||
###############################################################################
|
||||
# Fonctions
|
||||
|
@ -25,10 +25,16 @@ threads_cmd=[]
|
||||
debug_thread = scene.objects['System']['debug_thread']
|
||||
|
||||
# Jumeau numérique
|
||||
# twins_serial = None
|
||||
board = None
|
||||
board_it = None # Iterator (input)
|
||||
# board_io = None # Input - Ouput
|
||||
bp_int_pin = None
|
||||
bp_ext_pin = None
|
||||
fdc_o_pin = None
|
||||
fdc_f_pin = None
|
||||
ir_emett_pin = None
|
||||
ir_recept_pin = None
|
||||
mot_o_pin = None
|
||||
mot_f_pin = None
|
||||
gyr_pin = None
|
||||
|
||||
# UPBGE constants
|
||||
@ -261,13 +267,13 @@ def serial_devices():
|
||||
##
|
||||
# Activation de la communication avec la carte de communication (Arduino, Micro:bit)
|
||||
# Vitesse : 115200 -> 7 fps, 38400 -> 6 fps, 9600 -> 2 fps
|
||||
# pyserial : baudrate=115200
|
||||
# pyfirmata : baudrate=57600
|
||||
# pyserial : baudrate=115200
|
||||
# pyfirmata : baudrate=57600
|
||||
##
|
||||
|
||||
def jumeau(es_dict):
|
||||
def jumeau(pins):
|
||||
global board
|
||||
global gyr_pin
|
||||
# global gyr_pin
|
||||
|
||||
# UI : étape 1
|
||||
scene.objects['Twins-icon'].setVisible(True,True)
|
||||
@ -276,7 +282,7 @@ def jumeau(es_dict):
|
||||
|
||||
# Mise en place de la carte
|
||||
speed = 57600
|
||||
[device,board_name] =serial_autoget_port() # Recherche automatique du port
|
||||
[device,board_name] =serial_autoget_port() # Recherche automatique du port
|
||||
board = board_init(device)
|
||||
if board is None:
|
||||
scene.objects['System']['twins'] = False
|
||||
@ -298,9 +304,27 @@ def jumeau(es_dict):
|
||||
tempo (0.1)
|
||||
|
||||
# Déclaration des entrées - sorties
|
||||
gyr_pin = board.get_pin('d:'+str(es_dict['gyr'])+':o') # Gyrophare
|
||||
for pin in pins:
|
||||
print (pin)
|
||||
# if
|
||||
# bp_ext_pin = board_io('d:'+str(es_dict['bp_ext'])+':i') # Bouton poussoir coté rue
|
||||
# bp_int_pin = board_io('d:'+str(es_dict['bp_int'])+':i') # Bouton poussoir coté cour
|
||||
# fdc_o_pin = board_io('d:'+str(es_dict['fdc_o'])+':i') # Capteur fin de course portail ouvert
|
||||
# fdc_f_pin = board_io('d:'+str(es_dict['fdc_f'])+':i') # Capteur fin de course portail fermé
|
||||
# ir_recept_pin = board_io('d:'+str(es_dict['ir_recept'])+':i') # Recepteur pour le capteur barrage IR
|
||||
|
||||
# gyr_pin = board_io('d:'+str(es_dict['gyr'])+':o') # Gyrophare
|
||||
# mot_o_pin = board_io('d:'+str(es_dict['mot_o'])+':o') # Ouvrir le portail (moteur sens trigo)
|
||||
# mot_f_pin = board_io('d:'+str(es_dict['mot_f'])+':o') # Fermer le portail (moteur sens horaire
|
||||
# ir_emett_pin = board_io('d:'+str(es_dict['ir_emett'])+':o') # Emetteur pour le capteur barrage IR
|
||||
return True
|
||||
|
||||
# def board_io(da,pin,io):
|
||||
# if pin_def is not None:
|
||||
# return board.get_pin(da+':'+pin_def)
|
||||
# else:
|
||||
# print ("Définition entrée-sortie non trouvée : "+pin_def)
|
||||
|
||||
##
|
||||
# Fermeture de la communication série
|
||||
##
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user