Skip to content

Commit 73db3cb

Browse files
committed
Merge remote-tracking branch 'origin/indi_mount_control' into indi_mount_control
2 parents c5a130f + 717db31 commit 73db3cb

9 files changed

Lines changed: 175 additions & 28 deletions

File tree

install-indi-pifinder.sh

Lines changed: 114 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,46 @@ else
6363
git clone --branch v2.1.6 --depth 1 https://github.com/indilib/indi.git
6464
fi
6565

66+
# Build with-out camera drivers to save time and resources.
6667
mkdir -p ./indi/build
6768
cd ./indi/build
68-
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr ..
69+
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr \
70+
-DWITH_WEBCAM=OFF \
71+
-DWITH_SX=OFF \
72+
-DWITH_MI=OFF \
73+
-DWITH_FLI=OFF \
74+
-DWITH_SBIG=OFF \
75+
-DWITH_INOVAPLX=OFF \
76+
-DWITH_APOGEE=OFF \
77+
-DWITH_FFMV=OFF \
78+
-DWITH_QHY=OFF \
79+
-DWITH_GPHOTO=OFF \
80+
-DWITH_QSI=OFF \
81+
-DWITH_FISHCAMP=OFF \
82+
-DWITH_DSI=OFF \
83+
-DWITH_ASICAM=OFF \
84+
-DWITH_GIGE=OFF \
85+
-DWITH_NIGHTSCAPE=OFF \
86+
-DWITH_ATIK=OFF \
87+
-DWITH_TOUPCAM=OFF \
88+
-DWITH_ALTAIRCAM=OFF \
89+
-DWITH_BRESSERCAM=OFF \
90+
-DWITH_MALLINCAM=OFF \
91+
-DWITH_MEADECAM=OFF \
92+
-DWITH_NNCAM=OFF \
93+
-DWITH_OGMACAM=OFF \
94+
-DWITH_OPENOGMA=OFF \
95+
-DWITH_OMEGONPROCAM=OFF \
96+
-DWITH_STARSHOOTG=OFF \
97+
-DWITH_TSCAM=OFF \
98+
-DWITH_SVBONYCAM=OFF \
99+
-DWITH_PENTAX=OFF \
100+
-DWITH_ORION_SSG3=OFF \
101+
-DWITH_SVBONY=OFF \
102+
-DWITH_PLAYERONE=OFF \
103+
-DWITH_MGEN=OFF \
104+
-DWITH_ASTROASIS=OFF \
105+
..
69106
make -j2
70107
sudo make install
71108

@@ -86,10 +123,45 @@ else
86123
fi
87124

88125

89-
# Build libs
126+
# Build libs, with-out camera drivers, to save time and resources.
90127
mkdir -p ./indi-3rdparty/build-libs
91128
cd ./indi-3rdparty/build-libs
92-
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DBUILD_LIBS=1 ..
129+
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DBUILD_LIBS=1 \
130+
-DWITH_WEBCAM=OFF \
131+
-DWITH_SX=OFF \
132+
-DWITH_MI=OFF \
133+
-DWITH_FLI=OFF \
134+
-DWITH_SBIG=OFF \
135+
-DWITH_INOVAPLX=OFF \
136+
-DWITH_APOGEE=OFF \
137+
-DWITH_FFMV=OFF \
138+
-DWITH_QHY=OFF \
139+
-DWITH_GPHOTO=OFF \
140+
-DWITH_QSI=OFF \
141+
-DWITH_FISHCAMP=OFF \
142+
-DWITH_DSI=OFF \
143+
-DWITH_ASICAM=OFF \
144+
-DWITH_GIGE=OFF \
145+
-DWITH_NIGHTSCAPE=OFF \
146+
-DWITH_ATIK=OFF \
147+
-DWITH_TOUPCAM=OFF \
148+
-DWITH_ALTAIRCAM=OFF \
149+
-DWITH_BRESSERCAM=OFF \
150+
-DWITH_MALLINCAM=OFF \
151+
-DWITH_MEADECAM=OFF \
152+
-DWITH_NNCAM=OFF \
153+
-DWITH_OGMACAM=OFF \
154+
-DWITH_OPENOGMA=OFF \
155+
-DWITH_OMEGONPROCAM=OFF \
156+
-DWITH_STARSHOOTG=OFF \
157+
-DWITH_TSCAM=OFF \
158+
-DWITH_SVBONYCAM=OFF \
159+
-DWITH_PENTAX=OFF \
160+
-DWITH_ORION_SSG3=OFF \
161+
-DWITH_SVBONY=OFF \
162+
-DWITH_PLAYERONE=OFF \
163+
-DWITH_MGEN=OFF \
164+
-DWITH_ASTROASIS=OFF \
93165
make -j2
94166
sudo make install
95167

@@ -102,7 +174,43 @@ cd ./indi-3rdparty/build-drivers
102174
export LDFLAGS="-ludev"
103175
export CXXFLAGS="-DUSE_UDEV"
104176

105-
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DCMAKE_SHARED_LINKER_FLAGS="-ludev" ..
177+
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DCMAKE_SHARED_LINKER_FLAGS="-ludev" \
178+
-DWITH_WEBCAM=OFF \
179+
-DWITH_SX=OFF \
180+
-DWITH_MI=OFF \
181+
-DWITH_FLI=OFF \
182+
-DWITH_SBIG=OFF \
183+
-DWITH_INOVAPLX=OFF \
184+
-DWITH_APOGEE=OFF \
185+
-DWITH_FFMV=OFF \
186+
-DWITH_QHY=OFF \
187+
-DWITH_GPHOTO=OFF \
188+
-DWITH_QSI=OFF \
189+
-DWITH_FISHCAMP=OFF \
190+
-DWITH_DSI=OFF \
191+
-DWITH_ASICAM=OFF \
192+
-DWITH_GIGE=OFF \
193+
-DWITH_NIGHTSCAPE=OFF \
194+
-DWITH_ATIK=OFF \
195+
-DWITH_TOUPCAM=OFF \
196+
-DWITH_ALTAIRCAM=OFF \
197+
-DWITH_BRESSERCAM=OFF \
198+
-DWITH_MALLINCAM=OFF \
199+
-DWITH_MEADECAM=OFF \
200+
-DWITH_NNCAM=OFF \
201+
-DWITH_OGMACAM=OFF \
202+
-DWITH_OPENOGMA=OFF \
203+
-DWITH_OMEGONPROCAM=OFF \
204+
-DWITH_STARSHOOTG=OFF \
205+
-DWITH_TSCAM=OFF \
206+
-DWITH_SVBONYCAM=OFF \
207+
-DWITH_PENTAX=OFF \
208+
-DWITH_ORION_SSG3=OFF \
209+
-DWITH_SVBONY=OFF \
210+
-DWITH_PLAYERONE=OFF \
211+
-DWITH_MGEN=OFF \
212+
-DWITH_ASTROASIS=OFF \
213+
..
106214
make -j2
107215
sudo make install
108216

@@ -158,7 +266,8 @@ echo "PiFinder: Install time synchronization..."
158266
echo "==============================================================================="
159267

160268
sudo apt install chrony -y
161-
sudo bash -c 'echo -e "\n# Sync time from GPSD\nrefclock SHM 0 poll 3 refid gps1" >> /etc/chrony/chrony.conf'
269+
270+
sudo grep -q "refclock.*gps1" /etc/chrony/chrony.conf || sudo bash -c 'echo -e "\n# Sync time from GPSD\nrefclock SHM 0 poll 3 refid gps1" >> /etc/chrony/chrony.conf'
162271
sudo systemctl restart chrony
163272

164273

python/PiFinder/catalogs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def do_timed_task(self):
757757
with self._init_lock:
758758
if not self.initialized:
759759
logger.debug("Comets not yet initialized, skip periodic update...")
760-
760+
761761
def stop(self) -> None:
762762
"""Stop background loading gracefully"""
763763
self._stop_flag.set()

python/PiFinder/display_message.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import argparse
1717
from PIL import Image, ImageDraw
1818
from PiFinder import displays
19-
from PiFinder import config
2019

2120

2221
def display_message(lines, brightness=255, display_type=None):
@@ -107,26 +106,28 @@ def main():
107106
%(prog)s --brightness 200 "Bright message"
108107
%(prog)s --display st7789 "Message for LCD"
109108
""",
110-
formatter_class=argparse.RawDescriptionHelpFormatter
109+
formatter_class=argparse.RawDescriptionHelpFormatter,
111110
)
112111

113112
parser.add_argument(
114113
"message",
115114
nargs="+",
116-
help="Message text (multiple arguments will be displayed on separate lines)"
115+
help="Message text (multiple arguments will be displayed on separate lines)",
117116
)
118117

119118
parser.add_argument(
120-
"-b", "--brightness",
119+
"-b",
120+
"--brightness",
121121
type=int,
122122
default=125,
123-
help="Display brightness (0-255, default: 125)"
123+
help="Display brightness (0-255, default: 125)",
124124
)
125125

126126
parser.add_argument(
127-
"-d", "--display",
127+
"-d",
128+
"--display",
128129
choices=["ssd1351", "st7789", "pg_128", "pg_320"],
129-
help="Display hardware type (auto-detected from config if not specified)"
130+
help="Display hardware type (auto-detected from config if not specified)",
130131
)
131132

132133
args = parser.parse_args()
@@ -138,11 +139,16 @@ def main():
138139

139140
# Display the message
140141
try:
141-
display_message(args.message, brightness=args.brightness, display_type=args.display)
142-
print(f"Message displayed successfully on {args.display or 'auto-detected'} display")
142+
display_message(
143+
args.message, brightness=args.brightness, display_type=args.display
144+
)
145+
print(
146+
f"Message displayed successfully on {args.display or 'auto-detected'} display"
147+
)
143148
except Exception as e:
144149
print(f"Error displaying message: {e}")
145150
import traceback
151+
146152
traceback.print_exc()
147153
sys.exit(1)
148154

python/PiFinder/mountcontrol_alignment.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
# Config loading and merging
5252
# ---------------------------------------------------------------------------
5353

54+
5455
def _load_yaml_safe(path: Path) -> Optional[dict]:
5556
"""Load a YAML file, returning None on any error."""
5657
try:
@@ -133,6 +134,7 @@ def load_merged_config() -> dict:
133134
# Status persistence
134135
# ---------------------------------------------------------------------------
135136

137+
136138
def _save_status(status: dict) -> None:
137139
try:
138140
STATUS_FILE_PATH.parent.mkdir(parents=True, exist_ok=True)
@@ -160,6 +162,7 @@ def read_status() -> dict:
160162
# PyIndi helpers
161163
# ---------------------------------------------------------------------------
162164

165+
163166
def _get_switch_value(device, prop_name: str, elem_name: str) -> Optional[str]:
164167
"""
165168
Read a single switch element from a PyIndi device.
@@ -200,6 +203,7 @@ def _apply_switch_command(
200203
# Main entry point (called from mountcontrol_indi.init_mount)
201204
# ---------------------------------------------------------------------------
202205

206+
203207
def check_and_disable_alignment(client, device, console_queue=None) -> None:
204208
"""
205209
Detect active INDI alignment subsystems on *device* and optionally disable
@@ -257,7 +261,10 @@ def check_and_disable_alignment(client, device, console_queue=None) -> None:
257261
if current_val is None:
258262
logger.debug(
259263
"Driver '%s': property '%s' / element '%s' not found on '%s'",
260-
key, detect_prop, detect_elem, device_name,
264+
key,
265+
detect_prop,
266+
detect_elem,
267+
device_name,
261268
)
262269
status["drivers"][key] = result
263270
continue
@@ -269,7 +276,8 @@ def check_and_disable_alignment(client, device, console_queue=None) -> None:
269276
if not is_active:
270277
logger.info(
271278
"Driver '%s' (%s): alignment subsystem is already inactive",
272-
key, device_name,
279+
key,
280+
device_name,
273281
)
274282
status["drivers"][key] = result
275283
continue
@@ -284,7 +292,9 @@ def check_and_disable_alignment(client, device, console_queue=None) -> None:
284292
"INDI alignment subsystem ACTIVE on '%s' (%s)%s",
285293
device_name,
286294
drv.get("description", key),
287-
" — will disable" if disable_commands else " — no disable commands configured",
295+
" — will disable"
296+
if disable_commands
297+
else " — no disable commands configured",
288298
)
289299
_push_console(console_queue, msg)
290300

@@ -308,7 +318,10 @@ def check_and_disable_alignment(client, device, console_queue=None) -> None:
308318

309319
logger.info(
310320
"Sending: device=%s prop=%s element=%s value=%s",
311-
device_name, prop, elem, val,
321+
device_name,
322+
prop,
323+
elem,
324+
val,
312325
)
313326
ok = _apply_switch_command(client, device, prop, elem, val)
314327
result["commands_sent"].append(
@@ -329,7 +342,9 @@ def check_and_disable_alignment(client, device, console_queue=None) -> None:
329342
_push_console(console_queue, f"INDI: alignment disabled on {device_name}")
330343
else:
331344
logger.error("Alignment disable INCOMPLETE on '%s'", device_name)
332-
_push_console(console_queue, f"INDI: alignment disable FAILED on {device_name}")
345+
_push_console(
346+
console_queue, f"INDI: alignment disable FAILED on {device_name}"
347+
)
333348

334349
status["drivers"][key] = result
335350

@@ -349,6 +364,7 @@ def _push_console(console_queue, message: str) -> None:
349364
# Utility functions for the web server
350365
# ---------------------------------------------------------------------------
351366

367+
352368
def get_repo_config_path() -> Path:
353369
return REPO_CONFIG_PATH
354370

python/PiFinder/server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,9 @@ def indi_copy_config():
952952
@auth_required
953953
def indi_status_json():
954954
response.content_type = "application/json"
955-
return json.dumps(mountcontrol_alignment.read_status(), indent=2, default=str)
955+
return json.dumps(
956+
mountcontrol_alignment.read_status(), indent=2, default=str
957+
)
956958

957959
@app.route("/key_callback", method="POST")
958960
@auth_required

python/PiFinder/sys_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,15 @@ def is_mountcontrol_active() -> bool:
327327
"""
328328
Returns True if mount control service is active
329329
"""
330-
status = sh.sudo("systemctl", "is-active", "indiwebmanager.service", _ok_code=(0, 3))
330+
status = sh.sudo(
331+
"systemctl", "is-active", "indiwebmanager.service", _ok_code=(0, 3)
332+
)
331333
if status.exit_code == 0:
332334
return True
333335
else:
334336
return False
335-
337+
338+
336339
def mountcontrol_activate() -> None:
337340
"""
338341
Activates the mount control service
@@ -353,6 +356,8 @@ def mountcontrol_deactivate() -> None:
353356
# sh.sudo("systemctl", "stop", "indiwebmanager.service")
354357
# We do NOT need to start the mount control process during startup, so reboot
355358
sh.sudo("shutdown", "-r", "now")
359+
360+
356361
def check_and_sync_gpsd_config(baud_rate: int) -> bool:
357362
"""
358363
Checks if GPSD configuration matches the desired baud rate,

python/PiFinder/sys_utils_fake.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,17 @@ def switch_cam_imx296() -> None:
162162
logger.info('sh.sudo("python", "-m", "PiFinder.switch_camera", "imx296")')
163163

164164

165-
166165
mountcontrol_active = True
167166

167+
168168
def is_mountcontrol_active() -> bool:
169169
"""
170170
Returns True if mount control service is active
171171
"""
172172
global mountcontrol_active
173173
return mountcontrol_active
174-
174+
175+
175176
def mountcontrol_activate() -> None:
176177
"""
177178
Activates the mount control service
@@ -180,10 +181,11 @@ def mountcontrol_activate() -> None:
180181
global mountcontrol_active
181182
mountcontrol_active = True
182183

184+
183185
def mountcontrol_deactivate() -> None:
184186
"""
185187
Deactivates the mount control service
186188
"""
187189
logger.info("SYS: Deactivating Mount Control")
188190
global mountcontrol_active
189-
mountcontrol_active= False
191+
mountcontrol_active = False

0 commit comments

Comments
 (0)