From 4ddd74577181961a112a08fb9f72be15f3261a82 Mon Sep 17 00:00:00 2001 From: Huib Wouters Date: Fri, 23 Feb 2024 20:26:19 +0100 Subject: [PATCH] added support for the :GC# command for Moonlite focuser (#2004) * Added the :GC# command to retreive the stored temperature coefficient from my focuser * Added the :GC# command to retreive the stored temperature coefficient from my focuser --- drivers/focuser/moonlite.cpp | 24 ++++++++++++++++++++++++ drivers/focuser/moonlite.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/drivers/focuser/moonlite.cpp b/drivers/focuser/moonlite.cpp index f12274289b..1f574ddefb 100644 --- a/drivers/focuser/moonlite.cpp +++ b/drivers/focuser/moonlite.cpp @@ -205,6 +205,27 @@ bool MoonLite::readTemperature() return true; } +bool MoonLite::readTemperatureCoefficient() +{ + char res[ML_RES] = {0}; + + if (sendCommand(":GC#", res) == false) + return false; + + uint8_t coefficient = 0; + int rc = sscanf(res, "%hhX", &coefficient); + if (rc > 0) + // Signed HEX of two digits + TemperatureSettingNP[1].setValue(static_cast(coefficient) / 2.0); + else + { + LOGF_ERROR("Unknown error: focuser temperature coefficient value (%s)", res); + return false; + } + + return true; +} + bool MoonLite::readPosition() { char res[ML_RES] = {0}; @@ -425,6 +446,9 @@ void MoonLite::GetFocusParams() if (readTemperature()) TemperatureNP.apply(); + if (readTemperatureCoefficient()) + TemperatureSettingNP.apply(); + if (readSpeed()) IDSetNumber(&FocusSpeedNP, nullptr); diff --git a/drivers/focuser/moonlite.h b/drivers/focuser/moonlite.h index 0b709b8b95..4a70419255 100644 --- a/drivers/focuser/moonlite.h +++ b/drivers/focuser/moonlite.h @@ -102,6 +102,8 @@ class MoonLite : public INDI::Focuser bool readStepMode(); // Read and update Temperature bool readTemperature(); + // Read and update Temperature Coefficient + bool readTemperatureCoefficient(); // Read and update Position bool readPosition(); // Read and update speed