Commit 97b4d1f6 authored by Radek Polak's avatar Radek Polak

gta04 - charging log interval

parent d127494e
......@@ -25,6 +25,7 @@
#include <QLabel>
#include <QDesktopWidget>
#include <QProcess>
#include <QSettings>
#include <QPowerSourceProvider>
#include <qcontentset.h>
......@@ -88,6 +89,7 @@ ac(QPowerSource::Wall, "PrimaryAC", this)
, lastLogDt()
, ueventSocket(this)
, timer(this)
, chargingLogInterval(300)
, maxChargeCurrent(-1)
{
qLog(Hardware) << "gta04 hardware";
......@@ -115,6 +117,10 @@ ac(QPowerSource::Wall, "PrimaryAC", this)
// Y sets usb charging limit to 600mA which can be too high and causes
// charging voltage drops. We will set limit manually to prevent this.
qWriteFile("/sys/module/twl4030_charger/parameters/allow_usb", "N");
QSettings cfg("Trolltech", "qpe");
cfg.beginGroup("Charging");
chargingLogInterval = cfg.value("LogInterval", 300).toInt();
}
NeoHardware::~NeoHardware()
......@@ -174,7 +180,7 @@ static int getIntAttr(const char *name, QByteArray & uevent)
void NeoHardware::logCharge(QDateTime now, int chargeNow)
{
if (lastLogDt.secsTo(now) < 300)
if (lastLogDt.secsTo(now) < chargingLogInterval)
return;
lastLogDt = now;
......
......@@ -67,6 +67,7 @@ private:
QDateTime lastLogDt;
QTcpSocket ueventSocket;
QTimer timer;
int chargingLogInterval;
int maxChargeCurrent;
int oldChargeNow;
int oldChargerVoltage;
......
......@@ -85,6 +85,9 @@ Interval_LightOff=180
LightOff=false
Suspend=false
[Charging]
LogInterval=300
[Startup]
FirstUse=1
......@@ -146,7 +146,17 @@ void NeoControl::saveClicked()
QSettings cfg("Trolltech", "Modem");
cfg.setValue("OPSYS/Value", lineEdit->text());
cfg.sync();
QMessageBox::information(this, tr("Modem settings"), tr("Settings will be activated after restarting QtMoko with POWER button"));
QMessageBox::information(this, tr("Modem settings"),
tr
("Settings will be activated after restarting QtMoko with POWER button"));
}
if (screen == ScreenCharge) {
QSettings cfg("Trolltech", "qpe");
cfg.setValue("Charging/LogInterval", lineEdit->text().toInt());
cfg.sync();
QMessageBox::information(this, tr("Log settings"),
tr
("Settings will be activated after restarting QtMoko with POWER button"));
}
}
......@@ -539,10 +549,12 @@ void NeoControl::updateModem()
}
updatingScreen = true;
if(!lineEdit->hasFocus()) {
if (!lineEdit->hasFocus()) {
QSettings cfg("Trolltech", "Modem");
lineEdit->setText(cfg.value("OPSYS/Value", "AT_OPSYS=0,2").toString());
label->setText("AT_OPSYS=0,2 is 2G only\nAT_OPSYS=3,2 is 3G\n3G=modem troubles");
label->
setText
("AT_OPSYS=0,2 is 2G only\nAT_OPSYS=3,2 is 3G\n3G=modem troubles");
}
QString qpeEnv = getQpeEnv();
......@@ -612,15 +624,30 @@ void NeoControl::updateCharge()
QFile f(CHARGE_LOG_FILE);
bool isLogging = f.exists();
chkCharge->setChecked(isLogging);
label->setVisible(!isLogging);
lineEdit->setVisible(!isLogging);
bSave->setVisible(!isLogging);
if (isLogging) {
setFont(smallFont);
if (f.open(QIODevice::ReadOnly)) {
chargeLog = f.readAll();
f.close();
}
} else {
setFont(normalFont);
label->setText(tr("Logging interval"));
if (!lineEdit->hasFocus()) {
QSettings cfg("Trolltech", "qpe");
cfg.beginGroup("Charging");
int chargingLogInterval = cfg.value("LogInterval", 300).toInt();
lineEdit->setText(QString::number(chargingLogInterval));
}
}
QTimer::singleShot(10000, this, SLOT(updateCharge()));
QTimer::singleShot(3000, this, SLOT(updateCharge()));
update();
updatingScreen = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment