![]() I do this by adding an inactive counter (spellInactiveCount) which is used to count the number of consecutive motion values below the spell threshold (MOTION_THRES_SPELL). In order to detect the end of a spell, I needed to add some hysteresis since the motion score can occasionally fall below the spell threshold for a frame event once and a while. ![]() Whenever a new motion score is available, it's compared to this value and replaced if greater.įor spell duration, we just increment a counter (spellDuration) every time a motion score is received while spellActive is true. If the averaged score is above the threshold and the wandOrientation is facing up, we set the spellActive flag and then begin collecting our two primary signals which are used for spell classification: maximum spell motion and spell duration.įor maximum spell motion, we basically just use a variable (spellMaxMotion) to hold the maximum motion score measured during the spell. Once our averaged motion score is ready (after SAMPLE_NUM samples are collected) we then check if the averaged value is above a threshold (see "MOTION_THRES_SPELL" parameter) we define for judging whether the user is casting a spell or not. These values are sampled when an event is received from our LIS3DH and then the absolute value of each signal is taken and summed together to create a pseudo "motion score" which is then averaged over a configurable number of events (see "SAMPLE_NUM" parameter). We start our signal chain with (3) acceleration values corresponding to each axis of our accelerometer (x, y, z). ![]() Read Accelerometer Data, Calculate Motion Score, and Averaging
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |