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

Capture changes #2735

Merged
merged 6 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
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
26 changes: 15 additions & 11 deletions src/ASI_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,18 @@ bool setDefaults(config *cg, ASI_CAMERA_INFO ci)
cg->minDelay_ms = 0;
}

// The remaining settings are camera-specific and have camera defaults.
ret = getControlCapForControlType(cg->cameraNumber, ASI_AUTO_TARGET_BRIGHTNESS, &cc);
if (ret == ASI_SUCCESS)
{
cg->defaultBrightness = cc.DefaultValue; // used elsewhere
cg->dayBrightness = cc.DefaultValue;
cg->nightBrightness = cc.DefaultValue;
} else {
Log(0, "ASI_EXPOSURE failed with %s\n", getRetCode(ret));
ok = false;
}

// Get values used in several validations.
ret = getControlCapForControlType(cg->cameraNumber, ASI_EXPOSURE, &cc);
if (ret == ASI_SUCCESS)
Expand All @@ -1367,7 +1379,7 @@ bool setDefaults(config *cg, ASI_CAMERA_INFO ci)
} else {
Log(0, "ASI_AUTO_MAX_EXP failed with %s\n", getRetCode(ret));
ok = false;
}
}
} else {
Log(0, "ASI_EXPOSURE failed with %s\n", getRetCode(ret));
ok = false;
Expand Down Expand Up @@ -1523,16 +1535,8 @@ bool validateSettings(config *cg, ASI_CAMERA_INFO ci)
ret = getControlCapForControlType(cg->cameraNumber, ASI_AUTO_TARGET_BRIGHTNESS, &cc);
if (ret == ASI_SUCCESS)
{
cg->defaultBrightness = cc.DefaultValue; // used elsewhere
if (cg->dayBrightness == NOT_CHANGED)
cg->dayBrightness = cc.DefaultValue;
else
validateLong(&cg->dayBrightness, cc.MinValue, cc.MaxValue, "Daytime Brightness", true);

if (cg->nightBrightness == NOT_CHANGED)
cg->nightBrightness = cc.DefaultValue;
else
validateLong(&cg->nightBrightness, cc.MinValue, cc.MaxValue, "Nighttime Brightness", true);
validateLong(&cg->dayBrightness, cc.MinValue, cc.MaxValue, "Daytime Brightness", true);
validateLong(&cg->nightBrightness, cc.MinValue, cc.MaxValue, "Nighttime Brightness", true);
} else if (ret != ASI_ERROR_INVALID_CONTROL_TYPE) {
Log(0, "ASI_AUTO_TARGET_BRIGHTNESS failed with %s\n", getRetCode(ret));
ok = false;
Expand Down
19 changes: 9 additions & 10 deletions src/allsky_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ void displayHelp(config cg)
printf("\nNighttime settings:\n");
printf(" -%-*s - 1 enables nighttime auto-exposure [%s].\n", n, "nightautoexposure b", yesNo(cg.nightAutoExposure));
printf(" -%-*s - Maximum nighttime auto-exposure in ms.\n", n, "nightmaxexposure n");
printf(" -%-*s - Nighttime exposure in us [%'ld].\n", n, "nightexposure n", cg.nightExposure_us * US_IN_MS);
printf(" -%-*s - Nighttime exposure in us [%'ld].\n", n, "nightexposure n", cg.nightExposure_us);
printf(" -%-*s - Nighttime mean target brightness [%.2f].\n", n, "nightmean n", cg.myModeMeanSetting.nightMean);
printf(" %-*s NOTE: Nighttime auto-gain and auto-exposure should be on for best results.\n", n, "");
printf(" -%-*s - Nighttime brightness change [%ld].\n", n, "nightbrightness n n", cg.nightBrightness);
Expand Down Expand Up @@ -1043,7 +1043,7 @@ void displayHelp(config cg)
}
printf(" -%-*s - Camera maximum width [%ld].\n", n, "width n", cg.width);
printf(" -%-*s - Camera maximum height [%ld].\n", n, "height n", cg.height);
printf(" -%-*s - Type of image: 99 = auto, 0 = RAW8, 1 = RGB24 [%ld].\n", n, "type n", cg.imageType);
printf(" -%-*s - Type of image: 99 = auto, 0 = RAW8, 1 = RGB24 [%ld]", n, "type n", cg.imageType);
if (cg.ct == ctZWO) {
printf(", 2 = RAW16, 3 = Y8");
}
Expand Down Expand Up @@ -1188,21 +1188,20 @@ void displaySettings(config cg)
if (cg.nightAutoGain)
printf(", Max Auto-Gain: %s", LorF(cg.nightMaxAutoGain, "%ld", "%1.2f"));
printf("\n");
if (cg.supportsMyModeMean || cg.HB.useExperimentalExposure)
{
printf(" Target Mean Value (day): %1.3f\n", cg.myModeMeanSetting.dayMean);
printf(" Target Mean Value (night): %1.3f\n", cg.myModeMeanSetting.nightMean);
printf(" Threshold: %1.3f:\n", cg.myModeMeanSetting.mean_threshold);
}
if (cg.gainTransitionTimeImplemented)
printf(" Gain Transition Time: %.1f minutes\n", (float) cg.gainTransitionTime/60);

printf(" Target Mean Value (day): %1.3f\n", cg.myModeMeanSetting.dayMean);
printf(" Target Mean Value (night): %1.3f\n", cg.myModeMeanSetting.nightMean);
printf(" Target Mean Threshold: %1.3f:\n", cg.myModeMeanSetting.mean_threshold);

if (cg.supportsMyModeMean)
{
printf(" p0: %1.3f\n", cg.myModeMeanSetting.mean_p0);
printf(" p1: %1.3f\n", cg.myModeMeanSetting.mean_p1);
printf(" p2: %1.3f\n", cg.myModeMeanSetting.mean_p2);
}

if (cg.gainTransitionTimeImplemented)
printf(" Gain Transition Time: %.1f minutes\n", (float) cg.gainTransitionTime/60);
printf(" Brightness (day): %ld\n", cg.dayBrightness);
printf(" Brightness (night): %ld\n", cg.nightBrightness);
printf(" Binning (day): %ld\n", cg.dayBin);
Expand Down
45 changes: 23 additions & 22 deletions src/capture_ZWO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,35 +728,18 @@ int main(int argc, char *argv[])

//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
setlinebuf(stdout); // Line buffer output so entries appear in the log immediately.
setlinebuf(stdout); // Line buffer output so entries appear in the log immediately.

CG.ct = ctZWO;
if (! getCommandLineArguments(&CG, argc, argv))
{
// getCommandLineArguents outputs an error message.
exit(EXIT_ERROR_STOP);
}

if (! CG.saveCC && ! CG.help)
{
displayHeader(CG);
}

doLocale(&CG);

if (CG.help)
{
displayHelp(CG);
closeUp(EXIT_OK);
}

processConnectedCameras(); // exits on error
processConnectedCameras(); // exits on error. Sets CG.cameraNumber.

ASI_CAMERA_INFO ASICameraInfo;
asiRetCode = ASIOpenCamera(CG.cameraNumber);
if (asiRetCode != ASI_SUCCESS)
{
Log(0, "*** ERROR opening camera, check that you have root permissions! (%s)\n", getRetCode(asiRetCode));
Log(0, "*** ERROR opening camera, check that you have root permissions! (%s)\n",
getRetCode(asiRetCode));
closeUp(EXIT_NO_CAMERA);
}

Expand All @@ -774,11 +757,29 @@ int main(int argc, char *argv[])
}
CG.ASIversion = ASIGetSDKVersion();


// Set defaults that depend on the camera type.
if (! setDefaults(&CG, ASICameraInfo))
closeUp(EXIT_ERROR_STOP);

if (! getCommandLineArguments(&CG, argc, argv))
{
// getCommandLineArguents outputs an error message.
exit(EXIT_ERROR_STOP);
}

if (! CG.saveCC && ! CG.help)
{
displayHeader(CG);
}

doLocale(&CG);

if (CG.help)
{
displayHelp(CG);
closeUp(EXIT_OK);
}

// Do argument error checking if we're not going to exit soon.
if (! CG.saveCC && ! validateSettings(&CG, ASICameraInfo))
closeUp(EXIT_ERROR_STOP);
Expand Down
17 changes: 8 additions & 9 deletions src/include/allsky_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
#define DEFAULT_DAYMEAN_RPi 0.5 // target value
#define DEFAULT_DAYMEAN_THRESHOLD_RPi 0.1 // mean brightness must be within this % to be "ok"
#define DEFAULT_NIGHTMEAN_RPi 0.2 // target value
// TODO: allow different night threshold
#define DEFAULT_NIGHTMEAN_THRESHOLD_RPi DEFAULT_DAYMEAN_THRESHOLD_RPi
#define DEFAULT_NIGHTMEAN_THRESHOLD_RPi 0.2 // target value
#define DEFAULT_MEAN_P0_RPi 5.0
#define DEFAULT_MEAN_P1_RPi 20.0
#define DEFAULT_MEAN_P2_RPi 45.0
Expand All @@ -54,14 +53,14 @@
#define DEFAULT_DAYMEAN_ZWO (128.0 / 255) // matches old way
#define DEFAULT_DAYMEAN_THRESHOLD_ZWO (6.0 / 255) // matches old way
#define DEFAULT_NIGHTMEAN_ZWO (75.0 / 255) // TODO: pure guess as of May 22, 2023
#define DEFAULT_NIGHTMEAN_THRESHOLD_ZWO DEFAULT_DAYMEAN_THRESHOLD_ZWO
#define DEFAULT_NIGHTMEAN_THRESHOLD_ZWO (6.0 / 255)
#define DEFAULT_MEAN_P0_ZWO 5.0 // TODO: set after porting modemean to ZWO
#define DEFAULT_MEAN_P1_ZWO 20.0
#define DEFAULT_MEAN_P2_ZWO 45.0
#define DEFAULT_MINMEAN_ZWO 0
#define DEFAULT_MAXMEAN_ZWO 255
#define DEFAULT_MINMEAN_THRESHOLD_ZWO 0
#define DEFAULT_MAXMEAN_THRESHOLD_ZWO 255
#define DEFAULT_MEAN_P1_ZWO 20.0 // TODO: set after porting modemean to ZWO
#define DEFAULT_MEAN_P2_ZWO 45.0 // TODO: set after porting modemean to ZWO
#define DEFAULT_MINMEAN_ZWO DEFAULT_MINMEAN_RPi
#define DEFAULT_MAXMEAN_ZWO DEFAULT_MAXMEAN_RPi
#define DEFAULT_MINMEAN_THRESHOLD_ZWO DEFAULT_MINMEAN_THRESHOLD_RPi
#define DEFAULT_MAXMEAN_THRESHOLD_ZWO DEFAULT_MAXMEAN_THRESHOLD_RPi

// Default overlay values - will go away once external overlay program is implemented
#define SMALLFONTSIZE_MULTIPLIER 0.08
Expand Down