Anda di halaman 1dari 13

/*********************************************************** RS232 Control for TV-One products Please Read page 53 and on of the TV1 1T-C2-750 manual The

below values are used together to form properly formatted packets to send to the 1T-C2-750 (and friends) over serial. We will put together a packet that consists of: 1 2 3 4 5 6 7 8 9 Start of Packet (Always letter F) Command Channel / Source / Macro number Window or Logo ID Output number & Function High Bit Function Low Bit Payload values (ie, the data we want to send) Checksum (computed from the sum of the above values) Carriage Return (\r)

Produced by *spark audio-visual & vade Good for 1T-C2-750, others will need some extra work Copyright *spark audio-visual & vade 2009-2010 ***********************************************************/ // Are we in Arduino land? #ifdef F_CPU #include "WProgram.h" #endif #pragma mark #pragma mark READ ME: Timing info. // Ok, here is the deal. You dont want to send serial commands faster than:

//#define kTV1MaxSendSpeedLim 0.030 // TBZ: What we found you want for fade commands. But n #define kTV1MaxSendSpeedLim 0.060// TBZ: Key commands take longer to process than fade com // Miliseconds between commands, otherwise you can fill the command buffer // and that takes 1 second to flush - assuming you actually stop sending... // So heed this "delta t" and dont go faster than the speed limit #pragma mark #pragma mark Error Codes typedef unsigned int kTV1Error; #define kTV1NoError 0 #define kTV1InvalidCommand 1 #define kTV1NoReply 2 // Sources - Note only higher end models have more than 2 in.... #pragma mark -

#pragma mark Channel / Sources #define #define #define #define #define #define kTV1SourceRGB1 kTV1SourceRGB2 kTV1SourceRGB3 kTV1SourceRGB4 kTV1SourceRGB5 kTV1SourceRGB6 0x10 0x11 0x12 0x13 0x14 0x15

// Window #pragma mark #pragma mark Window IDs #define #define #define #define #define kTV1WindowIDA kTV1WindowIDB kTV1WindowIDZ kTV1WindowIDLogoA kTV1WindowIDLogoB

'A' // ak 'B' 'Z' 'a' // 'b'

#pragma mark #pragma mark Functions

// Complete function list for verbosity. We will probably only be using a small small subse // Preset & Mixer Mode Functions #define kTV1FunctionMode #define kTV1FunctionPreset #define kTV1FunctionPresetLoad #define kTV1FunctionPresetStore #define kTV1FunctionPresetErase // Adjust output Functions #pragma mark #define kTV1FunctionAdjustOutputsOutputEnable #define kTV1FunctionAdjustOutputsLockSource #define kTV1FunctionAdjustOutputsLockMethod #define kTV1FunctionAdjustOutputsLockHShift #define kTV1FunctionAdjustOutputsLockVShift #define kTV1FunctionAdjustOutputsOutputResolution #define kTV1FunctionAdjustOutputsOutputImageTypeA #define kTV1FunctionAdjustOutputsOutputImageTypeD #define kTV1FunctionAdjustOutputsHDCPRequired #define kTV1FunctionAdjustOutputsHDCPStatus #define kTV1FunctionAdjustOutputsBackgroundY #define kTV1FunctionAdjustOutputsBackgroundU #define kTV1FunctionAdjustOutputsBackgroundV #define kTV1FunctionAdjustOutputsSDIOptimization 0x197 #define kTV1FunctionAdjustOutputsOutputStandard #define kTV1FunctionAdjustOutputsCVYCIRE #define kTV1FunctionAdjustOutputsCVYCHue #define kTV1FunctionAdjustOutputsSCHPhase #define kTV1FunctionAdjustOutputsLumaBandwidth #define kTV1FunctionAdjustOutputsChromaBandwidth 0x135 #define kTV1FunctionAdjustOutputsOutputChromaDelay #define kTV1FunctionAdjustOutputsPalWSS

0x109 0x226 0x227 0x228

// Values: 0x225 // // Values: // Values: // Values:

0x170

// Values: 0 = Blanked 1 = 0x149 // Values: 0x10 to 0x10A // Values: 0 = Off 0x14A // Values: -4096 0x14B // Values: -4096 0x083 // Values: 0 - 1000 (which 0x0E2 // Values: 0 = RGBHV, 2 = 0x16C // Values: 0 = RGBHV, 3 = 0x233 // Values: 0 = Off, 1 = On 0x234 // Values: 0 = Una 0x13B // Values: 16-235 0x13C // Values: 16-235 0x13D // Values: 16-235 // Values: 0 = Off, 1 = On 0x101 // Values: 0 = NTSC/PAL, 1 0x133 // Values: -0.75 - 12.5 0x139 // Values: -22 - 22 0x085 // Values: -180 0x134 // Values: 0 = Low, 1 = Me // Values: 0 = Low, 1 = Medium, 2 0x137 // Values: -4 - 3 0x130 // Values: 0-8 (s

#define kTV1FunctionAdjustOutputsTake 0x11E // Values: 0->1 Pe #define kTV1FunctionAdjustOutputsVolume 0x201 // Values: -16 - 1 // Left out additional functions specific to SDI Audio Channel adjustment // Adjust Windows Functions #pragma mark #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define

Note for window functions, you must specify a Window to work

kTV1FunctionAdjustWindowsWindowSource kTV1FunctionAdjustWindowsSelectUniSource 0x241 kTV1FunctionAdjustWindowsSourceResolution kTV1FunctionAdjustWindowsEnable kTV1FunctionAdjustWindowsZoomLevel kTV1FunctionAdjustWindowsZoomLevelH kTV1FunctionAdjustWindowsZoomLevelV kTV1FunctionAdjustWindowsAspectRationIn kTV1FunctionAdjustWindowsZoomPanH kTV1FunctionAdjustWindowsZoomPanV kTV1FunctionAdjustWindowsImageFreeze kTV1FunctionAdjustWindowsCropH kTV1FunctionAdjustWindowsCropV kTV1FunctionAdjustWindowsOutShiftH kTV1FunctionAdjustWindowsOutShiftV kTV1FunctionAdjustWindowsShrinkLevel kTV1FunctionAdjustWindowsShrinkLevelH kTV1FunctionAdjustWindowsShrinkLevelV kTV1FunctionAdjustWindowsShrinkEnable kTV1FunctionAdjustWindowsShrinkPosH kTV1FunctionAdjustWindowsShrinkPosV kTV1FunctionAdjustWindowsInTopLeftH kTV1FunctionAdjustWindowsInTopLeftV kTV1FunctionAdjustWindowsInSizeH kTV1FunctionAdjustWindowsInSizeV kTV1FunctionAdjustWindowsOutTopLeftH kTV1FunctionAdjustWindowsOutTopLeftV kTV1FunctionAdjustWindowsOutSizeH kTV1FunctionAdjustWindowsOutTopLeft kTV1FunctionAdjustWindowsAspectChange kTV1FunctionAdjustWindowsAspectAdjust kTV1FunctionAdjustWindowsFlickerReduction kTV1FunctionAdjustWindowsImageSmoothing kTV1FunctionAdjustWindowsImageFlip kTV1FunctionAdjustWindowsTemporalInterp kTV1FunctionAdjustWindowsMaxFadeLevel kTV1FunctionAdjustWindowsFadeOutIn kTV1FunctionAdjustWindowsLayerPriority kTV1FunctionAdjustWindowsHeadPhonVolume kTV1FunctionAdjustWindowsAudioVolume kTV1FunctionAdjustWindowsAudioVolumeEnable

0x82 // Values: // Values: 0xE0 to 0xF8 // Values: 0x12B // 0x86 // 0x103 // 0x105 // 0x107 // Values: 0x9F // 0xA0 // 0x9C // Values: 0x223 // 0x224 // 0xAD // 0xAE // 0x87 // Values: 0x104 // Values: 0x106 // Values: 0x18E // Values: 0xDA // 0xDB // 0x21B // 0x21D // 0x21C // ?? 0x21E // ?? 0x21F // ?? 0x221 // ?? 0x220 // 0x222 // 0x190 // Values: 0x102 // Values: 0x92 // Values: 0xA1 // Values: 0x95 // 0x229 // Values: 0x10F // Values: 0x193 // 0x144 // Values: 0xFD // Vaules: 0x206 // Vaules: 0x206 // Vaules:

0x10 to 0x1F = OxEF for univer (Read only) Res Values: 0 = Off Values: 100 - 1 Values: 100 - 1 Values: 100 - 1 0.1:1 - 9.99:1 Values: 0 - 100 Values: 0 - 100 0 = Off, 1 = On Values: 0 - 100 Values: 0 - 100 Values: -4096 Values: -4096 10 - 100 10 - 100 (only 10 - 100 (only 0 = Off, 1 = On Values: 0 - 100 Values: 0 - 100 ?? ??

?? ?? 0 = Normal, 1 = 0 = Simple, 1 = 0 = Off, 1 = Lo 0 = Off, 1 = Me Values: 0 = Off 0 = Off, 1 = On 0 - 100 Values -1 = Fad 0 - 5 -16 - 15 (-16 = -128 - 127 ( 0 = Off, 1 = On

// Adjust Keyer #pragma mark #define kTV1FunctionAdjustKeyerEnable #define kTV1FunctionAdjustKeyerMinY #define kTV1FunctionAdjustKeyerMinU 0x127

// Values: 0 = Off 0xAF // Values: 0xB0 // Values:

#define #define #define #define #define #define #define #define #define #define #define

kTV1FunctionAdjustKeyerMinV kTV1FunctionAdjustKeyerMaxY kTV1FunctionAdjustKeyerMaxU kTV1FunctionAdjustKeyerMaxV kTV1FunctionAdjustKeyerSoftnessY kTV1FunctionAdjustKeyerSoftnessU kTV1FunctionAdjustKeyerSoftnessV kTV1FunctionAdjustKeyerInvertY kTV1FunctionAdjustKeyerInvertU kTV1FunctionAdjustKeyerInvertV kTV1FunctionAdjustKeyerSwap

0x121 0x123 0x125

0xB1 // 0xB2 // 0xB3 // 0xB4 // // Values: 0 - 255 // Values: 0 - 255 // Values: 0 - 255 0x122 // Values: 0x124 // Values: 0x126 // Values: 0x144 //

Values: Values: Values: Values:

0 = Off 0 = Off 0 = Of Values:

// Edge Blending (not used in TVOne 1T-C2-750, therefore not bothered with for now) #define kTV1FunctionAdjustEdgeBlendXXX // Adjust Logos #pragma mark #define #define #define #define #define #define kTV1FunctionAdjustLogoEnable kTV1FunctionAdjustLogoNumber kTV1FunctionAdjustLogoOutShiftH kTV1FunctionAdjustLogoOutShiftV kTV1FunctionAdjustLogoMaxFadeLevel kTV1FunctionAdjustLogoLayerPriority 0x12B 0x143 0xAD 0xAE 0x10F 0x144 // // // // // // Values: Values: Values: Values: Values: Values: 0 0 0 0 0 0 = -

Off 9 ( 100 100 100 5

// Adjust Borders #pragma mark #define #define #define #define #define #define #define #define #define kTV1FunctionAdjustBorderEnable kTV1FunctionAdjustBorderSizeH kTV1FunctionAdjustBorderSizeV kTV1FunctionAdjustBorderOffsetH kTV1FunctionAdjustBorderOffsetV kTV1FunctionAdjustBorderY kTV1FunctionAdjustBorderU kTV1FunctionAdjustBorderV kTV1FunctionAdjustBorderOpacity 0x150 0x151 0x152 0x153 0x154 // Values: // Values: // Values: // Values: // Values: 0x155 // 0x156 // 0x157 // // Values:

0x158

0 = Off 0 - 99 0 - 99 0 - 99 0 - 99 Values: Values: Values: 0 - 100

// Adjust Sources - Note: These functions require the Channel parameter to be properly set. #pragma mark #define #define #define #define #define #define #define #define #define #define #define #define #define #define kTV1FunctionAdjustSourceTestCard kTV1FunctionAdjustSourceAutoSet kTV1FunctionAdjustSourceAspectCorrect kTV1FunctionAdjustSourceEDID kTV1FunctionAdjustSourceEDIDCapureID kTV1FunctionAdjustSourceEditCaptureGrab kTV1FunctionAdjustSourceHDCPAdvertize kTV1FunctionAdjustSourceHDCPStatus kTV1FunctionAdjustSourcePositionH kTV1FunctionAdjustSourcePositionV kTV1FunctionAdjustSourceSizeH kTV1FunctionAdjustSourceSizeV kTV1FunctionAdjustSourceAudioXXX kTV1FunctionAdjustSourceOnSourceLoss 0xDC 0x240 0x244 0x245 0x237 // Values: 0xFE // // Values: 0x243 // // Values: // Values: // Values: 0x238 // 0xB6 // 0xB7 // 0xDE // 0xDF // // // Values:

0xA3

0 - 10 Values: 1 = Sta 0 = Fill, 1 = A Values: 0 - 7 ( 0 - 7 (edid ent 1 performs grab 0 = Off, 1 = On Values: 0 = Ina Values: -100 Values: -100 Values: -100 Values: -100 Ignored for no 0 = Show, 1 = F

#define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define

kTV1FunctionAdjustSourceSourceStable kTV1FunctionAdjustSourcePixelPhase kTV1FunctionAdjustSourceRGBInType kTV1FunctionAdjustSourceRGBContributionR 0xC5 kTV1FunctionAdjustSourceRGBContributionG 0xC6 kTV1FunctionAdjustSourceRGBContributionB 0xC7 kTV1FunctionAdjustSourceYUVSetup kTV1FunctionAdjustSourceDeInterlace kTV1FunctionAdjustSourceFilmMode kTV1FunctionAdjustSourceDiagonalInterp kTV1FunctionAdjustSourceNoiseReduction kTV1FunctionAdjustSourceBrightness kTV1FunctionAdjustSourceContrast kTV1FunctionAdjustSourceSaturation kTV1FunctionAdjustSourceHue kTV1FunctionAdjustSourceSharpness kTV1FunctionAdjustSourceLumaDelay kTV1FunctionAdjustSourceFieldSwap kTV1FunctionAdjustSourceFieldOffset kTV1FunctionAdjustSourceAudioChannel1 kTV1FunctionAdjustSourceAudioChannel2 kTV1FunctionAdjustSourceAudioChannel3 kTV1FunctionAdjustSourceAudioChannel4 kTV1FunctionAdjustSourceAudioChannel5 kTV1FunctionAdjustSourceAudioChannel6 kTV1FunctionAdjustSourceAudioChannel7

0x22A

// Values: 0 = Unstable, 1 0x91 // Values: 0 - 31 0xC1 // Values: 0 = Aut // Values: 75 - 150 // Values: 75 - 150 // Values: 75 - 150 0x23E // Values: 0 = 0 IRE, 1 = 0xB8 // Values: 0 = Nor 0xE3 // Values: 0 = Not Detect 0x22B // Values: 0 = Off, 1 = On 0x23F // Values: 0 = Off, 1 = On 0xBB // Values: 0 - 180 0xBC // Values: 0 - 180 0xB9 // Values: 0 - 180 0xBA // Values: 0x80 // Values: -7 - 7 0xBD // Values: -4 -3 0xC9 // Values: 0 = Off 0x196 // Values: = 0 - 7 // Ignored for now // Ignored for now // Ignored for now // Ignored for now // Ignored for now // Ignored for now // Ignored for now

// Adjust Audio #pragma mark #define kTV1FunctionAdjustAudioXXX // Adjust Transitions #pragma mark #define kTV1FunctionAdjustTransitionType #define kTV1FunctionAdjustTransitionFadeTime #define kTV1FunctionAdjustTransitionWipeType #define kTV1FunctionAdjustTransitionWipeSize // Adjust Resolutions

//

0x112 0xF5 0x145 0x146

// // // //

Values: Values: Values: Values:

0 = Cut, 1 = Fa 0 - 50 (0 - 5.0 0 = Left -> Ri 10 - 2000

/* Note: You MUST set the 'Image to adjust' value to the correct value first, and only then change the other values - otherwise you may be adjusting the wrong entry. The user should not adjust the 'Image to adjust' entry using the front panel whilst also a */ #pragma #define #define #define #define #define #define #define #define mark kTV1FunctionAdjustResolutionImageToAdjust kTV1FunctionAdjustResolutionInterlaced kTV1FunctionAdjustResolutionFreqCoarseH kTV1FunctionAdjustResolutionFreqFineH kTV1FunctionAdjustResolutionActiveH kTV1FunctionAdjustResolutionActiveV kTV1FunctionAdjustResolutionStartH kTV1FunctionAdjustResolutionStartV

0x81 0xCA 0xBE 0xBF

// Values: // Values: // Values: // Values: 0x96 // 0x97 // 0x8B // 0x8C //

0 - 1000 - the 0 = Off, 1 = On 10,000 - 200,00 10,000 - 200,00 Values: 64 - 20 Values: 64 - 20 Values: 0 - 102 Values: 0 - 102

#define #define #define #define #define

kTV1FunctionAdjustResolutionCLKS kTV1FunctionAdjustResolutionLines kTV1FunctionAdjustResolutionSyncH kTV1FunctionAdjustResolutionSyncV kTV1FunctionAdjustResolutionSyncPolarity 0x94

0x8E

// Values: 64 - 4095 0xBE // Values: 64 - 20 0x8F // Values: 8 - 102 0x90 // Values: 1 - 102 // Values: 0 - 3 (++, +-. -+. --)

// Adjust Misc #pragma mark #define kTV1FunctionAdjustFrontPanelLock // Resolutions #pragma mark #pragma mark Resolutions

0xFC

// Values: 0 = Unlocked, 1

// Selected Common Resolutions and resolution Descriptions. For a complete list, use the me // // // // Res Res Res Res #27 640x480, 59.97Hz #28 640x480, 60Hz #99 1920x1080, 60Hz #104 = 1920x1200, 60Hz kTV1ResolutionVGA kTV1ResolutionNTSC kTV1ResolutionPAL kTV1ResolutionSVGA kTV1ResolutionXGAp5994 kTV1ResolutionXGAp60 kTV1ResolutionXGAp75 kTV1Resolution720p2398 kTV1Resolution720p24 kTV1Resolution720p25 kTV1Resolution720p2997 kTV1Resolution720p30 kTV1Resolution720p50 kTV1Resolution720p5994 kTV1Resolution720p60 kTV1ResolutionWXGA5by3p60 kTV1ResolutionWXGA5by3p75 kTV1ResolutionWXGA16by10p60 kTV1ResolutionWXGA16by10p75 kTV1ResolutionSGAp60 kTV1ResolutionSGAp75 kTV1ResolutionWSXGAp60 kTV1ResolutionUXGAp60 kTV1ResolutionUXGAp75 kTV1ResolutionUXGAp85 kTV1ResolutionWSXGAPLUSp60 kTV1Resolution1080p2398 kTV1Resolution1080p24 kTV1Resolution1080p25 kTV1Resolution1080p2997 kTV1Resolution1080p30 kTV1Resolution1080p50 kTV1Resolution1080p5996 kTV1Resolution1080p60 0x8 0xF 0x10 0x12 0x1B 0x1C 0x1D 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x30 0x31 0x34 0x35 0x3A 0x3B 0x40 0x47 0x4A 0x4B 0x53 0x5B 0x5C 0x5D 0x5E 0x5F 0x60 0x61 0x6A

#define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define

// found as 0x62=9

#define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define

kTV1Resolution1080p75 kTV1ResolutionWUXGAp60 kTV1ResolutionWUXGAp75 kTV1ResolutionWUXGAp85

0x66 0x69 0x6C 0x6D

kTV1ResolutionDescriptionVGA "VGA (640x480) @ 60Hz" kTV1ResolutionDescriptionNTSC "NTSC (720x480 @ 59.95Hz)" kTV1ResolutionDescriptionPAL "PAL (720x576 @ 50Hz)" kTV1ResolutionDescriptionSVGA "SVGA (800x600) @ 60Hz" kTV1ResolutionDescriptionXGAp5994 "XGA (1024x768) @ 59.94Hz" kTV1ResolutionDescriptionXGAp60 "XGA (1024x768) @ 60Hz" kTV1ResolutionDescriptionXGAp75 "XGA (1024x768) @ 75Hz" kTV1ResolutionDescription720p2398 "720p HD (1280x720) @ 23.9 kTV1ResolutionDescription720p24 "720p HD (1280x720) @ 24Hz kTV1ResolutionDescription720p25 "720p HD (1280x720) @ 25Hz kTV1ResolutionDescription720p2997 "720p HD (1280x720) @ 29.9 kTV1ResolutionDescription720p30 "720p HD (1280x720) @ 30Hz kTV1ResolutionDescription720p50 "720p HD (1280x720) @ 50Hz kTV1ResolutionDescription720p5994 "720p HD (1280x720) @ 59.9 kTV1ResolutionDescription720p60 "720p HD (1280x720) @ 60Hz kTV1ResolutionDescriptionWXGA5by3p60 "WXGA (1280x768) @ 60Hz" kTV1ResolutionDescriptionWXGA5by3p75 "WXGA (1280x768) @ 75Hz" kTV1ResolutionDescriptionWXGA16by10p60 "WXGA (1280x800) @ 60Hz" kTV1ResolutionDescriptionWXGA16by10p75 "WXGA (1280x800) @ 75Hz" kTV1ResolutionDescriptionSGAp60 "SGA (1280x1024) @ 60Hz" kTV1ResolutionDescriptionSGAp75 "SGA (1280x1024) @ 75Hz" kTV1ResolutionDescriptionWSXGAp60 "WSXGA (1440x900) @ 60Hz" kTV1ResolutionDescriptionUXGAp60 "UXGA (1600x1200) @ 60Hz" kTV1ResolutionDescriptionUXGAp75 "UXGA (1600x1200) @ 75Hz" kTV1ResolutionDescriptionUXGAp85 "UXGA (1600x1200) @ 85Hz" kTV1ResolutionDescriptionWSXGAPLUSp60"WSXGA+ (1680x1050) @ 60Hz" kTV1ResolutionDescription1080p2398 "1080p (1920x1080) @ 23.98Hz" kTV1ResolutionDescription1080p24 "1080p (1920x1080) @ 24Hz" kTV1ResolutionDescription1080p25 "1080p (1920x1080) @ 25Hz" kTV1ResolutionDescription1080p2997 "1080p (1920x1080) @ 29.97Hz" kTV1ResolutionDescription1080p30 "1080p (1920x1080) @ 30Hz" kTV1ResolutionDescription1080p50 "1080p (1920x1080) @ 50Hz" kTV1ResolutionDescription1080p5996 "1080p (1920x1080) @ 59.94Hz" kTV1ResolutionDescription1080p60 "1080p (1920x1080) @ 60Hz" kTV1ResolutionDescription1080p75"1080p (1920x1080) @ 75Hz" kTV1ResolutionDescriptionWUXGAp60 "WUXGA (1920x1200) @ 60Hz" kTV1ResolutionDescriptionWUXGAp75 "WUXGA (1920x1200) @ 75Hz" kTV1ResolutionDescriptionWUXGAp85 "WUXGA (1920x1200) @ 85Hz" 0x71 0x73

#define kTV1Resolution2Kp60 #define kTV1ResolutionDoubleWXGA

#define kTV1Resolu #define kTV1ResolutionDesc

// Triplehead resolutions // Note these are currently either added to the resolution list (#123-125) via CorioTools // Previously these were written over existing resolutions (#112-114) #define kTV1ResolutionDualHeadSVGAp60 0x7B #define kTV1ResolutionDescriptionDualHeadSVGAp60 "Dual Head SVGA (1600x600) @ 60Hz" #define kTV1ResolutionDualHeadXGAp60 0x7C

#define

kTV1ResolutionDescriptionDualHeadXGAp60"Dual Head XGA (2028x768) @ 60 Hz"

#define kTV1ResolutionTripleHeadVGAp60 0x7D #define kTV1ResolutionDescriptionTripleHeadVGAp60 #pragma mark #pragma mark TV1Serial Packet command creation

"Triple Head VGA (1920x480) @ 60Hz

// This function outputs an ASCII char that can be sent as an ASCII Serial command to the T char* tv1CreateSerialCommandString(uint8_t channel, uint8_t window, int32_t function, int32 { // our command string - consists of COMMAND, CHANNEL, WINDOW, OUTPUT & FUNCTION HI uint8_t command[8]; // COMMAND command[0] = 1<<2;// write // CHANNEL command[1] = channel; // WINDOW command[2] = window; // OUTPUT & FUNCTION // cmd[3] cmd[4] // output 0 = 0000xxx xxxxxxx // function = xxxXXXX XXXXXXX command[3] = function >> 8; command[4] = function & 0xFF; // PAYLOAD command[5] = (payload >> 16) & 0xFF; command[6] = (payload >> 8) & 0xFF; command[7] = payload & 0xFF; // Calculate Checksum uint8_t checksum = 0; for (int i=0; i<8; i++) { checksum += command[i]; }

char serialCommand[21]; // Message is 20 characters long, but we have one addition sprintf

(serialCommand,"F%02X%02X%02X%02X%02X%02X%02X%02X%02X\r", command[0], com

// Leak : needs to be free'd by user return strdup(serialCommand); } #pragma mark #pragma mark TV1Serial Read and Write callbacks and functions // Writing serial commands to the TV1 hardware requires either an immediate read // of return values (success or failure) Or a timeout on the order ~ 50 - 100 ms. // For speed, and correctness whenever we do a write, we do an immediate read, // to ensure the command was successful. Because this library is agnostic to // language and Serial IO API, we provide 2 callbacks for reading and writing.

// You must provide both.

// This is the write callback. the context param is where you place your own object or data // The context will do the actual serial IO communication, and get the formatted 20 charact typedef void (*TV1SerialWriteCallback)(char* command,void* context);

// This is the read callback, this returns the 20 character (char[21], one extra for null t typedef void (*TV1SerialReadCallback)(char* result,void* context);

// Register the callbacks. TV1SerialReadCallback readCallback = 0; void* readCallbackContext = 0; TV1SerialWriteCallback writeCallback = 0; void* writeCallbackContext = 0;

void tv1RegisterSerialReadCallback(TV1SerialReadCallback { readCallback = callback; readCallbackContext = context; }

callback,void* context)

void tv1RegisterSerialWriteCallback(TV1SerialWriteCallback { writeCallback = callback; writeCallbackContext = context; }

callback,void* context)

// Use this command submit a created serial command. // It calls your callbacks talks to Serial IO, and does work - checks for a proper reply, kTV1Error tv1SubmitSerialCommand(char* command) { if((writeCallback == 0) || (readCallback == 0)) { printf("TV1 Read/Write Callbacks not registered"); printf("\r"); return 0; } // read the resulting ack from the serial line to determine if the last write was char resultString[21];// 20 character result + 1 for null termination // set resultString to all 0's for(unsigned int i = 0; i < 21; i++) { resultString[i] = 0; } readCallback(resultString, readCallbackContext); kTV1Error error = kTV1NoError;

// // // //

// If we dont get the ACK, whats up? It could be invalid, or NULL (all 0), meaning we if(resultString[1] != 52)// 52 is ASCII for 4, which is the proper ACK bit. { printf("Result: %s", resultString); printf("\r"); printf("Error Ack: %u", resultString[1]); printf("\r"); error = kTV1InvalidCommand; // check for null. unsigned int sum = 0; for(unsigned int i = 0; i < 21; i++) { sum += resultString[i]; }

// //

printf("Error Sum: %u", sum); printf("\r"); if(sum == 0) error = kTV1NoReply; } // Send the command over the serial line if the last command was susessfull writeCallback(command, writeCallbackContext); return error; return 1;

// }

#pragma mark #pragma mark Common Functions / Macros // RGB 0.0 - 1.0 to YUV integer 0 - 255 void tv1RGB2YUV(float R,float G,float { R *= 255; G *= 255; B *= 255;

B,unsigned int

*Y,unsigned int

*U,unsigned int *

float y = (0.299 * R) + (0.587 * G) + (0.114 * B); float u = -(0.169 * R) - (0.331 * G) + (0.5 * B); float v = (0.5 * R) - (0.419 * G) - (0.081 * B); *Y = y; *U = u + 128; *V = v + 128; } // RGB 0.0 - 1.0, to YUV int 16 - 235 Y, 16 - 240 UV (sigh) void tv1RGB2YUVLimited(float R,float G,float B,unsigned int { R *= 255; G *= 255; B *= 255;

// Y // U // V

*Y,unsigned int

*U,unsigne

float y = (0.257 * R) + (0.504 * G) + (0.098 * B); float u = -(0.148 * R) - (0.291 * G) + (0.439 * B); float v = (0.439 * R) - (0.368 * G) - (0.071 * B); *Y = y + 16; *U = u + 128; *V = v + 128; }

// Y // U // V

// These are one liners to setup the mixer, so we can use them all over the place. kTV1Error tv1DisableHDCP() { kTV1Error error = kTV1NoError; // Disable HDCP on outut error = tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, kTV1WindowIDA, kTV1

// On Window 1 Source 1 if(error == kTV1NoError) error = tv1SubmitSerialCommand(tv1CreateSerialCommandString(kTV1SourceRGB1

// On Window 2 Source 2 if(error == kTV1NoError) error = tv1SubmitSerialCommand(tv1CreateSerialCommandString(kTV1SourceRGB2 return error; }

// Create our Triple Head and Dual Head timings. // Note only if re-writing over existing resolutions? void tv1set1920x480(int resStoreNumber) { tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, } void tv1set1600x600(int resStoreNumber) { tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResol kTV1FunctionAdjustResol kTV1FunctionAdjustResol kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResol kTV1FunctionAdjustResolu

0, 0, 0, 0, 0,

kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu

tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, tv1SubmitSerialCommand(tv1CreateSerialCommandString(0, }

0, 0, 0, 0, 0, 0, 0, 0,

kTV1FunctionAdjustResolu kTV1FunctionAdjustResol kTV1FunctionAdjustResol kTV1FunctionAdjustResol kTV1FunctionAdjustResolu kTV1FunctionAdjustResolu kTV1FunctionAdjustResol kTV1FunctionAdjustResolu

kTV1Error tv1InitializeMixer() { kTV1Error error = kTV1NoError; // Lock Source to DVI in 1 error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1WindowIDA, kTV

// Disable Locking so our lock method is 'free' if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window

// Map Window A to DVI in 1 if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window

// Map Window B to DVI in 2 if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window

// Disable Window Z if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window

// Set Window Priority. abABZ, 12345 if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window // Disable Evil HDCP if(error == kTV1NoError) error = tv1DisableHDCP(); return error; }

kTV1Error tv1SetResolution(unsigned int resolution) // one of our kTV1ResolutionXXX, f { return tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1WindowIDA, kTV1 } // Handle Colors to Keyer - colors are in RGB 0.0 - 1.0 range kTV1Error tv1SetKeyerMinColor(float { unsigned int Y, U, V; r,float g,float b)

tv1RGB2YUV(r, g, b, &Y, &U, &V); kTV1Error error = kTV1NoError;

error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1WindowIDB, kTV if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window return error; } bool tv1SetKeyerMaxColor(float r,float g,float b) { unsigned int Y, U, V; tv1RGB2YUV(r, g, b, &Y, &U, &V); kTV1Error error = kTV1NoError;

error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1WindowIDB, kTV if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window return error; } bool tv1SetBackgroundColor(float r,float g,float b) { unsigned int Y, U, V; tv1RGB2YUVLimited(r, g, b, &Y, &U, &V); kTV1Error error = kTV1NoError;

error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1WindowIDA, kTV if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window if(error == kTV1NoError) error = tv1SubmitSerialCommand( tv1CreateSerialCommandString(0, kTV1Window return error; }

Anda mungkin juga menyukai