Skip to content

Commit b70c684

Browse files
authored
Merge pull request #1124 from chrisj951/development-chrisj951
Minor bug Fix / SmartProS OSD/Screen fixes
2 parents 0df0ed2 + 7a8e685 commit b70c684

File tree

6 files changed

+42
-32
lines changed

6 files changed

+42
-32
lines changed

App/PyUI/main-ui/devices/miyoo/flip/miyoo_flip.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -299,35 +299,6 @@ def _set_hue_to_config(self):
299299
ProcessRunner.run(["modetest", "-M", "rockchip", "-a", "-w",
300300
"179:hue:"+str(self.system_config.hue * 5)])
301301

302-
303-
#This was from ChatGPT and might be able to be modified to get the current display
304-
#but currently its capturing an old one which just says Loading...
305-
def capture_kmsdrm_png(self, output_path="/tmp/screenshot.png", fb_path="/dev/fb0"):
306-
logger = PyUiLogger.get_logger()
307-
308-
# Read width/height/stride from sysfs if possible
309-
try:
310-
with open("/sys/class/graphics/fb0/virtual_size", "r") as f:
311-
width_str, height_str = f.read().strip().split(",")
312-
width, height = int(width_str), int(height_str)
313-
with open("/sys/class/graphics/fb0/stride", "r") as f:
314-
stride = int(f.read().strip())
315-
except Exception as e:
316-
logger.warning(f"Failed to read fb0 sysfs info: {e}, using defaults")
317-
width, height, stride = 640, 480, 2560
318-
319-
# Open framebuffer for reading
320-
frame_bytes = bytearray()
321-
with open(fb_path, "rb") as fb:
322-
for _ in range(height):
323-
row = fb.read(stride)
324-
frame_bytes.extend(row[:width*4]) # slice only visible pixels
325-
326-
# Convert BGRA to RGBA
327-
img = Image.frombytes("RGBA", (width, height), bytes(frame_bytes), "raw", "BGRA")
328-
img.save(output_path)
329-
logger.info(f"Framebuffer saved to {output_path} ({width}x{height})")
330-
return output_path
331302

332303
def _take_snapshot(self, path):
333304
ProcessRunner.run(["/mnt/sdcard/spruce/flip/screenshot.sh", path])

App/PyUI/main-ui/devices/trimui/trim_ui_smart_pro_s.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from pathlib import Path
55
import threading
6+
import time
67
from audio.audio_player_delegate_sdl2 import AudioPlayerDelegateSdl2
78
from controller.controller_inputs import ControllerInput
89
from controller.key_state import KeyState
@@ -270,3 +271,23 @@ def enable_bluetooth(self):
270271
stdout=subprocess.DEVNULL,
271272
stderr=subprocess.DEVNULL)
272273
self.system_config.set_bluetooth(1)
274+
275+
def _signal_osd_quit(self):
276+
os.makedirs("/tmp/trimui_osd", exist_ok=True)
277+
open("/tmp/trimui_osd/osdd_quit", "a").close()
278+
time.sleep(1)
279+
280+
def power_off(self):
281+
Display.display_message("Powering off...")
282+
self._signal_osd_quit()
283+
self.run_cmd([self.power_off_cmd()])
284+
# So we dont update the display while shutting down
285+
time.sleep(10)
286+
287+
288+
def reboot(self):
289+
Display.display_message("Rebooting...")
290+
self._signal_osd_quit()
291+
self.run_cmd([self.reboot_cmd()])
292+
# So we dont update the display while rebooting
293+
time.sleep(10)

App/PyUI/main-ui/views/carousel_view.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,14 @@ def get_selection(self, select_controller_inputs = [ControllerInput.A]):
383383
self.adjust_selected(1, skip_by_letter=False)
384384
elif Controller.last_input() == ControllerInput.L1:
385385
if(Theme.skip_main_menu()):
386+
Display.restore_bg()
386387
return Selection(self.get_selected_option(),Controller.last_input(), self.selected)
387388
else:
388389
self.skip_next_animation = True
389390
self.adjust_selected(-1* self.cols, skip_by_letter=False)
390391
elif Controller.last_input() == ControllerInput.R1:
391392
if(Theme.skip_main_menu()):
393+
Display.restore_bg()
392394
return Selection(self.get_selected_option(),Controller.last_input(), self.selected)
393395
else:
394396
self.skip_next_animation = True

spruce/scripts/platform/device.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,8 @@ save_volume_to_config_file() {
290290

291291
# Update MainUI Config file
292292
sed -i "s/\"vol\":\s*\([0-9]*\)/\"vol\": $VOLUME_LV/" "$SYSTEM_JSON"
293+
}
294+
295+
device_prepare_for_poweroff() {
296+
log_message "Missing device_prepare_for_poweroff function" -v
293297
}

spruce/scripts/platform/device_functions/SmartProS.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,17 @@ set_volume() {
8888
amixer set DAC "$scaled"
8989

9090
if [ "$SAVE_TO_CONFIG" = true ]; then
91-
save_volume_to_config_file "$new_vol"
92-
sed -i "s/\"vol\":[[:space:]]*[0-9]\+/\"vol\": $new_vol/" /mnt/UDISK/system.json
91+
current_volume=$(jq -r '.vol' "$SYSTEM_JSON")
92+
93+
if [ "$current_volume" -ne "$new_vol" ]; then
94+
save_volume_to_config_file "$new_vol"
95+
sed -i "s/\"vol\":[[:space:]]*[0-9]\+/\"vol\": $new_vol/" /mnt/UDISK/system.json
96+
if ! pgrep MainUI >/dev/null; then
97+
/usr/trimui/osd/show_volume_msg.sh "$new_vol" &
98+
fi
99+
fi
93100
fi
94101

95-
/usr/trimui/osd/show_volume_msg.sh "$new_vol" &
96102
}
97103

98104

@@ -440,4 +446,8 @@ device_run_tsps_blobs() {
440446
if [ "$custom_thermal_watchdog" != "Custom" ]; then
441447
run_trimui_blobs "thermald"
442448
fi
449+
}
450+
451+
device_prepare_for_poweroff() {
452+
touch /tmp/trimui_osd/osdd_quit
443453
}

spruce/scripts/save_poweroff.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
killall -q -15 runtime.sh
88
killall -q -15 principal.sh
99

10+
device_prepare_for_poweroff
11+
1012
# Ensure PyUI message writer can run
1113
killall -q -9 MainUI
1214
sleep 0.5

0 commit comments

Comments
 (0)