########################################
# frankAllSkyCam
# configuration file -  config.txt
#
# please adjust according to your needs
# see comments and documentation
########################################

[system]
# where will be stored images - relative path to frankAllSkyCam
otuputFolder= img

# directory where to save logs
logFolder = log

# local web folder where to save the skycam.jpg
outputLocalWebFile = /var/www/html/img/skycam.jpg

#how many days you want to keep jpgs
days_retention = 3

#watchdog will reboot if after x minutes no image has been generated
rebootAfter = 15

[site]
# configure your site (lat / long / elevation in meters, IANA timezone e.g. Europe/Rome)
latitude = 44.75
longitude = 9.29
elevation = 1150
time_zone = Europe/Rome
#the following label will be printed on the image
inte = <your_name_here>


[resolution]
# may use  800 x 600 as you wish
horiz = 1024
vert = 768
picture_rotation = 0

[libcamera]
# may personalize the libcamara params.
# please DO NOT set --shutter, --immediate
# night parameters will be used only when exposure > 0
# NOTE: --denoise cdn_hq is applied by frankAllSkyCam at night regardless of
# what's set here (chrominance-only colour denoise, removes red/purple hot-
# pixel speckle from long exposures) - don't set --denoise here for night,
# it will be overridden. --sharpness/--contrast at night come from
# night_sharpness/night_contrast below, not from here.
additional_night_params = --gain 10 --awbgains 2.7,1.5
additional_day_params = --metering average

# night_mode: optional sensor readout mode pinned for night captures only,
# e.g. "2028:1520:12" for the imx477's true 2x2-binned full-FOV mode
# (real SNR gain for faint stars, but also concentrates a single hot
# photosite's signal into one binned pixel before the ISP's defect
# correction sees it). Leave empty to let libcamera pick a mode itself.
night_mode =

# night_sharpness/night_contrast: forced at night to preserve faint stars
# against the ISP's daylight-tuned defaults, which were assumed to crush
# them - untested against real captures. A known-good pre-regression
# capture used contrast 2.5 (the ISP default, i.e. no override) with
# visibly fewer hot-pixel artifacts than contrast 1.0, so that assumption
# is worth re-testing; change these to compare.
night_sharpness = 0
night_contrast = 1.0


[timelapse]
# if True, timelapse from sunset to sunrise will be generated  Otherwise, not.
nightTL = True

# if True, 24h timelapse from 9am to 9am next day will be generated. Otherwise, not.
fullTL = True
nightOnly = True

# following parameters are used by ffmpeg
tl_horiz = 1024
tl_vert = 768
framerate = 15

# smooths the frame-to-frame star "jump" from the 1-2 minute capture gap via
# a cheap tblend frame-blend (no motion estimation - safe and fast on a Pi,
# unlike ffmpeg's minterpolate which is not).
smoothMotion = True
# smooths frame-to-frame brightness flicker (exposure varies slightly shot to
# shot, especially with exposure_mode = auto_exposure above).
deflicker = True

ffmpeg1 = -c:v libx264 -crf 12 -preset slow -pix_fmt yuv420p
# additional ffmpeg parameters may be added by experts!
# NOTE: the software already applies its own -vf (scale + smoothMotion +
# deflicker above). ffmpeg errors out if -vf/-filter:v is given twice, so if
# you add your own -vf/-filter:v here, first set smoothMotion and deflicker
# to False and fold scale/tblend/deflicker into your own filter string.
ffmpeg2 =
ffmpeg3 =

[font]
#when 1024x768 you can increase it
font_size = 20
font_colorR = 0
font_colorG = 255
font_colorB = 255

[text_coords]
# coordinates of the text to be added on the allskycam image
  #date,time
top_left_x = 20
top_left_y = 0

 # moon
top_right_x = 820
top_right_y = 0

 #night and SQM
bottom_left_x = 20
bottom_left_y = 715

 #sun
bottom_right_x = 870 
bottom_right_y = 710

  #top, center (your name, see the [site] section above)
top_center_x = 450
top_center_y = 0


[extra_text]
# et_use = y if you want to add some extra text
et_use= y
# absolute path to your txt file
et_data_file = /home/pi/frankAllSkyCam/extra_data.txt
et_font_size = 20
et_font_colorR = 0
et_font_colorG = 255
et_font_colorB = 255
et_x_pos = 20
et_y_pos = 90

[compass]
# relative path from frankAllSkyCam/png
# if file not found, it will be skipped
# set your coords according to your resolution
compass_filename = compass.png
compass_x_pos = 915
compass_y_pos = 610
compass_rot_angle = 0

[logo]
# relative path from frankAllSkyCam/png
# if file not found, it will be skipped
# set your coords according to your resolution
logo_filename = logo.png
logo_x_pos = 30
logo_y_pos = 610

[moon_phase_img]
# relative path from frankAllSkyCam/png
# if file not found, it will be skipped
# set your coords according to your resolution
moon_filename = phase.png
moon_x_pos = 920
moon_y_pos = 110

[planets]
# relative path from frankAllSkyCam/png
# if file not found, it will be skipped
# set your coords according to your resolution

jupiter_x_pos = 15
mars_x_pos = 55
saturn_x_pos = 90
venus_x_pos = 142

jupiter_y_pos = 52
mars_y_pos = 53
saturn_y_pos = 52
venus_y_pos = 52


[exposure]
# max night exposure in seconds
#  for urban sky, suggested value is 4
#  for dark sky, suggested value is 55-60 (I found 55 secs ok for sqm 21,3).
#  this value only limits the max exposure. The calculated or real SQM will drive exposure
esp_secs =60

# how night exposure is decided:
#  auto_exposure - measure the previous frame's own brightness and adjust
#                  toward target_mean below. No sqmexp.csv calibration needed,
#                  but needs a few runs to converge and reacts a run late to
#                  fast sky changes (clouds moving in, moonrise). Default.
#  sqm_based    - predict exposure from a pre-calibrated SQM curve (sqmexp.csv).
exposure_mode = auto_exposure

[auto_exposure]
# only used when exposure_mode = auto_exposure above
# target mean brightness (0-255) inside the ROI below; tune per site/lens
target_mean = 30
# circular ROI used to measure brightness, centered in frame - excludes fixed
# dark obstructions (roofline, trees) near the edges from skewing the mean.
# 100 = full image width, 70 = circle whose diameter is 70% of image width.
roi_percent = 70
# floor so the feedback loop can't collapse exposure toward zero. During
# twilight (dusk and dawn) frankAllSkyCam no longer forces this floor the
# instant the sun crosses the horizon - see twilight_guard_deg below.
min_exposure_secs = 1
# used only for the very first run, before any state file exists yet
seed_exposure_secs = 5

# twilight handoff: while the sun is below the horizon but the algorithm's
# own honest prediction is still under min_exposure_secs above, the sky
# isn't dark enough yet for a floored fixed shutter to be meaningful -
# libcamera's own auto-exposure drives capture instead (same as daytime)
# until the real sky catches up. This sizing is automatic (reacts to the
# actual measured sky, clear or overcast, not a fixed clock), NOT
# controlled by the value below.
# twilight_guard_deg is only a cold-start safety strip: for this many
# degrees below the horizon, always let the ISP drive regardless of
# leftover state from many hours earlier (e.g. this morning's dawn) -
# it is not what sizes the handoff.
twilight_guard_deg = 3
# EV compensation applied only to twilight-handoff (ISP-driven) captures,
# not to full daytime - --metering average factors in the large near-black
# margin outside the fisheye circle, which can leave the ISP's own target
# a bit dim at twilight specifically. Small and deliberately conservative;
# raise a little further if frames still look underexposed, 0 to disable.
twilight_ev_bias = 0.3
# saturation guard: if the previous frame came back with at least this
# fraction of its ROI pixels clipped (e.g. a cloud reflecting light
# pollution at night), a clipped mean can't say how far over it really
# was, so the next exposure is cut harder than the plain ratio would -
# see saturation_severity_gain below. A single bright point source (Moon,
# a planet) alone stays well under this on real captures.
saturation_clip_frac_threshold = 0.05
# how much harder to cut when the clip-fraction guard above fires -
# severity = 1 + clip_frac * this value
saturation_severity_gain = 8

[ftp]
# if True, allSkyCam image, timelapse and startrails
#will be uploaded on your FTP Server
isFTP=False

# ftp parameters, to upload the allSkyCam image to your FTP server
FTP_server=your_server_here.com
FTP_login=your_username
FTP_pass= your_password
FTP_uploadFolder =/your_folder/

# uploaded file name (e.g.,allskycam.jpg). no need to add the jpg extention
FTP_filenameAllSkyImgJPG = /img/allskycam

# allskycam_night.mp4 will be generated if nightTL = True
# allskycam_24h.mp4 will be generated if fullTL = True
FTP_fileNameTimelapseMP4 = /video/frankAllSkycam

# starTrail.jpg will be generated
FTP_fileNameStarTrailJPG = /startrail/startrail.jpg

# combined weather/sky JSON (see [weather_export] below) - only used if
# weather_export.enabled = True. Like the img/video/startrail folders
# above, create this folder on your FTP server yourself first - STOR does
# not create missing directories.
FTP_fileNameWeatherJSON = /weather/weather.json

[weather_export]
# publishes a single combined JSON file (SQM, star count, cloud cover, plus
# a live reading from your WS90-style weather station) to your FTP server
# every night-time capture - see FTP_fileNameWeatherJSON above for where.
# Requires isFTP = True above; has no effect otherwise. Only ever runs at
# night (twilight and daytime captures are skipped), since SQM/star
# count/cloud cover aren't meaningful outside a real dark-sky exposure.
enabled = True

# full JSON URL of your WS90-style weather station (same kind of URL as
# generateExtraData.conf's station_url, but configured here independently -
# this feature does not read generateExtraData.py's own output or config).
# Leave empty to still export SQM/star count/cloud cover with weather
# fields zeroed. Fetched with a short timeout and no retries (unlike
# generateExtraData.py's own fetch), since this runs in the main capture
# loop - a slow/unreachable station must never delay the next capture.
station_url =

[sqm]
# info about your SQM-LE reader (if you have not it, just let use_sqm_le = n)
# directory where to save sqm info
sqmFolder = sqm
# would you use the SQM-LE ? y/n
use_sqm_le = n
# would you log your SQM ? y/n
sqmLog = n
# keep sqmDebug = n
sqmDebug = n
# in case you have SQM-LE, put your IP/port
ip_address = 192.168.2.59
port = 10001

