add vehichle force on next cycle
This commit is contained in:
+6
-2
@@ -308,9 +308,13 @@ def handle_program1():
|
|||||||
if scroll_node_active:
|
if scroll_node_active:
|
||||||
bottom_text_iteration_count += 1
|
bottom_text_iteration_count += 1
|
||||||
scroll_node_active = False
|
scroll_node_active = False
|
||||||
if s['program_vehicles_enabled'] and bottom_text_iteration_count >= config.PROGRAM2_TEXT_ITERATIONS:
|
force = s.get('force_vehicles', False)
|
||||||
|
if force:
|
||||||
|
with server._lock:
|
||||||
|
server.state['force_vehicles'] = False
|
||||||
|
if s['program_vehicles_enabled'] and (force or bottom_text_iteration_count >= config.PROGRAM2_TEXT_ITERATIONS):
|
||||||
|
if force or random.randint(0, 99) < config.PROGRAM2_TRIGGER_CHANCE:
|
||||||
bottom_text_iteration_count = 0
|
bottom_text_iteration_count = 0
|
||||||
if random.randint(0, 99) < config.PROGRAM2_TRIGGER_CHANCE:
|
|
||||||
program2_active = True
|
program2_active = True
|
||||||
reset_program2()
|
reset_program2()
|
||||||
low_level.fill_pixels(0, 9, config.DISPLAY_MAX_X, config.DISPLAY_MAX_Y, 0, 0, 0)
|
low_level.fill_pixels(0, 9, config.DISPLAY_MAX_X, config.DISPLAY_MAX_Y, 0, 0, 0)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ state = {
|
|||||||
'program_top_text_enabled': True,
|
'program_top_text_enabled': True,
|
||||||
'program_bottom_text_enabled': True,
|
'program_bottom_text_enabled': True,
|
||||||
'program_vehicles_enabled': True,
|
'program_vehicles_enabled': True,
|
||||||
|
'force_vehicles': False,
|
||||||
}
|
}
|
||||||
_lock = threading.Lock()
|
_lock = threading.Lock()
|
||||||
|
|
||||||
@@ -46,6 +47,11 @@ INDEX_HTML = """<!DOCTYPE HTML><html>
|
|||||||
.brightness-row { display: flex; align-items: center; gap: 12px; }
|
.brightness-row { display: flex; align-items: center; gap: 12px; }
|
||||||
.brightness-row input[type=range] { flex: 1; accent-color: #4CAF50; }
|
.brightness-row input[type=range] { flex: 1; accent-color: #4CAF50; }
|
||||||
.brightness-row span { min-width: 32px; text-align: right; }
|
.brightness-row span { min-width: 32px; text-align: right; }
|
||||||
|
.btn { display: block; width: 100%; padding: 14px; border: none; border-radius: 12px;
|
||||||
|
font-size: 1em; cursor: pointer; margin-bottom: 12px; transition: 0.2s; }
|
||||||
|
.btn-vehicles { background: #2a4a7f; color: #eee; }
|
||||||
|
.btn-vehicles:hover { background: #3a5a9f; }
|
||||||
|
.btn-vehicles:active { background: #1a3a6f; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -74,6 +80,7 @@ INDEX_HTML = """<!DOCTYPE HTML><html>
|
|||||||
<span id="brightnessValue">100</span>
|
<span id="brightnessValue">100</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<button class="btn btn-vehicles" onclick="forceVehicles()">Force Vehicles Next Cycle</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
@@ -110,6 +117,12 @@ INDEX_HTML = """<!DOCTYPE HTML><html>
|
|||||||
}
|
}
|
||||||
setInterval(pollDisplay, 100);
|
setInterval(pollDisplay, 100);
|
||||||
|
|
||||||
|
function forceVehicles() {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", "/force-vehicles", true);
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
|
||||||
function toggle(program, enabled) {
|
function toggle(program, enabled) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("POST", "/toggle-program", true);
|
xhr.open("POST", "/toggle-program", true);
|
||||||
@@ -191,6 +204,13 @@ def handle_toggle():
|
|||||||
return 'OK'
|
return 'OK'
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/force-vehicles', methods=['POST'])
|
||||||
|
def handle_force_vehicles():
|
||||||
|
with _lock:
|
||||||
|
state['force_vehicles'] = True
|
||||||
|
return 'OK'
|
||||||
|
|
||||||
|
|
||||||
@app.route('/program-status', methods=['GET'])
|
@app.route('/program-status', methods=['GET'])
|
||||||
def handle_status():
|
def handle_status():
|
||||||
with _lock:
|
with _lock:
|
||||||
|
|||||||
Reference in New Issue
Block a user