mirror of
https://forge.apps.education.fr/blender-edutech/jumeaux-numeriques.git
synced 2024-01-27 06:56:18 +01:00
Jumelage numérique du volet roulant
This commit is contained in:
parent
656813b7f3
commit
0ca1b712ac
@ -1,7 +1,7 @@
|
|||||||
<data>
|
<data>
|
||||||
<screen>
|
<screen>
|
||||||
<width>1573</width>
|
<width>1441</width>
|
||||||
<height>884</height>
|
<height>811</height>
|
||||||
<quality>1</quality>
|
<quality>1</quality>
|
||||||
</screen>
|
</screen>
|
||||||
</data>
|
</data>
|
Binary file not shown.
@ -16,6 +16,19 @@ import time
|
|||||||
# Récupérer la scène UPBGE
|
# Récupérer la scène UPBGE
|
||||||
scene = bge.logic.getCurrentScene()
|
scene = bge.logic.getCurrentScene()
|
||||||
|
|
||||||
|
# Configuration du brochage du jumeau réel
|
||||||
|
pin_config = {
|
||||||
|
'fdc_h' : [['d','i'],['Microrupteur haut','pin']],
|
||||||
|
'fdc_b' : [['d','i'],['Microrupteur bas','pin']],
|
||||||
|
'bp_m' : [['d','i'],['Bp monter','pin']],
|
||||||
|
'bp_d' : [['d','i'],['Bp descendre','pin']],
|
||||||
|
'bp_a' : [['d','i'],['Bp arret','pin']],
|
||||||
|
'mot_m' : [['d','o'],['Moteur','pin_m']],
|
||||||
|
'mot_d' : [['d','o'],['Moteur','pin_d']],
|
||||||
|
'bp_auto' : [['d','i'],['Bp auto','pin']],
|
||||||
|
'voy_auto' : [['d','o'],['Led auto','pin']],
|
||||||
|
'lum' : [['d','i'],['Recepteur LDR','pin']]}
|
||||||
|
|
||||||
# Couleurs
|
# Couleurs
|
||||||
color_passive = (0.800, 0.005, 0.315,1) # bouton non activable : magenta
|
color_passive = (0.800, 0.005, 0.315,1) # bouton non activable : magenta
|
||||||
color_active = (0.799, 0.130, 0.063,1) # bouton activable : orange
|
color_active = (0.799, 0.130, 0.063,1) # bouton activable : orange
|
||||||
@ -41,6 +54,11 @@ def init(cont):
|
|||||||
twin.manip_init() # Manipulation du modèle 3D
|
twin.manip_init() # Manipulation du modèle 3D
|
||||||
twin.cmd_init() # Commandes
|
twin.cmd_init() # Commandes
|
||||||
|
|
||||||
|
# Brochage
|
||||||
|
for pin in pin_config:
|
||||||
|
# print (pin_config[pin][1][0], pin_config[pin][1][1])
|
||||||
|
scene.objects[pin_config[pin][1][0]][pin_config[pin][1][1]] = None
|
||||||
|
|
||||||
# Description des composants sensibles
|
# Description des composants sensibles
|
||||||
scene.objects['Bp monter']['description']="Bouton poussoir monter volet : bp_m()"
|
scene.objects['Bp monter']['description']="Bouton poussoir monter volet : bp_m()"
|
||||||
scene.objects['Bp descendre']['description']="Bouton poussoir descendre volet : bp_d()"
|
scene.objects['Bp descendre']['description']="Bouton poussoir descendre volet : bp_d()"
|
||||||
@ -52,44 +70,23 @@ def init(cont):
|
|||||||
|
|
||||||
system_init() # Initialisation du système
|
system_init() # Initialisation du système
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Voyants
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
##
|
|
||||||
# Etat voyant mode automatique
|
|
||||||
# Modele 3d -> Arduino : FIXME
|
|
||||||
# Arduino -> Modele 3d : FIXME
|
|
||||||
##
|
|
||||||
|
|
||||||
def voy_auto (cont):
|
|
||||||
if scene.objects['System']['run']:
|
|
||||||
obj = cont.owner
|
|
||||||
if obj['activated'] and scene.objects['Led auto-on'].visible == False:
|
|
||||||
scene.objects['Led auto-on'].setVisible(True,False)
|
|
||||||
scene.objects['Led auto'].setVisible(False,False)
|
|
||||||
if obj['activated']==False and scene.objects['Led auto-on'].visible == True:
|
|
||||||
scene.objects['Led auto'].setVisible(True,False)
|
|
||||||
scene.objects['Led auto-on'].setVisible(False,False)
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Actionneurs
|
# Actionneurs
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
##
|
##
|
||||||
# Moteur et volet
|
# Moteur et volet
|
||||||
# Modele 3d -> Arduino : FIXME
|
|
||||||
# Arduino -> Modele 3d : FIXME
|
|
||||||
##
|
##
|
||||||
|
|
||||||
def mot (cont):
|
def mot (cont):
|
||||||
if scene.objects['System']['run']:
|
if scene.objects['System']['run']:
|
||||||
# scene.objects['System'].applyMovement((0, 0, 0), False)
|
|
||||||
# scene.objects['System'].applyRotation((0, 0, 0), True)
|
|
||||||
obj = cont.owner
|
obj = cont.owner
|
||||||
layer = 0
|
layer = 0
|
||||||
|
|
||||||
# Monter
|
# Monter
|
||||||
if obj['up']:
|
if obj['up']:
|
||||||
|
|
||||||
|
# Animation
|
||||||
if obj['frame_down']<105: # Volet pas cassé
|
if obj['frame_down']<105: # Volet pas cassé
|
||||||
if obj['frame_up'] <0: # Réinit entre 0 et -4
|
if obj['frame_up'] <0: # Réinit entre 0 et -4
|
||||||
obj['frame_up']=0
|
obj['frame_up']=0
|
||||||
@ -154,8 +151,17 @@ def mot (cont):
|
|||||||
obj['frame_up'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
|
obj['frame_up'] = scene.objects['Axe enrouleur'].getActionFrame(layer)
|
||||||
obj['frame_down']= 100-obj['frame_up']
|
obj['frame_down']= 100-obj['frame_up']
|
||||||
|
|
||||||
|
# Modele 3D -> Arduino
|
||||||
|
if scene.objects['System']['twins']:
|
||||||
|
if scene.objects['Moteur']['pin_m'] is not None:
|
||||||
|
if scene.objects['Moteur']['pin_d'] is not None:
|
||||||
|
scene.objects['Moteur']['pin_d'].write(0)
|
||||||
|
scene.objects['Moteur']['pin_m'].write(1)
|
||||||
|
|
||||||
# Descendre
|
# Descendre
|
||||||
if obj['down']:
|
if obj['down']:
|
||||||
|
|
||||||
|
# Animation
|
||||||
if obj['frame_up']<105: # Volet pas cassé
|
if obj['frame_up']<105: # Volet pas cassé
|
||||||
if obj['frame_down'] <0: # Réinit entre 0 et -4
|
if obj['frame_down'] <0: # Réinit entre 0 et -4
|
||||||
obj['frame_down']=0
|
obj['frame_down']=0
|
||||||
@ -224,8 +230,17 @@ def mot (cont):
|
|||||||
obj['frame_down'] +=1
|
obj['frame_down'] +=1
|
||||||
obj['frame_up']= 100-obj['frame_down']
|
obj['frame_up']= 100-obj['frame_down']
|
||||||
|
|
||||||
|
# Modele 3D -> Arduino
|
||||||
|
if scene.objects['System']['twins']:
|
||||||
|
if scene.objects['Moteur']['pin_d'] is not None:
|
||||||
|
if scene.objects['Moteur']['pin_m'] is not None:
|
||||||
|
scene.objects['Moteur']['pin_m'].write(0)
|
||||||
|
scene.objects['Moteur']['pin_d'].write(1)
|
||||||
|
|
||||||
# Arrêt
|
# Arrêt
|
||||||
if obj['up'] == False and obj['down'] == False:
|
if obj['up'] == False and obj['down'] == False:
|
||||||
|
|
||||||
|
# Animation
|
||||||
if scene.objects['Axe enrouleur'].isPlayingAction(layer):
|
if scene.objects['Axe enrouleur'].isPlayingAction(layer):
|
||||||
scene.objects['Axe enrouleur'].stopAction(layer)
|
scene.objects['Axe enrouleur'].stopAction(layer)
|
||||||
scene.objects['Axe fdc'].stopAction(layer)
|
scene.objects['Axe fdc'].stopAction(layer)
|
||||||
@ -243,20 +258,33 @@ def mot (cont):
|
|||||||
scene.objects['Lame volet 12'].stopAction(layer)
|
scene.objects['Lame volet 12'].stopAction(layer)
|
||||||
scene.objects['Lame volet 13'].stopAction(layer)
|
scene.objects['Lame volet 13'].stopAction(layer)
|
||||||
|
|
||||||
|
# Modele 3D -> Arduino
|
||||||
|
if scene.objects['System']['twins']:
|
||||||
|
if scene.objects['Moteur']['pin_d'] is not None:
|
||||||
|
if scene.objects['Moteur']['pin_m'] is not None:
|
||||||
|
scene.objects['Moteur']['pin_m'].write(0)
|
||||||
|
scene.objects['Moteur']['pin_d'].write(0)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Capteurs fin de course
|
# Capteurs fin de course
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
##
|
##
|
||||||
# Etat capteur fin de course volet en haut
|
# Etat capteur fin de course volet en haut
|
||||||
# Modele 3d -> Arduino : FIXME
|
|
||||||
# Arduino -> Modele 3d : FIXME
|
|
||||||
##
|
##
|
||||||
|
|
||||||
def fdc_h (cont):
|
def fdc_h (cont):
|
||||||
if scene.objects['System']['run'] :
|
if scene.objects['System']['run'] :
|
||||||
obj = cont.owner
|
obj = cont.owner
|
||||||
|
|
||||||
|
# Arduino -> Modele 3D
|
||||||
|
if scene.objects['System']['twins']:
|
||||||
|
if obj['pin'] is not None:
|
||||||
|
if obj['pin'].read()==True and obj['activated_real'] == False :
|
||||||
|
obj['activated_real'] = True
|
||||||
|
if obj['pin'].read()==False and obj['activated_real'] == True :
|
||||||
|
obj['activated_real'] = False
|
||||||
|
|
||||||
# Etat capteur en fonction du volet
|
# Etat capteur en fonction du volet
|
||||||
scene.objects['Axe fdc']['rx']= scene.objects['Axe fdc'].localOrientation.to_euler().x *(180/math.pi)
|
scene.objects['Axe fdc']['rx']= scene.objects['Axe fdc'].localOrientation.to_euler().x *(180/math.pi)
|
||||||
if scene.objects['Axe fdc']['rx'] >= -175 and scene.objects['Axe fdc']['rx'] <= -155 and obj['activated'] == False :
|
if scene.objects['Axe fdc']['rx'] >= -175 and scene.objects['Axe fdc']['rx'] <= -155 and obj['activated'] == False :
|
||||||
@ -264,79 +292,41 @@ def fdc_h (cont):
|
|||||||
if scene.objects['Axe fdc']['rx'] < -175 or scene.objects['Axe fdc']['rx'] > -155 and obj['activated'] == True :
|
if scene.objects['Axe fdc']['rx'] < -175 or scene.objects['Axe fdc']['rx'] > -155 and obj['activated'] == True :
|
||||||
obj['activated'] = False
|
obj['activated'] = False
|
||||||
|
|
||||||
# Forçage (click)
|
# Forçage par clic
|
||||||
if obj['click'] == True:
|
if obj['click'] == True:
|
||||||
obj['activated'] = True
|
obj['activated'] = True
|
||||||
|
|
||||||
# Couleurs
|
# Couleurs
|
||||||
if obj['activated'] == True and obj.color !=color_activated:
|
twin.cycle_sensitive_color(obj)
|
||||||
obj.color =color_activated
|
|
||||||
if obj['activated'] == False :
|
|
||||||
if obj['mo'] == True and obj.color !=color_hl:
|
|
||||||
obj.color =color_hl
|
|
||||||
if obj['mo'] == False and obj.color !=color_active:
|
|
||||||
obj.color =color_active
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Etat capteur fin de course volet en bas
|
# Etat capteur fin de course volet en bas
|
||||||
# Modele 3d -> Arduino : FIXME
|
|
||||||
# Arduino -> Modele 3d : FIXME
|
|
||||||
##
|
##
|
||||||
|
|
||||||
def fdc_b (cont):
|
def fdc_b (cont):
|
||||||
if scene.objects['System']['run'] :
|
if scene.objects['System']['run'] :
|
||||||
obj = cont.owner
|
obj = cont.owner
|
||||||
|
|
||||||
|
# Arduino -> Modele 3D
|
||||||
|
if scene.objects['System']['twins']:
|
||||||
|
if obj['pin'] is not None:
|
||||||
|
if obj['pin'].read()==True and obj['activated_real'] == False :
|
||||||
|
obj['activated_real'] = True
|
||||||
|
if obj['pin'].read()==False and obj['activated_real'] == True :
|
||||||
|
obj['activated_real'] = False
|
||||||
|
|
||||||
# Etat capteur en fonction du volet
|
# Etat capteur en fonction du volet
|
||||||
if scene.objects['Axe fdc']['rx'] >= -10 and scene.objects['Axe fdc']['rx'] <= 10 and obj['activated'] == False :
|
if scene.objects['Axe fdc']['rx'] >= -10 and scene.objects['Axe fdc']['rx'] <= 10 and obj['activated'] == False :
|
||||||
obj['activated'] = True
|
obj['activated'] = True
|
||||||
if scene.objects['Axe fdc']['rx'] < -10 or scene.objects['Axe fdc']['rx'] > 10 and obj['activated'] == True :
|
if scene.objects['Axe fdc']['rx'] < -10 or scene.objects['Axe fdc']['rx'] > 10 and obj['activated'] == True :
|
||||||
obj['activated'] = False
|
obj['activated'] = False
|
||||||
|
|
||||||
# Forçage (click)
|
# Forçage par clic
|
||||||
if obj['click'] == True:
|
if obj['click'] == True:
|
||||||
obj['activated'] = True
|
obj['activated'] = True
|
||||||
|
|
||||||
# Couleurs
|
# Couleurs
|
||||||
if obj['activated'] == True and obj.color !=color_activated:
|
twin.cycle_sensitive_color(obj)
|
||||||
obj.color =color_activated
|
|
||||||
if obj['activated'] == False :
|
|
||||||
if obj['mo'] == True and obj.color !=color_hl:
|
|
||||||
obj.color =color_hl
|
|
||||||
if obj['mo'] == False and obj.color !=color_active:
|
|
||||||
obj.color =color_active
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Boutons
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
# Modele 3d -> Arduino : FIXME
|
|
||||||
# Arduino -> Modele 3d : FIXME
|
|
||||||
|
|
||||||
# Arduino -> numérique
|
|
||||||
# bt_a_m_txt = txt_extrac_bool(serial_msg,"bt_a_m: ")
|
|
||||||
# bt_a_d_txt = txt_extrac_bool(serial_msg,"bt_a_d: ")
|
|
||||||
# bt_b_m_txt = txt_extrac_bool(serial_msg,"bt_b_m: ")
|
|
||||||
# bt_b_d_txt = txt_extrac_bool(serial_msg,"bt_b_d: ")
|
|
||||||
# bt_c_m_txt = txt_extrac_bool(serial_msg,"bt_c_m: ")
|
|
||||||
# bt_c_d_txt = txt_extrac_bool(serial_msg,"bt_c_d: ")
|
|
||||||
# bp_phy('Bp Am', bt_a_m_txt)
|
|
||||||
# bp_phy('Bp Ad', bt_a_d_txt)
|
|
||||||
# bp_phy('Bp Bm', bt_b_m_txt)
|
|
||||||
# bp_phy('Bp Bd', bt_b_d_txt)
|
|
||||||
# bp_phy('Bp Cm', bt_c_m_txt)
|
|
||||||
# bp_phy('Bp Cd', bt_c_d_txt)
|
|
||||||
|
|
||||||
# # Affichage de l'activation physique des boutons
|
|
||||||
# def bp_phy(obj_name, bp_phy_sig):
|
|
||||||
# obj=scene.objects[obj_name]
|
|
||||||
# if bp_phy_sig =="0":
|
|
||||||
# obj['actif_phy'] = True
|
|
||||||
# obj.color = couleur_jaune
|
|
||||||
# else:
|
|
||||||
# if obj['actif_phy']:
|
|
||||||
# obj['actif_phy'] = False
|
|
||||||
# obj.color = couleur_orange
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Système
|
# Système
|
||||||
@ -402,11 +392,17 @@ def system_reset ():
|
|||||||
# I/O à l'état initial
|
# I/O à l'état initial
|
||||||
scene.objects['Led auto']['activated']=False
|
scene.objects['Led auto']['activated']=False
|
||||||
scene.objects['Bp monter']['activated']=False
|
scene.objects['Bp monter']['activated']=False
|
||||||
|
scene.objects['Bp monter']['activated_real']=False
|
||||||
scene.objects['Bp arret']['activated']=False
|
scene.objects['Bp arret']['activated']=False
|
||||||
|
scene.objects['Bp arret']['activated_real']=False
|
||||||
scene.objects['Bp descendre']['activated']=False
|
scene.objects['Bp descendre']['activated']=False
|
||||||
|
scene.objects['Bp descendre']['activated_real']=False
|
||||||
scene.objects['Bp auto']['activated']=False
|
scene.objects['Bp auto']['activated']=False
|
||||||
|
scene.objects['Bp auto']['activated_real']=False
|
||||||
scene.objects['Microrupteur haut']['activated']=False
|
scene.objects['Microrupteur haut']['activated']=False
|
||||||
|
scene.objects['Microrupteur haut']['activated_real']=False
|
||||||
scene.objects['Microrupteur bas']['activated']=False
|
scene.objects['Microrupteur bas']['activated']=False
|
||||||
|
scene.objects['Microrupteur bas']['activated_real']=False
|
||||||
scene.objects['Moteur']['up']=False
|
scene.objects['Moteur']['up']=False
|
||||||
scene.objects['Moteur']['down']=False
|
scene.objects['Moteur']['down']=False
|
||||||
scene.objects['Recepteur LDR']['activated']=False
|
scene.objects['Recepteur LDR']['activated']=False
|
||||||
|
@ -32,11 +32,13 @@ from volrou_lib import * # Bibliothèque volet roulant
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# Brochage du volet roulant
|
# Brochage du volet roulant
|
||||||
brochage={
|
# brochage={
|
||||||
'fdc_h' : 2,'fdc_b' : 3,
|
# 'fdc_h' : 2,'fdc_b' : 3,
|
||||||
'bp_m' : 4,'bp_d' : 5, 'bp_a' : 6,
|
# 'bp_m' : 4,'bp_d' : 5, 'bp_a' : 6,
|
||||||
'mot_m' : 7,'mot_d' : 8,
|
# 'mot_m' : 7,'mot_d' : 8,
|
||||||
'bp_auto' : 9, 'voy_auto' : 10, 'lum' : 11}
|
# 'bp_auto' : 9, 'voy_auto' : 10, 'lum' : 11}
|
||||||
|
|
||||||
|
brochage={'voy_auto' : 4}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Fonctions
|
# Fonctions
|
||||||
@ -50,8 +52,12 @@ def commandes():
|
|||||||
|
|
||||||
# Ecrire votre code ici ...
|
# Ecrire votre code ici ...
|
||||||
jumeau(brochage)
|
jumeau(brochage)
|
||||||
voy_auto(True) # Activer le gyrophare
|
|
||||||
while True:
|
while True:
|
||||||
|
voy_auto(True)
|
||||||
|
tempo(0.5)
|
||||||
|
voy_auto(False)
|
||||||
|
tempo(0.5)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
fin() # A garder
|
fin() # A garder
|
||||||
|
@ -13,22 +13,11 @@ import time
|
|||||||
# @license: GNU GPL
|
# @license: GNU GPL
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
# Récupérer la scène UPBGE
|
||||||
scene = bge.logic.getCurrentScene()
|
scene = bge.logic.getCurrentScene()
|
||||||
|
|
||||||
# Carte du jumeau numérique
|
# Récupérer le brochage du jumeau réel
|
||||||
board = None
|
from volrou import pin_config
|
||||||
board_it = None # Iterator (input)
|
|
||||||
|
|
||||||
# Brochage du jumeau numérique
|
|
||||||
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
|
# UPBGE constants
|
||||||
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
|
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
|
||||||
@ -62,13 +51,20 @@ def mot_d (order):
|
|||||||
|
|
||||||
# Compte-rendu du capteur fin de course volet en haut
|
# Compte-rendu du capteur fin de course volet en haut
|
||||||
def fdc_h ():
|
def fdc_h ():
|
||||||
return scene.objects['Microrupteur haut']['activated']
|
if scene.objects['Microrupteur haut']['activated'] or scene.objects['Microrupteur haut']['activated_real']:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
# Compte-rendu du capteur fin de course volet en bas
|
# Compte-rendu du capteur fin de course volet en bas
|
||||||
def fdc_b():
|
def fdc_b():
|
||||||
return scene.objects['Microrupteur bas']['activated']
|
if scene.objects['Microrupteur bas']['activated'] or scene.objects['Microrupteur bas']['activated_real']:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
# Compte-rendu du capteur de luminosité
|
# Compte-rendu du capteur de luminosité
|
||||||
|
# FIXME : valeur numérique
|
||||||
def lum():
|
def lum():
|
||||||
return scene.objects['Recepteur LDR']['activated']
|
return scene.objects['Recepteur LDR']['activated']
|
||||||
|
|
||||||
@ -78,15 +74,24 @@ def lum():
|
|||||||
|
|
||||||
# Compte-rendu du bouton monter volet
|
# Compte-rendu du bouton monter volet
|
||||||
def bp_m ():
|
def bp_m ():
|
||||||
return scene.objects['Bp monter']['activated']
|
if scene.objects['Bp monter']['activated'] or scene.objects['Bp monter']['activated_real']:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
# Compte-rendu du bouton arrêt volet
|
# Compte-rendu du bouton arrêt volet
|
||||||
def bp_a ():
|
def bp_a ():
|
||||||
return scene.objects['Bp arret']['activated']
|
if scene.objects['Bp arret']['activated'] or scene.objects['Bp arret']['activated_real']:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
# Compte-rendu du bouton descendre volet
|
# Compte-rendu du bouton descendre volet
|
||||||
def bp_d ():
|
def bp_d ():
|
||||||
return scene.objects['Bp descendre']['activated']
|
if scene.objects['Bp descendre']['activated'] or scene.objects['Bp descendre']['activated_real']:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
# Compte-rendu du bouton mode automatique
|
# Compte-rendu du bouton mode automatique
|
||||||
def bp_auto ():
|
def bp_auto ():
|
||||||
@ -96,8 +101,30 @@ def bp_auto ():
|
|||||||
# Jumeau
|
# Jumeau
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
def jumeau ():
|
# Créer une broche
|
||||||
twin_serial.open()
|
def jumeau_get_pin(board, name, brochage):
|
||||||
|
for pin in brochage :
|
||||||
|
if pin ==name:
|
||||||
|
# print (pin_config[pin][0][0]+':'+str(brochage[pin])+':'+pin_config[pin][0][1])
|
||||||
|
return board.get_pin(pin_config[pin][0][0]+':'+str(brochage[pin])+':'+pin_config[pin][0][1])
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Activer le jumelage
|
||||||
|
def jumeau (brochage=None):
|
||||||
|
|
||||||
|
# Carte
|
||||||
|
board =twin_serial.open()
|
||||||
|
scene.objects['System']['board']=board
|
||||||
|
# print ("jumeau : ", scene.objects['System']['board'])
|
||||||
|
|
||||||
|
# Brochage
|
||||||
|
if brochage is not None:
|
||||||
|
for pin in pin_config :
|
||||||
|
scene.objects[pin_config[pin][1][0]][pin_config[pin][1][1]] = jumeau_get_pin(board, pin, brochage)
|
||||||
|
|
||||||
|
# Désactiver le jumelage
|
||||||
|
def jumeau_stop ():
|
||||||
|
twin_serial.close(scene.objects['System']['board'])
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Cycle
|
# Cycle
|
||||||
@ -107,10 +134,18 @@ def jumeau ():
|
|||||||
def tempo (duree):
|
def tempo (duree):
|
||||||
time.sleep(duree)
|
time.sleep(duree)
|
||||||
|
|
||||||
# Fin
|
# Arrêt
|
||||||
|
def stop():
|
||||||
|
if scene.objects['System']['twins']:
|
||||||
|
twin_serial.close(scene.objects['System']['board'])
|
||||||
|
time.sleep(1)
|
||||||
|
thread_cmd_stop()
|
||||||
|
|
||||||
|
# Fin naturelle
|
||||||
def end():
|
def end():
|
||||||
if scene.objects['System']['twins']:
|
if scene.objects['System']['twins']:
|
||||||
twin_serial.close()
|
twin_serial.close(scene.objects['System']['board'])
|
||||||
|
time.sleep(1)
|
||||||
thread_cmd_end()
|
thread_cmd_end()
|
||||||
|
|
||||||
def fin():
|
def fin():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user