commit 8ad4fe4f4e1d5dfdac26fb7d86acd503a84ca56f
Author: d3fault <d3fault@d3fault.net>
Date:   Tue May 23 18:24:11 2017 -0700

    QuickDirtyAutoBackupHalper3 Commit @23 May 2017 18:24:08 -0700

diff --git a/.lastModifiedTimestamps b/.lastModifiedTimestamps
index 4f4cd36..4df30ac 100644
--- a/.lastModifiedTimestamps
+++ b/.lastModifiedTimestamps
@@ -5899,23 +5899,23 @@ Projects/wasdf/assets/ArduinoSketches/ArduinoWriteChangesOnAnalogPinsToSerial/Ma
Projects/wasdf/design/:1495255816
Projects/wasdf/design/pin.detection.and.finger.mapping.are.same.step.as.calibration.txt:1495315077
Projects/wasdf/design/renaming.from.MusicFingers.txt:1495250184
Projects/wasdf/src/:1495587342Projects/wasdf/src/:1495589041
Projects/wasdf/src/cli/:1495395081
Projects/wasdf/src/cli/main.cpp:1495395081
Projects/wasdf/src/cli/wasdfcli.cpp:1495394570
Projects/wasdf/src/cli/wasdfcli.h:1495394574
Projects/wasdf/src/lib/:1495587281Projects/wasdf/src/lib/:1495589000
Projects/wasdf/src/lib/fingeriteratororderedbymostusedfingers.cpp:1495480054
Projects/wasdf/src/lib/fingeriteratororderedbymostusedfingers.h:1495480049
Projects/wasdf/src/lib/wasdf.cpp:1495494946
Projects/wasdf/src/lib/wasdf.h:1495585868
Projects/wasdf/src/lib/wasdfarduino.cpp:1495494079
Projects/wasdf/src/lib/wasdfarduino.h:1495419683
Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.cpp:1495587281
Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.h:1495587029Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.cpp:1495589000
Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.h:1495588618
Projects/wasdf/src/lib/wasdfcalibrationconfigurationsettingsreaderwriter.cpp:1495562619
Projects/wasdf/src/lib/wasdfcalibrationconfigurationsettingsreaderwriter.h:1495490722
Projects/wasdf/src/lib/wasdfcalibrator.cpp:1495585164Projects/wasdf/src/lib/wasdfcalibrator.cpp:1495588873
Projects/wasdf/src/lib/wasdfcalibrator.h:1495582802
Projects/wasdf/src/wasdf-cli.pro:1495396931
Projects/wasdf/src/wasdf.pri:1495582264
diff --git a/Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.cpp b/Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.cpp
index ce4421c..2125190 100644
--- a/Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.cpp
+++ b/Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.cpp
@@ -4,14 +4,15 @@
#include <QMutableHashIterator>

//TODOmb: like I'm pushing this functionality into it's own class, so too should I (probably/maybe, but also maybe not [yet] if it's too much work to refactor xD) push the "analog pin detection" and "normal use range detection" into their own classes. Additionally, all calibration related classes should go in a ./calibration subfolder. The WasdfCalibrator should simply hasA these 3 types of calibration 'mode' thingies (for lack of a better word)
//TODOreq: use assloads of typedefs to make the nested templates easier to understand
void WasdfCalibrationAtRestDetector::addAnalogPinPosition(int analogPinId, int newPinPosition)
{
    m_CurrentAllAnalogPinPositions_ByAnalogPinId.value(analogPinId, QSharedPointer<QList<int> >(new QList<int /*sensor value*/>()))->append(newPinPosition);
}
void WasdfCalibrationAtRestDetector::weJustFinishedCalibratingThisAnalogPinId(int analogPinIdToDiscardCurrentPinPositionsFor)WasdfCalibrationAtRestDetector::weJustFinishedCalibratingThisAnalogPinId(Finger fingerWeJustFinishedCalibrating, int analogPinWeJustFinishedCalibrating)
{
    //0) discard the positions for the analog pin id passed in (because we told the user to move it a bunch, so it wasn't "at rest" at all!)
    m_CurrentAllAnalogPinPositions_ByAnalogPinId.remove(analogPinIdToDiscardCurrentPinPositionsFor);m_CurrentAllAnalogPinPositions_ByAnalogPinId.remove(analogPinWeJustFinishedCalibrating);

    //now discard all position data for fingers on the same hand <---- NVM. although we know the finger that was just calibrated, we have no idea (yet) what finger the rest of them are (ok that's only partially true. as we get nearer and nearer to the last finger we know more and more fingers. still, simpler to discard "same hand" values at the very end in finalize, when we know ALL fingers)

@@ -21,7 +22,7 @@ void WasdfCalibrationAtRestDetector::weJustFinishedCalibratingThisAnalogPinId(in
    {
        it.next();
        int average = calculateAverage(*(it.value().data()));
        m_RunningAllAnalogPinsAtRestPositionsToBeAveragedYetAgainAtTheVeryEndOfCalibration_ByAnalogPinId.value(it.key(), QSharedPointer<QList<int>m_AveragedAtRestValuesGatheredWhileCalibratingFingers_ByFinger.value(fingerWeJustFinishedCalibrating, QSharedPointer<QList<QPair<int /*pin number on arduino*/, int /*sensor value*/> > >(new QList<int>()))->append(average);QList<QPair<int,int> >()))->append(qMakePair(it.key(), average));
    }

    //2) clear the 'current' lists for the next 5 seconds of calibration (assuming there will be more, but it doesn't matter if there isn't)
@@ -30,9 +31,11 @@ void WasdfCalibrationAtRestDetector::weJustFinishedCalibratingThisAnalogPinId(in
void WasdfCalibrationAtRestDetector::finalize(WasdfCalibrationConfiguration *out_Calibration)
{
    //first discard all position data collected for fingers on the same hand
    //fuck, 'staggered' deletion of averages? fuck, my head hurts, what? like uhh when Finger6_RightIndex was being calibrated we delete the index 0 at rest average of the right hand, then Figner5_LeftIndex was being calibrated we delete the index 0 at rest average of the left hand, then Finger7_RightMiddle we delete index 1.. WAIT NO if we 'removed' index 0 (during RightIndex), then the new one we remove is going to be index 0 again!!! not 'staggered' after all. still my head hurts, typing this out certainly helps. so I use my ordered finger iterator I think. hmm I need to map the analog pins to the fingers first though, wait no that's already done in out_Calibration. wait no it IS staggered after all, since index 0 [now] points to an at rest value that we want to keep (one gathered while the opposite hand finger was being calibrated)! fuck, my head!!! still that just means a ++indexToDeleteOnRightHand and a ++indexToDeleteOnLeftHand, or something?
    hmmmm//^hmmmm to make things easier for my head I could record which finger each set of "at rest" values corresponds to. Hmmmm QHash<Finger, QSharedPointer<QList> > atRestValues_ByFingerBeingCalibratedWhenTheyWereDetected ??? then I iterate that hash, map the analog pins to the fingers, determine if it's the same hand as in that QHash's key, drop that reading if it is, if it's opposite then add it to a newly built QHash<Finger, QSharedPointer<QList> >, then finally after that iteration of same-hand droppage, iterate the newly built onehash simply to calculate the average rest value and THEN stuff it into out_Calibration
    //TODOreq: ^

#if 0 //TODOreq: merge the below with the above
    //get all the at rest readings for the fingers connected to analog pins we actually care about, then average those all together one last time, then stuff that final "at rest" value into the calibration
    QMutableHashIterator<Finger, WasdfCalibrationFingerConfiguration> it(*out_Calibration);
    while(it.hasNext())
@@ -40,11 +43,12 @@ void WasdfCalibrationAtRestDetector::finalize(WasdfCalibrationConfiguration *out
        it.next();
        WasdfCalibrationFingerConfiguration fingerConfiguration = it.value();
        int analogPinId = fingerConfiguration.AnalogPinIdOnArduino;
        QSharedPointer<QList<int>QSharedPointer<QList<QPair<int, int> > > atRestReadings = m_RunningAllAnalogPinsAtRestPositionsToBeAveragedYetAgainAtTheVeryEndOfCalibration_ByAnalogPinId.value(analogPinId);m_AveragedAtRestValuesGatheredWhileCalibratingFingers_ByFinger.value(analogPinId);
        int finalAveragedAtRestReading = calculateAverage(*(atRestReadings.data()));
        fingerConfiguration.AtRestPosition = finalAveragedAtRestReading;
        it.setValue(fingerConfiguration);
    }
#endif
}
int WasdfCalibrationAtRestDetector::calculateAverage(const QList<int> &numbersToAverageTogether)
{
diff --git a/Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.h b/Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.h
index 8fd3279..c348505 100644
--- a/Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.h
+++ b/Projects/wasdf/src/lib/wasdfcalibrationatrestdetector.h
@@ -11,12 +11,12 @@ class WasdfCalibrationAtRestDetector
{
public:
    void addAnalogPinPosition(int analogPinId, int newPinPosition);
    void weJustFinishedCalibratingThisAnalogPinId(int analogPinIdToDiscardCurrentPinPositionsFor);weJustFinishedCalibratingThisAnalogPinId(Finger fingerWeJustFinishedCalibrating, int analogPinWeJustFinishedCalibrating);
    void finalize(WasdfCalibrationConfiguration *out_Calibration);
private:
    int calculateAverage(const QList<int> &numbersToAverageTogether);
    QHash<int /*pin number on arduino*/, QSharedPointer<QList<int/*sensor value*/> > > m_CurrentAllAnalogPinPositions_ByAnalogPinId;
    QHash<intQHash<Finger /*finger that was being calibrated when we gathered these averages*/, QSharedPointer<QList<QPair<int /*pin number on arduino*/, QSharedPointer<QList<int/*sensorint /*sensor value*/> > > m_RunningAllAnalogPinsAtRestPositionsToBeAveragedYetAgainAtTheVeryEndOfCalibration_ByAnalogPinId;> m_AveragedAtRestValuesGatheredWhileCalibratingFingers_ByFinger;
};

#endif // WASDFCALIBRATIONATRESTDETECTOR_H
diff --git a/Projects/wasdf/src/lib/wasdfcalibrator.cpp b/Projects/wasdf/src/lib/wasdfcalibrator.cpp
index 8ef7594..48e43de 100644
--- a/Projects/wasdf/src/lib/wasdfcalibrator.cpp
+++ b/Projects/wasdf/src/lib/wasdfcalibrator.cpp
@@ -79,7 +79,7 @@ void WasdfCalibrator::handleTimerTimedOut()

    PinNumDetectionAndCalibrationData pinCalibrationDataOfFingerCurrentlyBeingCalibrated = getPinCalibrationDataWithTheFurthestAccumulatedDistanceTraveled();

    m_AtRestDetector.weJustFinishedCalibratingThisAnalogPinId(pinCalibrationDataOfFingerCurrentlyBeingCalibrated.PinCalibrationData.AnalogPinIdOnArduino);m_AtRestDetector.weJustFinishedCalibratingThisAnalogPinId(m_FingerCurrentlyBeingCalibrated, pinCalibrationDataOfFingerCurrentlyBeingCalibrated.PinCalibrationData.AnalogPinIdOnArduino);

    m_Calibration.insert(m_FingerCurrentlyBeingCalibrated, pinCalibrationDataOfFingerCurrentlyBeingCalibrated.PinCalibrationData);