mirror of
https://git.citron-emu.org/Citron/Citron.git
synced 2025-01-22 16:46:59 +01:00
feat: Improve thermal display and build system
- Replace emoji thermal indicators with modern progress bar UI - Switch temperature source to battery sensor for better accuracy - Adjust temperature thresholds (30°C-45°C range) - Add automatic Vulkan Validation Layer download for Android - Downgrade Java/Kotlin target to 17 for wider compatibility The thermal display now shows a visual progress bar with percentage instead of emojis, making it easier to gauge system temperature at a glance. Temperature reading now comes from the battery sensor which is more reliable across devices. Build system improvements include automated VVL binary downloads and installation for Android builds when CITRON_DOWNLOAD_ANDROID_VVL is enabled. Java target downgraded to 17 to ensure compatibility with current Android toolchain.
This commit is contained in:
parent
9ae0eeeb87
commit
236ad28d61
3 changed files with 49 additions and 16 deletions
|
@ -97,7 +97,26 @@ if (ANDROID OR WIN32 OR APPLE)
|
||||||
endif()
|
endif()
|
||||||
option(ENABLE_OPENSSL "Enable OpenSSL backend for ISslConnection" ${DEFAULT_ENABLE_OPENSSL})
|
option(ENABLE_OPENSSL "Enable OpenSSL backend for ISslConnection" ${DEFAULT_ENABLE_OPENSSL})
|
||||||
|
|
||||||
# Copy the VVL arm64 binary to src/android/app/main/jniLibs. REF: https://github.com/KhronosGroup/Vulkan-ValidationLayers/actions/workflows/vvl.yml
|
if (ANDROID AND CITRON_DOWNLOAD_ANDROID_VVL)
|
||||||
|
set(vvl_version "sdk-1.3.261.1")
|
||||||
|
set(vvl_zip_file "${CMAKE_BINARY_DIR}/externals/vvl-android.zip")
|
||||||
|
if (NOT EXISTS "${vvl_zip_file}")
|
||||||
|
# Download and extract validation layer release to externals directory
|
||||||
|
set(vvl_base_url "https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases/download")
|
||||||
|
file(DOWNLOAD "${vvl_base_url}/${vvl_version}/android-binaries-${vvl_version}-android.zip"
|
||||||
|
"${vvl_zip_file}" SHOW_PROGRESS)
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${vvl_zip_file}"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Copy the arm64 binary to src/android/app/main/jniLibs only if it doesn't exist
|
||||||
|
set(vvl_lib_path "${CMAKE_CURRENT_SOURCE_DIR}/src/android/app/src/main/jniLibs/arm64-v8a/")
|
||||||
|
set(vvl_lib_file "${vvl_lib_path}/libVkLayer_khronos_validation.so")
|
||||||
|
if (NOT EXISTS "${vvl_lib_file}")
|
||||||
|
file(COPY "${CMAKE_BINARY_DIR}/externals/android-binaries-${vvl_version}/arm64-v8a/libVkLayer_khronos_validation.so"
|
||||||
|
DESTINATION "${vvl_lib_path}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set(CMAKE_SKIP_INSTALL_RULES ON)
|
set(CMAKE_SKIP_INSTALL_RULES ON)
|
||||||
|
|
|
@ -35,12 +35,12 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_21
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_21
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "21"
|
jvmTarget = "17"
|
||||||
}
|
}
|
||||||
|
|
||||||
packaging {
|
packaging {
|
||||||
|
|
|
@ -532,20 +532,20 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
!emulationViewModel.isEmulationStopping.value
|
!emulationViewModel.isEmulationStopping.value
|
||||||
) {
|
) {
|
||||||
val thermalStatus = when (powerManager.currentThermalStatus) {
|
val thermalStatus = when (powerManager.currentThermalStatus) {
|
||||||
PowerManager.THERMAL_STATUS_LIGHT -> "😥"
|
PowerManager.THERMAL_STATUS_LIGHT -> 0.25f
|
||||||
PowerManager.THERMAL_STATUS_MODERATE -> "🥵"
|
PowerManager.THERMAL_STATUS_MODERATE -> 0.5f
|
||||||
PowerManager.THERMAL_STATUS_SEVERE -> "🔥"
|
PowerManager.THERMAL_STATUS_SEVERE -> 0.75f
|
||||||
PowerManager.THERMAL_STATUS_CRITICAL,
|
PowerManager.THERMAL_STATUS_CRITICAL,
|
||||||
PowerManager.THERMAL_STATUS_EMERGENCY,
|
PowerManager.THERMAL_STATUS_EMERGENCY,
|
||||||
PowerManager.THERMAL_STATUS_SHUTDOWN -> "☢️"
|
PowerManager.THERMAL_STATUS_SHUTDOWN -> 1.0f
|
||||||
else -> "🙂"
|
else -> 0f
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get temperature in Celsius from thermal sensor
|
// Get temperature from battery thermal sensor
|
||||||
val temperature = try {
|
val temperature = try {
|
||||||
val process = Runtime.getRuntime().exec("cat /sys/class/thermal/thermal_zone0/temp")
|
val process = Runtime.getRuntime().exec("cat /sys/class/power_supply/battery/temp")
|
||||||
val reader = process.inputStream.bufferedReader()
|
val reader = process.inputStream.bufferedReader()
|
||||||
val temp = reader.readLine().toFloat() / 1000f // Convert from millicelsius to celsius
|
val temp = reader.readLine().toFloat() / 10f // Convert from decidegrees to degrees
|
||||||
reader.close()
|
reader.close()
|
||||||
temp
|
temp
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -556,16 +556,30 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
val fahrenheit = (temperature * 9f / 5f) + 32f
|
val fahrenheit = (temperature * 9f / 5f) + 32f
|
||||||
|
|
||||||
if (_binding != null) {
|
if (_binding != null) {
|
||||||
// Color interpolation based on temperature (green at 45°C, red at 85°C)
|
// Color interpolation based on temperature (green at 30°C, red at 45°C)
|
||||||
val normalizedTemp = ((temperature - 45f) / 40f).coerceIn(0f, 1f)
|
val normalizedTemp = ((temperature - 30f) / 15f).coerceIn(0f, 1f)
|
||||||
val red = (normalizedTemp * 255).toInt()
|
val red = (normalizedTemp * 255).toInt()
|
||||||
val green = ((1f - normalizedTemp) * 255).toInt()
|
val green = ((1f - normalizedTemp) * 255).toInt()
|
||||||
val color = android.graphics.Color.rgb(red, green, 0)
|
val color = android.graphics.Color.rgb(red, green, 0)
|
||||||
|
|
||||||
|
// Create a modern progress bar using block elements
|
||||||
|
val progressBarLength = 12
|
||||||
|
val filledBars = (thermalStatus * progressBarLength).toInt()
|
||||||
|
val progressBar = buildString {
|
||||||
|
append("│") // Left border
|
||||||
|
repeat(filledBars) { append("█") }
|
||||||
|
repeat(progressBarLength - filledBars) { append("░") }
|
||||||
|
append("│") // Right border
|
||||||
|
|
||||||
|
// Add percentage
|
||||||
|
append(" ")
|
||||||
|
append(String.format("%3d%%", (thermalStatus * 100).toInt()))
|
||||||
|
}
|
||||||
|
|
||||||
binding.showThermalsText.setTextColor(color)
|
binding.showThermalsText.setTextColor(color)
|
||||||
binding.showThermalsText.text = String.format(
|
binding.showThermalsText.text = String.format(
|
||||||
"%s %.1f°C\n%.1f°F",
|
"%s\n%.1f°C • %.1f°F",
|
||||||
thermalStatus,
|
progressBar,
|
||||||
temperature,
|
temperature,
|
||||||
fahrenheit
|
fahrenheit
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue