Skip to content

Commit

Permalink
Add option to use breathing led patterns
Browse files Browse the repository at this point in the history
Adds two new runtime configuration values
* sw breathing enable flag
* sw breathing battery level limit

These can be modified with mcetool options
  --set-sw-breathing=<enabled|disabled>
  --set-sw-breathing-limit=<0 ... 100>

The led patterns that are configured to use the fully on / fully off
blinking mode supported by the pwm led controller will oscillate
smoothly along the first half of sine wave.

For the smooth transitions to work frequent timer wakeups are needed
and the device can't be suspended. As this will increase the battery
consumption the sw breathing happens only if breathing is enabled and
battery level exceeds the limit or the device is connected to charger.

[mce] Add option to use breathing led patterns. Contributes to JB#17229
  • Loading branch information
spiiroin committed Apr 29, 2014
1 parent 969362a commit 134be26
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 36 deletions.
12 changes: 12 additions & 0 deletions builtin-gconf.c
Expand Up @@ -1506,6 +1506,18 @@ static const setting_t gconf_defaults[] =
.type = "b",
.def = "true",
},
{
// no define; used by led module
.key = "/system/osso/dsm/leds/sw_breath_enabled",
.type = "b",
.def = "false",
},
{
// no define; used by led module
.key = "/system/osso/dsm/leds/sw_breath_battery_limit",
.type = "i",
.def = "90",
},
{
// MCE_GCONF_PROXIMITY_PS_ENABLED_PATH @ proximity.h
.key = "/system/osso/dsm/proximity/ps_enabled",
Expand Down
11 changes: 11 additions & 0 deletions mce-hybris.c
Expand Up @@ -530,6 +530,17 @@ bool mce_hybris_indicator_set_pattern(int r, int g, int b, int ms_on, int ms_off
return !real ? false : real(r,g,b, ms_on, ms_off);
}

/** Enable/disable timer based led breathing
*
* @param enable true for smooth sw transitions, false for hw blinking only
*/
void mce_hybris_indicator_enable_breathing(bool enable)
{
static void (*real)(bool) = 0;
RESOLVE;
if( real ) real(enable);
}

/* ------------------------------------------------------------------------- *
* proximity sensor
* ------------------------------------------------------------------------- */
Expand Down
1 change: 1 addition & 0 deletions mce-hybris.h
Expand Up @@ -56,6 +56,7 @@ bool mce_hybris_keypad_init(void);
bool mce_hybris_indicator_init(void);
void mce_hybris_indicator_quit(void);
bool mce_hybris_indicator_set_pattern(int r, int g, int b, int ms_on, int ms_off);
void mce_hybris_indicator_enable_breathing(bool enable);

/* - - - - - - - - - - - - - - - - - - - *
* proximity sensor
Expand Down
1 change: 1 addition & 0 deletions mce.c
Expand Up @@ -291,6 +291,7 @@ static void mce_cleanup_wakelocks(void)
wakelock_unlock("mce_powerkey_stm");
wakelock_unlock("mce_proximity_stm");
wakelock_unlock("mce_bluez_wait");
wakelock_unlock("mce_led_breathing");
}
#endif // ENABLE_WAKELOCKS

Expand Down

0 comments on commit 134be26

Please sign in to comment.