The battery function:
# Start and stop streaming functions
def get_battery():
battery0 = senTSS.getBatteryPercentageRemaining(logicalID=0)
battery1 = senTSS.getBatteryPercentageRemaining(logicalID=1)
#print("Zero:"+ str(battery0))
#print("One:"+ str(battery1))
if( battery0 != -1 and battery1 != -1):
with st.empty():
bat_percent0 = battery0[-1]
#print("Battery0:"+ str(bat_percent0))
st.write("Battery Percentage of Sensor 00:")
st.write(f"{bat_percent0}")
bat_percent1 = battery1[-1]
#print("Battery1:"+ str(bat_percent1))
st.write("Battery Percentage of Sensor 01:")
st.write(f"{bat_percent1}")
calling the battery function in the code:
if senTSS:
senTSS.comClass.sensor.reset_input_buffer()
for id in LOGICAL_IDS:
senTSS.startStreaming(logicalID=id)
last_battery_check_time = time.time()
last_time_check = time.time()
# Collect data in the background
while st.session_state.data_collection_active:
record_data(senTSS)
battery_current_time = time.time()
time_clock_time = time.time()
if battery_current_time - last_battery_check_time >= 5: # 60 seconds
get_battery() # Call get_battery function
last_battery_check_time = battery_current_time # Update last check time
if time_clock_time - last_time_check >=21600: #stops the data collection automatically after 6 hours 21600
print("Got to the timer")
stop_recording()
sleep(0.01) # Adjust this based on your desired sample rate
Currently with the st.empty function, it is not replacing the value, but continually adding a line
Is there a way to replace the value without adding lines