-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #867 from Dmitry422/dev
Additional options for Input and Power service
- Loading branch information
Showing
20 changed files
with
330 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ App( | |
stack_size=1 * 1024, | ||
order=80, | ||
sdk_headers=["input.h"], | ||
provides=["input_settings"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "input_settings.h" | ||
#include "input_settings_filename.h" | ||
|
||
#include <saved_struct.h> | ||
#include <storage/storage.h> | ||
|
||
#define TAG "InputSettings" | ||
|
||
#define INPUT_SETTINGS_VER (1) // version nnumber | ||
|
||
#define INPUT_SETTINGS_PATH INT_PATH(INPUT_SETTINGS_FILE_NAME) | ||
#define INPUT_SETTINGS_MAGIC (0x29) | ||
|
||
void input_settings_load(InputSettings* settings) { | ||
furi_assert(settings); | ||
|
||
bool success = false; | ||
|
||
//a useless cycle do-while, may will be used in future with anoter condition | ||
do { | ||
// take version from settings file metadata, if cant then break and fill settings with 0 and save to settings file; | ||
uint8_t version; | ||
if(!saved_struct_get_metadata(INPUT_SETTINGS_PATH, NULL, &version, NULL)) break; | ||
|
||
// if config actual version - load it directly | ||
if(version == INPUT_SETTINGS_VER) { | ||
success = saved_struct_load( | ||
INPUT_SETTINGS_PATH, | ||
settings, | ||
sizeof(InputSettings), | ||
INPUT_SETTINGS_MAGIC, | ||
INPUT_SETTINGS_VER); | ||
// if config previous version - load it and inicialize new settings | ||
} | ||
// in case of another config version we exit from useless cycle to next step | ||
} while(false); | ||
|
||
// fill settings with 0 and save to settings file; | ||
if(!success) { | ||
FURI_LOG_W(TAG, "Failed to load file, using defaults"); | ||
memset(settings, 0, sizeof(InputSettings)); | ||
input_settings_save(settings); | ||
} | ||
} | ||
|
||
void input_settings_save(const InputSettings* settings) { | ||
furi_assert(settings); | ||
|
||
const bool success = saved_struct_save( | ||
INPUT_SETTINGS_PATH, | ||
settings, | ||
sizeof(InputSettings), | ||
INPUT_SETTINGS_MAGIC, | ||
INPUT_SETTINGS_VER); | ||
|
||
if(!success) { | ||
FURI_LOG_E(TAG, "Failed to save file"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
typedef struct { | ||
uint8_t vibro_touch_level; | ||
} InputSettings; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
void input_settings_load(InputSettings* settings); | ||
void input_settings_save(const InputSettings* settings); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
#define INPUT_SETTINGS_FILE_NAME ".input.settings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
typedef struct { | ||
uint32_t auto_poweroff_delay_ms; | ||
uint8_t charge_supress_percent; | ||
} PowerSettings; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
void power_settings_load(PowerSettings* settings); | ||
void power_settings_save(const PowerSettings* settings); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
App( | ||
appid="input_settings", | ||
name="Input", | ||
apptype=FlipperAppType.SETTINGS, | ||
entry_point="input_settings_app", | ||
requires=["input"], | ||
stack_size=1 * 1024, | ||
order=100, | ||
) |
Oops, something went wrong.