'+=======================================================================+===+ '+ GVG100 Panel software 14 includes cut subroutine for PGM to PST selection + '+ subroutines to display analogue pots currently T-Bar and Softness and + '+ wipe buttons positioner reverse buttons on top panel now active + '+LCD Display now shows PST PGM Source + '+ Revised lamp latch routine called latches, single IO subroutine + '+ code is Annex ESP8266 Basic + '+ https://sites.google.com/site/annexwifi/home + '+ CQ-DATV Magazine GVG project Author Trevor G8CJS + '+ Notes and guidance are in CQ-DATV issue 78 onwards + '+ + '+ + '+====================================================================++=====+ ' PCF8574 Device Addresses let PRT1=39 ' Port 1 Control address 64 for /A device sw 1 off off off let PRT3=37 ' Port 3 Address Bus address 62 for /A device sw 2 off on off let PRT4=32 ' Port 4 Data Bus address 56 for /A device sw 3 on on on let IOa =57 ' I/O Port a (IC5) address 33 for a non/A device sw 4 off off on let IOb =60 ' I/O Port b address 36 for a non/A device sw 5 on on off let ck=251 ' i2c conrtol of CPU lines let tristate =255 let lamps =254 let buttons=253 I2C.SETUP 4,5 ' SDA & SCL Pins LCD.INIT 63, 16, 2 ' PCF8574 Backpack Address 0X3F hex LCD.CLS LCD.PRINT 1,1, "G8CJS software " LCD.PRINT 1,2, "Revison 14 " pause 400 ' pause to display software version let n=0 :let o=0 :let p=0 'global variable to store copies off the panel lamps as they cannot be read let q=0 :let r=0 :let s=0 let t=0 :let u=0: let v=0 let w=0 let y=0 : let a=1 'other global variables that are in use but may change let z=0 :let cc=16: Tbarpos =0 'Global variables of all the analog pots let et = -7 let et2 =-6 let et3 =-5 let data1=0 let address1=0 let analogue = 239 let conv = 247 let tbar = 02 let joystickv = 01 let joystickh = 00 let ckhue = 03 'CK hue let hue = 04 'Matte Box Hue let chroma = 06 'Matte box Chroma let lum = 07 'Mattbox Lum let clip = 08 'CK clip let gain = 09 'CK gain let aspecta = 10 'aspect pattern ajust let mask = 11 'mask preset size let soft = 12 'ede softness let width = 13 'boarder width let pri = 14 'effects priority gosub sevenseg1 'illuminate the seven segment displays only 3 used gosub sevenseg2 gosub sevenseg3 '------------------------------------'power on to PST,PGM an Key bank lights and select source 0 let q=q+ 232 let r=r+66 gosub latches '-----------------------------------------------button pole to see if we have a button press-------------------------- do for B=0 to 9 i2c.begin PRT3 ' Address port i2c.write B ' Scan buttons BS2 low i2c.end i2c.begin PRT4 ' Control port i2c.write 255 ' needed to work i2c.end i2c.begin PRT1 ' Control port i2c.write buttons ' Scan buttons i2c.end i2c.reqfrom PRT4,1 e = i2c.read i2c.end if e< 255 then gosub push next B gosub analog1 gosub analog2 gosub analog3 gosub analog4 gosub mixduration gosub LCD loop until 0 '----------------------------------------push buttons director----------------------- push: If b=7 and e=127 then gosub sevenseg1 'frame one button pressed If b=8 and e=191 then gosub sevenseg2 'frame one button pressed If b=9 and e=191 then gosub sevenseg3 'frame one button pressed ' key bank buttons precessed here if B = 1 and e = 254 then gosub KEYlatch ' "Key 0 " if B = 1 and e = 253 then gosub KEYlatch ' "key 1 " if B = 1 and e = 251 then gosub KEYlatch ' "key 2 " If B = 1 and e = 247 then gosub KEYlatch ' "key 3 " if B = 1 and e = 239 then gosub KEYlatch ' "key 4 " if B = 1 and e = 223 then gosub KEYlatch ' "key 5 " if B = 1 and e = 191 then gosub KEYlatch ' "key 6 " if B = 1 and e = 127 then gosub KEYlatch ' "key 7 " if B = 4 and e = 251 then gosub KEYlatch ' "key 8 " if B = 4 and e = 247 then gosub KEYlatch ' "key 9 " if B = 4 and e = 127 then gosub auto 'autotrans 'PGM bank button processed here if B = 2 and e = 254 then gosub PGMlatch ' "PGM 0 if B = 2 and e = 253 then gosub PGMlatch ' "PGM 1 if B = 2 and e = 251 then gosub PGMlatch ' "PGM 2 if B = 2 and e = 247 then gosub PGMlatch ' "PGM 3 if B = 2 and e = 239 then gosub PGMlatch ' "PGM 4 if B = 2 and e = 223 then gosub PGMlatch ' "PGM 5 if B = 2 and e = 191 then gosub PGMlatch ' PGM 6 if B = 2 and e = 127 then gosub PGMlatch ' PGM 7 if B = 4 and e = 254 then gosub PGMlatch ' PGM 8 " if B = 4 and e = 253 then gosub PGMlatch ' PGM 9 'yellow key control buttons prrocessed here if B=0 and e = 254 then gosub KEYCTRL if B=0 and e = 253 then gosub KEYCTRL if B=0 and e = 251 then gosub KEYCTRL if B=0 and e = 247 then gosub KEYCTRL if B=0 and e = 239 then gosub KEYCTRL if B=0 and e = 223 then gosub KEYCTRL if B=0 and e = 191 then gosub KEYCTRL if B=5 and e = 127 then gosub KEYCTRL 'boardline key processed here if B=5 and e = 254 then gosub boarderline ' "NORMAL" if B=5 and e = 253 then gosub boarderline ' "BORDER" if B=5 and e = 251 then gosub boarderline ' "DROP SHADOW" if B=7 and e = 254 then gosub boarderline ' EXTRUDE" if B=7 and e = 253 then gosub boarderline 'OUTLINE" 'fade transition mix and wipe processed here if B=5 and e = 191 then gosub Tran 'Transition wipe if B=5 and e = 223 then gosub Tran 'Transistion mix if B=6 and e = 191 then gosub fade2black 'FADE TO BLACK ' cut button PGM = PST selection if B=4 and e= 191 then gosub cut ' cut button 'PST key processed here if B = 3 and e = 254 then gosub PSTlatch 'PST 0 if B = 3 and e = 253 then gosub PSTlatch 'PST 1 if B = 3 and e = 251 then gosub PSTlatch 'PST 2 if B = 3 and e = 247 then gosub PSTlatch 'PST 3 if B = 3 and e = 239 then gosub PSTlatch 'PST 4 if B = 3 and e = 223 then gosub PSTlatch 'PST 5 if B = 3 and e = 191 then gosub PSTlatch 'PST 6 if B = 3 and e = 127 then gosub PSTlatch 'PST 7 if B = 4 and e = 239 then gosub PSTlatch 'PST 8 if B = 4 and e = 223 then gosub PSTlatch 'PST 9 'wipe buttons processed here If b=8 and e=254 then gosub wipe 'wipe 5 if b=8 and e=253 then gosub wipe 'wipe 4 if b=8 and e=251 then gosub wipe 'wipe 3 if b=8 and e=247 then gosub revpos 'positioner if b=8 and e=239 then gosub wipe 'wipe 1 if b=8 and e=223 then gosub wipe 'wipe 2 if b=9 and e=254 then gosub wipe 'wipe 10 if b=9 and e=253 then gosub wipe 'wipe 9 if b=9 and e=251 then gosub wipe 'wipe 8 if b=9 and e=247 then gosub revpos 'reverse if b=9 and e=239 then gosub wipe 'wipe 6 if b=9 and e=223 then gosub wipe 'wipe 7 '--------------------------------mix and wipe ------ Tran: if (s and 2) <> 0 then let s=s-2 'if wipe lit turn off if (s and 8) <> 0 then let s=s-8 'if mix lit turn off if B=5 and e=223 then let s=s+2 'Transistion wipe on if B=5 and e= 191 then let s=s+8 ' Transistion mix on gosub latches return KEYCTRL: ' only one key allowed on ay once------- if (p and 8) <> 0 then let p=p-8 ' "EMEM" if (p and 16) <> 0 then let P=P-16 ' "AUTO SELECT" if (p and 32) <> 0 then let p=p-32 ' "PST PTN" if (p and 128) <>0 then let p=p-128 ' "LUM KEY" if (p and 4) <> 0 then let p=p-4 ' "LINEAR KEY" if (P and 64) <> 0 then let P=P-64 'CHROMA KEY" if (p and 2) <> 0 then let p=p-2 ' "KEY MASK" if ( p and 1) <> 0 then let p=p-1 ' "KEY INVERT" if (u and 1) <> 0 then let u=u-1 if B=0 and e = 254 then let p=p+8 ' "EMEM" if B=0 and e = 253 then let p=p+16 ' "AUTO SELECT" if B=0 and e = 251 then let p=p+32 ' "PST PTN" if B=0 and e = 247 then let p=p+128 ' "LUM KEY" if B=0 and e = 239 then let p=p+4 ' "LINEAR KEY" if B=0 and e = 223 then let p=P+64 ' "CHROMA KEY" if B=0 and e = 191 then let p=p+2 ' "KEY MASK" if B=5 and e = 127 then let p =p+1 ' "KEY INVERT" if B=0 and e=223 then let u=u+1 'key on if B=0 and e=239 then let u=u+1 if B=0 and e=247 then let u=u+1 gosub latches return '-----------------------turn oo one key at once--------- boarderline: if (u and 8) <> 0 then let u=u-8 'normal turn off if (u and 2) <> 0 then let u=u-2 'boarder turn off if (u and 64) <> 0 then let u=u-64 'shadow turn off If (u and 16) <> 0 then let u=u-16 'extrude turn of if (u and 4) <> 0 then let u=u-4 'outline turn off if B=5 and e = 254 then let u=u+8 'normal turn on if B=5 and e = 253 then let u=u+2 'boarder " if B=5 and e = 251 then let u=u+64 'shadow " if B=7 and e = 254 then let u=u+16 'Extrude " if B=7 and e = 253 then let u=u+4 'outline " gosub latches return '--------------------memory routines to mirror the PGM PST KEY latches------ ' more complex as soft control of turning keys off required KEYlatch: 'clear any previous selection from soft latch q, o and t if (q AND 64) <> 0 then let q = q-64 'if key 0 lit turn off if (q AND 16) <> 0 then let q = q-16 'if key 1 lit turn off if (q AND 4) <> 0 then let q = q -4 'if key 2 lit turn off if (q AND 1) <> 0 then let q = q -1 'if key 3 lit turn off if (o AND 2) <> 0 then let o = o -2 'if key 4 lit turn off if (o AND 1) <> 0 then let o = o -1 'if key 5 lit turn off if (o AND 8) <> 0 then let o = o -8 'if key 6 lit turn off if (o AND 4) <> 0 then let o = o -4 'if key 7 lit turn off if (t AND 8) <> 0 then let t = t- 8 'if key 8 lit turn off if (t AND 32) <> 0 then let t = t- 32 'if key 9 lit turn off if B=1 and e=254 then let q = q+64 'if key 0 pressed turn on if B=1 and e=253 then let q = q+16 'if key 1 pressed turn on if B=1 and e=251 then let q = q+4 'if key 2 pressed turn on if B=1 and e=247 then let q = q+1 'if key 3 pressed turn on if B=1 and e=239 then let o = o+2 'if key 4 pressed turn on if B=1 and e=223 then let o = o+1 'if key 5 pressed turn on if B=1 and e=191 then let o = o+8 'if key 6 pressed turn on if B=1 and e=127 then let o = o+4 'if key 7 pressed turn on if B=4 and e=251 then let t = t+8 'if key 8 pressed turn on if B=4 and e=247 then let t = t+32 'if key 9 pressed turn on gosub latches return PGMlatch: 'clear any previous selection from soft latch r o and n if (r AND 2) <> 0 then let r=r-2 'If PGM 0 lit turn off if (r AND 8) <> 0 then let r=r-8 'If PGM 1 lit turn off if (r AND 32) <> 0 then let r=r-32 'If PGM 2 lit turn off if (r AND 128) <> 0 then let r=r-128 'If PGM 3 lit turn off if (o AND 32) <> 0 then let o = o -32 'if PGM 4 lit turn off if (o AND 128) <> 0 then let o = o -128 'if PGM 5 lit turn off if (o AND 64) <> 0 then let o = o -64 'if PGM 6 lit turn off if (o AND 16) <> 0 then let o = o -16 'if PGM 7 lit turn off if (n AND 1) <> 0 then let n = n - 1 'If PGM 8 lit turn off if (n AND 4) <> 0 then let n = n - 4 'If PGM 9 lit turn off if B=2 and e=254 then let r = r+ 2 'if PGM 0 pressed turn on if B=2 and e=253 then let r = r+ 8 'if PGM 1 pressed turn on if B=2 and e=251 then let r = r+ 32 'if PGM 2 pressed turn on if B=2 and e=247 then let r =r + 128 'if PGM 3 pressed turn on if B=2 and e=239 then let o =o + 32 'if PGM 4 pressed turn on if B=2 and e=223 then let o =o + 128 'if PGM 5 pressed turn on if B=2 and e=191 then let o= o + 64 'if PGM 6 pressed turn on if B=2 and e=127 then let o= o + 16 'if PGM 7 Pressed turn on if b=4 and e=254 then let n= n + 1 'if PGM 8 pressed turn on if b=4 and e=253 then let n =n + 4 'if PGM 9 pressed turn on gosub latches return cut: LCD.PRINT 1,2, "Cut to PST " if (r AND 2) <> 0 then let r=r-2 'If PGM 0 lit turn off if (r AND 8) <> 0 then let r=r-8 'If PGM 1 lit turn off if (r AND 32) <> 0 then let r=r-32 'If PGM 2 lit turn off if (r AND 128) <> 0 then let r=r-128 'If PGM 3 lit turn off if (o AND 32) <> 0 then let o = o -32 'if PGM 4 lit turn off if (o AND 128) <> 0 then let o = o -128 'if PGM 5 lit turn off if (o AND 64) <> 0 then let o = o -64 'if PGM 6 lit turn off if (o AND 16) <> 0 then let o = o -16 'if PGM 7 lit turn off if (n AND 1) <> 0 then let n=n-1 'If PGM 8 lit turn off if (n AND 4) <> 0 then let n=n-4 'If PGM 9 lit turn off if (n and 16) <> 0 then let n=n+4 'PST9 cut to PGM9 if (n and 64) <> 0 then let n=n+1 'PST8 cut to PGM8 if (n and 128)<> 0 then let o=o+16 'PST7 cut to PGM7 if (n and 32) <> 0 then let o=o+64 'PST6 cut to PGM6 if (n and 8) <> 0 then let o=o +128 'PST5 cut to PGM5 if (n and 2) <> 0 then let o=o+32 'PST4 cut to PGM4 if (r and 1) <> 0 then let r=r+128 'PST3 cut to PGM3 if (r and 4) <> 0 then let r=r+32 'PST2 cut to PGM2 if (r and 16) <> 0 then let r=r+8 'PST1 cut to PGM1 if (r and 64) <> 0 then let r=r+2 'PST0 cut to PGM0 gosub latches return PSTlatch: 'clear any previous selection from soft latch r and n if (r AND 64) <> 0 then let r=r-64 'If PST 0 lit turn off if (r AND 16) <> 0 then let r=r-16 'If PST 1 lit turn off if (r AND 4 ) <> 0 then let r=r- 4 'If PST 2 lit turn off if (r AND 1) <> 0 then let r=r-1 'If PST 3 lit turn off if (n AND 2) <> 0 then let n=n-2 'If PST 4 lit turn off if (n AND 8) <> 0 then let n=n-8 'If PST 5 lit turn off if (n AND 32 ) <> 0 then let n=n-32 'If PST 6 lit turn off if (n AND 128) <> 0 then let n=n-128 'If PST 7 lit turn off if (n AND 64) <> 0 then let n=n-64 'If PST 8 lit turn off if (n AND 16) <> 0 then let n=n-16 'If PST 9 lit turn off if B= 3 AND e=254 then let r=r+64 'Turn PST 0 on if B= 3 AND e=253 then let r=r+16 'Turn PST 1 on if B= 3 AND e=251 then let r=r+4 'Turn PST 2 on if B= 3 AND e=247 then let r=r+1 'Turn PST 3 on if B= 3 AND e=239 then let n=n+2 'Turn PST 4 on if B= 3 AND e=223 then let n=n+8 'Turn PST 5 on if B= 3 AND e=191 then let n=n+32 'Turn PST 6 on if B= 3 AND e=127 then let n=n+128 'Turn PST 7 on if B= 4 AND e=239 then let n=n+64 'Turn PST 8 on if B= 4 AND e=223 then let n=n+16 'Turn PST 9 on gosub latches return wipe:' small pattern selector buttons on the top panel if (v and 64) <> 0 then let v=v-64 'turn wipe 1 off if (v and 32) <> 0 then let v=v-32 'turn wipe 2 off if (v and 2) <> 0 then let v=v-2 'turn wipe 3 off if (w and 128) <> 0 then let w=w-128 'turn wipe 4 off if (w and 8) <> 0 then let w=w-8 'turn wipe 5 off if (v and 16) <> 0 then let v=v-16 'turn wipe 6 off if (v and 128) <> 0 then let v=v-128 'turn wipe 7 off if (v and 8) <> 0 then let v=v-8 'turn wipe 8 off if (w and 64) <> 0 then let w=w-64 'turn wipe 9 off if (w and 32) <> 0 then let w=w-32 'turn wipe 10 off if b=8 and e=239 then let v=v+64 'turn on wipe 1 if b=8 and e=223 then let v=v+32 'turn on'wipe 2 if b=8 and e=251 then let v=v+2 'turn on wipe 3 if b=8 and e=253 then let w=w+128 'turn on wipe 4 If b=8 and e=254 then let w=w+8 'turn on wipe 5 if b=9 and e=239 then let v=v+16 'turn on wipe 6 if b=9 and e=223 then let v=v+128 'turn on wipe 7 if b=9 and e=251 then let v=v+8 'turn on wipe 8 if b=9 and e=253 then let w=w+64 'turn on'wipe 9 if b=9 and e=254 then let w=w+32 'turn on wipe 10 gosub latches return revpos: 'toggles position and reverse if b=9 and e=247 then goto rev 'reverse button pressed pause 100 'debounce dely if (v and 4) <> 0 then goto on 'pos light was on let v=v+4 'turn pos on as was not on goto done on: let v=v-4 'pos was on so turn off goto done rev: pause 100 'revlight routine if (v and 1) <> 0 then goto onn 'rev light was on let v=v+1 ' not lit turn on 'turn rev on as was no on goto done onn: let v=v-1 'rev was on so turn off done: gosub latches return 'IOswitch: ' I/O routine for 4 transition buttons if z=1 then let z =128 ' Fade to Black if z=8 then let z= 64 ' mix if z=2 then let z= 32 'wipe 'gosub IOPST return LCD: if (r and 2) <> 0 then LCD. PRINT 1,1, "On Air Black " ' PGM 0 LCD Legend if (r and 8) <> 0 then LCD. PRINT 1,1, "On Air Camera 1 " ' PGM 1 LCD Legend if (r and 32) <> 0 then LCD. PRINT 1,1, "On Air Camera 2 " ' PGM 2 LCD Legend if (r and 128) <> 0 then LCD. PRINT 1,1, "On Air Camera 3 " ' PGM 3 LCD Legend if (o and 32) <> 0 then LCD. PRINT 1,1, "On Air Camera 4 " ' PGM 4 LCD Legend if (o and 128) <> 0 then LCD. PRINT 1,1, "On Air Caption 1" ' PGM 5 LCD Legend if (o and 64) <> 0 then LCD. PRINT 1,1, "On Air Caption 2" ' PGM 6 LCD Legend if (o and 16) <> 0 then LCD. PRINT 1,1, "On Air VTR 1 " ' PGM 7 LCD Legend if (n and 1) <> 0 then LCD. PRINT 1,1, "On Air VTR 2 " ' PGM 8 LCD Legend if (n and 4) <> 0 then LCD. PRINT 1,1, "On Air Test Bars" ' PGM 9 LCD Legend if (r and 64) <> 0 then LCD. PRINT 1,2, "Preset Black " 'PST 0 LCD Legend if (r and 16) <> 0 then LCD. PRINT 1,2, "Preset Camera 1 " 'PST 1 LCD Legend if (r and 4) <> 0 then LCD. PRINT 1,2, "Preset Camera 2 " 'PST 2 LCD Legend if (r and 1) <> 0 then LCD. PRINT 1,2, "Preset Camera 3 " 'PST 3 LCD Legend if (n and 2) <> 0 then LCD. PRINT 1,2, "Preset Camera 4 " 'PST 4 LCD Legend if (n and 8) <> 0 then LCD. PRINT 1,2, "Preset Caption 1" 'PST 5 LCD legend if (n and 32) <> 0 then LCD. PRINT 1,2, "Preset Caption 2" 'PST 6 LCD Legend if (n and 128)<> 0 then LCD. PRINT 1,2, "Preset VTR 1 " 'PST 7 LCD Legend if (n and 64) <> 0 then LCD. PRINT 1,2, "Preset VTR 2 " 'PST 8 LCD Legend if (n and 16) <> 0 then LCD. PRINT 1,2, "Preset Test Bars" 'PST 9 LCD Legend return IO: 'I/O for PST and PGM bank to control 4 bits of IC5 if (r and 64) <> 0 then let a= 01 'PST 0 if (r and 16) <> 0 then let a= 02 'PST 1 if (r and 4) <> 0 then let a= 03 'PST 2 if (r and 1 ) <> 0 then let a= 04 'PST 3 if (n and 2) <> 0 then let a= 05 'PST 4 if (n and 8) <> 0 then let a =06 'PST 5 if (n and 32) <> 0 then let a =07 'PST 6 if (n and 128) <> 0 then let a= 08 'PST 7 if (n and 64) <> 0 then let a =09 'PST 8 if (n and 16) <> 0 then let a =10 'PST 9 if (r and 2) <> 0 then let cc=16+a 'PGM 0 if (r and 8) <> 0 then let cc=32+a 'PGM 1 if (r and 32) <> 0 then let cc=48+a 'PGM 2 if (r and 128) <> 0 then let cc=64+a 'PGM 3 if (o and 32) <> 0 then let cc=80+a 'PGM 4 if (o and 128) <> 0 then let cc=96+a 'PGM 5 if (o and 64) <> 0 then let cc=112+a 'PGM 6 if (o and 16) <> 0 then let cc=128+a 'PGM 7 if (n and 1) <> 0 then let cc=144+a 'PGM 8 if (n and 4) <> 0 then let cc=160+a 'PGM 9 i2c.begin IOa 'I/O port a' i2c.write cc i2c.end return fade2black: if B=6 and e = 191 let s=s+1' turn on FTB lamp gosub PSTlatch 'clear PST Lights let r=r+64 'set PST source 0 gosub latches gosub auto let s=s-1 'light off LCD.PRINT 1,2, "Fade to Black " gosub latches return auto: LCD.PRINT 1,2, "Auto Tran to PST" let s=s+192 'arrow lights on let t=t+4 'auto trans light gosub latches if Tbarpos = 255 then goto down 'virtual T-Bar down if Tbarpos = 0 then goto up 'virtual T-Bar up autotranoff: if (t and 4) <> 0 then let t = t -4 'autotrans off if (s and 128) <> 0 then let s=s -128 'arrow lights off if (s and 64) <> 0 then let s=s -64 'arrow lights off gosub latches gosub cut return up: for Tbarpos = 0 to 254 ' step Tbar up let z= durtotal 'value set in 7 segs doo: let z=z-1 'loop that steps through the 7 seg delay if z > 0 then goto doo next Tbarpos 'end of T-Bar loop goto autotranoff 'go to auto light off and arrow light off down: for x = 1 to 255 'Step T- Bar down let Tbarpos = Tbarpos-1 'decrement T-Bar position let z= durtotal 'value set by 7 segs dooo: let z=z-1 'Delay loop set by 7 segs if z > 0 then goto dooo next x 'terminate T-Bar goto autotranoff 'light off analog1: i2c. begin PRT3 i2c. write tbar 'tbar address i2c. end i2c. begin PRT1 i2c. write conv 'line low i2c. end i2c. begin PRT1 i2c. write tristate 'high again i2c. end i2c. begin PRT1 i2c. write analogue 'analogue line low i2c. end i2c.reqfrom PRT4,1 Tbarpos = i2c.read 'tbar value i2c.end wlog " " , "Tbarposition", Tbarpos return analog2: i2c. begin PRT3 i2c. write soft 'soft address i2c. end i2c. begin PRT1 i2c. write conv 'line low i2c. end i2c. begin PRT1 i2c. write tristate 'high again i2c. end i2c. begin PRT1 i2c. write analogue 'analogue line low i2c. end i2c.reqfrom PRT4,1 softpos = i2c.read 'soft value value i2c.end wlog "softness", softpos return analog3: i2c. begin PRT3 i2c. write hue 'tbar address i2c. end i2c. begin PRT1 i2c. write conv 'line low i2c. end i2c. begin PRT1 i2c. write tristate 'high again i2c. end i2c. begin PRT1 i2c. write analogue 'analogue line low i2c. end i2c.reqfrom PRT4,1 huevalue = i2c.read 'tbar value i2c.end wlog " " , "hue", huevalue return analog4: i2c. begin PRT3 i2c. write chroma 'tbar address i2c. end i2c. begin PRT1 i2c. write conv 'line low i2c. end i2c. begin PRT1 i2c. write tristate 'high again i2c. end i2c. begin PRT1 i2c. write analogue 'analogue line low i2c. end i2c.reqfrom PRT4,1 chromavalue = i2c.read 'tbar value i2c.end wlog " " ," ", "Chroma", Chromavalue return sevenseg1:'-------subrouting for the seven segment displays let et = et + 8 ' set the size of the incremnets if et = 81 then let et = 1 'reset the dispay after 9 i2c.begin PRT4 'data port' i2c.write et i2c.end i2c.begin PRT1 'Contol port' i2c.write ck 'ck low i2c.end i2c.begin PRT1 'Contol port' i2c.write tristate ' CK high i2c.end pause 400 'debounce delay return sevenseg2: let et2 = et2 + 8 if et2 = 82 then let et2 = 2 i2c.begin PRT4 'data port' i2c.write et2 i2c.end i2c.begin PRT1 'Contol port' i2c.write ck 'ck low i2c.end i2c.begin PRT1 'Contol port' i2c.write tristate ' CK high i2c.end pause 400 'debounce delay return sevenseg3: let et3 = et3 + 8 if et3 = 83 then let et3 = 3 i2c.begin PRT4 'data port' i2c.write et3 i2c.end i2c.begin PRT1 'Contol port' i2c.write ck 'ck low i2c.end i2c.begin PRT1 'Contol port' i2c.write tristate ' CK high i2c.end pause 400 'debounce delay return mixduration: 'add up and round off the product of the & segment displays let dur= et/8*100-12.5 let dur2 = et2/8*10-2.5 let dur3 = et3/8 let durtotal= INT ( dur+dur2+dur3)+1 ' "durtotal = lenght of mix return latches: for a= 0 to 9 if a=0 let data1=n if a=1 let data1=o if a=2 let data1=p if a=3 let data1=q if a=4 let data1=r if a=5 let data1=s if a=6 let data1=t if a=7 let data1=u if a=8 let data1=v if a=9 let data1=w i2c.begin PRT1 'Contol port' i2c.write tristate 'no command i2c.end i2c.begin PRT4 ' load n contents onto data bus i2c.write data1 i2c.end i2c.begin PRT3 ' Address hard latch i2c.write a i2c.end i2c.begin PRT1 ' Control port i2c.write lamps ' low i2c.end i2c.begin PRT1 ' switch lamp map off i2c.write tristate ' high i2c.end next a gosub IO return