RS232 control for TVOne products
spk_tvone_mbed.h@21:2260dde18dfa, 2013-05-12 (annotated)
- Committer:
- tobyspark
- Date:
- Sun May 12 18:36:40 2013 +0000
- Revision:
- 21:2260dde18dfa
- Parent:
- 20:ebddf3ddb1f6
- Child:
- 23:46f42462a183
Convenience methods getResolution() and getEDID()
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tobyspark | 0:533cfae24a1b | 1 | // *spark audio-visual |
tobyspark | 0:533cfae24a1b | 2 | // RS232 Control for TV-One products |
tobyspark | 0:533cfae24a1b | 3 | // Good for 1T-C2-750, others will need some extra work |
tobyspark | 1:349d6da461df | 4 | |
tobyspark | 1:349d6da461df | 5 | /* Copyright (c) 2011 Toby Harris, MIT License |
tobyspark | 1:349d6da461df | 6 | * |
tobyspark | 1:349d6da461df | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
tobyspark | 1:349d6da461df | 8 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
tobyspark | 1:349d6da461df | 9 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
tobyspark | 1:349d6da461df | 10 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
tobyspark | 1:349d6da461df | 11 | * furnished to do so, subject to the following conditions: |
tobyspark | 1:349d6da461df | 12 | * |
tobyspark | 1:349d6da461df | 13 | * The above copyright notice and this permission notice shall be included in all copies or |
tobyspark | 1:349d6da461df | 14 | * substantial portions of the Software. |
tobyspark | 1:349d6da461df | 15 | * |
tobyspark | 1:349d6da461df | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
tobyspark | 1:349d6da461df | 17 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
tobyspark | 1:349d6da461df | 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
tobyspark | 1:349d6da461df | 19 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
tobyspark | 1:349d6da461df | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
tobyspark | 1:349d6da461df | 21 | */ |
tobyspark | 0:533cfae24a1b | 22 | |
tobyspark | 0:533cfae24a1b | 23 | #ifndef SPKTVOne_mBed_h |
tobyspark | 0:533cfae24a1b | 24 | #define SPKTVOne_mBed_h |
tobyspark | 0:533cfae24a1b | 25 | |
tobyspark | 0:533cfae24a1b | 26 | #include "spk_tvone.h" |
tobyspark | 0:533cfae24a1b | 27 | #include "mbed.h" |
tobyspark | 0:533cfae24a1b | 28 | |
tobyspark | 0:533cfae24a1b | 29 | class SPKTVOne |
tobyspark | 0:533cfae24a1b | 30 | { |
tobyspark | 0:533cfae24a1b | 31 | public: |
tobyspark | 0:533cfae24a1b | 32 | SPKTVOne(PinName txPin, PinName rxPin, PinName signWritePin = NC, PinName signErrorPin = NC, Serial *debugSerial = NULL); |
tobyspark | 0:533cfae24a1b | 33 | |
tobyspark | 11:90e5a72a0034 | 34 | enum commandType {writeCommandType = 0, readCommandType = 1}; |
tobyspark | 10:5f398fc9b5c1 | 35 | static const int standardAckLength = 20; |
tobyspark | 10:5f398fc9b5c1 | 36 | |
tobyspark | 0:533cfae24a1b | 37 | bool command(uint8_t channel, uint8_t window, int32_t func, int32_t payload); |
tobyspark | 11:90e5a72a0034 | 38 | bool readCommand(uint8_t channel, uint8_t window, int32_t func, int32_t &payload); |
tobyspark | 14:da403a01f9ef | 39 | |
tobyspark | 18:d765b0d9271c | 40 | struct processorType {int version; int productType; int boardType;}; |
tobyspark | 18:d765b0d9271c | 41 | processorType getProcessorType(); |
tobyspark | 21:2260dde18dfa | 42 | |
tobyspark | 21:2260dde18dfa | 43 | int getResolution(); |
tobyspark | 21:2260dde18dfa | 44 | int getEDID(); |
tobyspark | 18:d765b0d9271c | 45 | bool setResolution(int resolution, int edidSlot); |
tobyspark | 18:d765b0d9271c | 46 | bool setHDCPOn(bool state); |
tobyspark | 18:d765b0d9271c | 47 | |
tobyspark | 16:ed8d08386034 | 48 | bool uploadEDID(FILE* file, int edidSlotIndex); |
tobyspark | 16:ed8d08386034 | 49 | bool uploadImage(FILE* file, int sisIndex); |
tobyspark | 18:d765b0d9271c | 50 | bool uploadCustomResolutions(); |
tobyspark | 14:da403a01f9ef | 51 | |
tobyspark | 18:d765b0d9271c | 52 | void setCommandTimeoutPeriod(int millis); |
tobyspark | 20:ebddf3ddb1f6 | 53 | int getCommandTimeoutPeriod(); |
tobyspark | 18:d765b0d9271c | 54 | void setCommandMinimumPeriod(int millis); |
tobyspark | 18:d765b0d9271c | 55 | void increaseCommandPeriods(int millis); |
tobyspark | 18:d765b0d9271c | 56 | void resetCommandPeriods(); |
tobyspark | 14:da403a01f9ef | 57 | |
tobyspark | 14:da403a01f9ef | 58 | int millisSinceLastCommandSent(); |
tobyspark | 0:533cfae24a1b | 59 | |
tobyspark | 0:533cfae24a1b | 60 | private: |
tobyspark | 18:d765b0d9271c | 61 | struct processorType processor; |
tobyspark | 18:d765b0d9271c | 62 | |
tobyspark | 11:90e5a72a0034 | 63 | bool command(commandType readWrite, int* ackBuffer, int ackLength, uint8_t channel, uint8_t window, int32_t func, int32_t payload); |
tobyspark | 16:ed8d08386034 | 64 | bool uploadFile(char command, FILE* file, int dataLength, int index); |
tobyspark | 14:da403a01f9ef | 65 | |
tobyspark | 11:90e5a72a0034 | 66 | bool set1920x480(int resStoreNumber); |
tobyspark | 11:90e5a72a0034 | 67 | bool set1600x600(int resStoreNumber); |
tobyspark | 11:90e5a72a0034 | 68 | bool set2048x768(int resStoreNumber); |
tobyspark | 0:533cfae24a1b | 69 | |
tobyspark | 9:42c83cac2f6d | 70 | Serial *serial; |
tobyspark | 0:533cfae24a1b | 71 | Serial *debug; |
tobyspark | 0:533cfae24a1b | 72 | |
tobyspark | 18:d765b0d9271c | 73 | int commandTimeoutPeriod; |
tobyspark | 18:d765b0d9271c | 74 | int commandMinimumPeriod; |
tobyspark | 18:d765b0d9271c | 75 | |
tobyspark | 14:da403a01f9ef | 76 | Timer timer; |
tobyspark | 17:68b9bb89da2b | 77 | Ticker timerCheckTicker; |
tobyspark | 17:68b9bb89da2b | 78 | void timerCheck(); |
tobyspark | 14:da403a01f9ef | 79 | |
tobyspark | 0:533cfae24a1b | 80 | DigitalOut *writeDO; |
tobyspark | 0:533cfae24a1b | 81 | DigitalOut *errorDO; |
tobyspark | 0:533cfae24a1b | 82 | Timeout signErrorTimeout; |
tobyspark | 0:533cfae24a1b | 83 | void signErrorOff(); |
tobyspark | 0:533cfae24a1b | 84 | }; |
tobyspark | 0:533cfae24a1b | 85 | |
tobyspark | 0:533cfae24a1b | 86 | #endif |