mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Merge pull request #31 from Szybet/master
Named pipe repair, minor improvements and other fixes
This commit is contained in:
commit
e92bd36a34
6 changed files with 61 additions and 72 deletions
|
@ -8,10 +8,11 @@ sleepThread::sleepThread() {}
|
|||
void sleepThread::start()
|
||||
{
|
||||
log("Sleep pipe thread active", className);
|
||||
QDir pipePath = QDir("/run/ipd");
|
||||
QDir pipeDirPath = QDir("/dev/ipd");
|
||||
QFile pipePath = QFile("/dev/ipd/fifo");
|
||||
while(true) {
|
||||
QThread::sleep(1);
|
||||
if(pipePath.exists() == true) {
|
||||
if(pipePath.exists() == true and pipeDirPath.exists() == true) {
|
||||
log("Looking for messages in pipe", className);
|
||||
char * pipe = "/dev/ipd/fifo";
|
||||
int fd = ::open(pipe, O_RDONLY);
|
||||
|
|
|
@ -91,45 +91,9 @@ void quit::on_pushButton_3_clicked()
|
|||
{
|
||||
log("Suspending", className);
|
||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep") == true) {
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/sleepCall", "deepsleep");
|
||||
writeFile("/dev/ipd/sleepCall", "deepSleep");
|
||||
}
|
||||
else {
|
||||
emulatePowerButtonInputEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void quit::emulatePowerButtonInputEvent() {
|
||||
log("Emulating power button input event", className);
|
||||
// Input event
|
||||
struct input_event inputEvent = {};
|
||||
inputEvent.type = EV_KEY;
|
||||
inputEvent.code = KEY_POWER;
|
||||
// SYN report event
|
||||
struct input_event synReportEvent = {};
|
||||
synReportEvent.type = EV_SYN;
|
||||
synReportEvent.code = SYN_REPORT;
|
||||
synReportEvent.value = 0;
|
||||
|
||||
int fd = open("/dev/input/event0", O_WRONLY);
|
||||
if(fd != -1) {
|
||||
// Send press event
|
||||
inputEvent.value = 1;
|
||||
::write(fd, &inputEvent, sizeof(inputEvent));
|
||||
|
||||
// Send SYN report event
|
||||
::write(fd, &synReportEvent, sizeof(synReportEvent));
|
||||
|
||||
// Some sleep
|
||||
QThread::msleep(50);
|
||||
|
||||
// Send release event
|
||||
inputEvent.value = 0;
|
||||
::write(fd, &inputEvent, sizeof(inputEvent));
|
||||
::write(fd, &synReportEvent, sizeof(synReportEvent));
|
||||
|
||||
::close(fd);
|
||||
}
|
||||
else {
|
||||
QString function = __func__; log(function + ": Failed to open input device node at '/dev/input/event0'", className);
|
||||
writeFile("/dev/ipd/sleepCall", "sleep");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ private slots:
|
|||
void on_pushButton_4_clicked();
|
||||
void on_backBtn_clicked();
|
||||
void on_pushButton_3_clicked();
|
||||
void emulatePowerButtonInputEvent();
|
||||
|
||||
private:
|
||||
Ui::quit *ui;
|
||||
|
|
|
@ -38,9 +38,15 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
|
||||
// Icons
|
||||
ui->CBSDecreaseBtn->setIcon(QIcon(":/resources/minus.png"));
|
||||
ui->CBSDecreaseBtn->setFixedWidth(80);
|
||||
ui->CBSIncreaseBtn->setIcon(QIcon(":/resources/plus.png"));
|
||||
ui->CBSIncreaseBtn->setFixedWidth(80);
|
||||
|
||||
ui->idleSleepDecreaseBtn->setIcon(QIcon(":/resources/minus.png"));
|
||||
ui->idleSleepDecreaseBtn->setFixedWidth(80);
|
||||
ui->idleSleepIncreaseBtn->setIcon(QIcon(":/resources/plus.png"));
|
||||
ui->idleSleepIncreaseBtn->setFixedWidth(80);
|
||||
|
||||
// Padding
|
||||
ui->CBSDecreaseBtn->setStyleSheet("padding: 10px");
|
||||
ui->CBSIncreaseBtn->setStyleSheet("padding: 10px");
|
||||
|
@ -54,10 +60,25 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
stylesheetFile.close();
|
||||
|
||||
// Button tweaks
|
||||
int autoRepeatDelay = 1250;
|
||||
int autoRepeatInterval = 20;
|
||||
|
||||
ui->CBSDecreaseBtn->setAutoRepeat(true);
|
||||
ui->CBSDecreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||
ui->CBSDecreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||
|
||||
ui->CBSIncreaseBtn->setAutoRepeat(true);
|
||||
ui->CBSIncreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||
ui->CBSIncreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||
|
||||
ui->idleSleepDecreaseBtn->setAutoRepeat(true);
|
||||
ui->idleSleepDecreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||
ui->idleSleepDecreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||
|
||||
ui->idleSleepIncreaseBtn->setAutoRepeat(true);
|
||||
ui->idleSleepIncreaseBtn->setAutoRepeatDelay(autoRepeatDelay);
|
||||
ui->idleSleepIncreaseBtn->setAutoRepeatInterval(autoRepeatInterval);
|
||||
|
||||
|
||||
// Hide items
|
||||
ui->hLabel_3->hide();
|
||||
|
@ -73,9 +94,10 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
// 1 - cinematicBrightnessDelayMs
|
||||
QString cinematicBrightnessMs = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/1-cinematicBrightnessDelayMs");
|
||||
|
||||
ui->CBSLabel->setText(cinematicBrightnessMs);
|
||||
cinematicBrightnessInt = cinematicBrightnessMs.toInt();
|
||||
convertCinematicInt();
|
||||
|
||||
// 2- cpuGovernor
|
||||
// 2 - cpuGovernor
|
||||
QString cpuGovernor = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/2-cpuGovernor");
|
||||
|
||||
QStringList cpuGovernorList = QStringList{cpuGovernor};
|
||||
|
@ -102,8 +124,7 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
ui->hCpuFreqComboBox->setCurrentIndex(0);
|
||||
|
||||
// 3 - whenChargerSleep
|
||||
QString whenChargerSleep = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/3-whenChargerSleep");
|
||||
if(whenChargerSleep == "true") {
|
||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/3-whenChargerSleep") == true) {
|
||||
whenChargerSleepBool = true;
|
||||
ui->hWhenChargerSleepBtn->click();
|
||||
}
|
||||
|
@ -112,8 +133,7 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
}
|
||||
|
||||
// 4 - chargerWakeUp
|
||||
QString chargerWakeUp = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/4-chargerWakeUp");
|
||||
if(chargerWakeUp == "true") {
|
||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/4-chargerWakeUp") == true) {
|
||||
chargerWakeUpBool = true;
|
||||
ui->hChargerWakeUpBtn->click();
|
||||
}
|
||||
|
@ -122,9 +142,8 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
}
|
||||
|
||||
// 5 - wifiReconnect
|
||||
QString wifiReconnect = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/5-wifiReconnect");
|
||||
if(wifiReconnect == "true") {
|
||||
ui->wifiReconnectBtn->click();
|
||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/5-wifiReconnect") == true) {
|
||||
ui->wifiReconnectBtn->click();
|
||||
wifiReconnectBool = true;
|
||||
}
|
||||
else {
|
||||
|
@ -132,9 +151,8 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
}
|
||||
|
||||
// 6 - ledUsage
|
||||
QString ledUsagePath = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/6-ledUsage");
|
||||
if(ledUsagePath == "true") {
|
||||
ui->ledUsageBtn->click();
|
||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/6-ledUsage") == true) {
|
||||
ui->ledUsageBtn->click();
|
||||
ledUsageBool = true;
|
||||
}
|
||||
else {
|
||||
|
@ -147,9 +165,8 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
convertIdleSleepInt();
|
||||
|
||||
// 8 - customCase
|
||||
QString customCaseString = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/8-customCase");
|
||||
if(customCaseString == "true") {
|
||||
ui->hCustomCaseBtn->click();
|
||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/8-customCase") == true) {
|
||||
ui->hCustomCaseBtn->click();
|
||||
customCaseBool = true;
|
||||
}
|
||||
else {
|
||||
|
@ -157,9 +174,8 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
}
|
||||
|
||||
// 9 - deepSleep
|
||||
QString deepSleepString = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep");
|
||||
if(deepSleepString == "true") {
|
||||
ui->deepSleepBtn->click();
|
||||
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/9-deepSleep") == true) {
|
||||
ui->deepSleepBtn->click();
|
||||
deepSleepBool = true;
|
||||
}
|
||||
else {
|
||||
|
@ -174,16 +190,17 @@ powerDaemonSettings::~powerDaemonSettings()
|
|||
|
||||
void powerDaemonSettings::on_CBSIncreaseBtn_clicked()
|
||||
{
|
||||
int value = ui->CBSLabel->text().toInt() + 1;
|
||||
ui->CBSLabel->setText(QString::number(value));
|
||||
if(cinematicBrightnessInt < 500) {
|
||||
cinematicBrightnessInt = cinematicBrightnessInt + 1;
|
||||
convertCinematicInt();
|
||||
}
|
||||
}
|
||||
|
||||
void powerDaemonSettings::on_CBSDecreaseBtn_clicked()
|
||||
{
|
||||
int value = ui->CBSLabel->text().toInt();
|
||||
if(value != 0) {
|
||||
value = value - 1;
|
||||
ui->CBSLabel->setText(QString::number(value));
|
||||
if(cinematicBrightnessInt != 0) {
|
||||
cinematicBrightnessInt = cinematicBrightnessInt - 1;
|
||||
convertCinematicInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,7 +208,7 @@ void powerDaemonSettings::on_exitBtn_clicked()
|
|||
{
|
||||
// Save all to files
|
||||
// 1 - cinematicBrightnessdelayMs
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/1-cinematicBrightnessDelayMs", ui->CBSLabel->text());
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/1-cinematicBrightnessDelayMs", QString::number(cinematicBrightnessInt));
|
||||
// 2 - cpuGovernor
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/2-cpuGovernor", ui->hCpuFreqComboBox->currentText());
|
||||
// 3 - whenChargerSleep
|
||||
|
@ -322,12 +339,11 @@ void powerDaemonSettings::convertIdleSleepInt()
|
|||
|
||||
QString text;
|
||||
if(minutes != 0) {
|
||||
text.append(QString::number(minutes) + "m");
|
||||
text.append(QString::number(minutes) + "m ");
|
||||
}
|
||||
if(seconds != 0) {
|
||||
text.append(QString::number(seconds) + "s");
|
||||
}
|
||||
|
||||
ui->idleSleepLabel->setText(text);
|
||||
}
|
||||
|
||||
|
@ -356,3 +372,10 @@ void powerDaemonSettings::on_deepSleepBtn_clicked(bool checked)
|
|||
deepSleepBool = false;
|
||||
}
|
||||
}
|
||||
|
||||
void powerDaemonSettings::convertCinematicInt() {
|
||||
QString text = QString::number(cinematicBrightnessInt);
|
||||
// To avoid moving other widgets when the value changes
|
||||
text.append("ms");
|
||||
ui->CBSLabel->setText(text);
|
||||
}
|
||||
|
|
|
@ -28,19 +28,21 @@ private slots:
|
|||
void on_ledUsageBtn_clicked(bool checked);
|
||||
void on_idleSleepIncreaseBtn_clicked();
|
||||
void on_idleSleepDecreaseBtn_clicked();
|
||||
void convertIdleSleepInt();
|
||||
void on_hCustomCaseBtn_clicked(bool checked);
|
||||
void on_deepSleepBtn_clicked(bool checked);
|
||||
|
||||
void convertIdleSleepInt();
|
||||
void convertCinematicInt();
|
||||
|
||||
private:
|
||||
Ui::powerDaemonSettings * ui;
|
||||
bool whenChargerSleepBool;
|
||||
bool chargerWakeUpBool;
|
||||
bool wifiReconnectBool;
|
||||
bool ledUsageBool;
|
||||
int idleSleepInt;
|
||||
bool customCaseBool;
|
||||
bool deepSleepBool;
|
||||
int idleSleepInt;
|
||||
int cinematicBrightnessInt;
|
||||
};
|
||||
|
||||
#endif // POWERDAEMONSETTINGS_H
|
||||
|
|
|
@ -494,7 +494,7 @@
|
|||
<item>
|
||||
<widget class="QCheckBox" name="hCustomCaseBtn">
|
||||
<property name="text">
|
||||
<string>Custom case</string>
|
||||
<string>Custom case support</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue