Commit 5667900c authored by spiiroin's avatar spiiroin

[led] Add proximity sensor debugging patterns. JB#43690

Debugging proximity sensor issues is difficult as inspecting logs is
usually not possible in the situation where the problem is detected,
or the sensor has failed in distant enough past so that logs have been
already lost due to log rotation.

Add led patterns that are activated/deactivated as follows:
- PatternProximityCovered when sensor is reporting closed state.
- PatternProximityUncovering when sensor is reporting uncovered state, but
  effective state is still covered (uncover hysteresis).
- PatternProximityUncovered when effective proximity state is uncovered.

The patterns are disabled by default, but can be enabled via:
  mcetool --enable-led-pattern=PatternProximityCovered\
          --enable-led-pattern=PatternProximityUncovering\
          --enable-led-pattern=PatternProximityUncovered

And disabled again with:
  mcetool --disable-led-pattern=PatternProximityCovered\
          --disable-led-pattern=PatternProximityUncovering\
          --disable-led-pattern=PatternProximityUncovered
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 3486cf9a
......@@ -1562,6 +1562,21 @@ static const setting_t gconf_defaults[] =
.type = "b",
.def = G_STRINGIFY(false),
},
{
.key = MCE_SETTING_LED_PATH"/"MCE_LED_PATTERN_PROXIMITY_COVERED,
.type = "b",
.def = G_STRINGIFY(false),
},
{
.key = MCE_SETTING_LED_PATH"/"MCE_LED_PATTERN_PROXIMITY_UNCOVERING,
.type = "b",
.def = G_STRINGIFY(false),
},
{
.key = MCE_SETTING_LED_PATH"/"MCE_LED_PATTERN_PROXIMITY_UNCOVERED,
.type = "b",
.def = G_STRINGIFY(false),
},
{
.key = MCE_SETTING_LED_SW_BREATH_ENABLED,
.type = "b",
......
......@@ -49,3 +49,12 @@ PatternScanningFingerprint=11;1;0;0;0;ffff00
# Fingerprint acquired -> blue blip
PatternFingerprintAcquired=10;1;1;0;0;0000ff
# Proximity sensor covered -> red
PatternProximityCovered=14;5;0;0;0;ff0000
# Proximity sensor uncovered - waiting -> yellow
PatternProximityUncovering=14;5;0;0;0;ffff00
# Proximity sensor uncovered - effective -> green
PatternProximityUncovered=14;5;0;0;0;00ff00
......@@ -117,6 +117,15 @@
/** LED pattern used when fingerprint acquisition events are seen */
#define MCE_LED_PATTERN_FINGERPRINT_ACQUIRED "PatternFingerprintAcquired"
/** LED pattern used when proximity sensor is covered */
#define MCE_LED_PATTERN_PROXIMITY_COVERED "PatternProximityCovered"
/** LED pattern used during proximity sensor uncover hysteresis */
#define MCE_LED_PATTERN_PROXIMITY_UNCOVERING "PatternProximityUncovering"
/** LED pattern used when proximity sensor is uncovered */
#define MCE_LED_PATTERN_PROXIMITY_UNCOVERED "PatternProximityUncovered"
/** Persistent lock file for backups */
#define MCE_SETTINGS_LOCK_FILE_PATH G_STRINGIFY(MCE_RUN_DIR) "/restored"
......
......@@ -977,6 +977,78 @@ EXIT:
/** Timer id for delayed proximity uncovering */
static guint tklock_datapipe_proximity_uncover_id = 0;
/** Re-evaluate proximity sensor debugging led pattern state
*/
static void tklock_datapipe_proximity_eval_led(void)
{
typedef enum {
PROXIMITY_LED_STATE_UNDEFINED = 0,
PROXIMITY_LED_STATE_COVERED = 1,
PROXIMITY_LED_STATE_UNCOVERING = 2,
PROXIMITY_LED_STATE_UNCOVERED = 3,
} proximity_led_state_t;
static proximity_led_state_t prev = PROXIMITY_LED_STATE_UNDEFINED;
/* Evaluate what led pattern should be active */
proximity_led_state_t curr = PROXIMITY_LED_STATE_UNDEFINED;
if( proximity_sensor_effective == COVER_OPEN )
curr = PROXIMITY_LED_STATE_UNCOVERED;
else if( proximity_sensor_actual == COVER_OPEN )
curr = PROXIMITY_LED_STATE_UNCOVERING;
else if( proximity_sensor_actual == COVER_CLOSED )
curr = PROXIMITY_LED_STATE_COVERED;
if( prev == curr )
goto EXIT;
/* Activate new pattern 1st, then deactivate old pattern
* to avoid transition via no active pattern.
*/
switch( curr )
{
case PROXIMITY_LED_STATE_UNCOVERED:
datapipe_exec_full(&led_pattern_activate_pipe,
MCE_LED_PATTERN_PROXIMITY_UNCOVERED);
break;
case PROXIMITY_LED_STATE_UNCOVERING:
datapipe_exec_full(&led_pattern_activate_pipe,
MCE_LED_PATTERN_PROXIMITY_UNCOVERING);
break;
case PROXIMITY_LED_STATE_COVERED:
datapipe_exec_full(&led_pattern_activate_pipe,
MCE_LED_PATTERN_PROXIMITY_COVERED);
break;
default:
break;
}
switch( prev )
{
case PROXIMITY_LED_STATE_UNCOVERED:
datapipe_exec_full(&led_pattern_deactivate_pipe,
MCE_LED_PATTERN_PROXIMITY_UNCOVERED);
break;
case PROXIMITY_LED_STATE_UNCOVERING:
datapipe_exec_full(&led_pattern_deactivate_pipe,
MCE_LED_PATTERN_PROXIMITY_UNCOVERING);
break;
case PROXIMITY_LED_STATE_COVERED:
datapipe_exec_full(&led_pattern_deactivate_pipe,
MCE_LED_PATTERN_PROXIMITY_COVERED);
break;
default:
break;
}
prev = curr;
EXIT:
return;
}
/** Set effective proximity state from current sensor state
*/
static void tklock_datapipe_proximity_update(void)
......@@ -990,6 +1062,7 @@ static void tklock_datapipe_proximity_update(void)
proximity_sensor_effective = proximity_sensor_actual;
tklock_datapipe_proximity_eval_led();
tklock_uiexception_rethink();
tklock_proxlock_rethink();
tklock_evctrl_rethink();
......@@ -1071,6 +1144,8 @@ static void tklock_datapipe_proximity_sensor_actual_cb(gconstpointer data)
proximity_state_repr(prev),
proximity_state_repr(proximity_sensor_actual));
tklock_datapipe_proximity_eval_led();
/* update lpm ui proximity history using raw data */
tklock_lpmui_update_history(proximity_sensor_actual);
......
......@@ -1893,6 +1893,9 @@ static const char * const led_patterns[] =
MCE_LED_PATTERN_DISPLAY_DIMMED,
MCE_LED_PATTERN_SCANNING_FINGERPRINT,
MCE_LED_PATTERN_FINGERPRINT_ACQUIRED,
MCE_LED_PATTERN_PROXIMITY_COVERED,
MCE_LED_PATTERN_PROXIMITY_UNCOVERING,
MCE_LED_PATTERN_PROXIMITY_UNCOVERED,
0
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment