diff --git a/indi_allsky/allsky.py b/indi_allsky/allsky.py index 81824dc5..f5172d35 100644 --- a/indi_allsky/allsky.py +++ b/indi_allsky/allsky.py @@ -116,6 +116,7 @@ def __init__(self): self.exposure_v = Value('f', -1.0) # this must be -1.0 to indicate unset self.exposure_min_v = Value('f', -1.0) + self.exposure_min_day_v = Value('f', -1.0) self.exposure_max_v = Value('f', -1.0) self.gain_v = Value('i', -1) # value set in CCD config self.bin_v = Value('i', 1) # set 1 for sane default @@ -300,6 +301,7 @@ def _startCaptureWorker(self): self.dec_v, self.exposure_v, self.exposure_min_v, + self.exposure_min_day_v, self.exposure_max_v, self.gain_v, self.bin_v, @@ -368,6 +370,7 @@ def _startImageWorker(self): self.dec_v, self.exposure_v, self.exposure_min_v, + self.exposure_min_day_v, self.exposure_max_v, self.gain_v, self.bin_v, diff --git a/indi_allsky/capture.py b/indi_allsky/capture.py index d7912221..38555942 100644 --- a/indi_allsky/capture.py +++ b/indi_allsky/capture.py @@ -68,6 +68,7 @@ def __init__( dec_v, exposure_v, exposure_min_v, + exposure_min_day_v, exposure_max_v, gain_v, bin_v, @@ -96,6 +97,7 @@ def __init__( self.exposure_v = exposure_v self.exposure_min_v = exposure_min_v + self.exposure_min_day_v = exposure_min_day_v self.exposure_max_v = exposure_max_v self.gain_v = gain_v self.bin_v = bin_v @@ -669,21 +671,43 @@ def _initialize(self): # Some CCD drivers will not accept their stated minimum exposure. # There might be some python -> C floating point conversion problem causing this. - ccd_min_exp = ccd_min_exp + 0.00000001 + ccd_min_exp += 0.00000001 + + + if not self.config.get('CCD_EXPOSURE_MIN_DAY'): + with self.exposure_min_day_v.get_lock(): + self.exposure_min_day_v.value = ccd_min_exp + elif self.config.get('CCD_EXPOSURE_MIN_DAY') > ccd_min_exp: + with self.exposure_min_day_v.get_lock(): + self.exposure_min_day_v.value = float(self.config.get('CCD_EXPOSURE_MIN_DAY')) + elif self.config.get('CCD_EXPOSURE_MIN_DAY') < ccd_min_exp: + logger.warning( + 'Minimum exposure (day) %0.8f too low, increasing to %0.8f', + self.config.get('CCD_EXPOSURE_MIN_DAY'), + ccd_min_exp, + ) + with self.exposure_min_day_v.get_lock(): + self.exposure_min_day_v.value = ccd_min_exp + + logger.info('Minimum CCD exposure: %0.8f (day)', self.exposure_min_day_v.value) + if not self.config.get('CCD_EXPOSURE_MIN'): with self.exposure_min_v.get_lock(): self.exposure_min_v.value = ccd_min_exp + elif self.config.get('CCD_EXPOSURE_MIN') > ccd_min_exp: + with self.exposure_min_v.get_lock(): + self.exposure_min_v.value = float(self.config.get('CCD_EXPOSURE_MIN')) elif self.config.get('CCD_EXPOSURE_MIN') < ccd_min_exp: logger.warning( - 'Minimum exposure %0.8f too low, increasing to %0.8f', + 'Minimum exposure (night) %0.8f too low, increasing to %0.8f', self.config.get('CCD_EXPOSURE_MIN'), ccd_min_exp, ) with self.exposure_min_v.get_lock(): self.exposure_min_v.value = ccd_min_exp - logger.info('Minimum CCD exposure: %0.8f', self.exposure_min_v.value) + logger.info('Minimum CCD exposure: %0.8f (night)', self.exposure_min_v.value) # set maximum exposure @@ -916,6 +940,7 @@ def reload_handler(self): ) self.config['CCD_EXPOSURE_MIN'] = ccd_min_exp + logger.info('Minimum CCD exposure: %0.8f', self.config['CCD_EXPOSURE_MIN']) diff --git a/indi_allsky/config.py b/indi_allsky/config.py index 7949d5c5..a481c251 100644 --- a/indi_allsky/config.py +++ b/indi_allsky/config.py @@ -67,6 +67,7 @@ class IndiAllSkyConfigBase(object): "CCD_EXPOSURE_MAX" : 15.00000, "CCD_EXPOSURE_DEF" : 0.0, "CCD_EXPOSURE_MIN" : 0.0, + "CCD_EXPOSURE_MIN_DAY" : 0.0, "CCD_BIT_DEPTH" : 0, # 0 is auto "EXPOSURE_PERIOD" : 15.00000, "EXPOSURE_PERIOD_DAY" : 15.00000, diff --git a/indi_allsky/flask/forms.py b/indi_allsky/flask/forms.py index 48867b40..1df81746 100644 --- a/indi_allsky/flask/forms.py +++ b/indi_allsky/flask/forms.py @@ -2165,7 +2165,8 @@ class IndiAllskyConfigForm(FlaskForm): CCD_CONFIG__DAY__BINNING = IntegerField('Daytime Bin Mode', validators=[DataRequired(), ccd_BINNING_validator]) CCD_EXPOSURE_MAX = FloatField('Max Exposure', validators=[DataRequired(), CCD_EXPOSURE_MAX_validator]) CCD_EXPOSURE_DEF = FloatField('Default Exposure', validators=[CCD_EXPOSURE_DEF_validator]) - CCD_EXPOSURE_MIN = FloatField('Min Exposure', validators=[CCD_EXPOSURE_MIN_validator]) + CCD_EXPOSURE_MIN = FloatField('Min Exposure (Night)', validators=[CCD_EXPOSURE_MIN_validator]) + CCD_EXPOSURE_MIN_DAY = FloatField('Min Exposure (Day)', validators=[CCD_EXPOSURE_MIN_validator]) CCD_BIT_DEPTH = SelectField('Camera Bit Depth', choices=CCD_BIT_DEPTH_choices, validators=[CCD_BIT_DEPTH_validator]) EXPOSURE_PERIOD = FloatField('Exposure Period (Night)', validators=[DataRequired(), EXPOSURE_PERIOD_validator]) EXPOSURE_PERIOD_DAY = FloatField('Exposure Period (Day)', validators=[DataRequired(), EXPOSURE_PERIOD_DAY_validator]) diff --git a/indi_allsky/flask/templates/config.html b/indi_allsky/flask/templates/config.html index d6c30547..012c26c7 100644 --- a/indi_allsky/flask/templates/config.html +++ b/indi_allsky/flask/templates/config.html @@ -190,6 +190,7 @@
0 = auto
+
{{ form_config.CCD_EXPOSURE_MIN.label(class='col-form-label') }} @@ -200,6 +201,16 @@
0 = auto
+
+
+ {{ form_config.CCD_EXPOSURE_MIN_DAY.label(class='col-form-label') }} +
+
+ {{ form_config.CCD_EXPOSURE_MIN_DAY(class='form-control bg-secondary') }} + +
+
0 = auto
+
@@ -3450,6 +3461,7 @@ 'CCD_EXPOSURE_MAX', 'CCD_EXPOSURE_DEF', 'CCD_EXPOSURE_MIN', + 'CCD_EXPOSURE_MIN_DAY', 'CCD_BIT_DEPTH', 'EXPOSURE_PERIOD', 'EXPOSURE_PERIOD_DAY', diff --git a/indi_allsky/flask/views.py b/indi_allsky/flask/views.py index f8b2a58f..bd483ca2 100644 --- a/indi_allsky/flask/views.py +++ b/indi_allsky/flask/views.py @@ -899,6 +899,7 @@ def get_context(self): 'CCD_EXPOSURE_MAX' : self.indi_allsky_config.get('CCD_EXPOSURE_MAX', 15.0), 'CCD_EXPOSURE_DEF' : '{0:.6f}'.format(self.indi_allsky_config.get('CCD_EXPOSURE_DEF', 0.0)), # force 6 digits of precision 'CCD_EXPOSURE_MIN' : '{0:.6f}'.format(self.indi_allsky_config.get('CCD_EXPOSURE_MIN', 0.0)), + 'CCD_EXPOSURE_MIN_DAY' : '{0:.6f}'.format(self.indi_allsky_config.get('CCD_EXPOSURE_MIN_DAY', 0.0)), 'CCD_BIT_DEPTH' : str(self.indi_allsky_config.get('CCD_BIT_DEPTH', 0)), # string in form, int in config 'EXPOSURE_PERIOD' : self.indi_allsky_config.get('EXPOSURE_PERIOD', 15.0), 'EXPOSURE_PERIOD_DAY' : self.indi_allsky_config.get('EXPOSURE_PERIOD_DAY', 15.0), @@ -1417,6 +1418,7 @@ def dispatch_request(self): self.indi_allsky_config['CCD_EXPOSURE_MAX'] = float(request.json['CCD_EXPOSURE_MAX']) self.indi_allsky_config['CCD_EXPOSURE_DEF'] = float(request.json['CCD_EXPOSURE_DEF']) self.indi_allsky_config['CCD_EXPOSURE_MIN'] = float(request.json['CCD_EXPOSURE_MIN']) + self.indi_allsky_config['CCD_EXPOSURE_MIN_DAY'] = float(request.json['CCD_EXPOSURE_MIN_DAY']) self.indi_allsky_config['CCD_BIT_DEPTH'] = int(request.json['CCD_BIT_DEPTH']) self.indi_allsky_config['EXPOSURE_PERIOD'] = float(request.json['EXPOSURE_PERIOD']) self.indi_allsky_config['EXPOSURE_PERIOD_DAY'] = float(request.json['EXPOSURE_PERIOD_DAY']) diff --git a/indi_allsky/image.py b/indi_allsky/image.py index 65cd61f5..b4deefd3 100644 --- a/indi_allsky/image.py +++ b/indi_allsky/image.py @@ -77,6 +77,7 @@ def __init__( dec_v, exposure_v, exposure_min_v, + exposure_min_day_v, exposure_max_v, gain_v, bin_v, @@ -103,6 +104,7 @@ def __init__( self.exposure_v = exposure_v self.exposure_min_v = exposure_min_v + self.exposure_min_day_v = exposure_min_day_v self.exposure_max_v = exposure_max_v self.gain_v = gain_v self.bin_v = bin_v @@ -1388,8 +1390,10 @@ def calculate_exposure(self, adu, exposure): if self.night_v.value: target_adu = self.config['TARGET_ADU'] + exposure_min = self.exposure_min_v.value else: target_adu = self.config['TARGET_ADU_DAY'] + exposure_min = self.exposure_min_day_v.value # Brightness when the sun is in view (very short exposures) can change drastically when clouds pass through the view @@ -1420,7 +1424,7 @@ def calculate_exposure(self, adu, exposure): if not self.target_adu_found: - self.recalculate_exposure(exposure, adu, target_adu, target_adu_min, target_adu_max, exp_scale_factor) + self.recalculate_exposure(exposure, adu, target_adu, target_adu_min, target_adu_max, exposure_min, exp_scale_factor) return adu, 0.0 @@ -1451,7 +1455,7 @@ def calculate_exposure(self, adu, exposure): return adu, adu_average - def recalculate_exposure(self, exposure, adu, target_adu, target_adu_min, target_adu_max, exp_scale_factor): + def recalculate_exposure(self, exposure, adu, target_adu, target_adu_min, target_adu_max, exposure_min, exp_scale_factor): # Until we reach a good starting point, do not calculate a moving average if adu <= target_adu_max and adu >= target_adu_min: @@ -1472,8 +1476,8 @@ def recalculate_exposure(self, exposure, adu, target_adu, target_adu_min, target # Do not exceed the limits - if new_exposure < self.exposure_min_v.value: - new_exposure = float(self.exposure_min_v.value) + if new_exposure < exposure_min: + new_exposure = float(exposure_min) elif new_exposure > self.exposure_max_v.value: new_exposure = float(self.exposure_max_v.value) diff --git a/misc/support_info.sh b/misc/support_info.sh index 6471aa5b..41af6c0c 100755 --- a/misc/support_info.sh +++ b/misc/support_info.sh @@ -8,6 +8,35 @@ PATH=/usr/local/bin:/usr/bin:/bin export PATH +function catch_error() { + echo + echo + echo "###############" + echo "### ERROR ###" + echo "###############" + echo + echo "The script exited abnormally, please try to run again..." + echo + echo + exit 1 +} +trap catch_error ERR + +function catch_sigint() { + echo + echo + echo "###############" + echo "### ERROR ###" + echo "###############" + echo + echo "The script was interrupted, please run the script again to finish..." + echo + echo + exit 1 +} +trap catch_sigint SIGINT + + DISTRO_NAME=$(lsb_release -s -i) DISTRO_RELEASE=$(lsb_release -s -r) CPU_ARCH=$(uname -m) @@ -16,6 +45,13 @@ CPU_TOTAL=$(grep -c "^proc" /proc/cpuinfo) MEM_TOTAL=$(grep MemTotal /proc/meminfo | awk "{print \$2}") +if [ -f "/proc/device-tree/model" ]; then + SYSTEM_MODEL=$(cat /proc/device-tree/model) +else + SYSTEM_MODEL="Generic PC" +fi + + if which indiserver >/dev/null 2>&1; then INDISERVER=$(which indiserver) else @@ -41,6 +77,8 @@ echo echo "CPUs: $CPU_TOTAL" echo "Memory: $MEM_TOTAL kB" echo +echo "System: $SYSTEM_MODEL" +echo echo "Uptime" uptime echo @@ -66,7 +104,7 @@ echo echo "Process info" # shellcheck disable=SC2009 -ps auxwww | grep indi | grep -v grep +ps auxwww | grep indi | grep -v grep || true echo echo "USB info" @@ -112,7 +150,11 @@ dpkg -l | grep libcamera || true echo echo "libcamera cameras" -if which libcamera-hello >/dev/null 2>&1; then +if which rpicam-hello >/dev/null 2>&1; then + echo "rpicam-hello: $(which rpicam-hello)" + rpicam-hello --list-cameras || true + echo +elif which libcamera-hello >/dev/null 2>&1; then echo "libcamera-hello: $(which libcamera-hello)" libcamera-hello --list-cameras || true echo diff --git a/misc/upgrade_web.sh b/misc/upgrade_web.sh index 1bb18b18..c7e7617e 100755 --- a/misc/upgrade_web.sh +++ b/misc/upgrade_web.sh @@ -10,7 +10,11 @@ export PATH function catch_error() { echo echo - echo "The script exited abnormally, please try to run again..." + echo "###############" + echo "### ERROR ###" + echo "###############" + echo + echo "The setup script exited abnormally, please try to run again..." echo echo exit 1 @@ -20,6 +24,10 @@ trap catch_error ERR function catch_sigint() { echo echo + echo "###############" + echo "### ERROR ###" + echo "###############" + echo echo "The setup script was interrupted, please run the script again to finish..." echo echo diff --git a/setup.sh b/setup.sh index 215565cd..f529e5a0 100755 --- a/setup.sh +++ b/setup.sh @@ -91,7 +91,11 @@ ASTROBERRY="false" function catch_error() { echo echo - echo "The script exited abnormally, please try to run again..." + echo "###############" + echo "### ERROR ###" + echo "###############" + echo + echo "The setup script exited abnormally, please try to run again..." echo echo exit 1 @@ -101,8 +105,11 @@ trap catch_error ERR function catch_sigint() { echo echo - echo "The setup script was interrupted, please run the script again to finish..." + echo "###############" + echo "### ERROR ###" + echo "###############" echo + echo "The setup script was interrupted, please run the script again to finish..." echo exit 1 }