hwapi::onCCWakeGpioChanged():

when switching cc-terminal off, send 0 to watch-file (watched by a
	filesystem watcher).
	when switching cc-terminal on, send 1 to watch-file (watched by a
	filesystem watcher).
This commit is contained in:
Gerhard Hoffmann 2024-11-11 16:20:15 +01:00
parent c31b38917a
commit 91a0f88cd9

View File

@ -146,11 +146,25 @@ void hwapi::onCCWakeGpioChanged(QString const &fileName) {
qCritical() << __func__ << ":" << __LINE__ << "switching terminal off...";
mod_switchWake(false);
mod_switchPower(false);
f.close();
f.setFileName(m_watchedFile);
// to turn off cc-terminal, the content must be "0"
if (f.open(QFile::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
QTextStream s(&f);
s << "switching terminal off";
}
} else
if (content.startsWith("1")) {
qCritical() << __func__ << ":" << __LINE__ << "switching terminal on...";
mod_switchPower(true);
mod_switchWake(true);
f.close();
f.setFileName(m_watchedFile);
// to turn on cc-terminal, the content must be "1"
if (f.open(QFile::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
QTextStream s(&f);
s << "switching terminal on";
}
} else {
qCritical() << "watched file contained" << content;
}