Skip to content

Instantly share code, notes, and snippets.

@FintasticMan
Last active January 1, 2023 22:52
Show Gist options
  • Save FintasticMan/72d3aa1fc5c7cb9739f45b81197836c7 to your computer and use it in GitHub Desktop.
Save FintasticMan/72d3aa1fc5c7cb9739f45b81197836c7 to your computer and use it in GitHub Desktop.

Revisions

  1. FintasticMan revised this gist Jan 1, 2023. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion batt_optimisation.md
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,13 @@ I then used the `itctl watch batt` command to monitor when the battery percentag

    I used the following formula to convert the percentages back to the voltage: `3200 + (reported_charge * 10 + 5) * (4180 - 3200) / 1000`.
    This is just a linear interpolation of `reported_charge + 0.5` between 3200 mV and 4180 mV (min. and max. voltages respectively).
    The reason for the + 0.5 is because the new percentage gets updated when it changes, so the actual voltage will be in the upper range of the possible voltages for that charge level.
    The reason for the + 0.5 is that the Bluetooth characteristic gets updated when the percentage changes, so the actual voltage will be in the upper range of the possible voltages for that percentage.
    I also normalised the time between 0 and 100, and inverted that to get the "best theoretical charge level".

    I then used some code to go through all possible values in a linear approximation using 6 points.
    I calculated the loss between the linear approximation and the best theoretical charge from all the tests, and chose the linear approximation with the lowest loss.

    # Results

    The results are shown in the CSV files below.
    The values where the watch reported 100% charge have been removed, as it is not possible to accurately calculate the voltage for those.
  2. FintasticMan revised this gist Jan 1, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions batt_optimisation.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,8 @@ I then set up a constant load on the PineTime, either with the heart rate monito
    I then used the `itctl watch batt` command to monitor when the battery percentage advertised by the watch changed.

    I used the following formula to convert the percentages back to the voltage: `3200 + (reported_charge * 10 + 5) * (4180 - 3200) / 1000`.
    This is just a linear interpolation of `reported_charge + 0.5` between 3200 mV and 4180 mV (min. and max. voltages respectively).
    The reason for the + 0.5 is because the new percentage gets updated when it changes, so the actual voltage will be in the upper range of the possible voltages for that charge level.
    I also normalised the time between 0 and 100, and inverted that to get the "best theoretical charge level".

    I then used some code to go through all possible values in a linear approximation using 6 points.
  3. FintasticMan revised this gist Jan 1, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions batt_optimisation.md
    Original file line number Diff line number Diff line change
    @@ -3,10 +3,10 @@
    To gather the battery data, I ran the 3 PineTimes running stock InfiniTime 1.11.
    I connected them to a Linux device with [ITD](https://gitea.arsenm.dev/Arsen6331/itd).
    I then set up a constant load on the PineTime, either with the heart rate monitor on and the torch on max, or with the heart rate monitor and screen both off.
    I then used the `itctl watch batt` command to watch when the battery percentage advertised by the watch changed.
    I then used the `itctl watch batt` command to monitor when the battery percentage advertised by the watch changed.

    I used the following formula to convert the percentages back to the voltage: `3200 + (reported_charge * 10 + 5) * (4180 - 3200) / 1000`.
    I also normalised the time between 0 and 100, and inverted that to get the best theoretical charge.
    I also normalised the time between 0 and 100, and inverted that to get the "best theoretical charge level".

    I then used some code to go through all possible values in a linear approximation using 6 points.
    I calculated the loss between the linear approximation and the best theoretical charge from all the tests, and chose the linear approximation with the lowest loss.
  4. FintasticMan created this gist Jan 1, 2023.
    12 changes: 12 additions & 0 deletions batt_optimisation.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # Methodology

    To gather the battery data, I ran the 3 PineTimes running stock InfiniTime 1.11.
    I connected them to a Linux device with [ITD](https://gitea.arsenm.dev/Arsen6331/itd).
    I then set up a constant load on the PineTime, either with the heart rate monitor on and the torch on max, or with the heart rate monitor and screen both off.
    I then used the `itctl watch batt` command to watch when the battery percentage advertised by the watch changed.

    I used the following formula to convert the percentages back to the voltage: `3200 + (reported_charge * 10 + 5) * (4180 - 3200) / 1000`.
    I also normalised the time between 0 and 100, and inverted that to get the best theoretical charge.

    I then used some code to go through all possible values in a linear approximation using 6 points.
    I calculated the loss between the linear approximation and the best theoretical charge from all the tests, and chose the linear approximation with the lowest loss.
    27 changes: 27 additions & 0 deletions pt1_intensive_load.csv
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    "time (s)","voltage (mV)","theoretical best charge (%)","original reported charge (%)","AlexXZero reported charge (%)","my reported charge (%)"
    82.315383,4135,99,95,95,95
    682.227791,4096,96,91,92,91
    1282.139351,4067,92,88,89,88
    1882.299515,4028,88,84,86,84
    2482.211231,3998,85,81,83,80
    3082.122718,3979,81,79,82,79
    3682.283310,3949,77,76,79,74
    4282.195255,3910,74,72,75,68
    4882.106557,3890,70,70,73,65
    5482.267185,3861,66,67,68,60
    6082.181445,3841,63,65,65,57
    6682.091274,3812,59,62,60,53
    7282.251875,3792,55,60,57,50
    7882.163279,3773,52,58,53,46
    8482.074691,3763,48,57,52,41
    9082.235630,3734,44,54,42,27
    10282.307539,3724,37,53,37,22
    11482.131390,3694,29,50,24,16
    12682.203492,3675,22,48,21,13
    14482.187406,3655,11,46,18,9
    15082.098751,3636,7,44,15,6
    15682.259415,3587,4,39,8,2
    16282.171473,3557,0,36,5,1
    16882.082599,3479,0,28,0,0
    17482.243498,3312,0,11,0,0
    18082.155006,3204,0,0,0,0
    92 changes: 92 additions & 0 deletions pt1_light_load.csv
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    "time (s)","voltage (mV)","theoretical best charge (%)","original reported charge (%)","AlexXZero reported charge (%)","my reported charge (%)"
    11026.674873,4175,99,99,99,99
    14626.642672,4165,99,98,98,98
    20626.755084,4155,98,97,97,97
    30226.587385,4145,97,96,96,96
    44626.707816,4135,96,95,95,95
    47026.602776,4126,95,94,95,94
    63226.708001,4116,94,93,94,93
    74026.612968,4106,93,92,93,92
    78826.652366,4096,92,91,92,91
    98026.563019,4086,90,90,91,90
    102826.603060,4077,90,89,90,89
    116626.562999,4067,88,88,89,88
    131026.707141,4057,87,87,89,87
    138226.643051,4047,86,86,88,86
    148426.635025,4037,85,85,87,85
    157426.555931,4028,84,84,86,84
    171226.514815,4018,83,83,85,83
    184426.562808,4008,82,82,84,82
    200026.506753,3998,80,81,83,80
    203026.562902,3988,80,80,82,79
    221026.650929,3979,78,79,82,79
    233626.538641,3969,77,78,81,77
    243826.530889,3959,76,77,80,75
    257626.491413,3949,74,76,79,74
    275626.330176,3939,73,75,78,72
    293626.419045,3930,71,74,77,71
    311026.346630,3920,69,73,76,69
    311626.506926,3910,69,72,75,68
    333826.474970,3890,67,70,73,65
    368026.419057,3881,63,69,71,64
    389626.226234,3871,61,68,70,62
    407626.315191,3861,59,67,68,60
    419026.378848,3851,58,66,66,59
    433426.250970,3841,57,65,65,57
    435226.235270,3832,57,64,63,56
    447826.370956,3822,55,63,62,55
    462826.154547,3812,54,62,60,53
    477226.274870,3802,53,61,58,51
    499426.242983,3792,50,60,57,50
    528826.146861,3783,47,59,55,49
    534826.006326,3773,47,58,53,46
    582826.163309,3763,42,57,52,41
    645826.098724,3753,36,56,50,36
    681826.026891,3743,32,55,46,31
    749026.091135,3734,26,54,42,27
    774826.027111,3724,23,53,37,22
    791626.043251,3714,21,52,32,20
    814425.922736,3704,19,51,27,18
    835426.067263,3694,17,50,24,16
    852825.995005,3685,15,49,22,15
    878625.930871,3675,13,48,21,13
    888825.922926,3665,12,47,19,11
    902625.883004,3655,10,46,18,9
    931425.874906,3645,7,45,16,8
    962025.850888,3636,4,44,15,6
    971625.930967,3626,3,43,13,4
    981226.011015,3616,2,42,12,3
    986625.962874,3606,2,41,10,2
    988425.946932,3596,2,40,9,2
    990825.842925,3587,1,39,8,2
    992625.827043,3577,1,38,7,1
    993825.898849,3567,1,37,6,1
    996225.794957,3557,1,36,5,1
    998625.938949,3547,1,35,4,1
    1000425.923036,3538,1,34,3,0
    1002825.818848,3528,0,33,2,0
    1005825.874206,3508,0,31,0,0
    1007025.699498,3498,0,30,0,0
    1010625.915509,3479,0,28,0,0
    1011825.737080,3469,0,27,0,0
    1014225.882803,3449,0,25,0,0
    1017825.850961,3430,0,23,0,0
    1019025.676241,3420,0,22,0,0
    1020225.747396,3410,0,21,0,0
    1021425.819242,3400,0,20,0,0
    1022025.730081,3391,0,19,0,0
    1023225.803060,3381,0,18,0,0
    1023825.714748,3371,0,17,0,0
    1024425.875370,3361,0,16,0,0
    1026225.858837,3342,0,14,0,0
    1027425.682415,3332,0,13,0,0
    1028625.755070,3322,0,12,0,0
    1029225.914963,3312,0,11,0,0
    1029825.827036,3302,0,10,0,0
    1031025.898959,3283,0,8,0,0
    1031625.810948,3273,0,7,0,0
    1032825.883251,3253,0,5,0,0
    1033425.794613,3244,0,4,0,0
    1034025.706107,3234,0,3,0,0
    1034625.866684,3224,0,2,0,0
    1035225.778943,3204,0,0,0,0
    28 changes: 28 additions & 0 deletions pt2_intensive_load.csv
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    "time (s)","voltage (mV)","theoretical best charge (%)","original reported charge (%)","AlexXZero reported charge (%)","my reported charge (%)"
    397.823671,4175,98,99,99,99
    997.984616,4145,94,96,96,96
    1597.897276,4096,90,91,92,91
    2197.808204,4067,86,88,89,88
    2797.970310,4037,83,85,87,85
    3397.880385,3988,79,80,82,79
    3997.791704,3949,75,76,79,74
    4597.952188,3939,71,75,78,72
    5197.864796,3920,68,73,76,69
    5798.024302,3881,64,69,71,64
    6397.936423,3861,60,67,68,60
    6997.848019,3851,56,66,66,59
    7598.008076,3822,53,63,62,55
    8197.921890,3802,49,61,58,51
    8797.831927,3792,45,60,57,50
    9397.992074,3783,41,59,55,49
    9997.904186,3773,38,58,53,46
    10597.815299,3753,34,56,50,36
    11797.887924,3734,26,54,42,27
    12398.048123,3724,23,53,37,22
    13597.874448,3704,15,51,27,18
    14198.031853,3675,11,48,21,13
    14797.944398,3645,8,45,16,8
    15397.855857,3616,4,42,12,3
    15998.016171,3538,0,34,3,0
    16597.929190,3361,0,16,0,0
    17197.839275,3204,0,0,0,0
    95 changes: 95 additions & 0 deletions pt2_light_load.csv
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,95 @@
    "time (s)","voltage (mV)","theoretical best charge (%)","original reported charge (%)","AlexXZero reported charge (%)","my reported charge (%)"
    61688.204255,4175,94,99,99,99
    72488.355837,4165,93,98,98,98
    80288.203157,4155,92,97,97,97
    94688.323687,4145,90,96,96,96
    105488.475812,4135,89,95,95,95
    118088.363046,4126,88,94,95,94
    123488.563912,4116,87,93,94,93
    136688.611864,4106,86,92,93,92
    145088.619949,4096,85,91,92,91
    170888.803945,4086,83,90,91,90
    179288.811808,4077,82,89,90,89
    190088.715778,4067,81,88,89,88
    196688.739844,4057,80,87,89,87
    209288.875910,4047,79,86,88,86
    217688.883778,4037,78,85,87,85
    222488.923842,4028,77,84,86,84
    232089.004668,4018,76,83,85,83
    251289.164071,4008,74,82,84,82
    254889.132229,3998,74,81,83,80
    265689.035982,3988,73,80,82,79
    286689.179699,3979,71,79,82,79
    307089.411491,3969,69,78,81,77
    337689.388165,3959,66,77,80,75
    345489.483789,3949,65,76,79,74
    362889.411051,3939,63,75,78,72
    372489.492051,3930,62,74,77,71
    391689.652243,3920,60,73,76,69
    394089.547489,3910,60,72,75,68
    408489.668214,3900,58,71,75,66
    413889.619061,3890,58,70,73,65
    428889.899947,3881,56,69,71,64
    439689.803890,3871,55,68,70,62
    466089.899892,3861,52,67,68,60
    486490.131952,3851,50,66,66,59
    499690.179809,3841,49,65,65,57
    523690.131741,3832,47,64,63,56
    558490.235131,3822,43,63,62,55
    602290.507685,3812,39,62,60,53
    620890.756141,3802,37,61,58,51
    653290.715187,3792,33,60,57,50
    689891.052027,3783,30,59,55,49
    722291.013737,3773,26,58,53,46
    752291.323912,3763,23,57,52,41
    782891.299880,3753,20,56,50,36
    802691.371792,3743,18,55,46,31
    823091.604289,3734,16,54,42,27
    839891.621315,3724,14,53,37,22
    853091.667871,3714,13,52,32,20
    863891.575153,3704,12,51,27,18
    887291.859765,3694,9,50,24,16
    929291.899597,3685,5,49,22,15
    941292.123842,3675,4,48,21,13
    944291.931308,3665,4,47,19,11
    947291.987741,3655,3,46,18,9
    951492.115630,3645,3,45,16,8
    954492.171997,3636,3,44,15,6
    955691.995575,3626,2,43,13,4
    957491.979168,3616,2,42,12,3
    961092.195931,3606,2,41,10,2
    962292.019075,3596,2,40,9,2
    965892.235929,3577,1,38,7,1
    968292.131977,3567,1,37,6,1
    970692.027238,3557,1,36,5,1
    973692.084039,3538,1,34,3,0
    976692.139830,3528,0,33,2,0
    977892.211597,3518,0,32,1,0
    979692.196235,3508,0,31,0,0
    980292.107932,3498,0,30,0,0
    981492.179858,3489,0,29,0,0
    983292.163460,3479,0,28,0,0
    983892.323696,3469,0,27,0,0
    984492.235852,3459,0,26,0,0
    988092.203879,3449,0,25,0,0
    989292.275960,3430,0,23,0,0
    989892.187791,3420,0,22,0,0
    992892.243761,3400,0,20,0,0
    994692.228241,3381,0,18,0,0
    995892.299775,3371,0,17,0,0
    996492.211845,3361,0,16,0,0
    997692.283672,3351,0,15,0,0
    998292.195936,3342,0,14,0,0
    998892.355731,3332,0,13,0,0
    1000092.179512,3322,0,12,0,0
    1001292.251872,3312,0,11,0,0
    1001892.163105,3302,0,10,0,0
    1002492.323897,3293,0,9,0,0
    1003092.235763,3283,0,8,0,0
    1003692.395733,3273,0,7,0,0
    1004292.307747,3263,0,6,0,0
    1004892.218999,3253,0,5,0,0
    1005492.379695,3234,0,3,0,0
    1006692.203053,3224,0,2,0,0
    1007292.363804,3214,0,1,0,0
    1007892.275796,3204,0,0,0,0
    25 changes: 25 additions & 0 deletions pt3_intensive_load.csv
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    "time (s)","voltage (mV)","theoretical best charge (%)","original reported charge (%)","AlexXZero reported charge (%)","my reported charge (%)"
    176.494553,4145,99,96,96,96
    776.654220,4096,94,91,92,91
    1376.566352,4057,90,87,89,87
    1976.726287,4028,86,84,86,84
    2576.638194,3988,82,80,82,79
    3176.550213,3939,77,75,78,72
    3776.710255,3930,73,74,77,71
    4376.622184,3890,69,70,73,65
    4976.534393,3871,64,68,70,62
    5576.695183,3832,60,64,63,56
    6176.606190,3812,56,62,60,53
    6776.518232,3792,52,60,57,50
    7376.678274,3773,47,58,53,46
    7976.590194,3763,43,57,52,41
    8576.501580,3734,39,54,42,27
    10376.734264,3724,26,53,37,22
    10976.646185,3704,21,51,27,18
    12176.718843,3685,13,49,22,15
    12776.630056,3645,9,45,16,8
    13376.541509,3596,4,40,9,2
    13976.702022,3528,0,33,2,0
    14576.614421,3449,0,25,0,0
    15176.775205,3283,0,8,0,0
    15776.686081,3204,0,0,0,0