Skip to content

Commit

Permalink
Add button for custom resolution in simulator CCD (#2074)
Browse files Browse the repository at this point in the history
  • Loading branch information
escribana authored Jul 3, 2024
1 parent e32eb24 commit 6623f35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions drivers/ccd/ccd_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ bool CCDSim::initProperties()
for (uint8_t i = 0; i < Resolutions.size(); i++)
{
std::ostringstream ss;
ss << Resolutions[i].first << " x " << Resolutions[i].second;
if (Resolutions[i].first > 0)
ss << Resolutions[i].first << " x " << Resolutions[i].second;
else
ss << "Custom";
ResolutionSP[i].fill(ss.str().c_str(), ss.str().c_str(), i == 0 ? ISS_ON : ISS_OFF);
}
ResolutionSP.fill(getDeviceName(), "CCD_RESOLUTION", "Resolution", SIMULATOR_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);
Expand Down Expand Up @@ -1220,7 +1223,7 @@ bool CCDSim::ISNewSwitch(const char * dev, const char * name, ISState * states,
ResolutionSP.apply();

int index = ResolutionSP.findOnSwitchIndex();
if (index >= 0 && index < static_cast<int>(Resolutions.size()))
if (index >= 0 && index < static_cast<int>(Resolutions.size() - 1))
{
SimulatorSettingsNP[SIM_XRES].setValue(Resolutions[index].first);
SimulatorSettingsNP[SIM_YRES].setValue(Resolutions[index].second);
Expand Down
5 changes: 3 additions & 2 deletions drivers/ccd/ccd_simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,12 @@ class CCDSim : public INDI::CCD, public INDI::FilterInterface

INDI::PropertySwitch CrashSP {1};

INDI::PropertySwitch ResolutionSP {2};
INDI::PropertySwitch ResolutionSP {3};
inline static const std::vector<std::pair<uint32_t, uint32_t>> Resolutions =
{
{1280, 1024},
{6000, 4000}
{6000, 4000},
{0, 0} // Custom
};

static const constexpr char* SIMULATOR_TAB = "Simulator Config";
Expand Down

0 comments on commit 6623f35

Please sign in to comment.