diff options
| author | tmk <nobody@nowhere> | 2013-06-23 09:19:04 +0900 | 
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-06-23 09:19:04 +0900 | 
| commit | 5a0415749d6cd6a095d9c3fbb335360ec5fa59e0 (patch) | |
| tree | 7ed39e24295fbf853625a12fe273ea3ab4c7b202 /common/backlight.c | |
| parent | 9de9d719527c7a8cac71d0bc49ba1d2d4f63cf06 (diff) | |
| parent | 25ad212c4adae5a27dd2d5a4e9d6bcdfc17edb1b (diff) | |
| download | firmware-5a0415749d6cd6a095d9c3fbb335360ec5fa59e0.tar.gz firmware-5a0415749d6cd6a095d9c3fbb335360ec5fa59e0.tar.bz2 firmware-5a0415749d6cd6a095d9c3fbb335360ec5fa59e0.zip | |
Merge branch 'Wraul-kmac'
Diffstat (limited to 'common/backlight.c')
| -rw-r--r-- | common/backlight.c | 77 | 
1 files changed, 77 insertions, 0 deletions
| diff --git a/common/backlight.c b/common/backlight.c new file mode 100644 index 000000000..00dc04a07 --- /dev/null +++ b/common/backlight.c @@ -0,0 +1,77 @@ +/* +Copyright 2013 Mathias Andersson <wraul@dbox.se> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program.  If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "backlight.h" +#include "eeconfig.h" +#include "debug.h" + +backlight_config_t backlight_config; + +void backlight_init(void) +{ +    /* check signature */ +    if (!eeconfig_is_enabled()) { +        eeconfig_init(); +    } +    backlight_config.raw = eeconfig_read_backlight(); +    backlight_set(backlight_config.enable ? backlight_config.level : 0); +} + +void backlight_increase(void) +{ +    if(backlight_config.level < BACKLIGHT_LEVELS) +    { +        backlight_config.level++; +        backlight_config.enable = 1; +        eeconfig_write_backlight(backlight_config.raw); +    } +    dprintf("backlight increase: %u\n", backlight_config.level); +    backlight_set(backlight_config.level); +} + +void backlight_decrease(void) +{ +    if(backlight_config.level > 0) +    { +        backlight_config.level--; +        backlight_config.enable = !!backlight_config.level; +        eeconfig_write_backlight(backlight_config.raw); +    } +    dprintf("backlight decrease: %u\n", backlight_config.level); +    backlight_set(backlight_config.level); +} + +void backlight_toggle(void) +{ +    backlight_config.enable ^= 1; +    eeconfig_write_backlight(backlight_config.raw); +    dprintf("backlight toggle: %u\n", backlight_config.enable); +    backlight_set(backlight_config.enable ? backlight_config.level : 0); +} + +void backlight_step(void) +{ +    backlight_config.level++; +    if(backlight_config.level > BACKLIGHT_LEVELS) +    { +        backlight_config.level = 0; +    } +    backlight_config.enable = !!backlight_config.level; +    eeconfig_write_backlight(backlight_config.raw); +    dprintf("backlight step: %u\n", backlight_config.level); +    backlight_set(backlight_config.level); +} | 
