From 236ad28d61d94d0848c863e2cefa168f75813f49 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Wed, 15 Jan 2025 16:44:07 +1000 Subject: feat: Improve thermal display and build system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- src/android/app/build.gradle.kts | 6 ++-- .../citron_emu/fragments/EmulationFragment.kt | 38 +++++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) (limited to 'src/android') diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts index 93c1bc798..1c740013e 100644 --- a/src/android/app/build.gradle.kts +++ b/src/android/app/build.gradle.kts @@ -35,12 +35,12 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "21" + jvmTarget = "17" } packaging { diff --git a/src/android/app/src/main/java/org/citron/citron_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/citron/citron_emu/fragments/EmulationFragment.kt index 57e4e37d8..a01530079 100644 --- a/src/android/app/src/main/java/org/citron/citron_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/citron/citron_emu/fragments/EmulationFragment.kt @@ -532,20 +532,20 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { !emulationViewModel.isEmulationStopping.value ) { val thermalStatus = when (powerManager.currentThermalStatus) { - PowerManager.THERMAL_STATUS_LIGHT -> "😥" - PowerManager.THERMAL_STATUS_MODERATE -> "🥵" - PowerManager.THERMAL_STATUS_SEVERE -> "🔥" + PowerManager.THERMAL_STATUS_LIGHT -> 0.25f + PowerManager.THERMAL_STATUS_MODERATE -> 0.5f + PowerManager.THERMAL_STATUS_SEVERE -> 0.75f PowerManager.THERMAL_STATUS_CRITICAL, PowerManager.THERMAL_STATUS_EMERGENCY, - PowerManager.THERMAL_STATUS_SHUTDOWN -> "☢️" - else -> "🙂" + PowerManager.THERMAL_STATUS_SHUTDOWN -> 1.0f + else -> 0f } - // Get temperature in Celsius from thermal sensor + // Get temperature from battery thermal sensor 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 temp = reader.readLine().toFloat() / 1000f // Convert from millicelsius to celsius + val temp = reader.readLine().toFloat() / 10f // Convert from decidegrees to degrees reader.close() temp } catch (e: Exception) { @@ -556,16 +556,30 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { val fahrenheit = (temperature * 9f / 5f) + 32f if (_binding != null) { - // Color interpolation based on temperature (green at 45°C, red at 85°C) - val normalizedTemp = ((temperature - 45f) / 40f).coerceIn(0f, 1f) + // Color interpolation based on temperature (green at 30°C, red at 45°C) + val normalizedTemp = ((temperature - 30f) / 15f).coerceIn(0f, 1f) val red = (normalizedTemp * 255).toInt() val green = ((1f - normalizedTemp) * 255).toInt() 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.text = String.format( - "%s %.1f°C\n%.1f°F", - thermalStatus, + "%s\n%.1f°C • %.1f°F", + progressBar, temperature, fahrenheit ) -- cgit v1.2.3