1 /* 2 Pegasus DMFC Focuser 3 Copyright (C) 2017 Jasem Mutlaq (mutlaqja@ikarustech.com) 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 19 */ 20 21 #pragma once 22 23 #include "indifocuser.h" 24 25 class DMFC : public INDI::Focuser 26 { 27 public: 28 DMFC(); 29 virtual ~DMFC() override = default; 30 31 virtual bool Handshake() override; 32 const char *getDefaultName() override; 33 virtual bool initProperties() override; 34 virtual bool updateProperties() override; 35 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override; 36 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override; 37 38 protected: 39 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override; 40 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override; 41 virtual bool AbortFocuser() override; 42 virtual void TimerHit() override; 43 44 virtual bool SyncFocuser(uint32_t ticks) override; 45 virtual bool ReverseFocuser(bool enabled) override; 46 virtual bool SetFocuserBacklash(int32_t steps) override; 47 virtual bool SetFocuserBacklashEnabled(bool enabled) override; 48 virtual bool saveConfigItems(FILE *fp) override; 49 50 private: 51 bool updateFocusParams(); 52 bool move(uint32_t newPosition); 53 bool setMaxSpeed(uint16_t speed); 54 bool setLedEnabled(bool enable); 55 bool setEncodersEnabled(bool enable); 56 bool setMotorType(uint8_t type); 57 bool ack(); 58 void ignoreResponse(); 59 60 uint32_t currentPosition { 0 }; 61 uint32_t targetPosition { 0 }; 62 bool isMoving = false; 63 64 // Temperature probe 65 INumber TemperatureN[1]; 66 INumberVectorProperty TemperatureNP; 67 68 // Motor Mode 69 ISwitch MotorTypeS[2]; 70 ISwitchVectorProperty MotorTypeSP; 71 enum { MOTOR_DC, MOTOR_STEPPER }; 72 73 // Rotator Encoders 74 ISwitch EncoderS[2]; 75 ISwitchVectorProperty EncoderSP; 76 enum { ENCODERS_ON, ENCODERS_OFF }; 77 78 // LED 79 ISwitch LEDS[2]; 80 ISwitchVectorProperty LEDSP; 81 enum { LED_OFF, LED_ON }; 82 83 // Maximum Speed 84 INumber MaxSpeedN[1]; 85 INumberVectorProperty MaxSpeedNP; 86 87 // Firmware Version 88 IText FirmwareVersionT[1] {}; 89 ITextVectorProperty FirmwareVersionTP; 90 }; 91