1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 17:25:18 +03:00
Commit graph

12 commits

Author SHA1 Message Date
Alberto García Hierro
aa8e46b2de Use new setting accessor functions for retriving settings
This reduces flash usage by 96 bytes, making the cost of the whole
PR around 300 bytes.
Also, the settings tables in settings_generated.c are now made
static to make sure no code outside of settings.c can reference
them.
2018-07-09 22:36:01 +01:00
Alberto García Hierro
5468d2fe6e Add support for retriving setting types and listing all of them
This allows an external caller to retrieve and change any setting
as well as listing all the available ones without any a priori
knowledge.
2018-07-09 13:58:02 +01:00
Alberto García Hierro
f36fe2386d Teach settings how to handle strings, make craft name a setting
Add a new type for settings to be able to handle strings. This makes
it easier to add more settings of this type and removes the need to
handle them with dedicated CLI commands.

Replace the `name` CLI command with a setting called `name`.

Saves 8 bytes of FLASH on OMNIBUS
2018-06-24 18:38:10 +01:00
Alberto García Hierro
2227580965 Rename settings related functions from snake_case to camelCase
Fits better with INAV code conventions

Renamed functions:
    - setting_get_name -> settingGetName
    - setting_name_contains -> settingNameContains
    - setting_name_exact_match -> settingNameIsExactMatch
    - setting_find -> settingFind
    - setting_get_value_size -> settingGetValueSize
    - setting_get_pgn -> settingGetPgn
    - setting_get_value_pointer -> settingGetValuePointer
    - setting_get_copy_value_pointer -> settingGetCopyValuePointer
    - setting_get_min -> settingGetMin
    - setting_get_max -> settingGetMax
2018-06-23 18:52:38 +01:00
Michel Pastor
ce8621ee8f Add battery profiles feature 2018-06-13 15:58:38 +02:00
Alberto García Hierro
bf0f05af5f Move build-stamp and generatic files to obj/main/$(TARGET)
This allows target level parallel builds, since now there are no
shared files between targets.

Fixes #3261
2018-05-25 11:00:12 +01:00
Alberto García Hierro
ea29cc3241 Add setting_get_value_size() function and use it for MSP
Used to reply to MSP2_COMMON_SETTING, since we're just copying
the value from memory to the wire. Will be used in more places
eventually.
2017-10-11 18:49:46 +01:00
Alberto García Hierro
ff18b726d3 Add support for getting and setting arbitrary settings via MSPv2
Add MSP2_COMMON_SETTING for retrieving arbitrary settings and
MSP2_COMMON_SET_SETTING for setting them. This exposes any setting
which was only available from the CLI via MSP now.

Add support in settings.rb to generate a JSON file with all the
settings, their types and their possible values for settings using
a table. This file can be used by clients to properly format
messages for settings over MSP.
2017-10-11 18:06:36 +01:00
Alberto García Hierro
f1fb918803 Add support for modifying settings directly in CMS (#2262)
* Add macros for injecting CMS key presses

Useful for testing and debugging

* Add support for CMS elements represented by just a bool function

Function is called for both getting and setting the value. Will
allow simplying the code for several CMS items.

* Use OME_BoolFunc on cms_menu_ledstrip.c

Allows removing a couple of static variables and replacing two
functions with just one.

* Add support for manipulating settings directly in CMS

Allows changing settings without intermediary values/functions,
reducing memory usage. Due to the required code to support this
feature we're using ~250 bytes of flash, but we're saving around
~300 bytes of RAM. However, eventually we should be able to migrate
all CMS code to use the settings API and end up saving flash space.
Also, the memory overhead per memory setting is now way smaller.

* Don't use SETTING_VBAT_* when the target doesn't use the ADC

Fixes build on COLIBRI

* Add support for CMS setting data types

This allows us to format angular rates without introducing a function
pointer for formatting on every CMS setting.

* Remove CMS_INJECTED_KEYS used for debugging

* Fix off-by-one error in setting_get_max() for MODE_LOOKUP values

Maximum value is one less than the number of entries in the table
2017-10-07 13:02:44 +01:00
Alberto García Hierro
00d1512b7e Move code for retrieving a setting value pointer to settings.c
This allows exposing these functions to other callers, so other
places besides cli.c might alter a setting.
2017-09-30 12:44:23 +01:00
Alberto García Hierro
c319446d2b Rename clivalue_t to setting_t
Rename also related types, constants and macros
2017-09-30 11:56:09 +01:00
Alberto García Hierro
a5607bc54c Generate CLI settings at build time (#2028)
* Initial commit for the CLI settings compiler

Not very useful for now, only generates settings.c in the same
way the settings were manually written in cli.c

* Move all settings to a YAML file

This will eventually let us compile and pack the settings saving
a lot of memory. For now, the code compiles but it doesn't work
since it uses a byte to index into the word array which has more
than 256 entries.

* Use varint encoding for cli name word indexing

This makes the CLI work again.

* Make clivalue_name_* funcs return bool

Makes more sense than returning uint8_t, even when the compiler will
probably generate exactly the same assembly in both cases.

* Fix invalid field name

Missing a closing ]

* Initial attempt at generating the settings files at build time

Optimize the generator to call into the compiler only once, so
we can afford to call it for each build and, eventually, generate
build-optimized settings.

* Fix build error due to generated files

Due to make's expansion rules, the generated implementation file
wasn't correctly compiled if the build was started when the
generated files didn't exist.

Althogh there's probably a better solution, this should work for
now.

* Generate a per-build settings_generated.{h,c}

This allows us to save a bit more space, since this way the words
array doesn't include words which are not used by the build.

* Remove pgn_t field from cliValueConfig_t

Use a couple of arrays to find the pgn_t for a setting from its
offset in the table. This saves another 384 bytes on NAZE.

* Use only a byte for the field offset in clivalue_t when possible

While compiling the settings, determine if any offset requires a
number bigger than 255. If that's not the case, use a uint8_t
rather than an uint16_t for storing the field offset.

* Add missing header to PG_MODE_ACTIVATION_OPERATOR_CONFIG group

* Fix unbalanced #endif

Introduced when deleting the hardcoded settings from cli.c

* Don't ignore the return value from g.CanUseByteOffsetoff()

CLIVALUE_USE_BYTE_OFFSETOF was always defined regardless of the
maximum offsetof() value found in the settings.

* clivalue_name_*() functions now take a buffer

Requires only CLIVALUE_MAX_NAME_LENGTH bytes in the stack rather
than 2*CLIVALUE_MAX_NAME_LENGTH, since those functions were called
from functions which already had a buffer for the name allocated
but had to allocate their own.

* Remove unneeded clivalue_get_name() call

clivalue_name_exact_match() will already fill the buffer with
the value name.

* Fix off-by-one error in the settings generator

The generated C code wasn't allocating enough space for the '\0'
terminator for setting names

* Fix off-by-one error in the name decoder

CLIVALUE_ENCODED_NAME_MAX_BYTES represents the maximum number of
bytes in an encoded name, not the maximum word index.

* Add missing headers to PG_STATS_CONFIG group

* Make sure the settings are always up to date

* Initial attempt at encoding constants used for min/max settings

Pretty naive approach for now. Saves ~400 bytes on F1 targets.

* Move tool for generating settings to tools/

Also, rename it from settings_gen to just settings.
Delete the .gitignore in src/main/fc and just add all ignored
files in the root .gitignore, since that speeds up git.

* Only print setting stats when the env var V=1

This way we get quiet output unless the Makefile has been invoked
with verbose output.

* Make setting generation rules compatible with gmake 4

Rules were working fine on gmake 3, but failing with gmake 4. These
new rules should work with both of them.

* Fix constant value detection with GCC 7.1

GCC 6.3 emits errors with <42type-suffix> while GCC 7.1
emits the errors with only <42>

* Format uint8_t arrays a bit better

Don't add a comma after the last element

* Sort words and values determiniscally

This will help while checking the upcoming Ruby implementation
of the generator against the previous one using Go.

* Add missing headers for some groups in settings.yaml

* Replace the Go settings generator with a Ruby implementation

This makes it easier to install the required dependencies to
build INAV, since Ruby is installed by default on macOS and
installing it in Linux should be easier than installing Go
and a 3rd party package (for YAML parsing).

* Don't hardcode the value type for each parameter group

Instead, add a value_type field to each group with a default
value of MASTER_VALUE

* Simplify code for adding custom methods to StringIO

* Only resolve types for enabled fields

This fixes issues with some types which are only defined
if the feature for them is enabled (e.g. STATS or NAV).

* Implement print_stats() in the Ruby settings generator

* Rename constant in generated settings

CLIVALUE_ENCODED_NAME_USES_DIRECT_INDEXING =>
CLIVALUE_ENCODED_NAME_USES_BYTE_INDEXING

* Remove old settings generator binary from .gitignore

* Enable DEBUG while generating settings

Travis build is failing, this should help determine why

* Add $TOOLCHAINPATH to $PATH on Travis builds

* Disable DEBUG in settings.rb

Travis build is now failing because the log is too big

* Fix warning when running settings.rb on RB >= 2.4

* Don't print message when generating settings with V=0

* Use a relative path for the temporary dir

Absolute paths cause issues calling out to g++ on Windows

* Add INAV license header to settings.rb

* Add missing header to settings.c

Required since last rebase, it was compiling fine previously

* Remove unneeded extern variable decl from settings.c

Not needed anymore since we're now including settings_generated.c
directly in settings.c to simplify the Makefile.

* Use obj/tmp rather than just tmp for temporary files

* Update devdocs to mention Ruby installation

* Update Dockerfile and Vagrantfile to install Ruby

Required by the settings generator

Fixes #1997
2017-08-29 00:08:38 +10:00