diff --git a/app/Command/Daemon.php b/app/Command/Daemon.php index 06af7bcae56a42868fb75a5e9eb46bc36f821690..00381a037cfe8c93fea1e05a9611d1bcb683812a 100644 --- a/app/Command/Daemon.php +++ b/app/Command/Daemon.php @@ -9,6 +9,7 @@ use Hugga\Console; class Daemon extends AbstractCommand { const PID_PATH = '/run/fan-ctrl.pid'; + const UPDATE_INTERVAL = 500_000; // in micro seconds protected $name = 'daemon'; @@ -48,13 +49,15 @@ class Daemon extends AbstractCommand // prepare $rules = $fanConfig->getRules(); + $this->console->setLogger($this->app->logger); + $this->info('Fan Control started'); // main loop while (true) { foreach ($rules as $rule) { $rule->apply($this->console); } - sleep(1); + usleep(self::UPDATE_INTERVAL); } } } diff --git a/app/Model/Rule/CurveRule.php b/app/Model/Rule/CurveRule.php index c20a987e52895f87efd2f6adb82fe536ba31fa84..ddf2ef784a8608e7a973cde480780bf911c2c924 100644 --- a/app/Model/Rule/CurveRule.php +++ b/app/Model/Rule/CurveRule.php @@ -84,7 +84,7 @@ class CurveRule extends Rule $percentage, $lastPercentage, $lastPercentage - ), Console::WEIGHT_DEBUG); + ), $speed > 30 ? Console::WEIGHT_LOW : Console::WEIGHT_DEBUG); $this->setSpeed($speed); } break; diff --git a/composer.json b/composer.json index 7ccc20cb29e7fe9446ab955b719d97fdb3186111..9e58c35c5224c6e34a281afadfa1546d60c24c3c 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "bin": ["bin/fan-ctrl"], "require": { "tflori/riki-framework": "dev-master", - "tflori/hugga": "^1.1", + "tflori/hugga": "^1.2", "ulrichsg/getopt-php": "^4.0", "filp/whoops": "^2.14", "monolog/monolog": "^1.9", diff --git a/composer.lock b/composer.lock index ff722eb801e49b36a26e03eb98cfac6355e179c9..b7b555f3701d94e93e25f16f3457c2ee1323be27 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cddd1ddd64b18141de6444950d1076f4", + "content-hash": "dc0a733546b0eca25d08dbfda7ed570c", "packages": [ { "name": "filp/whoops", - "version": "2.14.6", + "version": "2.15.2", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "f7948baaa0330277c729714910336383286305da" + "reference": "aac9304c5ed61bf7b1b7a6064bf9806ab842ce73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/f7948baaa0330277c729714910336383286305da", - "reference": "f7948baaa0330277c729714910336383286305da", + "url": "https://api.github.com/repos/filp/whoops/zipball/aac9304c5ed61bf7b1b7a6064bf9806ab842ce73", + "reference": "aac9304c5ed61bf7b1b7a6064bf9806ab842ce73", "shasum": "" }, "require": { @@ -67,7 +67,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.14.6" + "source": "https://github.com/filp/whoops/tree/2.15.2" }, "funding": [ { @@ -75,7 +75,7 @@ "type": "github" } ], - "time": "2022-11-02T16:23:29+00:00" + "time": "2023-04-12T12:00:00+00:00" }, { "name": "monolog/monolog", @@ -456,16 +456,16 @@ }, { "name": "tflori/hugga", - "version": "v1.1.0", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/tflori/hugga.git", - "reference": "204f03ccf04a5381a117dc6025364f74a70923d9" + "reference": "ece10d4e60d7208318bd14d7146d2fc3151ba7da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tflori/hugga/zipball/204f03ccf04a5381a117dc6025364f74a70923d9", - "reference": "204f03ccf04a5381a117dc6025364f74a70923d9", + "url": "https://api.github.com/repos/tflori/hugga/zipball/ece10d4e60d7208318bd14d7146d2fc3151ba7da", + "reference": "ece10d4e60d7208318bd14d7146d2fc3151ba7da", "shasum": "" }, "require": { @@ -497,9 +497,9 @@ "description": "library for console applications with input and output handling", "support": { "issues": "https://github.com/tflori/hugga/issues", - "source": "https://github.com/tflori/hugga/tree/v1.1.0" + "source": "https://github.com/tflori/hugga/tree/v1.2.0" }, - "time": "2022-03-18T16:46:56+00:00" + "time": "2023-06-01T20:11:36+00:00" }, { "name": "tflori/riki-framework", @@ -612,6 +612,7 @@ "prefer-lowest": false, "platform": { "ext-pcntl": "*", + "ext-posix": "*", "php": ">=7.4" }, "platform-dev": [],