Added charging status

This commit is contained in:
datalore 2025-06-02 19:56:37 +02:00
parent 22601ce0c6
commit 69ec05bb07
2 changed files with 5 additions and 1 deletions

View File

@ -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,
};

View File

@ -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});