summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2020-10-19 01:20:58 -0700
committeriximeow <me@iximeow.net>2020-10-19 01:20:58 -0700
commitfeb20c611752e88c86b738febed30bdb90234006 (patch)
treeb5fe4c4b626e5c715b175683d69beccecb903167 /src
parent34a8ba998986fbe696a41adb5eee36becba0831a (diff)
get and report readout modes at startupno-gods-no-
Diffstat (limited to 'src')
-rw-r--r--src/qhyccd/QHYCCDCam.rs5
-rw-r--r--src/qhyccd/mod.rs43
2 files changed, 48 insertions, 0 deletions
diff --git a/src/qhyccd/QHYCCDCam.rs b/src/qhyccd/QHYCCDCam.rs
index 2f6b4fb..246681a 100644
--- a/src/qhyccd/QHYCCDCam.rs
+++ b/src/qhyccd/QHYCCDCam.rs
@@ -199,4 +199,9 @@ extern "C" {
pub fn GetQHYCCDLiveFrame(handle: *mut os::raw::c_void, w: *mut os::raw::c_int, h: *mut os::raw::c_int, bpp: *mut os::raw::c_int, channels: *mut os::raw::c_int, data: *mut os::raw::c_uchar) -> os::raw::c_int;
pub fn CloseQHYCCD(handle: *mut os::raw::c_void) -> os::raw::c_int;
pub fn ReleaseQHYCCDResource() -> os::raw::c_int;
+ pub fn GetQHYCCDNumberOfReadModes(handle: *mut os::raw::c_void, num_modes: *mut os::raw::c_int) -> os::raw::c_int;
+ pub fn GetQHYCCDReadModeResolution(handle: *mut os::raw::c_void, mode_number: os::raw::c_int, width: *mut os::raw::c_int, height: *mut os::raw::c_int) -> os::raw::c_int;
+ pub fn GetQHYCCDReadModeName(handle: *mut os::raw::c_void, mode_number: os::raw::c_int, name: *mut os::raw::c_char) -> os::raw::c_int;
+ pub fn SetQHYCCDReadMode(handle: *mut os::raw::c_void, mode_number: os::raw::c_int) -> os::raw::c_int;
+ pub fn GetQHYCCDReadMode(handle: *mut os::raw::c_void, mode_number: *mut os::raw::c_int) -> os::raw::c_int;
}
diff --git a/src/qhyccd/mod.rs b/src/qhyccd/mod.rs
index bda6822..e819bd4 100644
--- a/src/qhyccd/mod.rs
+++ b/src/qhyccd/mod.rs
@@ -172,6 +172,9 @@ pub fn connect(camera_idx: i32) -> Result<(Receiver<QHYResponse>, Sender<QHYMess
},
};
+ eprintln!("camera readout modes: {:?}", camera.readout_modes());
+ eprintln!("current mode: {}", camera.get_readout_mode().expect("can get current read mode"));
+
camera.set_defaults().unwrap();
// sleep for 2ms between waiting for messages and reading frames. This introduces an
@@ -361,6 +364,13 @@ fn acquire(camera_idx: i32) -> Result<Camera> {
}
}
+#[derive(Debug)]
+struct ReadoutMode {
+ width: u32,
+ height: u32,
+ name: String,
+}
+
impl Camera {
pub fn get_frame(&mut self) -> Option<Vec<u8>> {
if self.frame_size != self.image_buf_size() {
@@ -381,6 +391,39 @@ impl Camera {
check(QHYCCDCam::ControlQHYCCDTemp(self.handle, temp))
}
}
+ pub fn readout_modes(&self) -> Result<Vec<ReadoutMode>> {
+ unsafe {
+ let mut num_readout_modes = 0;
+ check(QHYCCDCam::GetQHYCCDNumberOfReadModes(self.handle, &mut num_readout_modes as *mut os::raw::c_int))?;
+ let mut modes = Vec::new();
+ for i in 0..num_readout_modes {
+ let mut width = 0;
+ let mut height = 0;
+ let mut name = [0i8; 512];
+ check(QHYCCDCam::GetQHYCCDReadModeResolution(self.handle, i, &mut width as *mut i32, &mut height as *mut i32))?;
+ check(QHYCCDCam::GetQHYCCDReadModeName(self.handle, i, name.as_mut_ptr()))?;
+ modes.push(ReadoutMode {
+ name: std::ffi::CStr::from_ptr(name.as_ptr()).to_str().expect("valid string").to_string(),
+ width: width as u32,
+ height: height as u32,
+ });
+ }
+
+ Ok(modes)
+ }
+ }
+ pub fn get_readout_mode(&self) -> Result<u32> {
+ let mut mode = 0;
+ unsafe {
+ check(QHYCCDCam::GetQHYCCDReadMode(self.handle, &mut mode))?;
+ }
+ Ok(mode as u32)
+ }
+ pub fn set_readout_mode(&self, mode: u32) -> Result<()> {
+ unsafe {
+ check(QHYCCDCam::SetQHYCCDReadMode(self.handle, mode as i32))
+ }
+ }
pub fn has_control(&self, control: Control) -> bool {
unsafe {
match QHYResult::from(QHYCCDCam::IsQHYCCDControlAvailable(self.handle, control as i32) as u32) {