Update app.py
Browse files
app.py
CHANGED
|
@@ -46,6 +46,43 @@ if 'coolant_p' not in st.session_state:
|
|
| 46 |
if 'oil_temp' not in st.session_state:
|
| 47 |
st.session_state.oil_temp = 80.0
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
# --- CUSTOM CSS ---
|
| 50 |
st.markdown("""
|
| 51 |
<style>
|
|
@@ -381,15 +418,9 @@ def main():
|
|
| 381 |
|
| 382 |
input_col1, input_col2 = st.columns([1, 3])
|
| 383 |
with input_col1:
|
| 384 |
-
|
| 385 |
with input_col2:
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
# Update session state from whichever changed
|
| 389 |
-
if rpm_num != st.session_state.rpm:
|
| 390 |
-
st.session_state.rpm = rpm_num
|
| 391 |
-
if rpm_sld != st.session_state.rpm:
|
| 392 |
-
st.session_state.rpm = rpm_sld
|
| 393 |
|
| 394 |
st.markdown(f'<div class="param-value-display" style="color: #00d4ff;">{st.session_state.rpm}</div>', unsafe_allow_html=True)
|
| 395 |
st.plotly_chart(create_gauge(st.session_state.rpm, 2500, "#00d4ff"), use_container_width=True, config={'displayModeBar': False}, key="g_rpm")
|
|
@@ -401,14 +432,9 @@ def main():
|
|
| 401 |
|
| 402 |
input_col1, input_col2 = st.columns([1, 3])
|
| 403 |
with input_col1:
|
| 404 |
-
|
| 405 |
with input_col2:
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
if fuel_num != st.session_state.fuel_p:
|
| 409 |
-
st.session_state.fuel_p = fuel_num
|
| 410 |
-
if fuel_sld != st.session_state.fuel_p:
|
| 411 |
-
st.session_state.fuel_p = fuel_sld
|
| 412 |
|
| 413 |
st.markdown(f'<div class="param-value-display" style="color: #ff6b35;">{st.session_state.fuel_p:.1f}</div>', unsafe_allow_html=True)
|
| 414 |
st.plotly_chart(create_gauge(st.session_state.fuel_p, 25, "#ff6b35"), use_container_width=True, config={'displayModeBar': False}, key="g_fuel")
|
|
@@ -423,14 +449,9 @@ def main():
|
|
| 423 |
|
| 424 |
input_col1, input_col2 = st.columns([1, 3])
|
| 425 |
with input_col1:
|
| 426 |
-
|
| 427 |
with input_col2:
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
if oil_p_num != st.session_state.oil_p:
|
| 431 |
-
st.session_state.oil_p = oil_p_num
|
| 432 |
-
if oil_p_sld != st.session_state.oil_p:
|
| 433 |
-
st.session_state.oil_p = oil_p_sld
|
| 434 |
|
| 435 |
st.markdown(f'<div class="param-value-display" style="color: #ffaa00;">{st.session_state.oil_p:.2f}</div>', unsafe_allow_html=True)
|
| 436 |
st.plotly_chart(create_gauge(st.session_state.oil_p, 10, "#ffaa00"), use_container_width=True, config={'displayModeBar': False}, key="g_oil_p")
|
|
@@ -442,14 +463,9 @@ def main():
|
|
| 442 |
|
| 443 |
input_col1, input_col2 = st.columns([1, 3])
|
| 444 |
with input_col1:
|
| 445 |
-
|
| 446 |
with input_col2:
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
if coolant_t_num != st.session_state.coolant_temp:
|
| 450 |
-
st.session_state.coolant_temp = coolant_t_num
|
| 451 |
-
if coolant_t_sld != st.session_state.coolant_temp:
|
| 452 |
-
st.session_state.coolant_temp = coolant_t_sld
|
| 453 |
|
| 454 |
st.markdown(f'<div class="param-value-display" style="color: #ff3366;">{st.session_state.coolant_temp:.1f}</div>', unsafe_allow_html=True)
|
| 455 |
st.plotly_chart(create_gauge(st.session_state.coolant_temp, 200, "#ff3366"), use_container_width=True, config={'displayModeBar': False}, key="g_coolant_t")
|
|
@@ -464,14 +480,9 @@ def main():
|
|
| 464 |
|
| 465 |
input_col1, input_col2 = st.columns([1, 3])
|
| 466 |
with input_col1:
|
| 467 |
-
|
| 468 |
with input_col2:
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
if coolant_p_num != st.session_state.coolant_p:
|
| 472 |
-
st.session_state.coolant_p = coolant_p_num
|
| 473 |
-
if coolant_p_sld != st.session_state.coolant_p:
|
| 474 |
-
st.session_state.coolant_p = coolant_p_sld
|
| 475 |
|
| 476 |
st.markdown(f'<div class="param-value-display" style="color: #00ff88;">{st.session_state.coolant_p:.2f}</div>', unsafe_allow_html=True)
|
| 477 |
st.plotly_chart(create_gauge(st.session_state.coolant_p, 10, "#00ff88"), use_container_width=True, config={'displayModeBar': False}, key="g_coolant_p")
|
|
@@ -483,14 +494,9 @@ def main():
|
|
| 483 |
|
| 484 |
input_col1, input_col2 = st.columns([1, 3])
|
| 485 |
with input_col1:
|
| 486 |
-
|
| 487 |
with input_col2:
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
if oil_t_num != st.session_state.oil_temp:
|
| 491 |
-
st.session_state.oil_temp = oil_t_num
|
| 492 |
-
if oil_t_sld != st.session_state.oil_temp:
|
| 493 |
-
st.session_state.oil_temp = oil_t_sld
|
| 494 |
|
| 495 |
st.markdown(f'<div class="param-value-display" style="color: #a855f7;">{st.session_state.oil_temp:.1f}</div>', unsafe_allow_html=True)
|
| 496 |
st.plotly_chart(create_gauge(st.session_state.oil_temp, 150, "#a855f7"), use_container_width=True, config={'displayModeBar': False}, key="g_oil_t")
|
|
|
|
| 46 |
if 'oil_temp' not in st.session_state:
|
| 47 |
st.session_state.oil_temp = 80.0
|
| 48 |
|
| 49 |
+
# Callback functions to sync values
|
| 50 |
+
def update_rpm_from_num():
|
| 51 |
+
st.session_state.rpm = st.session_state.rpm_num
|
| 52 |
+
|
| 53 |
+
def update_rpm_from_sld():
|
| 54 |
+
st.session_state.rpm = st.session_state.rpm_sld
|
| 55 |
+
|
| 56 |
+
def update_fuel_from_num():
|
| 57 |
+
st.session_state.fuel_p = st.session_state.fuel_num
|
| 58 |
+
|
| 59 |
+
def update_fuel_from_sld():
|
| 60 |
+
st.session_state.fuel_p = st.session_state.fuel_sld
|
| 61 |
+
|
| 62 |
+
def update_oil_p_from_num():
|
| 63 |
+
st.session_state.oil_p = st.session_state.oil_p_num
|
| 64 |
+
|
| 65 |
+
def update_oil_p_from_sld():
|
| 66 |
+
st.session_state.oil_p = st.session_state.oil_p_sld
|
| 67 |
+
|
| 68 |
+
def update_coolant_t_from_num():
|
| 69 |
+
st.session_state.coolant_temp = st.session_state.coolant_t_num
|
| 70 |
+
|
| 71 |
+
def update_coolant_t_from_sld():
|
| 72 |
+
st.session_state.coolant_temp = st.session_state.coolant_t_sld
|
| 73 |
+
|
| 74 |
+
def update_coolant_p_from_num():
|
| 75 |
+
st.session_state.coolant_p = st.session_state.coolant_p_num
|
| 76 |
+
|
| 77 |
+
def update_coolant_p_from_sld():
|
| 78 |
+
st.session_state.coolant_p = st.session_state.coolant_p_sld
|
| 79 |
+
|
| 80 |
+
def update_oil_t_from_num():
|
| 81 |
+
st.session_state.oil_temp = st.session_state.oil_t_num
|
| 82 |
+
|
| 83 |
+
def update_oil_t_from_sld():
|
| 84 |
+
st.session_state.oil_temp = st.session_state.oil_t_sld
|
| 85 |
+
|
| 86 |
# --- CUSTOM CSS ---
|
| 87 |
st.markdown("""
|
| 88 |
<style>
|
|
|
|
| 418 |
|
| 419 |
input_col1, input_col2 = st.columns([1, 3])
|
| 420 |
with input_col1:
|
| 421 |
+
st.number_input("", 0, 2500, value=st.session_state.rpm, step=50, key="rpm_num", label_visibility="collapsed", on_change=update_rpm_from_num)
|
| 422 |
with input_col2:
|
| 423 |
+
st.slider("", 0, 2500, value=st.session_state.rpm, step=50, key="rpm_sld", label_visibility="collapsed", on_change=update_rpm_from_sld)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
|
| 425 |
st.markdown(f'<div class="param-value-display" style="color: #00d4ff;">{st.session_state.rpm}</div>', unsafe_allow_html=True)
|
| 426 |
st.plotly_chart(create_gauge(st.session_state.rpm, 2500, "#00d4ff"), use_container_width=True, config={'displayModeBar': False}, key="g_rpm")
|
|
|
|
| 432 |
|
| 433 |
input_col1, input_col2 = st.columns([1, 3])
|
| 434 |
with input_col1:
|
| 435 |
+
st.number_input("", 0.0, 25.0, value=st.session_state.fuel_p, step=0.1, key="fuel_num", label_visibility="collapsed", on_change=update_fuel_from_num)
|
| 436 |
with input_col2:
|
| 437 |
+
st.slider("", 0.0, 25.0, value=st.session_state.fuel_p, step=0.1, key="fuel_sld", label_visibility="collapsed", on_change=update_fuel_from_sld)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
|
| 439 |
st.markdown(f'<div class="param-value-display" style="color: #ff6b35;">{st.session_state.fuel_p:.1f}</div>', unsafe_allow_html=True)
|
| 440 |
st.plotly_chart(create_gauge(st.session_state.fuel_p, 25, "#ff6b35"), use_container_width=True, config={'displayModeBar': False}, key="g_fuel")
|
|
|
|
| 449 |
|
| 450 |
input_col1, input_col2 = st.columns([1, 3])
|
| 451 |
with input_col1:
|
| 452 |
+
st.number_input("", 0.0, 10.0, value=st.session_state.oil_p, step=0.1, key="oil_p_num", label_visibility="collapsed", on_change=update_oil_p_from_num)
|
| 453 |
with input_col2:
|
| 454 |
+
st.slider("", 0.0, 10.0, value=st.session_state.oil_p, step=0.1, key="oil_p_sld", label_visibility="collapsed", on_change=update_oil_p_from_sld)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
|
| 456 |
st.markdown(f'<div class="param-value-display" style="color: #ffaa00;">{st.session_state.oil_p:.2f}</div>', unsafe_allow_html=True)
|
| 457 |
st.plotly_chart(create_gauge(st.session_state.oil_p, 10, "#ffaa00"), use_container_width=True, config={'displayModeBar': False}, key="g_oil_p")
|
|
|
|
| 463 |
|
| 464 |
input_col1, input_col2 = st.columns([1, 3])
|
| 465 |
with input_col1:
|
| 466 |
+
st.number_input("", 0.0, 200.0, value=st.session_state.coolant_temp, step=1.0, key="coolant_t_num", label_visibility="collapsed", on_change=update_coolant_t_from_num)
|
| 467 |
with input_col2:
|
| 468 |
+
st.slider("", 0.0, 200.0, value=st.session_state.coolant_temp, step=1.0, key="coolant_t_sld", label_visibility="collapsed", on_change=update_coolant_t_from_sld)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 469 |
|
| 470 |
st.markdown(f'<div class="param-value-display" style="color: #ff3366;">{st.session_state.coolant_temp:.1f}</div>', unsafe_allow_html=True)
|
| 471 |
st.plotly_chart(create_gauge(st.session_state.coolant_temp, 200, "#ff3366"), use_container_width=True, config={'displayModeBar': False}, key="g_coolant_t")
|
|
|
|
| 480 |
|
| 481 |
input_col1, input_col2 = st.columns([1, 3])
|
| 482 |
with input_col1:
|
| 483 |
+
st.number_input("", 0.0, 10.0, value=st.session_state.coolant_p, step=0.1, key="coolant_p_num", label_visibility="collapsed", on_change=update_coolant_p_from_num)
|
| 484 |
with input_col2:
|
| 485 |
+
st.slider("", 0.0, 10.0, value=st.session_state.coolant_p, step=0.1, key="coolant_p_sld", label_visibility="collapsed", on_change=update_coolant_p_from_sld)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
|
| 487 |
st.markdown(f'<div class="param-value-display" style="color: #00ff88;">{st.session_state.coolant_p:.2f}</div>', unsafe_allow_html=True)
|
| 488 |
st.plotly_chart(create_gauge(st.session_state.coolant_p, 10, "#00ff88"), use_container_width=True, config={'displayModeBar': False}, key="g_coolant_p")
|
|
|
|
| 494 |
|
| 495 |
input_col1, input_col2 = st.columns([1, 3])
|
| 496 |
with input_col1:
|
| 497 |
+
st.number_input("", 0.0, 150.0, value=st.session_state.oil_temp, step=1.0, key="oil_t_num", label_visibility="collapsed", on_change=update_oil_t_from_num)
|
| 498 |
with input_col2:
|
| 499 |
+
st.slider("", 0.0, 150.0, value=st.session_state.oil_temp, step=1.0, key="oil_t_sld", label_visibility="collapsed", on_change=update_oil_t_from_sld)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
|
| 501 |
st.markdown(f'<div class="param-value-display" style="color: #a855f7;">{st.session_state.oil_temp:.1f}</div>', unsafe_allow_html=True)
|
| 502 |
st.plotly_chart(create_gauge(st.session_state.oil_temp, 150, "#a855f7"), use_container_width=True, config={'displayModeBar': False}, key="g_oil_t")
|