DMX CONTROLLER 12 channels + saveable 12 scenes (from old forum)

Place your projects here
Post Reply
MarioL
Posts: 5
Joined: Sun Mar 21, 2021 8:38 am
Has thanked: 46 times
Been thanked: 7 times

DMX CONTROLLER 12 channels + saveable 12 scenes (from old forum)

Post by MarioL »

Hi,
I share tested DMX controller code with more features .
The attached files:
"Present1.gif" for brief of function interface;
"DMX_circuit v3.gif" for RS485 simple interface diagram;
"WAVE_FORM GPIO1.gif" for info or trouble isolation.


Condivido il programma del controller DMX sufficientemente testato e con più funzioni.
I file allegati:
"Present1.gif" per una breve presentazione dell'interfaccia e funzioni;
"DMX_circuit v3.gif" per lo schema di una semplice interfaccia RS485;
"WAVE_FORM GPIO1.gif" per informazioni o verifica funzionamento.

Code: [Local Link Removed for Guests]

' *************************************************************************************
' *****                                 File Info                                 *****
' *************************************************************************************
'    Filename: DMX-12ch-12sc
'    Date    : 08/12/2019
'    Version : 00_c2 fast load file and simplified routine + simple CHECKoNLINE funct
'    Edit. by: MarioL.
'    Function: DMX controller 12 channels + saveable 12 scenes
'    Firmware: ANNEX WiFi 1.38 public
'    Hardware: ESP mini D1 pro (external antenna), MAX485(I.C.),  470nF capacitor.
'    Doc.Ref.: Annex WiFi RDS Help Version 1.38, DMX protocol spec., RS485 datasheet
'    Note    : SOME LOW COST DMX DEVICES NEED COMMON GROUND CONNECTION!
' ***************************************************************************************

onhtmlchange varchange
onhtmlreload lblPaint

L = 0 'led value, check connection active

PIN.MODE 1, OUTPUT  'USED TO FORCE BREAK SIGNAL LOW
PIN(1) = 1          'BREAK SIGNAL DISABLED,(idle status)

intValCh1 = 0  'Value data channel 1
intValCh2 = 0  'Value data channel 2
intValCh3 = 0  'Value data channel 3
intValCh4 = 0  'Value data channel 4
intValCh5 = 0  'Value data channel 5
intValCh6 = 0  'Value data channel 6
intValCh7 = 0  'Value data channel 7
intValCh8 = 0  'Value data channel 8
intValCh9 = 0  'Value data channel 9
intValCh10 = 0  'Value data channel 10
intValCh11 = 0  'Value data channel 11
intValCh12 = 0  'Value data channel 12

noteCh1$ = "No load"  'Note for channel 1
noteCh2$ = "No load"  'Note for channel 2
noteCh3$ = "No load"  'Note for channel 3
noteCh4$ = "No load"  'Note for channel 4
noteCh5$ = "No load"  'Note for channel 5
noteCh6$ = "No load"  'Note for channel 6
noteCh7$ = "No load"  'Note for channel 7
noteCh8$ = "No load"  'Note for channel 8
noteCh9$ = "No load"  'Note for channel 9
noteCh10$ = "No load"  'Note for channel 10
noteCh11$ = "No load"  'Note for channel 11
noteCh12$ = "No load"  'Note for channel 12

noteSC1$ = "No load"  'Note for SetUp 1
noteSC2$ = "No load"  'Note for SetUp 2
noteSC3$ = "No load"  'Note for SetUp 3
noteSC4$ = "No load"  'Note for SetUp 4
noteSC5$ = "No load"  'Note for SetUp 5
noteSC6$ = "No load"  'Note for SetUp 6
noteSC7$ = "No load"  'Note for SetUp 7
noteSC8$ = "No load"  'Note for SetUp 8
noteSC9$ = "No load"  'Note for SetUp 9
noteSC10$ = "No load"  'Note for SetUp 10
noteSC11$ = "No load"  'Note for SetUp 11
noteSC12$ = "No load"  'Note for SetUp 12

'load saved scenes only note used
for I = 1 to 12
filename$ = "/DMX/SCN" + str$(I,"%02d",1) + ".SCN"  'where nn is scene's number
wlog filename$
gosub lblRclSC2
next I

gosub lblLoadNOTECHNL    'load CHANNEL's note
gosub varchange 'only for refresh in this case
gosub lblPaint  'draw controller page
SERIAL.MODE 250000 'set baud rate to 250000 bps
timer0 20, DMXpacket   'send complete DMX Paket
wait


lblPaint:
cls
a$ = ""
a$ = a$ + |<table border=8 bordercolor=blue bgcolor=lightblue cellspacing=6 cellpadding=6>|
a$ = a$ + |<th align=center bgcolor=#ffefdd>CH VALUE, edit it or move slider | + BUTTON$("Save CHL's NOTE BELOW", lblSaveNOTECHNL)+ |</th>|
a$ = a$ + |<th bgcolor=lightgreen> SCENE: RECALL / NOTE / SAVE </th>|   'inserisce l'intestazione alle due colonne
a$ = a$ + |<tr>|  'inizia la prima riga
a$ = a$ + |     <td bgcolor=ffefdd>| 'inizia la prima colonna
a$ = a$ + |CH 01: |
a$ = a$ + TEXTBOX$(intValCh1,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh1, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh1$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 02: |
a$ = a$ + TEXTBOX$(intValCh2,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh2, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh2$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 03: |
a$ = a$ + TEXTBOX$(intValCh3,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh3, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh3$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 04: |
a$ = a$ + TEXTBOX$(intValCh4,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh4, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh4$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 05: |
a$ = a$ + TEXTBOX$(intValCh5,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh5, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh5$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 06: |
a$ = a$ + TEXTBOX$(intValCh6,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh6, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh6$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 07: |
a$ = a$ + TEXTBOX$(intValCh7,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh7, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh7$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 08: |
a$ = a$ + TEXTBOX$(intValCh8,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh8, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh8$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 09: |
a$ = a$ + TEXTBOX$(intValCh9,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh9, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh9$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 10: |
a$ = a$ + TEXTBOX$(intValCh10,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh10, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh10$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 11: |
a$ = a$ + TEXTBOX$(intValCh11,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh11, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh11$,"IDtxtNote")
a$ = a$ + |<br>|
a$ = a$ + |CH 12: |
a$ = a$ + TEXTBOX$(intValCh12,"IDtxtVal")
a$ = a$ + SLIDER$(intValCh12, 0, 255, 1, "IDslid")
a$ = a$ + TEXTBOX$(noteCh12$,"IDtxtNote")
a$ = a$ + |     </td>|  'fine prima colonna
a$ = a$ + cssid$("IDtxtVal", "width: 30px;")
a$ = a$ + cssid$("IDslid", "width: 200px; background-color: grey")
html a$

a$ = ""
a$ = a$ + |     <td bgcolor=lightgreen  align=center>| 'inizia la seconda colonna
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL01",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC1$,"IDtxtNoteS") + BUTTON$("SAV",lblSavSC01)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL02",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC2$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC02)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL03",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC3$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC03)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL04",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC4$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC04)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL05",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC5$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC05)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL06",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC6$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC06)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL07",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC7$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC07)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL08",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC8$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC08)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL09",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC9$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC09)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL10",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC10$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC10)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ +  BUTTON$("RCLL11",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC11$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC11)
a$ = a$ + |<br>|
'ADD SETTING ROWS
a$ = a$ + BUTTON$("RCLL12",lblRclSC,"IDbutRcl") + TEXTBOX$(noteSC12$,"IDtxtNoteS")  + BUTTON$("SAV",lblSavSC12)
a$ = a$ + |<br><br>|
'ADD menu' ROWS
a$ = a$ +  BUTTON$(" - ONLY SCENEs PAGE - ",lblPaintOnlySettPg)
a$ = a$ + |     </td>|  'fine seconda colonna
a$ = a$ + |</table>  |     'fine tabella
a$ = a$ + cssid$("IDtxtNote", "width: 180px")
a$ = a$ + cssid$("IDbutRcl:focus", "background-color: lime")
a$ = a$ + |<H3 ID="ADVICE" ALIGN="CENTER"> </H3>|
html a$
a$ = "" 'more ramfree will availables for running variables



J$ = ||
J$ = J$ + | setInterval(function() {|
J$ = J$ + |  {|
J$ = J$ + |  var r=navigator.onLine;|
J$ = J$ + |  if (r==true)|
J$ = J$ + |    {|
J$ = J$ + |    document.getElementById("ADVICE").innerHTML = "CONNECTED";|
J$ = J$ + |    document.getElementById("ADVICE").style.backgroundColor = "lime";|
J$ = J$ + |    }|
J$ = J$ + |  else|
J$ = J$ + |    {|
J$ = J$ + |    document.getElementById("ADVICE").innerHTML = "UNCONNECT";|
J$ = J$ + |    document.getElementById("ADVICE").style.backgroundColor = "red";|
J$ = J$ + |    }|
J$ = J$ + |  }|
J$ = J$ + |}, 2000);|
JSCRIPT J$ : J$ = ""   'more ramfree will availables
return


varchange:
refresh
'wlog ramfree
return


'**************************************  CREATE AND TRANSMIT  DMX PAKET **********************************************
DMXpacket:
'PIN(1) = 0 : PIN(1) = 0 : PIN(1) = 0    'FORCE BREAK Typical 180 usec (escamotage: 3 time to obtain 200us total pulse)
PIN.MODE 1, OUTPUT  'USED TO FORCE BREAK SIGNAL LOW
PIN(1) = 0     'FORCE BREAK Typical 180 usec
PIN(1) = 0 
PIN(1) = 0 
PIN(1) = 0 
'pause 1        'however in this case minimum pause is 1 ms
PIN(1) = 1     'TERMINE BREAK
pin.mode 1, special  'restore normal function (TX pin)
'pause 1       'Mark After Break min. 12 usec (internal delay between instruction is sufficient, no pause required)
'Send Start Code (byte = 0), Channel Datas (Mark Time Before Slot by internal delay betwen serial byte)
SERIAL.BYTE 0, intValCh1, intValCh2, intValCh3, intValCh4, intValCh5, intValCh6, intValCh7, intValCh8, intValCh9 , intValCh10, intValCh11, intValCh12
return

'************************************** SAVE CHANNEL'S NOTE ********************************************************
lblSaveNOTECHNL:
'SALVA NOTE RELATIVE AI CANALI
Testo$ = |noteCh1$="|+ noteCh1$+|":noteCh2$="|+noteCh2$ +|":noteCh3$="|+ noteCh3$ +|":noteCh4$="|+ noteCh4$
Testo$ = Testo$ +|":noteCh5$="|+ noteCh5$ + |":noteCh6$="|+ noteCh6$ + |":noteCh7$="| + noteCh7$ + |":noteCh8$="|+ noteCh8$ 
Testo$ = Testo$ + |":noteCh9$="|+ noteCh9$ + |":noteCh10$="|+ noteCh10$ + |":noteCh11$="|+ noteCh11$ + |":noteCh12$="|+ noteCh12$ + |"|
FILE.SAVE "/DMX/NOTECHNL.TXT", Testo$
 Testo$ = ""  'more ramfree will available
RETURN


'************************************** LOAD CHANNEL'S NOTE ********************************************************
lblLoadNOTECHNL:
temp$ = ""
if FILE.EXISTS("/DMX/NOTECHNL.TXT") = 0 THEN RETURN
temp$ = FILE.READ$("/DMX/NOTECHNL.TXT")
command temp$ : temp$ = ""  'more ramfree will available
return


'************************************** SAVE AND RECALL SETTING *********************************

lblSavSC01:  'SAVE SCENE SETTING 1
filename$ = "/DMX/SCN01.SCN"
noteSC$ = |:noteSC1$="|+ noteSC1$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC02:  'SAVE SCENE SETTING 2
filename$ = "/DMX/SCN02.SCN"
noteSC$ =  |:noteSC2$="|+ noteSC2$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC03:  'SAVE SCENE SETTING 3
filename$ = "/DMX/SCN03.SCN"
noteSC$ = |:noteSC3$="|+ noteSC3$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC04:  'SAVE SCENE SETTING 4
filename$ = "/DMX/SCN04.SCN"
noteSC$ = |:noteSC4$="|+ noteSC4$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC05:  'SAVE SCENE SETTING 5
filename$ = "/DMX/SCN05.SCN"
noteSC$ = |:noteSC5$="|+ noteSC5$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC06:  'SAVE SCENE SETTING 6
filename$ = "/DMX/SCN06.SCN"
noteSC$ = |:noteSC6$="|+ noteSC6$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC07:  'SAVE SCENE SETTING 7
filename$ = "/DMX/SCN07.SCN"
noteSC$ = |:noteSC7$="|+ noteSC7$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC08:  'SAVE SCENE SETTING 8
filename$ = "/DMX/SCN08.SCN"
noteSC$ = |:noteSC8$="|+ noteSC8$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC09:  'SAVE SCENE SETTING 9
filename$ = "/DMX/SCN09.SCN"
noteSC$ = |:noteSC9$="|+ noteSC9$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC10:  'SAVE SCENE SETTING 10
filename$ = "/DMX/SCN10.SCN"
noteSC$ = |:noteSC10$="|+ noteSC10$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC11:  'SAVE SCENE SETTING 11
filename$ = "/DMX/SCN11.SCN"
noteSC$ = |:noteSC11$="|+ noteSC11$+|"|
gosub lblWriteFileSCENE
RETURN

lblSavSC12:  'SAVE SCENE SETTING 12
filename$ = "/DMX/SCN12.SCN"
noteSC$ = |:noteSC12$="|+ noteSC12$+|"|
gosub lblWriteFileSCENE
RETURN

lblWriteFileSCENE:  'write SCENE setting file (common code)
Testo$ = "intValCh1=" + STR$(intValCh1) + ":intValCh2="+ STR$(intValCh2) + ":intValCh3="+ STR$(intValCh3) + ":intValCh4="+ STR$(intValCh4) 
Testo$ = Testo$ + ":intValCh5="+ STR$(intValCh5)+ ":intValCh6="+ STR$(intValCh6) + ":intValCh7="+ STR$(intValCh7) + ":intValCh8="+ STR$(intValCh8)
Testo$ = Testo$ + ":intValCh9="+ STR$(intValCh9) + ":intValCh10="+ STR$(intValCh10)+ ":intValCh11="+STR$(intValCh11) + ":intValCh12="+ STR$(intValCh12) + noteSC$
FILE.SAVE filename$, Testo$
 Testo$ = ""  'more ramfree will available
return



lblRclSC:
filename$ = "/DMX/SCN" + right$(HtmlEventButton$,2)+ ".SCN"
 'filename$ = "/DMX/SCNnn.SCN"  'where nn is scene's number
lblRclSC2:
if FILE.EXISTS(filename$) = 0 THEN RETURN
temp$ = ""
temp$ = FILE.READ$(filename$)
command temp$ : temp$ = ""  'more ramfree will available
refresh
return



lblPaintOnlySettPg:  'DRAW PAGE FOR ONLY BIG BUTTON SCENE RACAL
cls
a$ = ""
a$ = a$ + |<style> body {background-color: lightgreen; text-align:center}</style>|
a$ = a$ + BUTTON$(noteSC1$ + "_01", lblRclSC, "IDbuttPageSet")
a$ = a$ + BUTTON$(noteSC2$ + "_02", lblRclSC, "IDbuttPageSet")
a$ = a$ + BUTTON$(noteSC3$ + "_03", lblRclSC, "IDbuttPageSet")
a$ = a$ + |<br>|
a$ = a$ + BUTTON$(noteSC4$ + "_04", lblRclSC, "IDbuttPageSet")
a$ = a$ + BUTTON$(noteSC5$ + "_05", lblRclSC, "IDbuttPageSet")
a$ = a$ + BUTTON$(noteSC6$ + "_06", lblRclSC, "IDbuttPageSet")
a$ = a$ + |<br>|
a$ = a$ + BUTTON$(noteSC7$ + "_07", lblRclSC, "IDbuttPageSet")
a$ = a$ + BUTTON$(noteSC8$ + "_08", lblRclSC, "IDbuttPageSet")
a$ = a$ + BUTTON$(noteSC9$ + "_09", lblRclSC, "IDbuttPageSet")
a$ = a$ + |<br>|
a$ = a$ + BUTTON$(noteSC10$ + "_10", lblRclSC, "IDbuttPageSet")
a$ = a$ + BUTTON$(noteSC11$ + "_11", lblRclSC, "IDbuttPageSet")
a$ = a$ + BUTTON$(noteSC12$ + "_12", lblRclSC, "IDbuttPageSet")
a$ = a$ + |<br><br>|
a$ = a$ + BUTTON$("COMBINED PAGE",lblPaint)
a$ = a$ + cssid$("IDbuttPageSet", "width:250; height:40; font-size:18px; outline-style:groove; margin:10px")
a$ = a$ + cssid$("IDbuttPageSet:focus", "background-color: lime")
html a$
a$ = "" 'more ramfree for variables
return

regards


If you give me a penny and I give you a penny then you and me will have one penny. But if you give me an idea and I give you a an idea , then each of us will have two ideas. (various)

immagine.png
immagine.png
immagine.png
You do not have the required permissions to view the files attached to this post.
Post Reply