diff --git a/src/battery.cpp b/src/battery.cpp index e5d311b2..dfa09ec1 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -13,7 +13,7 @@ void BatteryStats::numBattery() { fs::path path("/sys/class/power_supply/"); for (auto& p : fs::directory_iterator(path)) { string fileName = p.path().filename(); - if (fileName.find("BAT") != std::string::npos) { + if (fileName.find("BAT") != std::string::npos || fileName.find("qcom-battmgr-bat") != std::string::npos) { battPath[batteryCount] = p.path(); batteryCount += 1; } @@ -141,6 +141,7 @@ float BatteryStats::getTimeRemaining(){ string energy_now = syspath + "/energy_now"; string voltage_now = syspath + "/voltage_now"; string power_now = syspath + "/power_now"; + string time_to_empty_avg = syspath + "/time_to_empty_avg"; if (fs::exists(current_now)) { std::ifstream input(current_now); @@ -185,6 +186,14 @@ float BatteryStats::getTimeRemaining(){ } if (current_now_vec.size() > 25) current_now_vec.erase(current_now_vec.begin()); + if (fs::exists(time_to_empty_avg)) { + std::ifstream input(time_to_empty_avg); + std::string line; + if(std::getline(input, line)) { + return std::stof(line) / 3600; + } + } + } for(auto& current_now : current_now_vec){ diff --git a/src/msm.cpp b/src/msm.cpp index c21127f5..bccc592f 100644 --- a/src/msm.cpp +++ b/src/msm.cpp @@ -54,6 +54,32 @@ void MSM::find_fd() { } closedir(dir); + + if (!fs::exists("/sys/class/devfreq/")) { + return; + } + + fs::path path("/sys/class/devfreq/"); + gpu_clock_path = ""; + for (auto& p : fs::directory_iterator(path)) { + std::string fileName = p.path().filename(); + if (fileName.find("gpu") != std::string::npos) { + gpu_clock_path = p.path(); + } + } +} + +uint16_t MSM::get_gpu_clock() { + if (gpu_clock_path.empty()){ + return 0; + } + + std::ifstream input(gpu_clock_path + "/cur_freq"); + std::string line; + if(std::getline(input,line)) { + return stoi(line) / 1000000; + } + return 0; } void MSM::get_fdinfo() { @@ -69,6 +95,7 @@ void MSM::get_fdinfo() { result = 100; gpu_info_msm.load = result; + gpu_info_msm.CoreClock = get_gpu_clock(); previous_gpu_time = gpu_time_now; previous_time = now; } else { diff --git a/src/msm.h b/src/msm.h index e8c2a1e1..d13a7cd2 100644 --- a/src/msm.h +++ b/src/msm.h @@ -7,8 +7,10 @@ class MSM { private: struct gpuInfo gpu_info_msm {}; std::vector fdinfo; + std::string gpu_clock_path; void find_fd(); uint64_t get_gpu_time(); + uint16_t get_gpu_clock(); void get_fdinfo(); public: