Skip to content

Commit

Permalink
Add UI controls to support BLC for AO mount bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
bwdev01 committed Mar 21, 2018
1 parent 789f9f2 commit 361eb69
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 58 deletions.
1 change: 1 addition & 0 deletions configdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ enum BRAIN_CTRL_IDS
AD_szBumpPercentage,
AD_szBumpSteps,
AD_cbBumpOnDither,
AD_szBumpBLCompCtrls,
AD_cbClearAOCalibration,
AD_cbEnableAOGuiding,
AD_cbRotatorReverse,
Expand Down
5 changes: 2 additions & 3 deletions mount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ void Mount::MountConfigDialogPane::LayoutControls(wxPanel *pParent, BrainCtrlIdM
{
stepGuider = m_pMount->IsStepGuider();
m_pAlgoBox = new wxStaticBoxSizer(wxHORIZONTAL, m_pParent, wxEmptyString);
m_pRABox = new wxStaticBoxSizer(wxVERTICAL, m_pParent, _("Right Ascension"));
m_pRABox = new wxStaticBoxSizer(wxVERTICAL, m_pParent, stepGuider ? _("AO X-Axis") : _("Right Ascension"));
if (m_pDecBox)
m_pDecBox->Clear(true);
m_pDecBox = new wxStaticBoxSizer(wxVERTICAL, m_pParent, _("Declination"));
m_pDecBox = new wxStaticBoxSizer(wxVERTICAL, m_pParent, stepGuider ? _("AO Y-Axis") : _("Declination"));
wxSizerFlags def_flags = wxSizerFlags(0).Border(wxALL, 5).Expand();

static GUIDE_ALGORITHM const X_ALGORITHMS[] =
Expand Down Expand Up @@ -252,7 +252,6 @@ void Mount::MountConfigDialogPane::LayoutControls(wxPanel *pParent, BrainCtrlIdM
if (!stepGuider)
{
wxBoxSizer *pSizer = new wxBoxSizer(wxHORIZONTAL);
//pSizer->Add(GetSingleCtrl(CtrlMap, AD_cbDecComp), wxSizerFlags(0).Border(wxTOP | wxLEFT, 5).Border(wxRIGHT, 20).Expand());
pSizer->Add(GetSizerCtrl(CtrlMap, AD_szBLCompCtrls), wxSizerFlags(0).Border(wxTOP | wxRIGHT, 5).Expand());
m_pDecBox->Add(pSizer);
m_pDecBox->Add(GetSizerCtrl(CtrlMap, AD_szMaxDecAmt), wxSizerFlags(0).Border(wxTOP, 10).Center());
Expand Down
119 changes: 65 additions & 54 deletions scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,54 +1710,63 @@ ScopeConfigDialogCtrlSet::ScopeConfigDialogCtrlSet(wxWindow *pParent, Scope *pSc
AddCtrl(CtrlMap, AD_cbAssumeOrthogonal, m_assumeOrthogonal,
_("Assume Dec axis is perpendicular to RA axis, regardless of calibration. Prevents RA periodic error from affecting Dec calibration. Option takes effect when calibrating DEC."));

if (pScope && !usingAO)
if (pScope)
{
wxBoxSizer* pComp1 = new wxBoxSizer(wxHORIZONTAL);
m_pUseBacklashComp = new wxCheckBox(GetParentWindow(AD_szBLCompCtrls), wxID_ANY, _("Enable"));
wxWindow* blcHostTab;
BRAIN_CTRL_IDS blcCtrlId;
if (usingAO)
blcCtrlId = AD_szBumpBLCompCtrls;
else
blcCtrlId = AD_szBLCompCtrls;
blcHostTab = GetParentWindow(blcCtrlId);
m_pUseBacklashComp = new wxCheckBox(blcHostTab, wxID_ANY, _("Enable"));
m_pUseBacklashComp->SetToolTip(_("Check this if you want to apply a backlash compensation guide pulse when declination direction is reversed."));
pComp1->Add(m_pUseBacklashComp);
m_pBacklashPulse = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szBLCompCtrls), wxID_ANY, wxEmptyString, wxDefaultPosition,
m_pBacklashPulse = pFrame->MakeSpinCtrlDouble(blcHostTab, wxID_ANY, wxEmptyString, wxDefaultPosition,
wxSize(width, -1), wxSP_ARROW_KEYS, pScope->m_backlashComp->GetBacklashPulseMinValue(), pScope->m_backlashComp->GetBacklashPulseMaxValue(), 450, 50);
pComp1->Add(MakeLabeledControl(AD_szBLCompCtrls, _("Amount"), m_pBacklashPulse, _("Size of backlash compensation guide pulse (mSec)")), wxSizerFlags().Border(wxLEFT, 26));
wxBoxSizer *pComp2 = new wxBoxSizer(wxHORIZONTAL);

m_pBacklashFloor = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szBLCompCtrls), wxID_ANY, wxEmptyString, wxDefaultPosition,
m_pBacklashFloor = pFrame->MakeSpinCtrlDouble(blcHostTab, wxID_ANY, wxEmptyString, wxDefaultPosition,
wxSize(width, -1), wxSP_ARROW_KEYS, pScope->m_backlashComp->GetBacklashPulseMinValue(), pScope->m_backlashComp->GetBacklashPulseMaxValue(), 300, 50);
m_pBacklashCeiling = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szBLCompCtrls), wxID_ANY, wxEmptyString, wxDefaultPosition,
m_pBacklashCeiling = pFrame->MakeSpinCtrlDouble(blcHostTab, wxID_ANY, wxEmptyString, wxDefaultPosition,
wxSize(width, -1), wxSP_ARROW_KEYS, pScope->m_backlashComp->GetBacklashPulseMinValue(), pScope->m_backlashComp->GetBacklashPulseMaxValue(), 300, 50);
pComp2->Add(MakeLabeledControl(AD_szBLCompCtrls, _("Min"), m_pBacklashFloor, _("Minimum length of backlash compensation pulse (mSec).")),
pComp2->Add(MakeLabeledControl(blcCtrlId, _("Min"), m_pBacklashFloor, _("Minimum length of backlash compensation pulse (mSec).")),
wxSizerFlags().Border(wxLEFT, 0));
pComp2->Add(MakeLabeledControl(AD_szBLCompCtrls, _("Max"), m_pBacklashCeiling, _("Maximum length of backlash compensation pulse (mSec).")),
pComp2->Add(MakeLabeledControl(blcCtrlId, _("Max"), m_pBacklashCeiling, _("Maximum length of backlash compensation pulse (mSec).")),
wxSizerFlags().Border(wxLEFT, 18));
wxBoxSizer* pCompVert = new wxStaticBoxSizer(wxVERTICAL, GetParentWindow(AD_szBLCompCtrls), _("Backlash Compensation"));
wxBoxSizer* pCompVert = new wxStaticBoxSizer(wxVERTICAL, blcHostTab, usingAO ? _("Mount Backlash Compensation") : _("Backlash Compensation"));
pCompVert->Add(pComp1);
pCompVert->Add(pComp2);
AddGroup(CtrlMap, AD_szBLCompCtrls, pCompVert);

m_pUseDecComp = new wxCheckBox(GetParentWindow(AD_cbUseDecComp), wxID_ANY, _("Use Dec compensation"));
m_pUseDecComp->Enable(enableCtrls && pPointingSource != NULL);
AddCtrl(CtrlMap, AD_cbUseDecComp, m_pUseDecComp, _("Automatically adjust RA guide rate based on scope declination"));

width = StringWidth(_T("00000"));
m_pMaxRaDuration = pFrame->MakeSpinCtrl(GetParentWindow(AD_szMaxRAAmt), wxID_ANY, _T(""), wxDefaultPosition,
wxSize(width, -1), wxSP_ARROW_KEYS, MAX_DURATION_MIN, MAX_DURATION_MAX, 150, _T("MaxRA_Dur"));
AddLabeledCtrl(CtrlMap, AD_szMaxRAAmt, _("Max RA duration"), m_pMaxRaDuration, _("Longest length of pulse to send in RA\nDefault = 2500 ms."));

m_pMaxDecDuration = pFrame->MakeSpinCtrl(GetParentWindow(AD_szMaxDecAmt), wxID_ANY, _T(""), wxDefaultPosition,
wxSize(width, -1), wxSP_ARROW_KEYS, MAX_DURATION_MIN, MAX_DURATION_MAX, 150, _T("MaxDec_Dur"));
AddLabeledCtrl(CtrlMap, AD_szMaxDecAmt, _("Max Dec duration"), m_pMaxDecDuration, _("Longest length of pulse to send in declination\nDefault = 2500 ms. Increase if drift is fast."));

wxString dec_choices[] = {
Scope::DecGuideModeLocaleStr(DEC_NONE),
Scope::DecGuideModeLocaleStr(DEC_AUTO),
Scope::DecGuideModeLocaleStr(DEC_NORTH),
Scope::DecGuideModeLocaleStr(DEC_SOUTH),
};

width = StringArrayWidth(dec_choices, WXSIZEOF(dec_choices));
m_pDecMode = new wxChoice(GetParentWindow(AD_szDecGuideMode), wxID_ANY, wxDefaultPosition,
wxSize(width + 35, -1), WXSIZEOF(dec_choices), dec_choices);
AddLabeledCtrl(CtrlMap, AD_szDecGuideMode, _("Dec guide mode"), m_pDecMode, _("Directions in which Dec guide commands will be issued"));
AddGroup(CtrlMap, blcCtrlId, pCompVert);
if (!usingAO)
{
m_pUseDecComp = new wxCheckBox(GetParentWindow(AD_cbUseDecComp), wxID_ANY, _("Use Dec compensation"));
m_pUseDecComp->Enable(enableCtrls && pPointingSource != NULL);
AddCtrl(CtrlMap, AD_cbUseDecComp, m_pUseDecComp, _("Automatically adjust RA guide rate based on scope declination"));

width = StringWidth(_T("00000"));
m_pMaxRaDuration = pFrame->MakeSpinCtrl(GetParentWindow(AD_szMaxRAAmt), wxID_ANY, _T(""), wxDefaultPosition,
wxSize(width, -1), wxSP_ARROW_KEYS, MAX_DURATION_MIN, MAX_DURATION_MAX, 150, _T("MaxRA_Dur"));
AddLabeledCtrl(CtrlMap, AD_szMaxRAAmt, _("Max RA duration"), m_pMaxRaDuration, _("Longest length of pulse to send in RA\nDefault = 2500 ms."));

m_pMaxDecDuration = pFrame->MakeSpinCtrl(GetParentWindow(AD_szMaxDecAmt), wxID_ANY, _T(""), wxDefaultPosition,
wxSize(width, -1), wxSP_ARROW_KEYS, MAX_DURATION_MIN, MAX_DURATION_MAX, 150, _T("MaxDec_Dur"));
AddLabeledCtrl(CtrlMap, AD_szMaxDecAmt, _("Max Dec duration"), m_pMaxDecDuration, _("Longest length of pulse to send in declination\nDefault = 2500 ms. Increase if drift is fast."));

wxString dec_choices[] = {
Scope::DecGuideModeLocaleStr(DEC_NONE),
Scope::DecGuideModeLocaleStr(DEC_AUTO),
Scope::DecGuideModeLocaleStr(DEC_NORTH),
Scope::DecGuideModeLocaleStr(DEC_SOUTH),
};

width = StringArrayWidth(dec_choices, WXSIZEOF(dec_choices));
m_pDecMode = new wxChoice(GetParentWindow(AD_szDecGuideMode), wxID_ANY, wxDefaultPosition,
wxSize(width + 35, -1), WXSIZEOF(dec_choices), dec_choices);
AddLabeledCtrl(CtrlMap, AD_szDecGuideMode, _("Dec guide mode"), m_pDecMode, _("Directions in which Dec guide commands will be issued"));
}
m_pScope->currConfigDialogCtrlSet = this;
}
}
Expand All @@ -1771,21 +1780,21 @@ void ScopeConfigDialogCtrlSet::LoadValues()
if (m_pStopGuidingWhenSlewing)
m_pStopGuidingWhenSlewing->SetValue(m_pScope->IsStopGuidingWhenSlewingEnabled());
m_assumeOrthogonal->SetValue(m_pScope->IsAssumeOrthogonal());
int pulseSize;
int floor;
int ceiling;
m_pScope->m_backlashComp->GetBacklashCompSettings(&pulseSize, &floor, &ceiling);
m_pBacklashPulse->SetValue(pulseSize);
m_pBacklashFloor->SetValue(floor);
m_pBacklashCeiling->SetValue(ceiling);
m_pUseBacklashComp->SetValue(m_pScope->m_backlashComp->IsEnabled());
bool usingAO = TheAO() != NULL;
if (!usingAO)
{
m_pMaxRaDuration->SetValue(m_pScope->GetMaxRaDuration());
m_pMaxDecDuration->SetValue(m_pScope->GetMaxDecDuration());
m_pDecMode->SetSelection(m_pScope->GetDecGuideMode());
m_pUseDecComp->SetValue(m_pScope->DecCompensationEnabled());
int pulseSize;
int floor;
int ceiling;
m_pScope->m_backlashComp->GetBacklashCompSettings(&pulseSize, &floor, &ceiling);
m_pBacklashPulse->SetValue(pulseSize);
m_pBacklashFloor->SetValue(floor);
m_pBacklashCeiling->SetValue(ceiling);
m_pUseBacklashComp->SetValue(m_pScope->m_backlashComp->IsEnabled());
}
}

Expand All @@ -1796,24 +1805,26 @@ void ScopeConfigDialogCtrlSet::UnloadValues()
if (m_pStopGuidingWhenSlewing)
m_pScope->EnableStopGuidingWhenSlewing(m_pStopGuidingWhenSlewing->GetValue());
m_pScope->SetAssumeOrthogonal(m_assumeOrthogonal->GetValue());
int newBC = m_pBacklashPulse->GetValue();
int newFloor = m_pBacklashFloor->GetValue();
int newCeiling = m_pBacklashCeiling->GetValue();
// SetBacklashPulse will handle floor/ceiling values that don't make sense
m_pScope->m_backlashComp->SetBacklashPulse(newBC, newFloor, newCeiling);;
m_pScope->m_backlashComp->EnableBacklashComp(m_pUseBacklashComp->GetValue());

// Following needed in case user changes max_duration with blc value already set
if (m_pScope->m_backlashComp->IsEnabled() && m_pScope->GetMaxDecDuration() < newBC)
m_pScope->SetMaxDecDuration(newBC);
if (pFrame)
pFrame->UpdateCalibrationStatus();
bool usingAO = TheAO() != NULL;
if (!usingAO)
{
m_pScope->EnableDecCompensation(m_pUseDecComp->GetValue());
m_pScope->SetMaxRaDuration(m_pMaxRaDuration->GetValue());
m_pScope->SetMaxDecDuration(m_pMaxDecDuration->GetValue());
m_pScope->SetDecGuideMode(m_pDecMode->GetSelection());
int newBC = m_pBacklashPulse->GetValue();
int newFloor = m_pBacklashFloor->GetValue();
int newCeiling = m_pBacklashCeiling->GetValue();
// SetBacklashPulse will handle floor/ceiling values that don't make sense
m_pScope->m_backlashComp->SetBacklashPulse(newBC, newFloor, newCeiling);;
m_pScope->m_backlashComp->EnableBacklashComp(m_pUseBacklashComp->GetValue());
m_pScope->EnableDecCompensation(m_pUseDecComp->GetValue());
// Following needed in case user changes max_duration with blc value already set
if (m_pScope->m_backlashComp->IsEnabled() && m_pScope->GetMaxDecDuration() < newBC)
m_pScope->SetMaxDecDuration(newBC);
if (pFrame)
pFrame->UpdateCalibrationStatus();

}
MountConfigDialogCtrlSet::UnloadValues();
}
Expand Down
3 changes: 2 additions & 1 deletion stepguider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,14 +1373,15 @@ AOConfigDialogPane::AOConfigDialogPane(wxWindow *pParent, StepGuider *pStepGuide

void AOConfigDialogPane::LayoutControls(wxPanel *pParent, BrainCtrlIdMap& CtrlMap)
{
wxFlexGridSizer *pAoDetailSizer = new wxFlexGridSizer(3, 3, 15, 15);
wxFlexGridSizer *pAoDetailSizer = new wxFlexGridSizer(4, 3, 15, 15);
wxSizerFlags def_flags = wxSizerFlags(0).Border(wxALL, 10).Expand();
pAoDetailSizer->Add(GetSizerCtrl(CtrlMap, AD_AOTravel));
pAoDetailSizer->Add(GetSizerCtrl(CtrlMap, AD_szCalStepsPerIteration));
pAoDetailSizer->Add(GetSizerCtrl(CtrlMap, AD_szSamplesToAverage));
pAoDetailSizer->Add(GetSizerCtrl(CtrlMap, AD_szBumpPercentage));
pAoDetailSizer->Add(GetSizerCtrl(CtrlMap, AD_szBumpSteps));
pAoDetailSizer->Add(GetSingleCtrl(CtrlMap, AD_cbBumpOnDither));
pAoDetailSizer->Add(GetSizerCtrl(CtrlMap, AD_szBumpBLCompCtrls));
pAoDetailSizer->Add(GetSingleCtrl(CtrlMap, AD_cbEnableAOGuiding));
pAoDetailSizer->Add(GetSingleCtrl(CtrlMap, AD_cbClearAOCalibration));
this->Add(pAoDetailSizer, def_flags);
Expand Down

0 comments on commit 361eb69

Please sign in to comment.