Calibration mode
What is calibration mode?
No two arms are the exact same, and calibration mode helps us ensure that the readings we take from the
sensors are calibrated such that the predictions we eventually make are personalized for the current user.
The mode takes the user through a series of hand movements and collects data that it will later use to
make predictions. Calibration mode starts off by defining the number of trials - which is the number of
runs of the predetermined movements that a user would be guided through during calibration. It then
checks if the user has initiated calibration mode by pressing a switch, and if so, zeros out all the peaks and
mins and peak percents and min percents in all the sensor structs. The calibration thread then collects
sensor peak, min, peak percent, min percent for each different movement, for each different sensor, for
each trial and maintains a running average of each of these values. The code snippet for this running
average can be seen below:
1. //Zero out arrays
2. for (i = 0; i < num_valid_sensors; i++)
3. {
4. for (j = 0; j < 11; j++)
5. {
6. sensors[i].peaks[j] = 0.0;
7. sensors[i].mins[j] = 0.0;
8. sensors[i].peak_percents[j] = 0.0;
9. sensors[i].min_percents[j] = 0.0;
10. }
11. }
12.
13. //print start message
14. tft_fillRoundRect(0, 0, 300, 380, 1, ILI9340_BLACK);
15. tft_setCursor(2, 180);
16. sprintf(buffer2, "%s", finger_msgs[0]);
17. tft_writeString(buffer2);
18. PT_YIELD_TIME_msec(1000);
19.
20. for (i = 0; i < num_trials; i++)
21. {
22. for (j = 0; j < 11; j++)
23. {
24. tft_fillRoundRect(0, 0, 300, 280, 1, ILI9340_BLACK);
25. tft_setCursor(2, 180);
26. sprintf(buffer2, "%s", finger_msgs[j + 1]);
27. tft_writeString(buffer2);
28. PT_YIELD_TIME_msec(2000);
29. for (k = 0; k < num_valid_sensors; k++) // adding all he peaks and peak percents to later average