libraries / Mitov / Mitov_Servo.hon commit Added link to project report (97a3ba0)
   1////////////////////////////////////////////////////////////////////////////////
   2//                                                                            //
   3//     This software is supplied under the terms of a license agreement or    //
   4//     nondisclosure agreement with Mitov Software and may not be copied      //
   5//     or disclosed except in accordance with the terms of that agreement.    //
   6//         Copyright(c) 2002-2016 Mitov Software. All Rights Reserved.        //
   7//                                                                            //
   8////////////////////////////////////////////////////////////////////////////////
   9
  10#ifndef _MITOV_SERVO_h
  11#define _MITOV_SERVO_h
  12
  13#include <Mitov.h>
  14
  15#include <Servo.h>
  16
  17namespace Mitov
  18{
  19        template<int PIN_NUMBER> class MitovServo : public Mitov::CommonSink
  20        {
  21                typedef Mitov::CommonSink inherited;
  22
  23        protected:
  24                Servo   FServo;
  25                
  26        protected:
  27                virtual void DoReceive( void *_Data ) override
  28                {
  29                        float AValue = constrain( *((float *)_Data), 0.0f, 1.0f ) * 180;
  30                        FServo.write( AValue );
  31                }
  32
  33                virtual void SystemStart() override
  34                {
  35                        FServo.attach( PIN_NUMBER );
  36                        inherited::SystemStart();
  37                }
  38
  39        };
  40}
  41
  42#endif