feature/analog_input (#12)
Co-authored-by: Paul Obernesser <paul.obernesser@inncubator.at> Reviewed-on: https://gitea.pstruebi.xyz/auracaster/bumble-auracast/pulls/12
This commit was merged in pull request #12.
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
import sounddevice as sd, pprint
|
||||
from auracast.utils.sounddevice_utils import devices_by_backend
|
||||
|
||||
print("PortAudio library:", sd._libname)
|
||||
print("PortAudio version:", sd.get_portaudio_version())
|
||||
print("\nHost APIs:")
|
||||
pprint.pprint(sd.query_hostapis())
|
||||
print("\nDevices:")
|
||||
pprint.pprint(sd.query_devices())
|
||||
|
||||
# Example: only PulseAudio devices on Linux
|
||||
print("\nOnly PulseAudio devices:")
|
||||
for i, d in devices_by_backend("PulseAudio"):
|
||||
print(f"{i}: {d['name']} in={d['max_input_channels']} out={d['max_output_channels']}")
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import sounddevice as sd, pprint
|
||||
from auracast.utils.sounddevice_utils import (
|
||||
devices_by_backend,
|
||||
get_alsa_inputs,
|
||||
get_alsa_usb_inputs,
|
||||
get_network_pw_inputs,
|
||||
refresh_pw_cache,
|
||||
)
|
||||
|
||||
print("PortAudio library:", sd._libname)
|
||||
print("PortAudio version:", sd.get_portaudio_version())
|
||||
|
||||
print("\nHost APIs:")
|
||||
apis = sd.query_hostapis()
|
||||
pprint.pprint(apis)
|
||||
|
||||
print("\nAll Devices (with host API name):")
|
||||
devs = sd.query_devices()
|
||||
for i, d in enumerate(devs):
|
||||
ha_name = apis[d['hostapi']]['name'] if isinstance(d.get('hostapi'), int) and d['hostapi'] < len(apis) else '?'
|
||||
if d.get('max_input_channels', 0) > 0:
|
||||
print(f"IN {i:>3}: {d['name']} api={ha_name} in={d['max_input_channels']}")
|
||||
elif d.get('max_output_channels', 0) > 0:
|
||||
print(f"OUT {i:>3}: {d['name']} api={ha_name} out={d['max_output_channels']}")
|
||||
else:
|
||||
print(f"DEV {i:>3}: {d['name']} api={ha_name} (no I/O)")
|
||||
|
||||
print("\nALSA input devices (PortAudio ALSA host):")
|
||||
for i, d in devices_by_backend('ALSA'):
|
||||
if d.get('max_input_channels', 0) > 0:
|
||||
print(f"ALSA {i:>3}: {d['name']} in={d['max_input_channels']}")
|
||||
|
||||
print("\nALSA USB-filtered inputs:")
|
||||
for i, d in get_alsa_usb_inputs():
|
||||
print(f"USB {i:>3}: {d['name']} in={d['max_input_channels']}")
|
||||
|
||||
print("\nRefreshing PipeWire caches...")
|
||||
try:
|
||||
refresh_pw_cache()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
print("PipeWire Network inputs (from cache):")
|
||||
for i, d in get_network_pw_inputs():
|
||||
print(f"NET {i:>3}: {d['name']} in={d.get('max_input_channels', 0)}")
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import csv
|
||||
import time
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from auracast.utils.read_temp import read_case_temp, read_cpu_temp
|
||||
|
||||
|
||||
def main() -> None:
|
||||
script_path = Path(__file__).resolve()
|
||||
log_dir = script_path.parent
|
||||
|
||||
start_time = datetime.now()
|
||||
filename = start_time.strftime("temperature_log_%Y%m%d_%H%M%S.csv")
|
||||
log_path = log_dir / filename
|
||||
|
||||
with log_path.open("w", newline="") as csvfile:
|
||||
writer = csv.writer(csvfile)
|
||||
writer.writerow(["timestamp", "cpu_temp_c", "case_temp_c"])
|
||||
|
||||
try:
|
||||
while True:
|
||||
now = datetime.now().isoformat(timespec="seconds")
|
||||
cpu_temp = read_cpu_temp()
|
||||
case_temp = read_case_temp()
|
||||
|
||||
writer.writerow([now, cpu_temp, case_temp])
|
||||
csvfile.flush()
|
||||
|
||||
time.sleep(30)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,8 +0,0 @@
|
||||
from smbus2 import SMBus
|
||||
addr = 0x48 # change if your scan shows different
|
||||
with SMBus(1) as bus:
|
||||
msb, lsb = bus.read_i2c_block_data(addr, 0x00, 2)
|
||||
raw = ((msb << 8) | lsb) >> 4
|
||||
if raw & 0x800: # sign bit for 12-bit
|
||||
raw -= 1 << 12
|
||||
print(f"{raw * 0.0625:.2f} °C")
|
||||
Reference in New Issue
Block a user