summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs52
1 files changed, 41 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs
index 4b54a3a..ce1c19e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -14,6 +14,7 @@ use crossbeam_channel::{Sender, Receiver};
use crossbeam_channel::unbounded;
use std::time::Duration;
+use std::time::Instant;
use crate::asicam::ASICamera2::{ControlType, ImageType};
use crate::asicam::Camera;
@@ -60,8 +61,8 @@ fn record_image(data: &[u8], dimensions: Dimensions, target: &'static str, image
println!(".. writing raw");
let raw_path = format!("{}_{}.raw", target, image_id);
let raw_dest = Path::new(&raw_path);
- let mut file = File::create(raw_dest).unwrap();
- file.write(data);
+// let mut file = File::create(raw_dest).unwrap();
+// file.write(data);
}
fn main() {
@@ -99,7 +100,7 @@ fn main() {
}
});
- operate_qhy("ngc7635", None, free_frames, image_writer);
+ operate_qhy("settings", None, free_frames, image_writer);
// println!("Doing asi...");
// operate_asi(test);
}
@@ -130,7 +131,7 @@ struct Properties {
impl Properties {
pub fn stringy(&self) -> String {
- format!("{{\n device: \"{}\",\n exposure_ms: {}\n, gain: {}\n offset: {}\n gamma: {}\n temp: {}\n}}",
+ format!("{{\n \"device\": \"{}\",\n \"exposure_ms\": {},\n \"gain\": {},\n \"offset\": {},\n \"gamma\": {},\n \"temp\": {}\n}}",
self.device,
self.exposure_ms,
self.gain,
@@ -161,22 +162,51 @@ fn operate_qhy(target: &'static str, count: Option<u32>, free_frames: Receiver<V
let mut image_id = 0u32;
let mut settings_copy = qhyccd::Settings::default();
- camera_tx.send(QHYMessage::SetControl(Control::Exposure, 2000.0 * 1000.0)).unwrap();
- camera_tx.send(QHYMessage::SetControl(Control::Offset, 00.0)).unwrap();
-// camera_tx.send(QHYMessage::SetControl(Control::Gamma, 10.0)).unwrap();
+ // qhy376c settings
+ camera_tx.send(QHYMessage::SetControl(Control::Exposure, 20000.0 * 1000.0)).unwrap();
+// camera_tx.send(QHYMessage::SetControl(Control::Exposure, 200.0 * 1000.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Cooler, 0.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Color, 1.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Gain, 4000.0)).unwrap();
+
+ /*
+ camera_tx.send(QHYMessage::SetControl(Control::Exposure, 60000.0 * 1000.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Cooler, 0.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Color, 0.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Gain, 110.0)).unwrap();
+ */
+
+ /*
+ camera_tx.send(QHYMessage::SetControl(Control::Exposure, 20000.0 * 1000.0)).unwrap();
+// camera_tx.send(QHYMessage::SetControl(Control::Offset, 00.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Gamma, 1.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Brightness, 00.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Contrast, 00.0)).unwrap();
// camera_tx.send(QHYMessage::SetControl(Control::Gamma, 2.0)).unwrap();
- camera_tx.send(QHYMessage::SetControl(Control::Cooler, 15.0)).unwrap();
+ camera_tx.send(QHYMessage::SetControl(Control::Cooler, 0.0)).unwrap();
camera_tx.send(QHYMessage::SetControl(Control::USBTraffic, 60.0)).unwrap();
camera_tx.send(QHYMessage::SetControl(Control::Color, 0.0)).unwrap(); // disable color
-// camera_tx.send(QHYMessage::SetControl(Control::Gain, 3750.0)).unwrap();
camera_tx.send(QHYMessage::SetControl(Control::Gain, 4000.0)).unwrap();
+// camera_tx.send(QHYMessage::SetControl(Control::Gain, 140.0)).unwrap();
// camera_tx.send(QHYMessage::SetControl(Control::Gain, 4000.0)).unwrap();
// camera.set_roi(0, 0, 1920 * 2, 1080 * 2).unwrap();
+ */
// println!("Gain: {:?}", camera.get_param_limits(Control::ManulPwm));
// println!("cur pwm ???: {}", camera.get_param(Control::CurPWM));
- camera_tx.send(QHYMessage::BeginCapture).unwrap();
+
+ camera_tx.send(QHYMessage::BeginCapture(None)).unwrap();
+ let LAPSE_PERIOD = Duration::from_millis(0);
+
+ let mut capture_start = Instant::now().checked_sub(Duration::from_millis(10)).unwrap().checked_sub(LAPSE_PERIOD).unwrap();;
loop {
+ /*
+ if capture_start.elapsed() > LAPSE_PERIOD {
+ println!("Lapsing!!");
+ camera_tx.send(QHYMessage::BeginCapture(Some(1))).unwrap();
+ capture_start = Instant::now();
+ }
+ */
select! {
recv(free_frames) -> msg => {
match msg {
@@ -205,7 +235,7 @@ fn operate_qhy(target: &'static str, count: Option<u32>, free_frames: Receiver<V
settings_copy = settings;
}
Ok(QHYResponse::Data(data, dimensions, properties)) => {
- image_writer.send(ImageInfo { data, dimensions, target, image_id, properties}).unwrap();
+ image_writer.send(ImageInfo { data, dimensions, target, image_id: image_id, properties}).unwrap();
// images.log(target, image_id, settings_copy);
image_id += 1;
if Some(image_id) == count {