Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final QHY improvements #1259

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 50 additions & 27 deletions src/cam_qhy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class Camera_QHY : public GuideCamera
double m_devicePixelSize;
unsigned char *RawBuffer;
wxSize m_maxSize;
int m_curExposure;
unsigned short m_curBin;
wxRect m_roi;
bool Color;
Expand All @@ -100,6 +99,7 @@ class Camera_QHY : public GuideCamera
bool m_highGain;
bool m_hasSpeedMode;
bool m_speedMode;
bool m_has16bitMode;
double coolerSetpoint;

public:
Expand Down Expand Up @@ -223,11 +223,11 @@ Camera_QHY::Camera_QHY()
m_camhandle = 0;

m_curBin = 1;
m_curExposure = 0;
m_devicePixelSize = 0;
coolerSetpoint = 0;

m_bpp = pConfig->Profile.GetInt(CONFIG_PATH_QHY_BPP, DEFAULT_BPP);
m_has16bitMode = false;

m_curGain = 0;
m_gainMin = 0;
Expand Down Expand Up @@ -401,10 +401,19 @@ void Camera_QHY::ShowPropertyDialog()

dlg.SetTitle(wxString::Format("%s Settings", camShortName));

if (m_bpp == 8)
if (!m_has16bitMode)
{
dlg.m_bpp8->SetValue(true);
dlg.m_bpp8->Enable(false);
dlg.m_bpp16->Enable(false);
}
else
dlg.m_bpp16->SetValue(true);
{
if (m_bpp == 8)
dlg.m_bpp8->SetValue(true);
else
dlg.m_bpp16->SetValue(true);
}

dlg.m_gainText->SetLabel(wxString::Format("Gain: %d (min: %g, max: %g)", GetQhyGain(), m_gainMin, m_gainMax));

Expand Down Expand Up @@ -469,7 +478,7 @@ void Camera_QHY::ShowPropertyDialog()

if (reconnect)
{
pFrame->Alert(_("Camera must be reconnected to set the new bit mode"));
pFrame->Alert(_("Camera must be reconnected to set the new mode"));
}
}
}
Expand Down Expand Up @@ -651,6 +660,7 @@ bool Camera_QHY::Connect(const wxString& camId)
}
else
{
Debug.Write("QHY: CONTROL_OFFSET is not available\n");
m_hasOffset = false;
}

Expand All @@ -662,6 +672,7 @@ bool Camera_QHY::Connect(const wxString& camId)
}
else
{
Debug.Write("QHY: CONTROL_USBTRAFFIC is not available\n");
m_hasUsbTraffic = false;
}

Expand All @@ -672,6 +683,7 @@ bool Camera_QHY::Connect(const wxString& camId)
}
else
{
Debug.Write("QHY: CONTROL_AMPV is not available\n");
m_hasAmpnr = false;
}

Expand All @@ -682,6 +694,7 @@ bool Camera_QHY::Connect(const wxString& camId)
}
else
{
Debug.Write("QHY: CONTROL_ROWNOISERE is not available\n");
m_hasRownr = false;
}

Expand All @@ -692,6 +705,7 @@ bool Camera_QHY::Connect(const wxString& camId)
}
else
{
Debug.Write("QHY: CONTROL_SPEED is not available\n");
m_hasSpeedMode = false;
}

Expand All @@ -702,6 +716,7 @@ bool Camera_QHY::Connect(const wxString& camId)
}
else
{
Debug.Write("QHY: CAM_LIGHT_PERFORMANCE_MODE is not available\n");
m_hasHighGain = false;
}

Expand All @@ -715,6 +730,22 @@ bool Camera_QHY::Connect(const wxString& camId)
return CamConnectFailed(_("Failed to get camera chip info"));
}

if (IsQHYCCDControlAvailable(m_camhandle, CAM_16BITS) == QHYCCD_SUCCESS)
{
m_has16bitMode = true;
}
else
{
Debug.Write("QHY: CAM_16BITS is not available\n");
m_has16bitMode = false;

if (m_bpp == 16)
{
m_bpp = 8;
pConfig->Profile.SetInt(CONFIG_PATH_QHY_BPP, m_bpp);
}
}

ret = SetQHYCCDBitsMode(m_camhandle, (uint32_t) m_bpp);
if (ret != QHYCCD_SUCCESS)
{
Expand All @@ -739,17 +770,17 @@ bool Camera_QHY::Connect(const wxString& camId)
}
else
{
Debug.Write("QHY: DDR buffer not available\n");
Debug.Write("QHY: CONTROL_DDR is not available\n");
}

if (IsQHYCCDControlAvailable(m_camhandle, CONTROL_COOLER) == QHYCCD_SUCCESS)
{
Debug.Write("QHY: cooler control available\n");
Debug.Write("QHY: CONTROL_COOLER available\n");
HasCooler = true;
}
else
{
Debug.Write("QHY: cooler control not available\n");
Debug.Write("QHY: CONTROL_COOLER is not available\n");
HasCooler = false;
}

Expand Down Expand Up @@ -822,7 +853,6 @@ bool Camera_QHY::Connect(const wxString& camId)
m_devicePixelSize = sqrt(pixelw * pixelh);

m_curGain = -1;
m_curExposure = -1;
m_roi = wxRect(0, 0, FullSize.GetWidth(), FullSize.GetHeight()); // binned coordinates

Debug.Write(wxString::Format("QHY: call SetQHYCCDResolution roi = %d,%d\n", m_roi.width, m_roi.height));
Expand Down Expand Up @@ -976,20 +1006,6 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
}
}

if (duration != m_curExposure)
{
ret = SetQHYCCDParam(m_camhandle, CONTROL_EXPOSURE, duration * 1000.0); // QHY duration is usec
if (ret == QHYCCD_SUCCESS)
{
m_curExposure = duration;
}
else
{
Debug.Write(wxString::Format("QHY set exposure ret %d\n", (int) ret));
pFrame->Alert(_("Failed to set camera exposure"));
}
}

if (GuideCameraGain != m_curGain)
{
if (SetQhyGain(GuideCameraGain))
Expand Down Expand Up @@ -1062,6 +1078,13 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
m_settingsChanged = false;
}

ret = SetQHYCCDParam(m_camhandle, CONTROL_EXPOSURE, duration * 1000.0); // QHY duration is usec
if (ret == QHYCCD_ERROR)
{
Debug.Write(wxString::Format("QHY set exposure ret %d\n", (int) ret));
pFrame->Alert(_("Failed to set camera exposure length"));
}

ret = ExpQHYCCDSingleFrame(m_camhandle);
if (ret == QHYCCD_ERROR)
{
Expand Down Expand Up @@ -1283,7 +1306,7 @@ bool Camera_QHY::SetQhyAmpNoiseReduction(bool enable)

if (!m_hasAmpnr)
{
Debug.Write("QHY: amp noise reduction is not available\n");
return false;
}
else
{
Expand All @@ -1307,7 +1330,7 @@ bool Camera_QHY::SetQhyRowNoiseReduction(bool enable)

if (!m_hasRownr)
{
Debug.Write("QHY: row noise reduction is not available\n");
return false;
}
else
{
Expand Down Expand Up @@ -1335,7 +1358,7 @@ bool Camera_QHY::SetQhySpeedMode(bool highSpeed)

if (!m_hasSpeedMode)
{
Debug.Write("QHY: speed modes are not available\n");
return false;
}
else
{
Expand All @@ -1359,7 +1382,7 @@ bool Camera_QHY::SetQhyHighGainMode(bool enable)

if (!m_hasHighGain)
{
Debug.Write("QHY: selectable gain modes not available\n");
return false;
}
else
{
Expand Down