Skip to content

Commit

Permalink
Merge pull request #3758 from AllskyTeam/AWB-fixes
Browse files Browse the repository at this point in the history
AWB fixes
  • Loading branch information
EricClaeys authored Jul 21, 2024
2 parents 071da56 + 8dbca5b commit b64dab4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
30 changes: 16 additions & 14 deletions src/allsky_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,22 +236,24 @@ void add_variables_to_command(config cg, char *cmd, timeval startDateTime)
strcat(cmd, tmp);
}

snprintf(tmp, s, " AUTOWB=%d", cg.currentAutoAWB ? 1 : 0);
strcat(cmd, tmp);
snprintf(tmp, s, " sAUTOAWB='%s'", cg.currentAutoAWB ? "(auto)" : "");
strcat(cmd, tmp);
if (cg.lastWBR >= 0.0) {
snprintf(tmp, s, " WBR=%s", LorF(cg.lastWBR, "%d", "%f"));
strcat(cmd, tmp);
}
if (cg.lastWBB >= 0.0) {
snprintf(tmp, s, " WBB=%s", LorF(cg.lastWBB, "%d", "%f"));
if (cg.isColorCamera)
{
snprintf(tmp, s, " AUTOWB=%d", cg.currentAutoAWB ? 1 : 0);
strcat(cmd, tmp);
}

if (cg.lastMean >= 0.0) {
snprintf(tmp, s, " MEAN=%f", cg.lastMean);
snprintf(tmp, s, " sAUTOAWB='%s'", cg.currentAutoAWB ? "(auto)" : "");
strcat(cmd, tmp);
if (cg.lastWBR >= 0.0) {
snprintf(tmp, s, " WBR=%s", LorF(cg.lastWBR, "%d", "%f"));
strcat(cmd, tmp);
}
if (cg.lastWBB >= 0.0) {
snprintf(tmp, s, " WBB=%s", LorF(cg.lastWBB, "%d", "%f"));
strcat(cmd, tmp);
}
if (cg.lastMean >= 0.0) {
snprintf(tmp, s, " MEAN=%f", cg.lastMean);
strcat(cmd, tmp);
}
}

// Since negative temperatures are valid, check against an impossible temperature.
Expand Down
23 changes: 16 additions & 7 deletions src/capture_ZWO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ ASI_ERROR_CODE takeOneExposure(config *cg, unsigned char *imageBuffer)
long timeout = ((cg->currentExposure_us * 2) / US_IN_MS) + 5000; // timeout is in ms

// Sanity check.
if (cg->HB.useHistogram && cg->currentAutoExposure == ASI_TRUE)
if (cg->HB.useHistogram && cg->currentAutoExposure)
Log(0, " > %s: ERROR: HB.useHistogram AND currentAutoExposure are both set\n", cg->ME);

if (cg->ZWOexposureType != ZWOsnap)
Expand Down Expand Up @@ -1232,6 +1232,7 @@ int main(int argc, char *argv[])
length_in_units(CG.currentMaxAutoExposure_us, true));
CG.currentExposure_us = CG.currentMaxAutoExposure_us;
}

// Don't use camera auto-exposure since we mimic it ourselves.
CG.HB.useHistogram = CG.dayAutoExposure;
// With the histogram method we NEVER use ZWO auto exposure - either the user said
Expand Down Expand Up @@ -1361,13 +1362,21 @@ int main(int argc, char *argv[])
{
setControl(CG.cameraNumber, ASI_WB_R, CG.currentWBR, CG.currentAutoAWB ? ASI_TRUE : ASI_FALSE);
setControl(CG.cameraNumber, ASI_WB_B, CG.currentWBB, CG.currentAutoAWB ? ASI_TRUE : ASI_FALSE);

if (! CG.currentAutoAWB && ! CG.takeDarkFrames)
{
// We only read the actual values if in auto white balance; since we're not,
// set the "last" values to the user-specified numbers.
CG.lastWBR = CG.currentWBR;
CG.lastWBB = CG.currentWBB;
}
else
{
CG.lastWBR = NOT_SET;
CG.lastWBB = NOT_SET;
}
}
else if (! CG.currentAutoAWB && ! CG.takeDarkFrames)
{
// We only read the actual values if in auto white balance; since we're not, get them now.
CG.lastWBR = CG.currentWBR;
CG.lastWBB = CG.currentWBB;
}

if (CG.isCooledCamera)
{
setControl(CG.cameraNumber, ASI_COOLER_ON, CG.currentEnableCooler ? ASI_TRUE : ASI_FALSE, ASI_FALSE);
Expand Down

0 comments on commit b64dab4

Please sign in to comment.