#ifndef gpio_servo_pp_h #define gpio_servo_pp_h // gpio_servo_pp.h // nono - programme du robot 2004. {{{ // // Copyright (C) 2004 Nicolas Schodet // // Robot APB Team/Efrei 2004. // Web: http://assos.efrei.fr/robot/ // Email: robot AT efrei DOT fr // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // }}} #include "gpio.h" #include "servo.h" #include "serial/serial.h" #include "logger/log.h" #include /// Classe pour la gestion de la carte servo à Pierre Prot. class GpioServoPp : public Gpio, public Servo { /// Nombre d'entrées/sorties. static const int nbInputs_ = 6, nbOutputs_ = 6, nbServo_ = 2; /// Sorties courantes. unsigned int outputs_; /// Dernière valeurs d'entrées. unsigned int inputs_; /// Timeouts. static const int inputRequestTimeout_ = 100, inputValidityTimeout_ = 100; /// Date du dernier envois. int lastInputRequestSend_; /// Date de la dernière reception. int lastInputRecv_; /// Position des servos. int servoPos_[nbServo_]; // Ligne série. Serial serial_; std::string ttyname_; int ttyspeed_; // Logger. Log log_; public: /// Constructeur. GpioServoPp (void); /// Destructeur. ~GpioServoPp (void); /// Change plusieurs sorties. void set (int n, unsigned int bits, int nb); /// Change une sortie. void set (int n, unsigned int bit); /// Lit plusieurs entrées. unsigned int get (int n, int nb); /// Lit une entrée. unsigned int get (int n); /// Pré-lit plusieurs entrées. bool preget (int n, int nb); /// Pré-lit une entrée. bool preget (int n); /// Change la direction de plusieurs I/O. void dir (int n, unsigned int bits, int nb); /// Change la direction d'un I/O (1 pour I, 0 pour O). void dir (int n, unsigned int bit); /// Bouge un servo de DIFF. void move (int n, int diff); /// Bouge un servo en position POS. void moveTo (int n, int pos); }; #endif // gpio_servo_pp_h