summaryrefslogtreecommitdiff
path: root/src/up-device-battery.h
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2022-06-07 16:20:31 +0200
committerBenjamin Berg <bberg@redhat.com>2022-06-21 11:15:57 +0200
commitd672eb1d908bcd7534ac325421f7841bd1dfec15 (patch)
treea4444b2ebfcf22f191cd5d8db0b5438a19feeae4 /src/up-device-battery.h
parentc6cd9beff30588be711c3dd22d30f0496b210e1f (diff)
downloadupower-d672eb1d908bcd7534ac325421f7841bd1dfec15.tar.gz
Add generic UpDeviceBattery base class
This class can handle laptop battery related quirks and estimations.
Diffstat (limited to 'src/up-device-battery.h')
-rw-r--r--src/up-device-battery.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/up-device-battery.h b/src/up-device-battery.h
new file mode 100644
index 0000000..94cfcc9
--- /dev/null
+++ b/src/up-device-battery.h
@@ -0,0 +1,93 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2022 Benjamin Berg <bberg@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#pragma once
+
+#include "up-device.h"
+
+G_BEGIN_DECLS
+
+#define MAX_DISCHARGE_RATE 300
+
+#define UP_TYPE_DEVICE_BATTERY (up_device_battery_get_type ())
+
+G_DECLARE_DERIVABLE_TYPE (UpDeviceBattery, up_device_battery, UP, DEVICE_BATTERY, UpDevice)
+
+struct _UpDeviceBatteryClass
+{
+ UpDeviceClass parent_class;
+};
+
+typedef enum {
+ UP_BATTERY_UNIT_UNDEFINED = 0,
+ UP_BATTERY_UNIT_ENERGY,
+ UP_BATTERY_UNIT_CHARGE,
+} UpBatteryUnits;
+
+typedef struct {
+ gint64 ts_us;
+ UpDeviceState state;
+ UpBatteryUnits units;
+
+ union {
+ struct {
+ gdouble cur;
+ gdouble rate;
+ } energy;
+ struct {
+ gdouble cur;
+ gdouble rate;
+ } charge;
+ };
+ gdouble percentage;
+ gdouble voltage;
+ gdouble temperature;
+} UpBatteryValues;
+
+typedef struct {
+ gboolean present;
+
+ const char *vendor;
+ const char *model;
+ const char *serial;
+
+ UpBatteryUnits units;
+
+ union {
+ struct {
+ gdouble full;
+ gdouble design;
+ } energy;
+ struct {
+ gdouble full;
+ gdouble design;
+ } charge;
+ };
+
+ UpDeviceTechnology technology;
+ gdouble voltage_design;
+ gint charge_cycles;
+} UpBatteryInfo;
+
+
+void up_device_battery_update_info (UpDeviceBattery *self, UpBatteryInfo *info);
+void up_device_battery_report (UpDeviceBattery *self, UpBatteryValues *values, UpRefreshReason reason);
+
+G_END_DECLS