Instrument Neutral Distributed Interface INDI 2.2.5
pinefeat_cef.h
Go to the documentation of this file.
1/*
2 Pinefeat EF / EF-S Lens Controller – Canon® Lens Compatible
3 Copyright (C) 2025 Pinefeat LLP ([email protected])
4
5 Based on Moonlite focuser
6 Copyright (C) 2013-2019 Jasem Mutlaq ([email protected])
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21*/
22
23#pragma once
24
25#include "indifocuser.h"
26#include <chrono>
27
29{
30 public:
32 ~PinefeatCEF() override = default;
33
34 bool initProperties() override;
35 bool updateProperties() override;
36 bool ISNewNumber(const char * dev, const char * name, double values[], char * names[], int n) override;
37 bool ISNewSwitch(const char * dev, const char * name, ISState * states, char * names[], int n) override;
38 void TimerHit() override;
39
40 protected:
41 const char * getDefaultName() override;
42 bool Handshake() override;
43 IPState MoveAbsFocuser(uint32_t targetTicks) override;
44 IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
45 bool SetFocuserSpeed(int speed) override;
46
47 private:
48 void updateProperties(const int32_t pos, const int32_t max, const std::string dist, const std::string aper);
49 bool readFocusPosition(int32_t &pos);
50 bool readFocusMaxPosition(int32_t &pos);
51 bool readFocusDistance(std::string &result);
52 bool readApertureRange(std::string &result);
53 bool readFirmwareVersion();
54 bool isNotMoving();
55 bool moveFocusAbs(uint32_t position);
56 bool moveFocusRel(FocusDirection dir, uint32_t offset);
57 bool setSpeed(int speed);
58 bool setApertureAbs(double value);
59 bool setApertureRel(double value);
60 bool calibrate();
61
69 bool sendCommand(const char * cmd, char * res = nullptr);
70
71 INDI::PropertySwitch CalibrateSP {1};
72
73 INDI::PropertyNumber ApertureRelNP {1};
74
75 INDI::PropertyNumber ApertureAbsNP {1};
76
77 INDI::PropertyText ApertureRangeTP {1};
78
79 INDI::PropertyText FocusDistanceTP {1};
80
81 INDI::PropertyText FirmwareTP {1};
82
83 // CEF Buffer Size
84 static const uint8_t CEF_BUF { 16 };
85
86 // CEF Command Delimiter
87 static const char CEF_DEL { '\n' };
88
89 // CEF Command Timeout
90 static const uint8_t CEF_TIMEOUT { 3 };
91
92 std::chrono::steady_clock::time_point lastUpdate;
93
94 uint16_t firmwareMinor {0};
95};
const char * getDefaultName() override
IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
~PinefeatCEF() override=default
bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
double max(void)
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2