Store backlight breathing state in EEPROM (#6105)
* Store backlight breathing state in EEPROM * Reduce backlight_config.level from 6 bits to 4 (max 15 "on" levels) * Error out if BACKLIGHT_LEVELS is > 15 * Remove mention of default backlight pin in rules.mk template * Remove pointless comment
This commit is contained in:
		
							parent
							
								
									e2dfb787da
								
							
						
					
					
						commit
						a32f7e1a25
					
				
					 5 changed files with 82 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -100,7 +100,7 @@ void backlight_enable(void)
 | 
			
		|||
	backlight_set(backlight_config.level);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** /brief Disable backlight
 | 
			
		||||
/** \brief Disable backlight
 | 
			
		||||
 *
 | 
			
		||||
 * FIXME: needs doc
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -162,3 +162,56 @@ uint8_t get_backlight_level(void)
 | 
			
		|||
{
 | 
			
		||||
    return backlight_config.level;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef BACKLIGHT_BREATHING
 | 
			
		||||
/** \brief Backlight breathing toggle
 | 
			
		||||
 *
 | 
			
		||||
 * FIXME: needs doc
 | 
			
		||||
 */
 | 
			
		||||
void backlight_toggle_breathing(void)
 | 
			
		||||
{
 | 
			
		||||
    bool breathing = backlight_config.breathing;
 | 
			
		||||
    dprintf("backlight breathing toggle: %u\n", breathing);
 | 
			
		||||
    if (breathing) 
 | 
			
		||||
        backlight_disable_breathing();
 | 
			
		||||
    else
 | 
			
		||||
        backlight_enable_breathing();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** \brief Enable backlight breathing
 | 
			
		||||
 *
 | 
			
		||||
 * FIXME: needs doc
 | 
			
		||||
 */
 | 
			
		||||
void backlight_enable_breathing(void)
 | 
			
		||||
{
 | 
			
		||||
    if (backlight_config.breathing) return; // do nothing if breathing is already on
 | 
			
		||||
 | 
			
		||||
    backlight_config.breathing = true;
 | 
			
		||||
    eeconfig_update_backlight(backlight_config.raw);
 | 
			
		||||
    dprintf("backlight breathing enable\n");
 | 
			
		||||
    breathing_enable();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** \brief Disable backlight breathing
 | 
			
		||||
 *
 | 
			
		||||
 * FIXME: needs doc
 | 
			
		||||
 */
 | 
			
		||||
void backlight_disable_breathing(void)
 | 
			
		||||
{
 | 
			
		||||
    if (!backlight_config.breathing) return; // do nothing if breathing is already off
 | 
			
		||||
 | 
			
		||||
    backlight_config.breathing = false;
 | 
			
		||||
    eeconfig_update_backlight(backlight_config.raw);
 | 
			
		||||
    dprintf("backlight breathing disable\n");
 | 
			
		||||
    breathing_disable();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** \brief Get the backlight breathing status
 | 
			
		||||
 *
 | 
			
		||||
 * FIXME: needs doc
 | 
			
		||||
 */
 | 
			
		||||
bool is_backlight_breathing(void)
 | 
			
		||||
{
 | 
			
		||||
    return backlight_config.breathing;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,11 +20,18 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		|||
#include <stdint.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
#ifndef BACKLIGHT_LEVELS
 | 
			
		||||
  #define BACKLIGHT_LEVELS 3
 | 
			
		||||
#elif BACKLIGHT_LEVELS > 15
 | 
			
		||||
  #error "Maximum value of BACKLIGHT_LEVELS is 15"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef union {
 | 
			
		||||
    uint8_t raw;
 | 
			
		||||
    struct {
 | 
			
		||||
        bool    enable :1;
 | 
			
		||||
        uint8_t level  :7;
 | 
			
		||||
        bool    enable    :1;
 | 
			
		||||
        bool    breathing :1;
 | 
			
		||||
        uint8_t level     :4;
 | 
			
		||||
    };
 | 
			
		||||
} backlight_config_t;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -40,3 +47,11 @@ void backlight_set(uint8_t level);
 | 
			
		|||
void backlight_level(uint8_t level);
 | 
			
		||||
uint8_t get_backlight_level(void);
 | 
			
		||||
 | 
			
		||||
#ifdef BACKLIGHT_BREATHING
 | 
			
		||||
void backlight_toggle_breathing(void);
 | 
			
		||||
void backlight_enable_breathing(void);
 | 
			
		||||
void backlight_disable_breathing(void);
 | 
			
		||||
bool is_backlight_breathing(void);
 | 
			
		||||
void breathing_enable(void);
 | 
			
		||||
void breathing_disable(void);
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue