mirror of
https://github.com/pdxlocations/contact.git
synced 2026-03-28 17:12:35 +01:00
Compare commits
3 Commits
single-pan
...
1.4.16
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45626f5e83 | ||
|
|
e9181972b2 | ||
|
|
795ab84ef5 |
@@ -5,9 +5,10 @@ import shutil
|
||||
import time
|
||||
import subprocess
|
||||
import threading
|
||||
from typing import Any, Dict, Optional
|
||||
# Debounce notification sounds so a burst of queued messages only plays once.
|
||||
_SOUND_DEBOUNCE_SECONDS = 0.8
|
||||
_sound_timer: threading.Timer | None = None
|
||||
_sound_timer: Optional[threading.Timer] = None
|
||||
_sound_timer_lock = threading.Lock()
|
||||
_last_sound_request = 0.0
|
||||
|
||||
@@ -42,8 +43,6 @@ def schedule_notification_sound(delay: float = _SOUND_DEBOUNCE_SECONDS) -> None:
|
||||
_sound_timer = threading.Timer(delay, _fire, args=(now,))
|
||||
_sound_timer.daemon = True
|
||||
_sound_timer.start()
|
||||
from typing import Any, Dict
|
||||
|
||||
from contact.utilities.utils import (
|
||||
refresh_node_list,
|
||||
add_new_message,
|
||||
|
||||
@@ -18,7 +18,7 @@ from contact.ui.nav_utils import move_main_highlight, draw_main_arrows, get_msg_
|
||||
from contact.utilities.singleton import ui_state, interface_state, menu_state
|
||||
|
||||
|
||||
MIN_COL = 2 # keep hidden panes at least border-safe for curses
|
||||
MIN_COL = 1 # "effectively zero" without breaking curses
|
||||
root_win = None
|
||||
|
||||
|
||||
@@ -48,18 +48,14 @@ def compute_widths(total_w: int, focus: int):
|
||||
# tiny terminals: allocate something, anything
|
||||
return max(1, total_w), 0, 0
|
||||
|
||||
hidden_w = MIN_COL
|
||||
if focus == 0:
|
||||
return total_w - 2 * hidden_w, hidden_w, hidden_w
|
||||
return total_w - 2 * MIN_COL, MIN_COL, MIN_COL
|
||||
if focus == 1:
|
||||
return hidden_w, total_w - 2 * hidden_w, hidden_w
|
||||
return hidden_w, hidden_w, total_w - 2 * hidden_w
|
||||
return MIN_COL, total_w - 2 * MIN_COL, MIN_COL
|
||||
return MIN_COL, MIN_COL, total_w - 2 * MIN_COL
|
||||
|
||||
|
||||
def paint_frame(win, selected: bool) -> None:
|
||||
h, w = win.getmaxyx()
|
||||
if h < 2 or w < 2:
|
||||
return
|
||||
win.attrset(get_color("window_frame_selected") if selected else get_color("window_frame"))
|
||||
win.box()
|
||||
win.attrset(get_color("window_frame"))
|
||||
@@ -145,22 +141,9 @@ def handle_resize(stdscr: curses.window, firstrun: bool) -> None:
|
||||
packetlog_win.resize(pkt_h, messages_width)
|
||||
packetlog_win.mvwin(height - pkt_h - entry_height, channel_width)
|
||||
|
||||
# Draw only currently relevant borders in single-pane mode.
|
||||
if ui_state.single_pane_mode:
|
||||
target_wins = [entry_win]
|
||||
if ui_state.current_window == 0:
|
||||
target_wins.append(channel_win)
|
||||
elif ui_state.current_window == 1:
|
||||
target_wins.append(messages_win)
|
||||
else:
|
||||
target_wins.append(nodes_win)
|
||||
else:
|
||||
target_wins = [channel_win, entry_win, nodes_win, messages_win]
|
||||
|
||||
for win in target_wins:
|
||||
h, w = win.getmaxyx()
|
||||
if h >= 2 and w >= 2:
|
||||
win.box()
|
||||
# Draw window borders
|
||||
for win in [channel_win, entry_win, nodes_win, messages_win]:
|
||||
win.box()
|
||||
win.refresh()
|
||||
|
||||
entry_win.keypad(True)
|
||||
|
||||
@@ -435,16 +435,10 @@ def draw_main_arrows(win: object, max_index: int, window: int, **kwargs) -> None
|
||||
usable_height = height - 2
|
||||
usable_width = width - 2
|
||||
|
||||
if usable_height <= 0 or usable_width <= 0:
|
||||
return
|
||||
|
||||
if window == 1 and ui_state.display_log:
|
||||
if log_height := kwargs.get("log_height"):
|
||||
usable_height -= log_height - 1
|
||||
|
||||
if usable_height <= 0:
|
||||
return
|
||||
|
||||
if usable_height < max_index:
|
||||
if ui_state.start_index[window] > 0:
|
||||
win.addstr(1, usable_width, "▲", get_color("settings_default"))
|
||||
|
||||
@@ -68,19 +68,19 @@ def get_chunks(data):
|
||||
# Leave it string as last resort
|
||||
value = value
|
||||
|
||||
match key:
|
||||
# Python 3.9-compatible alternative to match/case.
|
||||
if key == "uptime_seconds":
|
||||
# convert seconds to hours, for our sanity
|
||||
case "uptime_seconds":
|
||||
value = round(value / 60 / 60, 1)
|
||||
value = round(value / 60 / 60, 1)
|
||||
elif key in ("longitude_i", "latitude_i"):
|
||||
# Convert position to degrees (humanize), as per Meshtastic protobuf comment for this telemetry
|
||||
# truncate to 6th digit after floating point, which would be still accurate
|
||||
case "longitude_i" | "latitude_i":
|
||||
value = round(value * 1e-7, 6)
|
||||
value = round(value * 1e-7, 6)
|
||||
elif key == "wind_direction":
|
||||
# Convert wind direction from degrees to abbreviation
|
||||
case "wind_direction":
|
||||
value = humanize_wind_direction(value)
|
||||
case "time":
|
||||
value = datetime.datetime.fromtimestamp(int(value)).strftime("%d.%m.%Y %H:%m")
|
||||
value = humanize_wind_direction(value)
|
||||
elif key == "time":
|
||||
value = datetime.datetime.fromtimestamp(int(value)).strftime("%d.%m.%Y %H:%m")
|
||||
|
||||
if key in sensors:
|
||||
parsed+= f"{sensors[key.strip()]['icon']}{value}{sensors[key]['unit']} "
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "contact"
|
||||
version = "1.4.14"
|
||||
version = "1.4.16"
|
||||
description = "This Python curses client for Meshtastic is a terminal-based client designed to manage device settings, enable mesh chat communication, and handle configuration backups and restores."
|
||||
authors = [
|
||||
{name = "Ben Lipsey",email = "ben@pdxlocations.com"}
|
||||
|
||||
Reference in New Issue
Block a user