From a7313612782bff92f765d39fe9c1740f861204f7 Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 30 Jun 2020 21:42:49 +1200 Subject: [PATCH] Document dbus a bit better --- CHANGELOG.md | 7 ++ README.md | 12 +--- README_DBUS.md | 105 ++++++++++++++++++++++++++++ data/rogcore.conf | 149 ---------------------------------------- rog-core/src/daemon.rs | 2 +- rog-core/src/rogcore.rs | 4 +- 6 files changed, 116 insertions(+), 163 deletions(-) create mode 100644 README_DBUS.md delete mode 100644 data/rogcore.conf diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eeac00a..3e904046 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Further refine the way setting LED modes works so it is more universal, this + also allows for setting the brightness through `SetKeyBacklight` + +### Added +- REDME_DBUS.md to document DBUS interface + ## [0.13.1] - 2020-29-06 ### Fixed - Properly initialise the device diff --git a/README.md b/README.md index 77e8a292..2b5a9d61 100644 --- a/README.md +++ b/README.md @@ -225,17 +225,7 @@ little of. Most parts will be byte arrays, but you can adjust things like ### DBUS Input -Paths: - -```rust -pub static DBUS_NAME: &str = "org.rogcore.Daemon"; -pub static DBUS_PATH: &str = "/org/rogcore/Daemon"; -pub static DBUS_IFACE: &str = "org.rogcore.Daemon"; -``` - -Commands: `FanMode`, `LedWriteBytes`, `LedWriteMultizone`, `LedWriteEffect` - -TODO: fill in this info +See [README_DBUS.md](./README_DBUS.md). ### AniMe input diff --git a/README_DBUS.md b/README_DBUS.md new file mode 100644 index 00000000..576be41f --- /dev/null +++ b/README_DBUS.md @@ -0,0 +1,105 @@ +# DBUS Guide + +```rust +pub static DBUS_NAME: &str = "org.rogcore.Daemon"; +pub static DBUS_PATH: &str = "/org/rogcore/Daemon"; +pub static DBUS_IFACE: &str = "org.rogcore.Daemon"; +``` + +## Methods + +- `SetKeyBacklight` +- `AnimatrixWrite` +- `SetFanMode` +- `GetFanMode` +- `SetChargeLimit` +- `GetChargeLimit` +- TODO: GetLEDModes + +## Signals + +- `KeyBacklightChanged` +- `FanModeChanged` +- `ChargeLimitChanged` + +## Method Inputs + +### SetKeyBacklight + +This method expects a string of JSON as input. The JSON is of format such: + +``` +{ + "Stable": { + "colour": [ 255, 0, 0] + } +} +``` + +The possible contents of a mode are: + +- `"colour": [u8, u8, u8],` +- `"speed": ,` +- `"direction": ,` + +Modes may or may not be available for a specific laptop (TODO: dbus getter for +supported modes). Modes are: + +- `"Stable": { "colour": },` +- `"Pulse": { "colour": },` +- `"Comet": { "colour": },` +- `"Flash": { "colour": },` +- `"Strobe": { "speed": },` +- `"Rain": { "speed": },` +- `"Laser": { "colour": , "speed": },` +- `"Ripple": { "colour": , "speed": },` +- `"Highlight": { "colour": , "speed": },` +- `"Rainbow": { "direction": , "speed": },` +- `"Breathe": { "colour": , "colour2": , "speed": },` +- `"Star": { "colour": , "colour2": , "speed": },` +- `"MultiStatic": { "colour1": , "colour2": , , "colour3": , "colour4": },` + +Additionally to the above there is `"RGB": [[u8; 64]; 11]` which is for per-key +setting of LED's but this requires some refactoring to make it easily useable over +dbus. + +Lastly, there is `"LedBrightness": ` which accepts 0-3 for off, low, med, high. + +### AnimatrixWrite + +Used to write data to the AniMe display if available. Currently is takes `[[u8; 640]; 2]` +which must be the byte data that will be written directly to the USB device. + +### SetFanMode + +Accepts an integer from the following: + +- `0`: Normal +- `1`: Boost mode +- `2`: Silent mode + +### GetFanMode + +Returns the integer set from above. + +### SetChargeLimit + +Accepts an integer in the range of 20-100. + +### GetChargeLimit + +Returns the integer set from above. + +## Signal Outs + +### KeyBacklightChanged + +When emitted, it will emit a true or false. + +### FanModeChanged + +When emitted, it will include the integer the fan mode was changed to. + +### ChargeLimitChanged + +When emitted, it will include the integer the charging limit was changed to. \ No newline at end of file diff --git a/data/rogcore.conf b/data/rogcore.conf deleted file mode 100644 index 80153154..00000000 --- a/data/rogcore.conf +++ /dev/null @@ -1,149 +0,0 @@ -{ - "fan_mode": 1, - "bat_charge_limit": 100, - "brightness": 1, - "current_mode": 0, - "builtin_modes": [ - { - "Stable": { - "help": false, - "colour": [ - 255, - 0, - 0 - ] - } - }, - { - "Breathe": { - "help": false, - "colour": [ - 255, - 0, - 0 - ], - "colour2": [ - 255, - 0, - 0 - ], - "speed": "Med" - } - }, - { - "Strobe": { - "help": false, - "speed": "Med" - } - }, - { - "Rainbow": { - "help": false, - "direction": "Up", - "speed": "Low" - } - }, - { - "Star": { - "help": false, - "colour": [ - 255, - 0, - 0 - ], - "colour2": [ - 255, - 0, - 0 - ], - "speed": "Med" - } - }, - { - "Rain": { - "help": false, - "speed": "Med" - } - }, - { - "Highlight": { - "help": false, - "colour": [ - 255, - 0, - 0 - ], - "speed": "Med" - } - }, - { - "Laser": { - "help": false, - "colour": [ - 255, - 0, - 0 - ], - "speed": "Med" - } - }, - { - "Ripple": { - "help": false, - "colour": [ - 255, - 0, - 0 - ], - "speed": "Med" - } - }, - { - "Pulse": { - "help": false, - "colour": [ - 255, - 0, - 0 - ] - } - }, - { - "Comet": { - "help": false, - "colour": [ - 255, - 0, - 0 - ] - } - }, - { - "Flash": { - "help": false, - "colour": [ - 255, - 0, - 0 - ] - } - } - ], - "mode_performance": { - "normal": { - "min_percentage": 0, - "max_percentage": 100, - "no_turbo": false - }, - "boost": { - "min_percentage": 0, - "max_percentage": 100, - "no_turbo": false - }, - "silent": { - "min_percentage": 0, - "max_percentage": 80, - "no_turbo": false - } - } -} \ No newline at end of file diff --git a/rog-core/src/daemon.rs b/rog-core/src/daemon.rs index 8be328f5..e563a733 100644 --- a/rog-core/src/daemon.rs +++ b/rog-core/src/daemon.rs @@ -125,7 +125,7 @@ pub async fn start_daemon() -> Result<(), Box> { if let Some(n) = lock.take() { let mut config = config1.lock().await; rogcore - .fan_mode_set(n, &mut config) + .set_fan_mode(n, &mut config) .unwrap_or_else(|err| warn!("{:?}", err)); } } diff --git a/rog-core/src/rogcore.rs b/rog-core/src/rogcore.rs index bb581c69..d950627d 100644 --- a/rog-core/src/rogcore.rs +++ b/rog-core/src/rogcore.rs @@ -139,7 +139,7 @@ impl RogCore { Ok(()) } - pub fn fan_mode_set(&mut self, n: u8, config: &mut Config) -> Result<(), Box> { + pub fn set_fan_mode(&mut self, n: u8, config: &mut Config) -> Result<(), Box> { let path = RogCore::get_fan_path()?; let mut fan_ctrl = OpenOptions::new().read(true).write(true).open(path)?; @@ -164,7 +164,7 @@ impl RogCore { } else { n = 0; } - self.fan_mode_set(n, config) + self.set_fan_mode(n, config) } fn set_pstate_for_fan_mode(