powerConsumtion function
General Library Documentation Undocument By General Corporation & Global Corporation & General Developer
Implementation
String powerConsumtion() {
final String realBatPath = () {
if (Directory(_bat1Path).existsSync()) {
return _bat1Path;
}
if (Directory(_battPath).existsSync()) {
return _battPath;
}
return _bat0Path;
}();
final num rawPower = () {
try {
{
final File filePowerNow = File(realBatPath + _powerNowFile);
if (filePowerNow.existsSync()) {
return filePowerNow._get_file_value() / 1000000;
}
}
{
return (File(realBatPath + _currentNowFile)._get_file_value() *
File(realBatPath + _voltageNowFile)._get_file_value()) /
1000000000000;
}
} catch (e) {}
return 0;
}();
final String power = rawPower.toStringAsFixed(1);
final String status = () {
try {
final data = File(realBatPath + _statusFile).readAsStringSync().trim();
if (data == "Charging") {
return "+";
} else if (data == "Full") {
return "";
} else {
return "-";
}
} catch (e) {}
return "";
}();
return ("${status}${power} W");
}