mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 15:47:22 -08:00
pipe repair, minor improvments and fixes
This commit is contained in:
parent
4463ced4c7
commit
4eaaeb33b8
6 changed files with 81 additions and 86 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;
|
||||
|
|
|
@ -36,11 +36,32 @@ powerDaemonSettings::powerDaemonSettings(QWidget *parent) :
|
|||
// Experimental features label
|
||||
ui->label_2->setStyleSheet("font-weight: bold");
|
||||
|
||||
/*
|
||||
if(global::deviceID == "n306")
|
||||
{
|
||||
ui->wifiReconnectBtn->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
ui->ledUsageBtn->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
ui->deepSleepBtn->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
ui->hWhenChargerSleepBtn->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
ui->hChargerWakeUpBtn->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
ui->hCustomCaseBtn->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
ui->wifiReconnectBtn->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
ui->wifiReconnectBtn->setStyleSheet("QCheckBox::indicator { width:50px; height: 50px; }");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// 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");
|
||||
|
@ -73,7 +94,8 @@ 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
|
||||
QString cpuGovernor = readFile("/mnt/onboard/.adds/inkbox/.config/20-sleep_daemon/2-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,19 @@ 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 +210,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 +341,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 +374,13 @@ 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,10 +28,12 @@ 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;
|
||||
|
@ -41,6 +43,7 @@ private:
|
|||
int idleSleepInt;
|
||||
bool customCaseBool;
|
||||
bool deepSleepBool;
|
||||
int cinematicBrightnessInt;
|
||||
};
|
||||
|
||||
#endif // POWERDAEMONSETTINGS_H
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>680</width>
|
||||
<height>545</height>
|
||||
<height>553</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
|
@ -114,15 +114,15 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="CBSLabel">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>50</string>
|
||||
<string>Cinematic brightness speed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -137,15 +137,15 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="CBSLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cinematic brightness speed</string>
|
||||
<string>50</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -241,15 +241,15 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="idleSleepLabel">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Idle sleep number</string>
|
||||
<string>Sleep when idle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -264,15 +264,15 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<widget class="QLabel" name="idleSleepLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sleep when idle</string>
|
||||
<string>60</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -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