summaryrefslogtreecommitdiff
path: root/common/gesture.c
Commit message (Collapse)AuthorAgeFilesLines
* motion: Use empty CONFIG_ variable to use IS_ENABLED()Gwendal Grignou2020-11-061-1/+1
| | | | | | | | | | | | | | | | Split information in a boolean variable and another variable that contains a property. For instance, CONFIG_GESTURE_SENSOR_DOUBLE_TAP becomes: CONFIG_GESTURE_SENSOR_DOUBLE_TAP : boolean variable CONFIG_GESTURE_TAP_SENSOR : property that contains the sensor number. BUG=chromium:1140877 BRANCH=none TEST=buildall Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I27ba462f8a12b14882104b9f983f2dc17f917314 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2488937
* Clean up double tap related definitionHeng-Ruey Hsu2019-11-131-1/+1
| | | | | | | | | | | | | | | | Fixes: commit 2f2a81079191ca "Add double tap and make motion sense wake up ap" CONFIG_GESTURE_DETECTION_MASK includes significant motion in activity list. We cannot use it for double tap. Add more flags to distinguish it. BUG=b:135575671 BRANCH=kukui TEST=AP can receive mkbp event when double tap is triggered Change-Id: I13776a01b14dc251396a615c8c97353f2d0477d4 Signed-off-by: Heng-Ruey Hsu <henryhsu@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1911263 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* cleanup: refactor CPRINTF("[%T ...]\n") to CPRINTSJack Rosenthal2019-07-171-7/+8
| | | | | | | | | | | | | | | | Looking at where the non-standard %T printf modifier is used in EC codebase, the majority is cases where CPRINTS could have been used instead of CPRINTF. This is a somewhat-mechanical refactor of these cases, which will make implementing a standard printf easier. BUG=chromium:984041 BRANCH=none TEST=buildall Change-Id: I75ea0be261bfbfa50fb850a0a37fe2ca6ab67cb9 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1703128 Reviewed-by: Evan Green <evgreen@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* motion: Define macros for custom eventsGwendal Grignou2019-03-201-1/+2
| | | | | | | | | | | | | | Define macros to define custom events used by sensor interrupt handlers. Remove CONFIG_ for activity events. BUG=none BRANCH=none TEST=compile, sensors work on eve. Change-Id: I08ef6ed2a004466ebc5f7650d6952a150b9de713 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1272189 Reviewed-by: Jett Rink <jettrink@chromium.org>
* Fix various misspellings in commentsMartin Roth2016-11-151-1/+1
| | | | | | | | | | | | | No functional changes. BUG=none BRANCH=none TEST=make buildall passes Change-Id: Ie852feb8e3951975d99dce5a49c17f5f0e8bc791 Signed-off-by: Martin Roth <martinroth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/403417 Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
* cleanup: DECLARE_CONSOLE_COMMAND only needs 4 argsBill Richardson2016-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since pretty much always, we've declared console commands to take a "longhelp" argument with detailed explanations of what the command does. But since almost as long, we've never actually used that argument for anything - we just silently throw it away in the macro. There's only one command (usbchargemode) that even thinks it defines that argument. We're never going to use this, let's just get rid of it. BUG=none BRANCH=none CQ-DEPEND=CL:*279060 CQ-DEPEND=CL:*279158 CQ-DEPEND=CL:*279037 TEST=make buildall; tested on Cr50 hardware Everything builds. Since we never used this arg anyway, there had better not be any difference in the result. Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/374163 Reviewed-by: Myles Watson <mylesgw@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gesture: fix double tap doesn't always work in suspendAlec Berg2015-09-291-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix bug where sometimes on suspend tap for battery would never work, but open a resume and suspend again it would work fine. Problem is that if suspended when accel circular buffer index is 1, then we would never run the detection algorithm, because the check for if the history buffer has been initialized is incorrect. This also fixes the algorithm so that on suspend, it requires the full sensor history buffer be filled up again before starting to detect the double tap. BUG=chrome-os-partner:45930 BRANCH=samus TEST=go in to suspend when history_index is 1 and verify that tap for battery works. wrote following console command to pause the circular buffer at a specific index. static int pause_index = -1; static int check_pause; static void gesture_chipset_resume(void) { /* disable tap detection */ check_pause = 1; } DECLARE_HOOK(HOOK_CHIPSET_RESUME, gesture_chipset_resume, GESTURE_HOOK_PRIO); void gesture_calc(void) { if (check_pause) { if (pause_index < 0 || history_idx == pause_index) { ccprintf("Paused at %d\n", pause_index); tap_detection = 0; pause_index = -1; check_pause = 0; } } ... static int command_tap_pause(int argc, char **argv) { char *e; int v; if (argc == 2) { v = strtoi(argv[1], &e, 0); if (*e) return EC_ERROR_PARAM1; pause_index = v; } return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(tappause, command_tap_pause, "", "", NULL); Change-Id: I2ba4ab2c807ec6ac1885a4829efedac3c83b32f1 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/302648 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: motion: move gesture actions in motion task.Gwendal Grignou2015-09-181-8/+3
| | | | | | | | | | | | | | Change the IRQ interface to allow adding events. Move code to send the lightbar sequence from gesture.c to motion task. TEST=compile, works on Ryu. BRANCH=smaug BUG=chrome-os-partner:44754 Change-Id: I981ea123ebef0e8e3d6aa320eade89f10e83b6fc Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/296822 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* samus: Use new config, fix gestureGwendal Grignou2015-08-291-13/+0
| | | | | | | | | | | | | | Use new config table. Move ODR setting in motion sense, fix variable names. BRANCH=samus BUG=chromium:513458 TEST=Test accelerator and double tap on Samus Change-Id: I341add11a18de8e4cc97c57da29f9114bd2014cf Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295638 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* driver: change get_ interface.Gwendal Grignou2015-08-291-3/+2
| | | | | | | | | | | | | | | Simplify sensor get_data_rate, get_range and get_resolution. Error code was not checked and these functions as currently implemented have no reason to fail. BRANCH=ryu,samus,cyan,strago BUG=chromium:513458 TEST=Check on ryu, compile Change-Id: I40dca41cee29a19f65b2f84d434b4c19eb6cbf3c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295635 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* motion_sense: Fix init routinesGwendal Grignou2015-07-271-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | active state is global, remove it from motion_sensor structure. Reinit sensors when entering RW, fix regression introduced by CL:284616. Improve EC polling rate calculation by excluding suspended sensors. Wake up sensor thread in case the motion task was in deep sleep. Do not send sense interrupt while suspened. Will revisit once wakeup sensors are implemented. BRANCH=smaug TEST=Check when in RW the sensors are exposed. Check EC rate are correct in different power state. Check when jumping from RO to RW and back, after setting the frequencies parameters via sysfs properly, AndroSensor acquires the data properly. BUG=chrome-os-partner:43132,chrome-os-partner:40741 Change-Id: Ie70732b135a432d64935eead4200ddc0e1a7c0b4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/288201 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* cleanup: rename motion sensor CONFIG_ optionsBill Richardson2015-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This renames some motion sensor options to start with more consistent prefixes. For gesture (tap) detection: CONFIG_GESTURE_DETECTION: CONFIG_SENSOR_BATTERY_TAP => CONFIG_GESTURE_SENSOR_BATTERY_TAP For detecting lid angle: CONFIG_LID_ANGLE: CONFIG_SENSOR_BASE => CONFIG_LID_ANGLE_SENSOR_BASE CONFIG_SENSOR_LID => CONFIG_LID_ANGLE_SENSOR_LID BUG=none BRANCH=none TEST=make buildall Change-Id: Ib8f645902a5585346e1d8d2cbf73d825c896a521 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/268777 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gesture: add absolute threshold for start of tap for batteryAlec Berg2014-12-301-1/+2
| | | | | | | | | | | | | | | | | | | | Add absolute threshold on delta_z_inner for tap for battery to guarantee that we have at least some minimum absolute change in z that has started the tap for battery. This change makes it such that if the accel readings are really steady for a while, then a sudden noisy signal doesn't trigger tap for battery. BUG=chrome-os-partner:34592 BRANCH=samus TEST=use tapinfo on to observe tap values and do a double tap of varying intensities. note that it should be just a little less sensitive to weak taps. Change-Id: I95367bc7f99b888e15e9ac3a2bc8c9cca32d30d6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/237666 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* gesture: double tap for battery accelereomter ODRAlec Berg2014-12-301-1/+5
| | | | | | | | | | | | | | | | | | | | Double the output data rate setting for accels for tap for battery because with the lsm6ds0 sensor, the current ODR does not guarantee that we get fresh data every time we do a read. BUG=chrome-os-partner:34592 BRANCH=samus TEST=load onto samus, go to G3, use tapinfo on to see ODR set to 476000Hz. add printf to lsm6ds0 to print when data is not ready, and see that without this change, the printf is hit once a minute or so, and with this change, the printf is never hit, meaning new data is always ready. Change-Id: Ib09cba0d70642f59df8a35b5b6bb4fd7b9a4fa3d Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/237665 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* samus: accel: fix initialization bug in tap gestureAlec Berg2014-10-311-12/+8
| | | | | | | | | | | | | | | | | | | | | Fix bug in tap gesture. When turning on tap detection, don't clear the history circular array index. This was causing inconsitent tap for battery recognition because the inner window sum of z-axis data (sum_z_inner) was relying on subtracting out old historical data and adding in the new data, but when the array index changed, it was subtracting out the wrong old data. This really only came in to play if there was significant z motion before the last wakeup. BUG=none BRANCH=samus TEST=keep going to sleep and waking up and test that tap for battery works every time. Change-Id: I55e00c805d504dd6d257a81f2cd25fe384a53257 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226591 Reviewed-by: Sheng-liang Song <ssl@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* gesture: Minor fixesGwendal Grignou2014-10-291-3/+5
| | | | | | | | | | | | | | | Set state or numeric when needed Add debug for the idle state. BUG=None BRANCH=ToT TEST=Check debug appears when enabled. Check tap still works. Change-Id: Ic4660f70a27464dc68c02fdaef60dc36d7c2edad Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225487 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* Samus: move gesture to commonGwendal Grignou2014-10-291-0/+340
Move gesture to common directory, 1st step to be reused by other board. Cleanup motion_sense shutdown path. BUG=chrome-os-partner:33102 TEST=Double tap still works on Samus BRANCH=ToT Change-Id: I0a3b38c4a7dbe95c27dcdebff04c1176aaf932d1 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225235 Reviewed-by: Sheng-liang Song <ssl@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>