jumeaux-numeriques/volet_roulant/volrou_lib.py

97 lines
3.0 KiB
Python
Raw Normal View History

import bge # Bibliothèque Blender Game Engine (UPBGE)
from twin_threading import thread_cmd_start, thread_cmd_stop # Multithreading
from twin_serial import jumeau # Liaison série
import time
###############################################################################
# volrou_lib.py
# @title: Bibliothèque utilisateur du volet roulant
# @project: Blender-EduTech
# @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2022 Philippe Roy
# @license: GNU GPL
###############################################################################
scene = bge.logic.getCurrentScene()
# Carte du jumeau numérique
board = None
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
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
JUST_RELEASED = bge.logic.KX_INPUT_JUST_RELEASED
ACTIVATE = bge.logic.KX_INPUT_ACTIVE
# JUST_DEACTIVATED = bge.logic.KX_SENSOR_JUST_DEACTIVATED
###############################################################################
# Voyant
###############################################################################
# Ordre pour allumer le voyant témoin mode automatique
def voy_auto (order):
scene.objects['Led auto']['activated']=order
###############################################################################
# Actionneurs
###############################################################################
# Ordre pour le moteur pour monter le volet
def mot_m (order):
scene.objects['Moteur']['up']=order
# Ordre pour le moteur pour descendre le volet
def mot_d (order):
scene.objects['Moteur']['down']=order
###############################################################################
# Capteurs
###############################################################################
# Compte-rendu du capteur fin de course volet en haut
def fdc_h ():
return scene.objects['Microrupteur fdc haut']['activated']
# Compte-rendu du capteur fin de course volet en bas
def fdc_fb():
return scene.objects['Microrupteur fdc bas']['activated']
###############################################################################
# Boutons poussoirs
###############################################################################
# Compte-rendu du bouton monter volet
def bp_m ():
return scene.objects['Bp monter']['activated']
# Compte-rendu du bouton arrêt volet
def bp_a ():
return scene.objects['Bp arret']['activated']
# Compte-rendu du bouton descendre volet
def bp_d ():
return scene.objects['Bp descendre']['activated']
# Compte-rendu du bouton mode automatique
def bp_auto ():
return scene.objects['Bp auto']['activated']
###############################################################################
# Temporisation
###############################################################################
def tempo (duree):
time.sleep(duree)