mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-15 11:31:16 +01:00
33 lines
783 B
Java
33 lines
783 B
Java
package nodomain.freeyourgadget.gadgetbridge.miband;
|
|
|
|
public class BatteryInfo extends AbstractInfo {
|
|
public BatteryInfo(byte[] data) {
|
|
super(data);
|
|
}
|
|
|
|
public int getLevelInPercent() {
|
|
if (mData.length >= 1) {
|
|
return mData[0];
|
|
}
|
|
return 50; // actually unknown
|
|
}
|
|
|
|
// TODO: localization
|
|
public String getStatus() {
|
|
if (mData.length >= 10) {
|
|
int value = mData[9];
|
|
switch (value) {
|
|
case 1:
|
|
return "low";
|
|
case 2:
|
|
return "medium";
|
|
case 3:
|
|
return "full";
|
|
case 4:
|
|
return "not charging";
|
|
}
|
|
}
|
|
return "(unknown)";
|
|
}
|
|
}
|