diff --git a/src/cam_qhy.cpp b/src/cam_qhy.cpp index 95b4e1793..0a0a882df 100644 --- a/src/cam_qhy.cpp +++ b/src/cam_qhy.cpp @@ -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; @@ -100,6 +99,7 @@ class Camera_QHY : public GuideCamera bool m_highGain; bool m_hasSpeedMode; bool m_speedMode; + bool m_has16bitMode; double coolerSetpoint; public: @@ -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; @@ -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)); @@ -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")); } } } @@ -651,6 +660,7 @@ bool Camera_QHY::Connect(const wxString& camId) } else { + Debug.Write("QHY: CONTROL_OFFSET is not available\n"); m_hasOffset = false; } @@ -662,6 +672,7 @@ bool Camera_QHY::Connect(const wxString& camId) } else { + Debug.Write("QHY: CONTROL_USBTRAFFIC is not available\n"); m_hasUsbTraffic = false; } @@ -672,6 +683,7 @@ bool Camera_QHY::Connect(const wxString& camId) } else { + Debug.Write("QHY: CONTROL_AMPV is not available\n"); m_hasAmpnr = false; } @@ -682,6 +694,7 @@ bool Camera_QHY::Connect(const wxString& camId) } else { + Debug.Write("QHY: CONTROL_ROWNOISERE is not available\n"); m_hasRownr = false; } @@ -692,6 +705,7 @@ bool Camera_QHY::Connect(const wxString& camId) } else { + Debug.Write("QHY: CONTROL_SPEED is not available\n"); m_hasSpeedMode = false; } @@ -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; } @@ -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) { @@ -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; } @@ -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)); @@ -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)) @@ -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) { @@ -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 { @@ -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 { @@ -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 { @@ -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 {