summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2019-03-15 19:08:25 -0700
committeriximeow <me@iximeow.net>2019-03-15 19:08:25 -0700
commit1e720ec89ac03c5ed8534461c2f5340ac4dafa7d (patch)
treef8fefb3962fa8961b498941078cada2d196cfe4b /src
parent7ab1ab5f8d923eceda77e0913900a5abec4b4c15 (diff)
several in-the-field tweaks for qhy367c
Diffstat (limited to 'src')
-rw-r--r--src/main.rs27
-rw-r--r--src/qhyccd/QHYCCDCam.rs1
-rw-r--r--src/qhyccd/mod.rs37
3 files changed, 53 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs
index 3640f34..eeb816d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,12 +18,19 @@ fn operate_qhy() {
use crate::qhyccd::Control;
println!("Operating on qhy camera ... or i'll die trying");
let mut camera = qhyccd::acquire(0).unwrap();
- camera.set_exposure_ms(40000).unwrap();
- camera.set_param(Control::Gain, 64.0).unwrap();
- camera.set_param(Control::Offset, 00.0).unwrap();
- camera.set_param(Control::USBTraffic, 250.0).unwrap();
- camera.set_target_temp(0.0).unwrap();
- camera.set_param(Control::Cooler, 0.0).unwrap();
+ camera.set_exposure_ms(4500).unwrap();
+ camera.set_param(Control::Gain, 100.0).unwrap();
+ camera.set_param(Control::Offset, 000.0).unwrap();
+ camera.set_param(Control::USBTraffic, 50.0).unwrap();
+// camera.set_target_temp(0.0).unwrap();
+ camera.set_param(Control::Cooler, -15.0).unwrap();
+ println!("Gain: {:?}", camera.get_param_limits(Control::Gain));
+ println!("Offset: {:?}", camera.get_param_limits(Control::Offset));
+ println!("USBTraffic: {:?}", camera.get_param_limits(Control::USBTraffic));
+ println!("Gama: {:?}", camera.get_param_limits(Control::Gamma));
+ println!("WB Red: {:?}", camera.get_param_limits(Control::CONTROL_WBR));
+ println!("WB Green: {:?}", camera.get_param_limits(Control::CONTROL_WBG));
+ println!("WB Blue: {:?}", camera.get_param_limits(Control::CONTROL_WBB));
println!("Binning modes:");
println!("1x1: {}", camera.has_param(Control::Bin1x1Mode));
println!("2x2: {}", camera.has_param(Control::Bin2x2Mode));
@@ -32,8 +39,14 @@ fn operate_qhy() {
// camera.set_param(Control::Speed, 1.0).unwrap();
println!("current temp: {}", camera.get_param(Control::CurTemp));
camera.set_defaults().unwrap();
+ camera.set_param(Control::CONTROL_WBR, 4027.0).unwrap();
+ camera.set_param(Control::CONTROL_WBG, 4027.0).unwrap();
+ camera.set_param(Control::CONTROL_WBB, 4027.0).unwrap();
// camera.set_bin_mode(2).unwrap();
- camera.take_image("../../asdf.png");
+ let object = "jupiter";
+ for i in 0..10 {
+ camera.take_image(&format!("{}_{}.png", object, i));//, i));
+ }
camera.release().unwrap();
}
diff --git a/src/qhyccd/QHYCCDCam.rs b/src/qhyccd/QHYCCDCam.rs
index 6194835..9988791 100644
--- a/src/qhyccd/QHYCCDCam.rs
+++ b/src/qhyccd/QHYCCDCam.rs
@@ -106,6 +106,7 @@ extern "C" {
pub fn InitQHYCCD(id: *mut os::raw::c_void) -> os::raw::c_int;
pub fn IsQHYCCDControlAvailable(handle: *mut os::raw::c_void, control: os::raw::c_int) -> os::raw::c_int;
pub fn SetQHYCCDParam(handle: *mut os::raw::c_void, control: os::raw::c_int, value: os::raw::c_double) -> os::raw::c_int;
+ pub fn GetQHYCCDParamMinMaxStep(handle: *mut os::raw::c_void, control: os::raw::c_int, min: *mut os::raw::c_double, max: *mut os::raw::c_double, step: *mut os::raw::c_double) -> os::raw::c_int;
pub fn GetQHYCCDParam(handle: *mut os::raw::c_void, control: os::raw::c_int) -> os::raw::c_double;
pub fn GetQHYCCDEffectiveArea(handle: *mut os::raw::c_void, startx: *mut os::raw::c_int, starty: *mut os::raw::c_int, sizex: *mut os::raw::c_int, sizey: *mut os::raw::c_int) -> os::raw::c_int;
pub fn GetQHYCCDOverScanArea(handle: *mut os::raw::c_void, startx: *mut os::raw::c_int, starty: *mut os::raw::c_int, sizex: *mut os::raw::c_int, sizey: *mut os::raw::c_int) -> os::raw::c_int;
diff --git a/src/qhyccd/mod.rs b/src/qhyccd/mod.rs
index 192b943..4404ddb 100644
--- a/src/qhyccd/mod.rs
+++ b/src/qhyccd/mod.rs
@@ -104,6 +104,26 @@ impl Camera {
}
}
}
+ pub fn get_param_limits(&self, control: Control) -> Result<(f64, f64, f64)> {
+ unsafe {
+ if self.has_param(control) {
+ let mut min = 0f64;
+ let mut max = 0f64;
+ let mut step = 0f64;
+ match check(QHYCCDCam::GetQHYCCDParamMinMaxStep(self.handle, control as i32, &mut min, &mut max, &mut step)) {
+ Ok(_) => {
+ Ok((min, max, step))
+ },
+ Err(_) => {
+ Err(CameraError::QHYError)
+ }
+ }
+ } else {
+ Err(CameraError::InvalidControl)
+ }
+ }
+ }
+
pub fn get_param(&self, control: Control) -> f64 {
unsafe {
QHYCCDCam::GetQHYCCDParam(self.handle, control as i32)
@@ -227,15 +247,22 @@ impl Camera {
let ref mut w = BufWriter::new(file);
let mut encoder = png::Encoder::new(w, castediw as u32, castedih as u32);
encoder.set(png::ColorType::RGB).set(png::BitDepth::Sixteen);
- let mut writer = encoder.write_header().unwrap();
- writer.write_image_data(
+ // crazy theory, endianness might be wrong...
+ // so flip the bytes first
+ let mut dataslice: &mut [u8] =
unsafe {
- std::slice::from_raw_parts(
+ std::slice::from_raw_parts_mut(
data,
bufsize as usize
)
- }
- ).unwrap();
+ };
+ for i in 0..(bufsize as usize / 2) {
+ let tmp = dataslice[i * 2];
+ dataslice[i * 2] = dataslice[i * 2 + 1];
+ dataslice[i * 2 + 1] = tmp;
+ }
+ let mut writer = encoder.write_header().unwrap();
+ writer.write_image_data(dataslice).unwrap();
dealloc(data as *mut u8, data_layout);
Ok(())
}