Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BufferedSerial FatFileSystemCpp mbed
frameRates.h@9:7214e3c3e5f8, 2021-02-18 (annotated)
- Committer:
- AndyA
- Date:
- Thu Feb 18 18:15:48 2021 +0000
- Revision:
- 9:7214e3c3e5f8
- Parent:
- 0:97661408d0f9
massive ripup and redesign; currently has file system build errors
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| AndyA | 0:97661408d0f9 | 1 | #ifndef __frameRates_h__ |
| AndyA | 0:97661408d0f9 | 2 | #define __frameRates_h__ |
| AndyA | 0:97661408d0f9 | 3 | |
| AndyA | 0:97661408d0f9 | 4 | namespace frameRateInfo { |
| AndyA | 0:97661408d0f9 | 5 | |
| AndyA | 0:97661408d0f9 | 6 | const float FrameRates[] = {0, 23.976, 24, 25, 29.97, 30, |
| AndyA | 0:97661408d0f9 | 7 | 47.95, 48, 50, 59.94, 60, 10000000}; |
| AndyA | 0:97661408d0f9 | 8 | |
| AndyA | 0:97661408d0f9 | 9 | /// us |
| AndyA | 0:97661408d0f9 | 10 | const double FramePeriods[] = {1000000, 1000000 / 23.976, 1000000 / 24, |
| AndyA | 0:97661408d0f9 | 11 | 1000000 / 25, 1000000 / 29.97, 1000000 / 30, |
| AndyA | 0:97661408d0f9 | 12 | 1000000 / 47.95, 1000000 / 48, 1000000 / 50, |
| AndyA | 0:97661408d0f9 | 13 | 1000000 / 59.94, 1000000 / 60, 10}; |
| AndyA | 0:97661408d0f9 | 14 | |
| AndyA | 0:97661408d0f9 | 15 | const int numberOfRates = 11; |
| AndyA | 0:97661408d0f9 | 16 | } |
| AndyA | 0:97661408d0f9 | 17 | |
| AndyA | 0:97661408d0f9 | 18 | class frameRates { |
| AndyA | 0:97661408d0f9 | 19 | |
| AndyA | 0:97661408d0f9 | 20 | public: |
| AndyA | 0:97661408d0f9 | 21 | |
| AndyA | 0:97661408d0f9 | 22 | frameRates(); |
| AndyA | 0:97661408d0f9 | 23 | |
| AndyA | 0:97661408d0f9 | 24 | void setRate(int index); |
| AndyA | 0:97661408d0f9 | 25 | void setDrop(bool drop) {_currentDrop = drop;}; |
| AndyA | 0:97661408d0f9 | 26 | bool isSyncable(); |
| AndyA | 0:97661408d0f9 | 27 | bool isValid() {return _currentRate!=0;}; |
| AndyA | 0:97661408d0f9 | 28 | |
| AndyA | 0:97661408d0f9 | 29 | const char *frameRateString(); |
| AndyA | 0:97661408d0f9 | 30 | // gets time since the start of the second in us. |
| AndyA | 0:97661408d0f9 | 31 | // in some frame drop modes this could be negative. |
| AndyA | 0:97661408d0f9 | 32 | static long getOffsetFromSecondStart(int minutes, int seconds, int frame, |
| AndyA | 0:97661408d0f9 | 33 | int rateIndex, bool frameDrop); |
| AndyA | 0:97661408d0f9 | 34 | |
| AndyA | 0:97661408d0f9 | 35 | // gets time since the start of the second in us. |
| AndyA | 0:97661408d0f9 | 36 | // in some frame drop modes this could be negative. |
| AndyA | 0:97661408d0f9 | 37 | long getOffsetFromSecondStart(int minutes, int seconds, int frame); |
| AndyA | 0:97661408d0f9 | 38 | |
| AndyA | 0:97661408d0f9 | 39 | |
| AndyA | 0:97661408d0f9 | 40 | float currentRate() {return _currentRate;}; |
| AndyA | 0:97661408d0f9 | 41 | double currentPeriodUS() {return _currentPeriod;}; |
| AndyA | 0:97661408d0f9 | 42 | int currentIndex() {return _currentIndex;}; |
| AndyA | 0:97661408d0f9 | 43 | bool currentDrop() {return _currentDrop;}; |
| AndyA | 0:97661408d0f9 | 44 | |
| AndyA | 9:7214e3c3e5f8 | 45 | static int getClosestRate(long int framePeriodUS); |
| AndyA | 9:7214e3c3e5f8 | 46 | |
| AndyA | 0:97661408d0f9 | 47 | private: |
| AndyA | 0:97661408d0f9 | 48 | float _currentRate; |
| AndyA | 0:97661408d0f9 | 49 | double _currentPeriod; |
| AndyA | 0:97661408d0f9 | 50 | int _currentIndex; |
| AndyA | 0:97661408d0f9 | 51 | bool _currentDrop; |
| AndyA | 0:97661408d0f9 | 52 | }; |
| AndyA | 0:97661408d0f9 | 53 | |
| AndyA | 0:97661408d0f9 | 54 | |
| AndyA | 0:97661408d0f9 | 55 | #endif |