Browse files

gta04 - poll battery charge every 30s

No idea how to do this better. GTA02 was sending battery changes on
netlink socket.
  • Loading branch information...
1 parent 42e77a7 commit e4bddedd88cb74edbb507cc3b5af1c16523968e8 @radekp committed May 4, 2012
Showing with 6 additions and 0 deletions.
  1. +4 −0 devices/gta04/server/neohardware.cpp
  2. +2 −0 devices/gta04/server/neohardware.h
View
4 devices/gta04/server/neohardware.cpp
@@ -96,6 +96,7 @@ NeoHardware::NeoHardware()
ac(QPowerSource::Wall, "PrimaryAC", this)
, battery(QPowerSource::Battery, "NeoBattery", this)
, ueventSocket(this)
+ , timer(this)
{
qLog(Hardware) << "gta04 hardware";
@@ -108,6 +109,9 @@ ac(QPowerSource::Wall, "PrimaryAC", this)
hasSmartBattery =
QFile::exists("/sys/class/power_supply/bq27000-battery/status");
+ connect(&timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
+ timer.start(30 * 1000);
+
QTimer::singleShot(1, this, SLOT(updateStatus()));
}
View
2 devices/gta04/server/neohardware.h
@@ -21,6 +21,7 @@
#ifndef NEOHARDWARE_H
#define NEOHARDWARE_H
+#include <QTimer>
#include <QObject>
#include <QProcess>
#include <QTcpSocket>
@@ -48,6 +49,7 @@ class NeoHardware : public QObject
QPowerSourceProvider ac;
QPowerSourceProvider battery;
QTcpSocket ueventSocket;
+ QTimer timer;
bool hasSmartBattery;
private slots:

0 comments on commit e4bdded

Please sign in to comment.