Changes made based on pr feedback.

This commit is contained in:
PhosphorosVR
2025-09-23 01:46:53 +02:00
parent 15641753f0
commit e47735c720
8 changed files with 48 additions and 50 deletions

View File

@@ -1063,10 +1063,9 @@ def get_settings(device: OpenIrisDevice, args=None):
print("🔑 Serial/MAC: unavailable")
# Advertised Name
adv = summary.get("AdvertisedName", {})
adv_name = adv.get("advertised_name")
if adv_name:
print(f"📛 Name: {adv_name}")
advertised_name_data = summary.get("AdvertisedName", {})
if advertised_name := advertised_name_data.get("advertised_name"):
print(f"📛 Name: {advertised_name}")
# Info
info = summary.get("Info", {})
@@ -1090,12 +1089,11 @@ def get_settings(device: OpenIrisDevice, args=None):
print(f"🎚️ Mode: {mode if mode else 'unknown'}")
# Current
current = summary.get("Current", {}).get("led_current_ma")
if current is not None:
print(f"🔌 LED Current: {current:.3f} mA")
current_section = summary.get("Current", {})
if (led_current_ma := current_section.get("led_current_ma")) is not None:
print(f"🔌 LED Current: {led_current_ma:.3f} mA")
else:
err = summary.get("Current", {}).get("error")
if err:
if (err := current_section.get("error")):
print(f"🔌 LED Current: unavailable ({err})")
else:
print("🔌 LED Current: unavailable")

View File

@@ -1,4 +1,5 @@
import os
import difflib
import argparse
from typing import Dict, Optional, List
@@ -70,22 +71,9 @@ def _suggest_boards(partial: str) -> List[str]:
contains = [b for b in BOARD_CONFIGS if partial_low in b.lower()]
if contains:
return contains[:10]
# simple levenshtein distance limited (manual lightweight)
def distance(a: str, b: str) -> int:
if len(a) < len(b):
a, b = b, a
prev = list(range(len(b)+1))
for i, ca in enumerate(a, 1):
cur = [i]
for j, cb in enumerate(b, 1):
ins = cur[j-1] + 1
dele = prev[j] + 1
sub = prev[j-1] + (ca != cb)
cur.append(min(ins, dele, sub))
prev = cur
return prev[-1]
ranked = sorted(BOARD_CONFIGS, key=lambda k: distance(partial_low, k.lower()))
return ranked[:5]
# fallback to fuzzy matching using difflib
choices = list(BOARD_CONFIGS.keys())
return difflib.get_close_matches(partial, choices, n=5, cutoff=0.4)
def normalize_board_name(raw: Optional[str]) -> Optional[str]:
if raw is None: