'+=========================================================================+ '+ GVG100 Panel software 10b includes cut subroutine for PGM to PST selection + '+also two subroutines to display analogue pots currently T-Bar and Softness + '+ 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 + '+ + ' + '+=========================================================================+ ' 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 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 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 10b " let n=0 :let o=0 : let p=0 let q=0 : let r=0 : let s=0 let t=0 : let u=0 : let y=0 let z=0 :let x =255: let w=255 let analogue = 239 let conv = 231 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 '--------------------------------clear all lights and turn power on to PGM,KEY and PST banks----------------------- for a = 0 to 8 'clearlights i2c.begin PRT1 'Contol port' i2c.write tristate 'no command i2c.end i2c.begin PRT4 ' Data bus i2c.write 0 i2c.end i2c.begin PRT3 ' Address bus i2c.write a i2c.end i2c.begin PRT1 ' Contol port i2c.write lamps ' Writelamp i2c.end i2c.begin PRT1 'Contol port' i2c.write tristate 'no command i2c.end next a 'power on to PST,PGM an Key bank lights if (q AND 128) <> 0 then let q = q -128 ' turn KEY PGM PST power off if (q AND 32) <> 0 then let q = q -32 if (q AND 8) <> 0 then let q = q -8 let q=q+ 168 ' turn key PGM PST power on gosub strobeq '---------------------set Set KEY PGM PST to source 0 selected-------------------- let B = 1 'set key bank to 0 let e = 254 gosub KEYlatch ' "Key 0 " let B = 2 'set PGM bank to 0 let e = 254 gosub PGMlatch ' "PGM 0 let B = 3 'set PST bank to 0 let e = 254 gosub PSTlatch ' PST 0 '-----------------------------------------------button pole-------------------------- do ' read the buttons loop for B=0 to 7 i2c.begin PRT1 ' switch all maps off i2c.write tristate i2c.end 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 i2c.begin PRT1 ' switch all maps off i2c.write tristate i2c.end if e< 255 then gosub push next B gosub analog1 gosub analog2 loop until 0 '----------------------------------------push buttons director----------------------- push: ' 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 Tran 'FADE TO BLACK if B=4 and e = 127 then gosub Tran 'Auto Transistion 'if B=4 and e = 191 then gosub Tran '*cut if B=6 and e = 223 then gosub Tran '*DSK mix 'if B=6 and e = 239 then gosub Tran '*DSK cut ' 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 return '-----yellow buttons no memory cannot read latches--own strobe within the routine------ tran: if B=5 and e = 223 then let z = 2 'Transistion wipe if B=5 and e = 191 then let z = 8 ' Transistion mix if B=6 and e = 191 then let z = 1 ' Fade to Black if B=4 and e = 127 then let z= 0 'auto Trans if B=4 and e = 127 then gosub auto 'auto Trans i2c.begin PRT1 'strobe routine to move data to GVG latch i2c.write tristate 'no command i2c.end i2c.begin PRT4 ' Data bus i2c.write z ' Y address i2c.end i2c.begin PRT3 ' Address bus i2c.write 5 ' X address i2c.end i2c.begin PRT1 ' Control port i2c.write lamps ' Scan lamps i2c.end i2c.begin PRT1 ' Control port i2c.write tristate ' Scan buttons i2c.end gosub auto gosub IOswitch return KEYCTRL: ' no soft latch used so latch resets for every new entry own strobe in routine------- let n=0 :let o=0 : let p=0 if B=0 and e = 254 then let y = 8 ' "EMEM" if B=0 and e = 253 then let y = 16 ' "AUTO SELECT" if B=0 and e = 251 then let y = 32 ' "PST PTN" if B=0 and e = 247 then let y = 128 ' "LUM KEY" if B=0 and e = 239 then let y = 4 ' "LINEAR KEY" if B=0 and e = 223 then let y = 64 ' "CHROMA KEY" if B=0 and e = 191 then let y = 2 ' "KEY MASK" if B=5 and e = 127 then let y = 1 ' "KEY INVERT" i2c.begin PRT1 ' Data bus i2c.write tristate 'no command i2c.end i2c.begin PRT4 ' Data bus i2c.write y ' Y address i2c.end i2c.begin PRT3 ' Address bus i2c.write 2 ' X address i2c.end i2c.begin PRT1 ' Control port i2c.write lamps ' Scan lamps i2c.end i2c.begin PRT1 ' Control port i2c.write tristate ' Scan buttons i2c.end return boarderline: ' no soft latch used so latch resets for every new entry -own strobe in routine----- if B=5 and e = 254 then let x = 8 'normal if B=5 and e = 253 then let x = 2 ' boarder if B=5 and e = 251 then let x = 64 'shadow if B=7 and e = 254 then let x = 16 ' Extrude if B=7 and e = 253 then let x = 4 'outline i2c.begin PRT1 ' Data bus i2c.write tristate 'no command i2c.end i2c.begin PRT4 ' Data bus i2c.write x ' Y address i2c.end i2c.begin PRT3 ' Address bus i2c.write 7 ' X address i2c.end i2c.begin PRT1 ' Control port i2c.write lamps ' Scan lamps i2c.end i2c.begin PRT1 ' Control port i2c.write tristate ' Scan buttons i2c.end 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 strobeq 'q latch lamps gosub strobeo 'o latch lamps gosub strobet 't latch lamps gosub IOkey 'Input Output routines 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 strobeo ' O latch lamps gosub strober ' r latch lamps gosub stroben ' n latch lamps gosub IOpgm ' Input Output routine return cut: 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 if (n and 16) <> 0 then let x = 80 'PGM 9 IO update if (n and 64) <> 0 then let x = 96 'PGM 8 IO update if (n and 128)<>0 then let x = 112 'PGM 7 IO update if (n and 32)<> 0 then let x = 128 'PGM 6 IO update if (n and 8) <> 0 then let x = 144 'PGM 5 IO update if (n and 2) <> 0 then let x = 160 'PGM 4 IO update if (r and 1) <> 0 then let x = 176 'PGM 3 IO update if (r and 4) <> 0 then let x = 192 'PGM 2 IO update if (r and 16)<> 0 then let x = 208 'PGM 1 IO update if (r and 64)<> 0 then let x = 224 'PGM 0 IO update gosub strobeo ' O latch lamps gosub strober ' r latch lamps gosub stroben ' n latch lamps i2c.begin IOa 'I/O port a' i2c.write x+w 'PGM bank to I/O i2c.end 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 strober ' r latch lamps gosub stroben ' n latch lamps gosub IOPST 'Input Output routines 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 if z=0 then let z=16 'auto transistion gosub IOPST return IOPST: 'I/O for PST bank to control 4 bits of IC5 if B = 3 and e = 254 then let y=14 'if PST 0 pressed turn on if B = 3 and e = 253 then let y=13 'if PST 1 pressed turn on if B = 3 and e = 251 then let y=12 'if PST 2 pressed turn on if B = 3 and e = 247 then let y=11 'if PST 3 pressed turn on if B = 3 and e = 239 then let y=10 'if PST 4 pressed turn on if B = 3 and e = 223 then let y=9 'if PST 5 pressed turn on if B = 3 and e = 191 then let y=8 'if PST 6 pressed turn on if B = 3 and e = 127 then let y=7 'if PST 7 pressed turn on if B = 4 and e = 239 then let y=6 'if PST 8 pressed turn on if B = 4 and e = 223 then let y=5 'if PST 9 pressed turn on i2c.begin IOb 'I/O port a' i2c.write y+z 'PST Bank to I/O i2c.end return IOkey: 'I/O for key bank to control 4 bits of IC4 if B=1 and e=254 then let w=14 'if key 0 pressed turn on if B=1 and e=253 then let w=13 'if key 1 pressed turn on if B=1 and e=251 then let w=12 'if key 2 pressed turn on if B=1 and e=247 then let w=11 'if key 3 pressed turn on if B=1 and e=239 then let w=10 'if key 4 pressed turn on if B=1 and e=223 then let w=9 'if key 5 pressed turn on if B=1 and e=191 then let w=8 'if key 6 pressed turn on if B=1 and e=127 then let w=7 'if key 7 pressed turn on if B=4 and e=251 then let w=6 'if key 8 pressed turn on if B=4 and e=247 then let w=5 'if key 9 pressed turn on i2c.begin IOa 'I/O port a' i2c.write w+x 'key bank to I/O i2c.end return IOpgm: 'I/O for PGM bank to control 4 bits of IC4 if B=2 and e=254 then let x= 224 'if PGM 0 pressed turn on if B=2 and e=253 then let x= 208 'if PGM 1 pressed turn on if B=2 and e=251 then let x= 192 'if PGM 2 pressed turn on if B=2 and e=247 then let x= 176 'if PGM 3 pressed turn on if B=2 and e=239 then let x= 160 'if PGM 4 pressed turn on if B=2 and e=223 then let x= 144 'if PGM 5 pressed turn on if B=2 and e=191 then let x= 128 'if PGM 6 pressed turn on if B=2 and e=127 then let x= 112 'If PGM 7 pressed turn on if b=4 and e=254 then let x= 96 'if PGM 8 pressed turn on if b=4 and e=253 then let x= 80 'if PGM 9 pressed turn on i2c.begin IOa 'I/O port a' i2c.write x+w 'PGM bank to I/O i2c.end return auto: 'turn auto tran on (work around) if (t and 4) <> 0 then let t = t -4 'autotrans if b=4 and e = 127 then let t=t +4 'if (t and 4) <> 0 then let t = t -4 'autotrans 'if b=6 and e= 191 then let t=t-4 gosub strobet return ' ----------------------------------strobe the latches to move data to GVG Lamp Latches----------- stroben: i2c.begin PRT1 ' switch all maps off i2c.write tristate i2c.end i2c.begin PRT4 ' load n contents onto data bus i2c.write n i2c.end i2c.begin PRT3 ' Address hard latch i2c.write 0 i2c.end i2c.begin PRT1 ' Control port i2c.write lamps ' load hard latch with n i2c.end i2c.begin PRT1 ' switch lamp map off i2c.write tristate ' return strobeq: ' move the soft latch q into hard latch 03 i2c.begin PRT1 ' switch all maps off i2c.write tristate i2c.end i2c.begin PRT4 ' load Q contents onto data bus i2c.write Q i2c.end i2c.begin PRT3 ' Address hard latch i2c.write 03 i2c.end i2c.begin PRT1 ' Control port i2c.write lamps ' load hard latch with Q i2c.end i2c.begin PRT1 ' switch lamp map off i2c.write tristate i2c.end return strobeo: ' move contents of o into hard latch i2c.begin PRT1 ' switch lamp map off i2c.write tristate i2c.end i2c.begin PRT4 ' load o contents onto data bus i2c.write o i2c.end i2c.begin PRT3 ' Address hard latch i2c.write 01 i2c.end i2c.begin PRT1 ' Control port i2c.write lamps ' load hard latch with o i2c.end i2c.begin PRT1 ' switch lamp map off i2c.write tristate i2c.end return strober: ' move contents of o into hard latch i2c.begin PRT1 ' switch lamp map off i2c.write tristate i2c.end i2c.begin PRT4 ' load r contents onto data bus i2c.write r i2c.end i2c.begin PRT3 ' Address hard latch i2c.write 04 i2c.end i2c.begin PRT1 ' Control port i2c.write lamps ' load hard latch with r i2c.end i2c.begin PRT1 ' switch lamp map off i2c.write tristate i2c.end return strobet: 'move contents of t into hard latch i2c.begin PRT1 ' switch lamp map off i2c.write tristate i2c.end i2c.begin PRT4 ' load t contents onto data bus i2c.write t i2c.end i2c.begin PRT3 ' Address hard latch i2c.write 06 i2c.end i2c.begin PRT1 ' Control port i2c.write lamps ' load hard latch with t i2c.end i2c.begin PRT1 ' switch all maps off i2c.write tristate i2c.end return 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. begin PRT1 i2c. write analogue 'analogue line low i2c. end i2c.reqfrom PRT4,1 tt = i2c.read 'tbar value i2c.end wlog tt 'print the value of the tbar return analog2: i2c. begin PRT3 i2c. write soft 'tbar address i2c. end i2c. begin PRT1 i2c. write conv 'line low i2c. end i2c. begin PRT1 i2c. write tristate 'high again i2c. begin PRT1 i2c. write analogue 'analogue line low i2c. end i2c.reqfrom PRT4,1 tt = i2c.read 'tbar value i2c.end wlog tt 'print the value of the tbar return