Skip to content

Commit

Permalink
Simplify driver and no need to load all the config as it can be done …
Browse files Browse the repository at this point in the history
…by client
  • Loading branch information
knro committed Apr 5, 2024
1 parent cd5aac9 commit 43dfcde
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
47 changes: 18 additions & 29 deletions indi-svbony/svbony_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ void SVBONYBase::workerStreamVideo(const std::atomic_bool &isAboutToQuit)
RGB channel data align in targetFrame: 24bit:BGR, 32bit:BGRA
RGB channel data align in file: 24bit:RGB, 32bit:RGBA
*/
if (Helpers::isRGB(mCurrentVideoFormat)) {
if (Helpers::isRGB(mCurrentVideoFormat))
{
int nChannels = Helpers::getNChannels(mCurrentVideoFormat);
for (uint32_t i = 0; i < totalBytes; i += nChannels)
std::swap(targetFrame[i], targetFrame[i + 2]); // swap R and B channel.
}

Streamer->newFrame(targetFrame, totalBytes);
}

Expand Down Expand Up @@ -347,7 +348,7 @@ void SVBONYBase::workerExposure(const std::atomic_bool &isAboutToQuit, float dur
delay = 0.5f;
break;
}
//fall through
//fall through
default: // Cannot continue to retrive image data when ret is any error except timeout.
if (Helpers::isRGB(type))
free(buffer);
Expand Down Expand Up @@ -384,11 +385,6 @@ const char *SVBONYBase::getDefaultName()
return "SVBONY CCD";
}

void SVBONYBase::ISGetProperties(const char *dev)
{
INDI::CCD::ISGetProperties(dev);
}

bool SVBONYBase::initProperties()
{
INDI::CCD::initProperties();
Expand Down Expand Up @@ -443,33 +439,22 @@ bool SVBONYBase::updateProperties()
if (HasCooler())
{
defineProperty(CoolerNP);
loadConfig(true, CoolerNP.getName());
defineProperty(CoolerSP);
loadConfig(true, CoolerSP.getName());
}
// // Even if there is no cooler, we define temperature property as READ ONLY
// else
// {
// TemperatureNP.p = IP_RO;
// defineProperty(&TemperatureNP);
// }

if (!ControlNP.isEmpty())
{
defineProperty(ControlNP);
loadConfig(true, ControlNP.getName());
}

if (!ControlSP.isEmpty())
{
defineProperty(ControlSP);
loadConfig(true, ControlSP.getName());
}

if (hasFlipControl())
{
defineProperty(FlipSP);
loadConfig(true, FlipSP.getName());
}

if (!VideoFormatSP.isEmpty())
Expand Down Expand Up @@ -608,11 +593,13 @@ bool SVBONYBase::Connect()
// Output camera properties to log
if (isDebug())
{
for (int i = 0; (i < (int)(sizeof(mCameraProperty.SupportedBins) / sizeof(mCameraProperty.SupportedBins[0]))) && mCameraProperty.SupportedBins[i] != 0; i++)
for (int i = 0; (i < (int)(sizeof(mCameraProperty.SupportedBins) / sizeof(mCameraProperty.SupportedBins[0])))
&& mCameraProperty.SupportedBins[i] != 0; i++)
{
LOGF_DEBUG(" Bin %d", mCameraProperty.SupportedBins[i]);
}
for (int i = 0; (i < (int)(sizeof(mCameraProperty.SupportedVideoFormat) / sizeof(mCameraProperty.SupportedVideoFormat[0]))) && mCameraProperty.SupportedVideoFormat[i] != SVB_IMG_END; i++)
for (int i = 0; (i < (int)(sizeof(mCameraProperty.SupportedVideoFormat) / sizeof(mCameraProperty.SupportedVideoFormat[0])))
&& mCameraProperty.SupportedVideoFormat[i] != SVB_IMG_END; i++)
{
LOGF_DEBUG(" Supported Video Format: %s", Helpers::toString(mCameraProperty.SupportedVideoFormat[i]));
}
Expand Down Expand Up @@ -774,7 +761,8 @@ void SVBONYBase::setupParams()
SetCCDParams(maxWidth, maxHeight, bpp, pixelSize, pixelSize);

// Let's calculate required buffer
int nbuf = (PrimaryCCD.getXRes() * PrimaryCCD.getYRes() * PrimaryCCD.getBPP() / 8) * Helpers::getNChannels(mCurrentVideoFormat);
int nbuf = (PrimaryCCD.getXRes() * PrimaryCCD.getYRes() * PrimaryCCD.getBPP() / 8) * Helpers::getNChannels(
mCurrentVideoFormat);
PrimaryCCD.setFrameBufferSize(nbuf);

long value = 0;
Expand Down Expand Up @@ -1023,7 +1011,8 @@ int SVBONYBase::SetTemperature(double temperature)

SVB_ERROR_CODE ret;

ret = SVBSetControlValue(mCameraInfo.CameraID, SVB_TARGET_TEMPERATURE, std::round(temperature * 10.0), SVB_TRUE); // For SVB_TARGET_TEMPERATURE, 1 unit is set as 0.1 degree.
ret = SVBSetControlValue(mCameraInfo.CameraID, SVB_TARGET_TEMPERATURE, std::round(temperature * 10.0),
SVB_TRUE); // For SVB_TARGET_TEMPERATURE, 1 unit is set as 0.1 degree.
if (ret != SVB_SUCCESS)
{
LOGF_ERROR("Failed to set temperature (%s).", Helpers::toString(ret));
Expand Down Expand Up @@ -1212,10 +1201,10 @@ void SVBONYBase::temperatureTimerTimeout()
TemperatureNP.s = newState;
TemperatureN[0].value = mCurrentTemperature;
IDSetNumber(&TemperatureNP, nullptr);
/*
This log should be commented out except when investigating bugs, etc., as it outputs very frequently.
LOGF_DEBUG("Current Temperature %.2f degree", mCurrentTemperature);
*/
/*
This log should be commented out except when investigating bugs, etc., as it outputs very frequently.
LOGF_DEBUG("Current Temperature %.2f degree", mCurrentTemperature);
*/
}

if (HasCooler())
Expand Down Expand Up @@ -1430,7 +1419,7 @@ void SVBONYBase::updateRecorderFormat()
mCurrentVideoFormat,
mCameraProperty.BayerPattern,
Helpers::isColor(mCurrentVideoFormat)
),
),
Helpers::getBPP(mCurrentVideoFormat)
);
}
Expand Down Expand Up @@ -1478,4 +1467,4 @@ bool SVBONYBase::saveConfigItems(FILE *fp)
bool SVBONYBase::SetCaptureFormat(uint8_t index)
{
return setVideoFormat(index);
}
}
1 change: 0 additions & 1 deletion indi-svbony/svbony_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class SVBONYBase : public INDI::CCD

virtual const char *getDefaultName() override;

virtual void ISGetProperties(const char *dev) override;
virtual bool initProperties() override;
virtual bool updateProperties() override;

Expand Down

0 comments on commit 43dfcde

Please sign in to comment.