Skip to content

Commit 381ebab

Browse files
authored
Merge pull request #285 from aaronwmorris/dev
Add new mode to assist focusing the camera
2 parents 2fcefaa + aa989af commit 381ebab

11 files changed

Lines changed: 437 additions & 14 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ All configuration is read from /etc/indi-allsky/config.json . You can find conf
238238
| CCD_EXPOSURE_DEF | CCD_EXPOSURE_MIN | (float) Default/starting exposure |
239239
| EXPOSURE_PERIOD | 15.0 | (float) Seconds between beginning of each exposure (Night) |
240240
| EXPOSURE_PERIOD_DAY | 15.0 | (float) Seconds between beginning of each exposure (Day) |
241+
| FOCUS_MODE | false | (bool) Focus mode is used to take exposures as quickly as possible to aid in focusing |
242+
| FOCUS_DELAY | 4.0 | (float) Delay between exposures during focus mode |
241243
| AUTO_WB | false | (bool) Automatic white balance adjustment |
242244
| WBR_FACTOR | 1.0 | (float) Red Balance Adjustment Factor |
243245
| WBG_FACTOR | 1.0 | (float) Green Balance Adjustment Factor |

config.json_template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
"EXPOSURE_PERIOD" : 15.00000,
3131
"EXPOSURE_PERIOD_DAY" : 15.00000,
3232

33+
"FOCUS_MODE" : false,
34+
"FOCUS_DELAY" : 4.0,
35+
3336
"AUTO_WB" : false,
3437
"WBR_FACTOR" : 1.0,
3538
"WBG_FACTOR" : 1.0,

indi_allsky/allsky.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def __init__(self, f_config_file):
7070
self.moonmode_v = Value('i', -1) # bogus initial value
7171
self.moonmode = None
7272

73+
self.focus_mode = self.config.get('FOCUS_MODE', False) # focus mode takes images as fast as possible
74+
7375
self.night_sun_radians = math.radians(self.config['NIGHT_SUN_ALT_DEG'])
7476
self.night_moonmode_radians = math.radians(self.config['NIGHT_MOONMODE_ALT_DEG'])
7577

@@ -81,8 +83,6 @@ def __init__(self, f_config_file):
8183
self.video_worker = None
8284
self.video_worker_idx = 0
8385

84-
self.save_images = True
85-
8686
self.upload_q = Queue()
8787
self.upload_worker = None
8888
self.upload_worker_idx = 0
@@ -156,6 +156,9 @@ def sighup_handler(self, signum, frame):
156156
ccd_info = self.indiclient.getCcdInfo(self.ccdDevice)
157157
self.config['CCD_INFO'] = ccd_info
158158

159+
# Update focus mode
160+
self.focus_mode = self.config.get('FOCUS_MODE', False)
161+
159162
# set minimum exposure
160163
ccd_min_exp = self.config['CCD_INFO']['CCD_EXPOSURE']['CCD_EXPOSURE_VALUE']['min']
161164

@@ -457,7 +460,6 @@ def _startImageWorker(self):
457460
self.sensortemp_v,
458461
self.night_v,
459462
self.moonmode_v,
460-
save_images=self.save_images,
461463
)
462464
self.image_worker.start()
463465

@@ -727,7 +729,11 @@ def run(self):
727729
camera_ready = False
728730
waiting_for_frame = True
729731

730-
if self.night:
732+
if self.focus_mode:
733+
# Start frame immediately in focus mode
734+
logger.warning('*** FOCUS MODE ENABLED ***')
735+
next_frame_time = now + self.config.get('FOCUS_DELAY', 4.0)
736+
elif self.night:
731737
next_frame_time = frame_start_time + self.config['EXPOSURE_PERIOD']
732738
else:
733739
next_frame_time = frame_start_time + self.config['EXPOSURE_PERIOD_DAY']

indi_allsky/flask/forms.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ def EXPOSURE_PERIOD_DAY_validator(form, field):
129129
raise ValidationError('Exposure period must be 1.0 or more')
130130

131131

132+
def FOCUS_DELAY_validator(form, field):
133+
if not isinstance(field.data, (int, float)):
134+
raise ValidationError('Please enter valid number')
135+
136+
if field.data < 1.0:
137+
raise ValidationError('Focus delay must be 1.0 or more')
138+
139+
132140
def WB_FACTOR_validator(form, field):
133141
if not isinstance(field.data, (int, float)):
134142
raise ValidationError('Please enter valid number')
@@ -849,6 +857,8 @@ class IndiAllskyConfigForm(FlaskForm):
849857
CCD_EXPOSURE_MIN = FloatField('Min Exposure', validators=[CCD_EXPOSURE_MIN_validator])
850858
EXPOSURE_PERIOD = FloatField('Exposure Period (Night)', validators=[DataRequired(), EXPOSURE_PERIOD_validator])
851859
EXPOSURE_PERIOD_DAY = FloatField('Exposure Period (Day)', validators=[DataRequired(), EXPOSURE_PERIOD_DAY_validator])
860+
FOCUS_MODE = BooleanField('Focus Mode')
861+
FOCUS_DELAY = FloatField('Focus Delay', validators=[DataRequired(), FOCUS_DELAY_validator])
852862
AUTO_WB = BooleanField('Auto White Balance')
853863
WBR_FACTOR = FloatField('Red Balance Factor', validators=[DataRequired(), WB_FACTOR_validator])
854864
WBG_FACTOR = FloatField('Green Balance Factor', validators=[DataRequired(), WB_FACTOR_validator])
@@ -1505,3 +1515,26 @@ class IndiAllskySetDateTimeForm(FlaskForm):
15051515

15061516
NEW_DATETIME = DateTimeLocalField('New Datetime', render_kw={'step' : '1'}, format='%Y-%m-%dT%H:%M:%S', validators=[DataRequired()])
15071517

1518+
1519+
1520+
class IndiAllskyFocusForm(FlaskForm):
1521+
ZOOM_SELECT_choices = (
1522+
(2, 'Off'),
1523+
(3, 'Low'),
1524+
(5, 'Medium'),
1525+
(8, 'High'),
1526+
(12, 'Extreme'),
1527+
)
1528+
REFRESH_SELECT_choices = (
1529+
(2, '2s'),
1530+
(3, '3s'),
1531+
(4, '4s'),
1532+
(5, '5s'),
1533+
(10, '10s'),
1534+
(15, '15s'),
1535+
)
1536+
1537+
1538+
ZOOM_SELECT = SelectField('Zoom', choices=ZOOM_SELECT_choices, default=ZOOM_SELECT_choices[0][0], validators=[])
1539+
REFRESH_SELECT = SelectField('Refresh', choices=REFRESH_SELECT_choices, default=REFRESH_SELECT_choices[3][0], validators=[])
1540+
Lines changed: 3 additions & 0 deletions
Loading

indi_allsky/flask/templates/base.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
<a href="{{ url_for('indi_allsky.sqm_view') }}" class="nav-link px-sm-0 px-2">
4747
<img src="{{ url_for('indi_allsky.static', filename='svg/cloud-moon-fill.svg') }}" width="16" height="16"><span class="ms-1 d-none d-sm-inline">SQM</span></a>
4848
</li>
49+
<li>
50+
<a href="{{ url_for('indi_allsky.focus_view') }}" class="nav-link px-sm-0 px-2">
51+
<img src="{{ url_for('indi_allsky.static', filename='svg/stars.svg') }}" width="16" height="16"><span class="ms-1 d-none d-sm-inline">Focus</span></a>
52+
</li>
4953
<li>
5054
<a href="{{ url_for('indi_allsky.chart_view') }}" class="nav-link px-sm-0 px-2">
5155
<img src="{{ url_for('indi_allsky.static', filename='svg/graph-up.svg') }}" width="16" height="16"><span class="ms-1 d-none d-sm-inline">Charts</span> </a>

indi_allsky/flask/templates/config.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,36 @@
175175

176176
<hr />
177177

178+
<div class="form-group row">
179+
<div class="col-sm-2">
180+
{{ form_config.FOCUS_MODE.label }}
181+
</div>
182+
<div class="col-sm-2">
183+
<div class="form-switch">
184+
{{ form_config.FOCUS_MODE(class='form-check-input') }}
185+
<div id="FOCUS_MODE-error" class="invalid-feedback text-danger" style="display: none;"></div>
186+
</div>
187+
</div>
188+
<div class="col-sm-8">Focus mode removes any pause between exposures so they are taken as quickly as possible</div>
189+
</div>
190+
191+
<div class="form-group row">
192+
<div class="col-sm-2">
193+
{{ form_config.FOCUS_DELAY.label(class='col-form-label') }}
194+
</div>
195+
<div class="col-sm-2">
196+
{{ form_config.FOCUS_DELAY(class='form-control bg-secondary') }}
197+
<div id="FOCUS_DELAY-error" class="invalid-feedback text-danger" style="display: none;"></div>
198+
</div>
199+
<div class="col-sm-8">
200+
<div>Seconds between each frame during focusing. This value should be slightly higher than the download time of images for your camera.</div>
201+
<div>RasPi HQ camera is about 3.5 seconds, therefore 4.0 should be sufficient.</div>
202+
<div>Astronomy cameras may be able to go as low as 1.0 or 2.0</div>
203+
</div>
204+
</div>
205+
206+
<hr />
207+
178208
<div class="form-group row">
179209
<div class="col-sm-2">
180210
{{ form_config.AUTO_WB.label }}
@@ -1415,6 +1445,7 @@
14151445
'CCD_EXPOSURE_MIN',
14161446
'EXPOSURE_PERIOD',
14171447
'EXPOSURE_PERIOD_DAY',
1448+
'FOCUS_DELAY',
14181449
'WBR_FACTOR',
14191450
'WBG_FACTOR',
14201451
'WBB_FACTOR',
@@ -1498,6 +1529,7 @@
14981529
];
14991530

15001531
const checkbox_field_names = [
1532+
'FOCUS_MODE',
15011533
'AUTO_WB',
15021534
'DETECT_STARS',
15031535
'DETECT_METEORS',

0 commit comments

Comments
 (0)