mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 12:23:33 +00:00
feat(#188): support battery-percent header
This commit is contained in:
parent
d9ab052cbc
commit
8400c1eaf1
2 changed files with 37 additions and 2 deletions
|
|
@ -49,8 +49,9 @@ Route::get('/display', function (Request $request) {
|
|||
'last_refreshed_at' => now(),
|
||||
]);
|
||||
|
||||
if ($request->hasHeader('battery-percent')) {
|
||||
$batteryPercent = (int) $request->header('battery-percent');
|
||||
$batteryPercent = $request->header('battery-percent') ?? $request->header('percent-charged');
|
||||
if ($batteryPercent !== null) {
|
||||
$batteryPercent = (int) $batteryPercent;
|
||||
$batteryVoltage = $device->calculateVoltageFromPercent($batteryPercent);
|
||||
$device->update([
|
||||
'last_battery_voltage' => $batteryVoltage,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue