Made it so the config file works on the TableLaptop.py file

This commit is contained in:
wildercayden 2025-06-26 10:02:35 -04:00
parent da1f8b8d02
commit 705259f0e8

View File

@ -1,15 +1,21 @@
from networktables import NetworkTables from networktables import NetworkTables
from time import sleep from time import sleep
import configparser
NetworkTables.initialize() NetworkTables.initialize()
NetworkTables.startServer() NetworkTables.startServer()
table = NetworkTables.getTable("PiStatus") config = configparser.ConfigParser()
config.read('config.ini')
table = config.get('settings', 'tables')
table = NetworkTables.getTable(table)
print("Server started, waiting for data...") print("Server started, waiting for data...")
while True: while True:
cpu = table.getNumber("CPU Usage", -1) cpu = table.getNumber("CPU Usage", -1)
temp = table.getNumber("Temperature", -1) temp = table.getNumber("Temperature", -1)
mem = table.getNumber("Memory", -1) mem = table.getNumber("Memory", -1)
print(f"CPU: {cpu}, Temp: {temp} Mem:{mem}") print(f"CPU: {cpu}%, Temp: {temp}C Mem:{mem} MB")
sleep(1) sleep(1)