| 1105 | } |
| 1106 | |
| 1107 | static uint32_t getCoefForResolution(uint8_t resolution, uint32_t duration) { |
| 1108 | uint32_t resolDuration = getUsForResolution(resolution); |
| 1109 | uint32_t result = duration / resolDuration; |
| 1110 | |
| 1111 | // If the next-higher coefficient is closer, use that |
| 1112 | if (abs(duration - ((result + 1) * resolDuration)) < abs(duration - (result * resolDuration))) |
| 1113 | return result + 1; |
| 1114 | |
| 1115 | return result; |
| 1116 | } |
| 1117 | |
| 1118 | static bool chooseResolutionAndCoef(uint8_t *resolutions, uint32_t duration, uint8_t& resolOut, uint8_t& coefOut) { |
| 1119 | for (int i = 0; resolutions[i]; i++) { |
no test coverage detected