diff --git a/drivers/rotator/deepskydad_fr1.cpp b/drivers/rotator/deepskydad_fr1.cpp index 37098fe6ef..f3c3040beb 100644 --- a/drivers/rotator/deepskydad_fr1.cpp +++ b/drivers/rotator/deepskydad_fr1.cpp @@ -58,22 +58,22 @@ bool DeepSkyDadFR1::initProperties() addAuxControls(); // Speed mode - IUFillSwitch(&SpeedModeS[Slow], "SLOW", "Slow", ISS_OFF); - IUFillSwitch(&SpeedModeS[Fast], "FAST", "Fast", ISS_OFF); - IUFillSwitchVector(&SpeedModeSP, SpeedModeS, 2, getDeviceName(), "Speed mode", "Speed mode", MAIN_CONTROL_TAB, IP_RW, + SpeedModeSP[Slow].fill("SLOW", "Slow", ISS_OFF); + SpeedModeSP[Fast].fill( "FAST", "Fast", ISS_OFF); + SpeedModeSP.fill(getDeviceName(), "Speed mode", "Speed mode", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); // Step mode - IUFillSwitch(&StepSizeS[One], "1", "1", ISS_OFF); - IUFillSwitch(&StepSizeS[Two], "2", "1/2", ISS_OFF); - IUFillSwitch(&StepSizeS[Four], "4", "1/4", ISS_OFF); - IUFillSwitch(&StepSizeS[Eight], "8", "1/8", ISS_OFF); - IUFillSwitchVector(&StepSizeSP, StepSizeS, 4, getDeviceName(), "Step mode", "Step mode", MAIN_CONTROL_TAB, IP_RW, + StepSizeSP[One].fill("1", "1", ISS_OFF); + StepSizeSP[Two].fill("2", "1/2", ISS_OFF); + StepSizeSP[Four].fill( "4", "1/4", ISS_OFF); + StepSizeSP[Eight].fill( "8", "1/8", ISS_OFF); + StepSizeSP.fill(getDeviceName(), "Step mode", "Step mode", MAIN_CONTROL_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE); // Firmware version - IUFillText(&FirmwareT[0], "Version", "Version", nullptr); - IUFillTextVector(&FirmwareTP, FirmwareT, 1, getDeviceName(), "Firmware", "Firmware", MAIN_CONTROL_TAB, IP_RO, 60, IPS_IDLE); + FirmwareTP[0].fill("Version", "Version", nullptr); + FirmwareTP.fill(getDeviceName(), "Firmware", "Firmware", MAIN_CONTROL_TAB, IP_RO, 60, IPS_IDLE); serialConnection->setDefaultPort("/dev/ttyACM0"); serialConnection->registerHandshake([&]() @@ -90,15 +90,15 @@ bool DeepSkyDadFR1::updateProperties() if (isConnected()) { - defineProperty(&SpeedModeSP); - defineProperty(&StepSizeSP); - defineProperty(&FirmwareTP); + defineProperty(SpeedModeSP); + defineProperty(StepSizeSP); + defineProperty(FirmwareTP); } else { - deleteProperty(SpeedModeSP.name); - deleteProperty(StepSizeSP.name); - deleteProperty(FirmwareTP.name); + deleteProperty(SpeedModeSP); + deleteProperty(StepSizeSP); + deleteProperty(FirmwareTP); } return true; @@ -119,18 +119,18 @@ bool DeepSkyDadFR1::ISNewSwitch(const char * dev, const char * name, ISState * s { if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { - if (strcmp(SpeedModeSP.name, name) == 0) + if (SpeedModeSP.isNameMatch(name)) { - int current_mode = IUFindOnSwitchIndex(&SpeedModeSP); + int current_mode = SpeedModeSP.findOnSwitchIndex(); - IUUpdateSwitch(&SpeedModeSP, states, names, n); + SpeedModeSP.update(states, names, n); - int target_mode = IUFindOnSwitchIndex(&SpeedModeSP); + int target_mode = SpeedModeSP.findOnSwitchIndex(); if (current_mode == target_mode) { - SpeedModeSP.s = IPS_OK; - IDSetSwitch(&SpeedModeSP, nullptr); + SpeedModeSP.setState(IPS_OK); + SpeedModeSP.apply(); return true; } @@ -141,29 +141,29 @@ bool DeepSkyDadFR1::ISNewSwitch(const char * dev, const char * name, ISState * s bool rc = sendCommand(cmd, response); if (!rc) { - IUResetSwitch(&SpeedModeSP); - SpeedModeS[current_mode].s = ISS_ON; - SpeedModeSP.s = IPS_ALERT; - IDSetSwitch(&SpeedModeSP, nullptr); + SpeedModeSP.reset(); + SpeedModeSP[current_mode].setState(ISS_ON); + SpeedModeSP.setState(IPS_ALERT); + SpeedModeSP.apply(); return false; } - SpeedModeSP.s = IPS_OK; - IDSetSwitch(&SpeedModeSP, nullptr); + SpeedModeSP.setState(IPS_OK); + SpeedModeSP.apply(); return true; } - else if (strcmp(StepSizeSP.name, name) == 0) + else if (StepSizeSP.isNameMatch(name)) { - int current_mode = IUFindOnSwitchIndex(&StepSizeSP); + int current_mode = StepSizeSP.findOnSwitchIndex(); - IUUpdateSwitch(&StepSizeSP, states, names, n); + StepSizeSP.update(states, names, n); - int target_mode = IUFindOnSwitchIndex(&StepSizeSP); + int target_mode = StepSizeSP.findOnSwitchIndex(); if (current_mode == target_mode) { - StepSizeSP.s = IPS_OK; - IDSetSwitch(&StepSizeSP, nullptr); + StepSizeSP.setState(IPS_OK); + StepSizeSP.apply(); return true; } @@ -174,15 +174,15 @@ bool DeepSkyDadFR1::ISNewSwitch(const char * dev, const char * name, ISState * s bool rc = sendCommand(cmd, response); if (!rc) { - IUResetSwitch(&StepSizeSP); - StepSizeS[current_mode].s = ISS_ON; - StepSizeSP.s = IPS_ALERT; - IDSetSwitch(&StepSizeSP, nullptr); + StepSizeSP.reset(); + StepSizeSP[current_mode].setState(ISS_ON); + StepSizeSP.setState(IPS_ALERT); + StepSizeSP.apply(); return false; } - StepSizeSP.s = IPS_OK; - IDSetSwitch(&StepSizeSP, nullptr); + StepSizeSP.setState(IPS_OK); + StepSizeSP.apply(); return true; } } @@ -302,8 +302,8 @@ bool DeepSkyDadFR1::getInitialStatusData() char versionString[6] = { 0 }; snprintf(versionString, 6, "%s", response + 31); - IUSaveText(&FirmwareT[0], response); - IDSetText(&FirmwareTP, nullptr); + FirmwareTP[0].setText(response); + FirmwareTP.apply(); int motorReversed; @@ -324,21 +324,21 @@ bool DeepSkyDadFR1::getInitialStatusData() return false; if(strcmp(response, "(2)") == 0) - SpeedModeS[Slow].s = ISS_ON; + SpeedModeSP[Slow].setState(ISS_ON); else if(strcmp(response, "(3)") == 0) - SpeedModeS[Fast].s = ISS_ON; + SpeedModeSP[Fast].setState(ISS_ON); if (!sendCommand("[GSTP]", response)) return false; if(strcmp(response, "(1)") == 0) - StepSizeS[One].s = ISS_ON; + StepSizeSP[One].setState(ISS_ON); else if(strcmp(response, "(2)") == 0) - StepSizeS[Two].s = ISS_ON; + StepSizeSP[Two].setState(ISS_ON); else if(strcmp(response, "(4)") == 0) - StepSizeS[Four].s = ISS_ON; + StepSizeSP[Four].setState(ISS_ON); else if(strcmp(response, "(8)") == 0) - StepSizeS[Eight].s = ISS_ON; + StepSizeSP[Eight].setState(ISS_ON); return true; } diff --git a/drivers/rotator/deepskydad_fr1.h b/drivers/rotator/deepskydad_fr1.h index 55ff9617bc..58512f0df0 100644 --- a/drivers/rotator/deepskydad_fr1.h +++ b/drivers/rotator/deepskydad_fr1.h @@ -72,13 +72,10 @@ class DeepSkyDadFR1 : public INDI::Rotator //////////////////////////////////////////////////////////////////////////////////// // Firmware version - ITextVectorProperty FirmwareTP; - IText FirmwareT[1] {}; + INDI::PropertyText FirmwareTP {1}; // Speed mode - ISwitch SpeedModeS[2]; - ISwitchVectorProperty SpeedModeSP; + INDI::PropertySwitch SpeedModeSP {2}; // Step size - ISwitch StepSizeS[4]; - ISwitchVectorProperty StepSizeSP; + INDI::PropertySwitch StepSizeSP {4}; };