diff --git a/dingux/dingux_utils.c b/dingux/dingux_utils.c index ec4eca19f1..f9d45c5f5d 100644 --- a/dingux/dingux_utils.c +++ b/dingux/dingux_utils.c @@ -2,6 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2019-2020 - James Leaver + * Copyright (C) 2022-2022 - Jahed Ahmed * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- @@ -49,6 +50,9 @@ #define DINGUX_SCALING_SHARPNESS_ENVAR "SDL_VIDEO_KMSDRM_SCALING_SHARPNESS" #define DINGUX_VIDEO_REFRESHRATE_ENVAR "SDL_VIDEO_REFRESHRATE" +/* Miyoo defines */ +#define MIYOO_BATTERY_VOLTAGE_NOW_FILE "/sys/class/power_supply/miyoo-battery/voltage_now" + /* Enables/disables downscaling when using * the IPU hardware scaler */ bool dingux_ipu_set_downscaling_enable(bool enable) @@ -307,6 +311,24 @@ int dingux_get_battery_level(void) return -1; return (int)(((voltage_now - voltage_min) * 100) / (voltage_max - voltage_min)); +#elif defined(MIYOO) + /* miyoo-battery only provides "voltage_now". Results are based on + * value distribution while running a game at max load. */ + int voltage_now = dingux_read_battery_sys_file(MIYOO_BATTERY_VOLTAGE_NOW_FILE); + if (voltage_now < 0) return -1; // voltage_now not available + if (voltage_now > 4300) return 100; // 4320 + if (voltage_now > 4200) return 90; // 4230 + if (voltage_now > 4100) return 80; // 4140 + if (voltage_now > 4000) return 70; // 4050 + if (voltage_now > 3900) return 60; // 3960 + if (voltage_now > 3800) return 50; // 3870 + if (voltage_now > 3700) return 40; // 3780 + if (voltage_now > 3600) return 30; // 3690 + if (voltage_now > 3550) return 20; // 3600 + if (voltage_now > 3500) return 10; // 3510 + if (voltage_now > 3400) return 5; // 3420 + if (voltage_now > 3300) return 1; // 3330 + return 0; // 3240 #else return dingux_read_battery_sys_file(DINGUX_BATTERY_CAPACITY_FILE); #endif