Skip to content

Commit

Permalink
Saturation adu change (#1269)
Browse files Browse the repository at this point in the history
* Cleanup of MultiStar processing and UI if subframes enabled

* Force rebuild of MultiStar list when subframes are disabled

* Fix star.cpp clang regression

* Remove bit-depth controls from profile wizard; add code to set a rational default saturation ADU value based on bit-depth
  • Loading branch information
bwdev01 authored Dec 26, 2024
1 parent 0b04d07 commit 96b5f95
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 43 deletions.
45 changes: 4 additions & 41 deletions src/profile_wizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ class ProfileWizard : public wxDialog
wxStaticBitmap *m_scaleIcon;
wxStaticText *m_pixelScale;
wxChoice *m_pBinningLevel;
wxRadioButton *m_pBits8;
wxRadioButton *m_pBits16;
wxSpinCtrlDouble *m_pFocalLength;
wxStaticText *m_pFocalLengthWarning;
wxSpinCtrlDouble *m_pGuideSpeed;
Expand Down Expand Up @@ -270,21 +268,12 @@ ProfileWizard::ProfileWizard(wxWindow *parent, bool showGreeting)
"With long focal length guide scopes and OAGs, binning can allow use of fainter guide "
"stars. For more common setups, it's better to leave binning at 1."));
m_pBinningLevel->SetSelection(0);
m_pBits8 = new wxRadioButton(this, wxID_ANY, _("8-bit"));
m_pBits8->SetToolTip(_("Choose this if your guide camera driver downloads 8-bit data"));
m_pBits16 = new wxRadioButton(this, wxID_ANY, _("16-bit"));
m_pBits16->SetToolTip(_("Choose this if your guide camera driver downoads 16-bit data. Requires a camera with 10, 12, 14 "
"or 16-bit ADC electronics"));

wxBoxSizer *sz = new wxBoxSizer(wxHORIZONTAL);
sz->Add(Label(this, _("Binning level")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
sz->Add(m_pBinningLevel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
m_pUserProperties->Add(sz, wxGBPosition(1, 1), wxDefaultSpan, 0, 0);
// Camera bit depth
wxBoxSizer *sz2 = new wxBoxSizer(wxHORIZONTAL);
sz2->Add(Label(this, _("Bit depth (bits/pixel)")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
sz2->Add(m_pBits8, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
sz2->Add(m_pBits16, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
m_pUserProperties->Add(sz2, wxGBPosition(2, 1), wxDefaultSpan, 0, 0);

// Focal length
m_pFocalLength = pFrame->MakeSpinCtrlDouble(this, ID_FOCALLENGTH, wxEmptyString, wxDefaultPosition,
wxSize(StringWidth(this, _T("888888")), -1), wxSP_ARROW_KEYS,
Expand Down Expand Up @@ -631,8 +620,7 @@ bool ProfileWizard::SemanticCheck(DialogState state, int change)
case STATE_GREETINGS:
break;
case STATE_CAMERA:
bOk = (m_SelectedCamera.length() > 0 && m_PixelSize > 0 && m_FocalLength > 0 &&
(m_pBits8->GetValue() || m_pBits16->GetValue()) && m_SelectedCamera != _("None"));
bOk = (m_SelectedCamera.length() > 0 && m_PixelSize > 0 && m_FocalLength > 0 && m_SelectedCamera != _("None"));
if (!bOk)
ShowStatus(_("Please specify camera type, guider focal length, camera bit-depth, and guide camera pixel size"));
break;
Expand Down Expand Up @@ -983,10 +971,7 @@ void ProfileWizard::WrapUp()
double ImageScale = MyFrame::GetPixelScale(m_PixelSize, m_FocalLength, binning);
if (ImageScale < 2.0)
pConfig->Profile.SetBoolean("/guider/onestar/MassChangeThresholdEnabled", false);
if (m_pBits8->GetValue())
pConfig->Profile.SetInt("/camera/SaturationADU", 255);
else
pConfig->Profile.SetInt("/camera/SaturationADU", 65535);
pConfig->Profile.SetInt("/camera/SaturationADU", 0); // Default will be updated with first auto-find to reflect bpp

GuideLog.EnableLogging(true); // Especially for newbies

Expand Down Expand Up @@ -1161,8 +1146,6 @@ static double GetPixelSize(GuideCamera *cam)

void ProfileWizard::InitCameraProps(bool tryConnect)
{
m_pBits8->Enable(true);
m_pBits16->Enable(true);
if (tryConnect)
{
// Pixel size
Expand All @@ -1182,24 +1165,6 @@ void ProfileWizard::InitCameraProps(bool tryConnect)
GuideCamera::GetBinningOpts(4, &opts);
m_pBinningLevel->Set(opts);
m_pBinningLevel->SetSelection(0);
// Bit depth
wxByte bitDepth = 0;
if (cam)
bitDepth = cam->BitsPerPixel();
if (bitDepth == 0) // Cam doesn't report it, force the user to choose
{
m_pBits8->SetValue(false);
m_pBits16->SetValue(false);
}
else
{
m_pBits8->Enable(false);
m_pBits16->Enable(false);
if (bitDepth == 8)
m_pBits8->SetValue(true);
else
m_pBits16->SetValue(true);
}
}
else
{
Expand All @@ -1211,8 +1176,6 @@ void ProfileWizard::InitCameraProps(bool tryConnect)
m_pPixelSize->Enable(true);
wxSpinDoubleEvent dummy;
OnPixelSizeChange(dummy);
m_pBits8->SetValue(false); // force a user selection
m_pBits16->SetValue(false);
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,16 @@ bool GuideStar::AutoFind(const usImage& image, int extraEdgeAllowance, int searc

if (pCamera->IsSaturationByADU())
{
// known saturation level ... easy
sat_level = pCamera->GetSaturationADU() + image.Pedestal;
// known saturation level ... maybe easy
unsigned short satADU = pCamera->GetSaturationADU();
wxByte bpp = image.BitsPerPixel;
if (satADU == 0 || (bpp == 8 && satADU > 255) || (bpp > 8 && satADU < 4095))
{
satADU = ((1U << bpp) - 1);
pCamera->SetSaturationByADU(true, satADU);
Debug.Write(wxString::Format("SaturationADU auto-adjusted to %d\n", satADU));
}
sat_level = satADU + image.Pedestal;
}
else
{
Expand Down

0 comments on commit 96b5f95

Please sign in to comment.