Added charging status
This commit is contained in:
parent
22601ce0c6
commit
69ec05bb07
@ -6,6 +6,7 @@ pub const BatteryInfo = struct {
|
||||
Manufacturer: []u8,
|
||||
Model: []u8,
|
||||
Technology: []u8,
|
||||
Status: []u8,
|
||||
CellSeriesCount: u32 = 0,
|
||||
Capacity: u32 = 0,
|
||||
CapacityDesign: u32 = 0,
|
||||
@ -21,6 +22,7 @@ pub const BatteryInfo = struct {
|
||||
self._allocator.free(self.Manufacturer);
|
||||
self._allocator.free(self.Model);
|
||||
self._allocator.free(self.Technology);
|
||||
self._allocator.free(self.Status);
|
||||
}
|
||||
};
|
||||
|
||||
@ -41,11 +43,13 @@ pub fn GetBatteryInfoAlloc(allocator: std.mem.Allocator, dir: std.fs.Dir) !Batte
|
||||
const manufacturer = try _readInfo(allocator, dir, "manufacturer");
|
||||
const model = try _readInfo(allocator, dir, "model_name");
|
||||
const technology = try _readInfo(allocator, dir, "technology");
|
||||
const status = try _readInfo(allocator, dir, "status");
|
||||
|
||||
var info = BatteryInfo{
|
||||
.Manufacturer = manufacturer,
|
||||
.Model = model,
|
||||
.Technology = technology,
|
||||
.Status = status,
|
||||
._allocator = allocator,
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,7 @@ pub fn main() !void {
|
||||
|
||||
fn printBattery(battery: batinfo.BatteryInfo) !void {
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
try stdout.print("Battery {s} {s}\n", .{battery.Manufacturer, battery.Model});
|
||||
try stdout.print("Battery {s} {s} ({s})\n", .{battery.Manufacturer, battery.Model, battery.Status});
|
||||
try stdout.print("\tTechnology: {s}\n", .{battery.Technology});
|
||||
try stdout.print("\tCell series count: {}s (guessed)\n\n", .{battery.CellSeriesCount});
|
||||
try stdout.print("\tCapacity: {}%\n", .{battery.Capacity});
|
||||
|
Loading…
Reference in New Issue
Block a user