26 #define HID_TIMEOUT 10000
27 #define FUDGE_FACTOR_H 1000
28 #define FUDGE_FACTOR_L 885
30 #define FOCUS_SETTINGS_TAB "Settings"
43 if (m_HIDHandle !=
nullptr)
46 m_HIDHandle =
nullptr;
57 m_HIDHandle =
hid_open(0x04D8, 0xFAC2,
nullptr);
59 if (m_HIDHandle ==
nullptr)
60 m_HIDHandle =
hid_open(0x04D8, 0xF53A,
nullptr);
62 LOG_DEBUG(m_HIDHandle ?
"HitecAstroDCFocuser opened." :
"HitecAstroDCFocuser failed.");
64 if (m_HIDHandle !=
nullptr)
66 LOG_INFO(
"Experimental driver. Report issues to https://github.com/A-j-K/hitecastrodcfocuser/issues");
77 if (m_HIDHandle !=
nullptr)
80 m_HIDHandle =
nullptr;
89 return "HitecAstro DC";
105 IUFillNumber(&SlewSpeedN[0],
"Steps/sec",
"",
"%.f", 1, 100, 0., 50);
150 if (m_State ==
SLEWING && m_Duration > 0)
156 unsigned char command[8] = {0};
158 memset(command, 0, 8);
159 command[0] = m_StopChar;
182 if (strcmp(name, SlewSpeedNP.
name) == 0)
200 int rc, speed = (int)SlewSpeedN[0].value;
202 unsigned char command[8] = {0};
205 LOGF_DEBUG(
"::move() begin %d ticks at speed %d", ticks, speed);
207 if (m_HIDHandle ==
nullptr)
230 LOGF_DEBUG(
"::move() over speed %d, limiting to 100", ticks, speed);
237 memset(command, 0, 8);
239 command[1] = (
unsigned char)((ticks >> 8) & 0xFF);
240 command[2] = (
unsigned char)(ticks & 0xFF);
242 command[4] = (
unsigned char)(speed & 0xFF);
247 LOGF_DEBUG(
"==> TX %2.2x %2.2x%2.2x %2.2x %2.2x %2.2x%2.2x%2.2x", command[0], command[1],
248 command[2], command[3], command[4], command[5], command[6], command[7]);
259 memset(command, 0, 8);
261 LOGF_DEBUG(
"==> RX %2.2x %2.2x%2.2x %2.2x %2.2x %2.2x%2.2x%2.2x", command[0], command[1],
262 command[2], command[3], command[4], command[5], command[6], command[7]);
275 unsigned char command[8] = {0};
278 LOGF_DEBUG(
"::MoveFocuser(%d %d %d)", dir, speed, duration);
280 if (m_HIDHandle ==
nullptr)
295 LOGF_DEBUG(
"::MoveFocuser() over speed %d, limiting to 100", speed);
301 memset(command, 0, 8);
303 command[1] = (
unsigned char)((speed >> 8) & 0xFF);
304 command[2] = (
unsigned char)(speed & 0xFF);
311 LOGF_DEBUG(
"==> TX %2.2x %2.2x%2.2x %2.2x %2.2x %2.2x%2.2x%2.2x", command[0], command[1],
312 command[2], command[3], command[4], command[5], command[6], command[7]);
321 memset(command, 0, 8);
323 LOGF_DEBUG(
"==> RX %2.2x %2.2x%2.2x %2.2x %2.2x %2.2x%2.2x%2.2x", command[0], command[1],
324 command[2], command[3], command[4], command[5], command[6], command[7]);
331 m_Duration = duration;
virtual ~HitecAstroDCFocuser() override
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
bool Disconnect() override
Disconnect from device.
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
const char * getDefaultName() override
virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override
MoveFocuser the focuser in a particular direction with a specific speed for a finite duration.
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
const char * getDeviceName() const
void setDefaultPollingPeriod(uint32_t msec)
setDefaultPollingPeriod Change the default polling period to call TimerHit() function in the driver.
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
void addDebugControl()
Add Debug control to the driver.
INumberVectorProperty FocusSpeedNP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
void setSupportedConnections(const uint8_t &value)
setConnection Set Focuser connection mode. Child class should call this in the constructor before Foc...
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number.
int HID_API_EXPORT hid_init(void)
Initialize the HIDAPI library.
int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds)
Read an Input report from a HID device with timeout.
int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length)
Write an Output report to a HID device.
void HID_API_EXPORT hid_close(hid_device *dev)
Close a HID device.
HID_API_EXPORT const wchar_t *HID_API_CALL hid_error(hid_device *dev)
Get a string describing the last error which occurred.
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)