diff --git a/DMX-2.0/DriverBoitierV3.cs b/DMX-2.0/DriverBoitierV3.cs
index 5741c47..4dc58ba 100644
--- a/DMX-2.0/DriverBoitierV3.cs
+++ b/DMX-2.0/DriverBoitierV3.cs
@@ -42,7 +42,7 @@ namespace DMX2
Fin
}
- const int timeout = 100;
+ const int timeout = 50;
// tampons Entrée/Sortie
public byte[] inputbuffer = new byte[516];
@@ -61,38 +61,88 @@ namespace DMX2
int brk = 150;
int mab = 50;
int nbc1 = 512;
- byte flag_merge1 = 1;
+ byte flags = 0;
+ byte dmxinterval= 40;
+ int usbrefresh = 40;
bool reinit=false ;
-
-
public void ReInit () {
reinit=true;
}
public int Break {
+ set {
+ brk = value;
+ paramFlag = true;
+ }
get {
return brk;
}
}
public int Mab {
+ set {
+ mab = value;
+ paramFlag = true;
+ }
get {
return mab;
}
}
- public byte Flag_merge1 {
+ public bool Merge {
+ set {
+ flags = (byte)( (flags & 0xFE) | (value?1:0));
+ paramFlag = true;
+ }
get {
- return flag_merge1;
+ return (flags&1)>0;
}
}
+ public bool Sync {
+ get {
+ return (flags & 2)>0;
+ }
+ set {
+ flags = (byte)((flags & 0xFD) | (value?2:0));
+ paramFlag = true;
+ }
+ }
+ public int NbCircuits {
+ get {
+ return nbc1;
+ }
+ set {
+ nbc1 = value;
+ paramFlag= true;
+ }
+ }
+
+ public byte DmxInterval {
+ get {
+ return dmxinterval;
+ }
+ set {
+ dmxinterval = value;
+ paramFlag= true;
+ }
+ }
+
+ public int UsbRefresh {
+ get {
+ return usbrefresh;
+ }
+ set {
+ usbrefresh = value;
+ }
+ }
public DriverBoitierV3 (string serialport, string id): base(id)
{
+ patch1 = Conduite.Courante.Patches[0];
portname = serialport;
outputbuffer[0]=27;
outputbuffer[1]=68;
@@ -102,14 +152,6 @@ namespace DMX2
bool paramFlag = false;
- public void SetBreak( int _brk, int _mab, byte _merge1)
- {
- brk = _brk;
- mab = _mab;
- flag_merge1 = _merge1;
- paramFlag = true;
- }
-
void Start ()
{
if (loopthread == null) {
@@ -165,20 +207,15 @@ namespace DMX2
if (!serial.IsOpen)
return false;
- // Au cas ou le boitier attends une fin de commande : envoi 1030 octets a 0 (le boitier ignorera tout seul la suite)
byte[] tmpBuffer = new byte[2];
- serial.Write (tmpBuffer, 0, tmpBuffer.Length);
// On attends un peu
- Thread.Sleep (50);
+ Thread.Sleep (5);
// Vide le buffer d'entree
if (serial.BytesToRead > 0)
serial.ReadExisting ();
- if(serial.BytesToWrite > 0)
- Console.WriteLine("Les infos partent pas ...");
-
// on envoie Esc 'A'
tmpBuffer [0] = 27;
tmpBuffer [1] = 65;
@@ -209,7 +246,7 @@ namespace DMX2
compteErreur = 0;
break;
case etatAutomate.Transmission:
- finAttente = DateTime.Now.AddMilliseconds (22);
+ finAttente = DateTime.Now.AddMilliseconds (usbrefresh);
//Console.WriteLine(DateTime.Now-t);
//t = DateTime.Now;
EnvoiTrame ();
@@ -345,7 +382,7 @@ namespace DMX2
return;
}
- byte[] tmpBuffer = new byte[6];
+ byte[] tmpBuffer = new byte[7];
tmpBuffer [0] = 27; // Esc
tmpBuffer [1] = 66; // 'B'
@@ -356,7 +393,8 @@ namespace DMX2
tmpBuffer [3] = (byte)brk;
tmpBuffer [4] = (byte)mab;
- tmpBuffer [5] = (byte) (flag_merge1 );
+ tmpBuffer [5] = (byte) (flags );
+ tmpBuffer [6] = (byte) (dmxinterval);
serial.Write (tmpBuffer, 0, tmpBuffer.Length);
@@ -540,10 +578,13 @@ namespace DMX2
if(patch1!=null) el.SetAttribute ("univers1", patch1.Nom);
-
+ el.SetAttribute("circuits", nbc1.ToString());
el.SetAttribute("mab",mab.ToString());
el.SetAttribute("brk",brk.ToString());
- el.SetAttribute("merge1",(flag_merge1!=0).ToString());
+ el.SetAttribute("merge1",((flags&1)>0).ToString());
+ el.SetAttribute("sync",((flags&2)>0).ToString());
+ el.SetAttribute("dmxinterval",dmxinterval.ToString());
+ el.SetAttribute("usbrefresh",usbrefresh.ToString());
}
@@ -571,16 +612,14 @@ namespace DMX2
}
}
+ drv.NbCircuits = int.Parse(el.TryGetAttribute("circuits","512"));
+ drv.Mab = int.Parse(el.TryGetAttribute("mab","150"));
+ drv.Break = int.Parse(el.TryGetAttribute("brk","50"));
+ drv.Merge = bool.Parse(el.TryGetAttribute("merge1","True"));
+ drv.Sync = bool.Parse(el.TryGetAttribute("sync","True"));
+ drv.DmxInterval = byte.Parse(el.TryGetAttribute("dmxinterval","22"));
+ drv.UsbRefresh = int.Parse(el.TryGetAttribute("usbrefresh","22"));
- int mab,brk;
- byte merge1;
-
- mab = int.Parse(el.TryGetAttribute("mab","150"));
- brk = int.Parse(el.TryGetAttribute("brk","50"));
- merge1 = (byte)( bool.Parse(el.TryGetAttribute("merge1","True"))?1:0 );
-
-
- drv.SetBreak(brk,mab,merge1);
return drv;
}
diff --git a/DMX-2.0/DriverBoitierV3UI.cs b/DMX-2.0/DriverBoitierV3UI.cs
index 5384c0e..23dd157 100644
--- a/DMX-2.0/DriverBoitierV3UI.cs
+++ b/DMX-2.0/DriverBoitierV3UI.cs
@@ -40,8 +40,11 @@ namespace DMX2
{
caseBrk.Text = drv.Break.ToString ();
caseMab.Text = drv.Mab.ToString ();
-
- chkMerge1.Active = drv.Flag_merge1 == 1;
+ caseCircuits.Text = drv.NbCircuits.ToString();
+ caseDMXInt.Text = drv.DmxInterval.ToString();
+ caseUSBRef.Text = drv.UsbRefresh.ToString();
+ chkMerge1.Active = drv.Merge;
+ chkSync.Active = drv.Sync;
cbUnivers1.Model = lsCbUnivers1;
var cellCbUnivers1 = new CellRendererText ();
@@ -86,18 +89,33 @@ namespace DMX2
}
- int a, b;
+ int a, b, c,d, f;
if (!int.TryParse (caseBrk.Text, out a))
return;
if (!int.TryParse (caseMab.Text, out b))
return;
- if (a < 92) {
- a = 92;
- }
- if (b < 12) {
- b = 12;
- }
- drv.SetBreak(a,b,(byte)(chkMerge1.Active?1:0));
+ if (!int.TryParse (caseCircuits.Text, out c))
+ return;
+
+ if (!int.TryParse (caseUSBRef.Text, out d))
+ return;
+
+ if (!int.TryParse (caseDMXInt.Text, out f))
+ return;
+
+ if (a < 92) a = 92;
+ if (b < 12) b = 12;
+ if (c < 8 || c > 512 ) c = 512;
+ if (d < 22 ) d = 22;
+ if (f < 22 || f > 255 ) f = 22;
+
+ drv.Break = a;
+ drv.Mab = b;
+ drv.NbCircuits = c;
+ drv.UsbRefresh = d;
+ drv.DmxInterval = (byte)f;
+ drv.Merge = chkMerge1.Active;
+ drv.Sync = chkSync.Active;
}
@@ -105,9 +123,6 @@ namespace DMX2
{
drv.ReInit();
}
-
-
-
}
}
diff --git a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV1UI.cs b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV1UI.cs
index 758efa1..6d3dac6 100644
--- a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV1UI.cs
+++ b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV1UI.cs
@@ -35,7 +35,6 @@ namespace DMX2
w1.Fill = false;
// Container child vbox2.Gtk.Box+BoxChild
this.table1 = new global::Gtk.Table (((uint)(3)), ((uint)(2)), false);
- this.table1.Name = "table1";
this.table1.RowSpacing = ((uint)(6));
this.table1.ColumnSpacing = ((uint)(6));
// Container child table1.Gtk.Table+TableChild
diff --git a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV2UI.cs b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV2UI.cs
index 119dee8..c089e20 100644
--- a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV2UI.cs
+++ b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV2UI.cs
@@ -45,7 +45,6 @@ namespace DMX2
w1.Fill = false;
// Container child vbox2.Gtk.Box+BoxChild
this.table1 = new global::Gtk.Table (((uint)(4)), ((uint)(5)), false);
- this.table1.Name = "table1";
this.table1.RowSpacing = ((uint)(6));
this.table1.ColumnSpacing = ((uint)(6));
// Container child table1.Gtk.Table+TableChild
diff --git a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV3UI.cs b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV3UI.cs
index 8cc97c0..72d4ce6 100644
--- a/DMX-2.0/gtk-gui/DMX2.DriverBoitierV3UI.cs
+++ b/DMX-2.0/gtk-gui/DMX2.DriverBoitierV3UI.cs
@@ -8,15 +8,21 @@ namespace DMX2
private global::Gtk.Label label1;
private global::Gtk.Table table1;
private global::Gtk.Entry caseBrk;
+ private global::Gtk.Entry caseCircuits;
+ private global::Gtk.Entry caseDMXInt;
private global::Gtk.Entry caseMab;
+ private global::Gtk.Entry caseUSBRef;
private global::Gtk.ComboBox cbUnivers1;
private global::Gtk.CheckButton chkMerge1;
- private global::Gtk.Label label2;
+ private global::Gtk.CheckButton chkSync;
+ private global::Gtk.Label label10;
+ private global::Gtk.Label label11;
private global::Gtk.Label label3;
private global::Gtk.Label label4;
private global::Gtk.Label label5;
- private global::Gtk.Label label6;
private global::Gtk.Label label8;
+ private global::Gtk.Label label9;
+ private global::Gtk.Label labelsync;
private global::Gtk.HBox hbox1;
private global::Gtk.Button btnValider;
private global::Gtk.Button btnInit;
@@ -41,8 +47,7 @@ namespace DMX2
w1.Expand = false;
w1.Fill = false;
// Container child vbox2.Gtk.Box+BoxChild
- this.table1 = new global::Gtk.Table (((uint)(3)), ((uint)(5)), false);
- this.table1.Name = "table1";
+ this.table1 = new global::Gtk.Table (((uint)(5)), ((uint)(4)), false);
this.table1.RowSpacing = ((uint)(6));
this.table1.ColumnSpacing = ((uint)(6));
// Container child table1.Gtk.Table+TableChild
@@ -55,35 +60,70 @@ namespace DMX2
global::Gtk.Table.TableChild w2 = ((global::Gtk.Table.TableChild)(this.table1 [this.caseBrk]));
w2.TopAttach = ((uint)(1));
w2.BottomAttach = ((uint)(2));
- w2.LeftAttach = ((uint)(2));
- w2.RightAttach = ((uint)(3));
+ w2.LeftAttach = ((uint)(1));
+ w2.RightAttach = ((uint)(2));
w2.XOptions = ((global::Gtk.AttachOptions)(4));
w2.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child table1.Gtk.Table+TableChild
+ this.caseCircuits = new global::Gtk.Entry ();
+ this.caseCircuits.CanFocus = true;
+ this.caseCircuits.Name = "caseCircuits";
+ this.caseCircuits.IsEditable = true;
+ this.caseCircuits.InvisibleChar = '•';
+ this.table1.Add (this.caseCircuits);
+ global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.table1 [this.caseCircuits]));
+ w3.LeftAttach = ((uint)(3));
+ w3.RightAttach = ((uint)(4));
+ w3.YOptions = ((global::Gtk.AttachOptions)(4));
+ // Container child table1.Gtk.Table+TableChild
+ this.caseDMXInt = new global::Gtk.Entry ();
+ this.caseDMXInt.CanFocus = true;
+ this.caseDMXInt.Name = "caseDMXInt";
+ this.caseDMXInt.IsEditable = true;
+ this.caseDMXInt.InvisibleChar = '•';
+ this.table1.Add (this.caseDMXInt);
+ global::Gtk.Table.TableChild w4 = ((global::Gtk.Table.TableChild)(this.table1 [this.caseDMXInt]));
+ w4.TopAttach = ((uint)(3));
+ w4.BottomAttach = ((uint)(4));
+ w4.LeftAttach = ((uint)(3));
+ w4.RightAttach = ((uint)(4));
+ w4.YOptions = ((global::Gtk.AttachOptions)(4));
+ // Container child table1.Gtk.Table+TableChild
this.caseMab = new global::Gtk.Entry ();
this.caseMab.CanFocus = true;
this.caseMab.Name = "caseMab";
this.caseMab.IsEditable = true;
this.caseMab.InvisibleChar = '•';
this.table1.Add (this.caseMab);
- global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.table1 [this.caseMab]));
- w3.TopAttach = ((uint)(1));
- w3.BottomAttach = ((uint)(2));
- w3.LeftAttach = ((uint)(3));
- w3.RightAttach = ((uint)(4));
- w3.XOptions = ((global::Gtk.AttachOptions)(4));
- w3.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w5 = ((global::Gtk.Table.TableChild)(this.table1 [this.caseMab]));
+ w5.TopAttach = ((uint)(1));
+ w5.BottomAttach = ((uint)(2));
+ w5.LeftAttach = ((uint)(3));
+ w5.RightAttach = ((uint)(4));
+ w5.YOptions = ((global::Gtk.AttachOptions)(4));
+ // Container child table1.Gtk.Table+TableChild
+ this.caseUSBRef = new global::Gtk.Entry ();
+ this.caseUSBRef.CanFocus = true;
+ this.caseUSBRef.Name = "caseUSBRef";
+ this.caseUSBRef.IsEditable = true;
+ this.caseUSBRef.InvisibleChar = '•';
+ this.table1.Add (this.caseUSBRef);
+ global::Gtk.Table.TableChild w6 = ((global::Gtk.Table.TableChild)(this.table1 [this.caseUSBRef]));
+ w6.TopAttach = ((uint)(3));
+ w6.BottomAttach = ((uint)(4));
+ w6.LeftAttach = ((uint)(1));
+ w6.RightAttach = ((uint)(2));
+ w6.XOptions = ((global::Gtk.AttachOptions)(4));
+ w6.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child table1.Gtk.Table+TableChild
this.cbUnivers1 = global::Gtk.ComboBox.NewText ();
this.cbUnivers1.Name = "cbUnivers1";
this.table1.Add (this.cbUnivers1);
- global::Gtk.Table.TableChild w4 = ((global::Gtk.Table.TableChild)(this.table1 [this.cbUnivers1]));
- w4.TopAttach = ((uint)(1));
- w4.BottomAttach = ((uint)(2));
- w4.LeftAttach = ((uint)(1));
- w4.RightAttach = ((uint)(2));
- w4.XOptions = ((global::Gtk.AttachOptions)(4));
- w4.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w7 = ((global::Gtk.Table.TableChild)(this.table1 [this.cbUnivers1]));
+ w7.LeftAttach = ((uint)(1));
+ w7.RightAttach = ((uint)(2));
+ w7.XOptions = ((global::Gtk.AttachOptions)(4));
+ w7.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child table1.Gtk.Table+TableChild
this.chkMerge1 = new global::Gtk.CheckButton ();
this.chkMerge1.CanFocus = true;
@@ -92,74 +132,116 @@ namespace DMX2
this.chkMerge1.DrawIndicator = true;
this.chkMerge1.UseUnderline = true;
this.table1.Add (this.chkMerge1);
- global::Gtk.Table.TableChild w5 = ((global::Gtk.Table.TableChild)(this.table1 [this.chkMerge1]));
- w5.TopAttach = ((uint)(1));
- w5.BottomAttach = ((uint)(2));
- w5.LeftAttach = ((uint)(4));
- w5.RightAttach = ((uint)(5));
- w5.XOptions = ((global::Gtk.AttachOptions)(4));
- w5.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w8 = ((global::Gtk.Table.TableChild)(this.table1 [this.chkMerge1]));
+ w8.TopAttach = ((uint)(2));
+ w8.BottomAttach = ((uint)(3));
+ w8.LeftAttach = ((uint)(3));
+ w8.RightAttach = ((uint)(4));
+ w8.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child table1.Gtk.Table+TableChild
- this.label2 = new global::Gtk.Label ();
- this.label2.Name = "label2";
- this.label2.LabelProp = "Etat";
- this.table1.Add (this.label2);
- global::Gtk.Table.TableChild w6 = ((global::Gtk.Table.TableChild)(this.table1 [this.label2]));
- w6.XOptions = ((global::Gtk.AttachOptions)(4));
- w6.YOptions = ((global::Gtk.AttachOptions)(4));
+ this.chkSync = new global::Gtk.CheckButton ();
+ this.chkSync.CanFocus = true;
+ this.chkSync.Name = "chkSync";
+ this.chkSync.Label = "";
+ this.chkSync.DrawIndicator = true;
+ this.chkSync.UseUnderline = true;
+ this.table1.Add (this.chkSync);
+ global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.table1 [this.chkSync]));
+ w9.TopAttach = ((uint)(2));
+ w9.BottomAttach = ((uint)(3));
+ w9.LeftAttach = ((uint)(1));
+ w9.RightAttach = ((uint)(2));
+ w9.XOptions = ((global::Gtk.AttachOptions)(4));
+ w9.YOptions = ((global::Gtk.AttachOptions)(4));
+ // Container child table1.Gtk.Table+TableChild
+ this.label10 = new global::Gtk.Label ();
+ this.label10.Name = "label10";
+ this.label10.LabelProp = "Freq. USB (ms)";
+ this.table1.Add (this.label10);
+ global::Gtk.Table.TableChild w10 = ((global::Gtk.Table.TableChild)(this.table1 [this.label10]));
+ w10.TopAttach = ((uint)(3));
+ w10.BottomAttach = ((uint)(4));
+ w10.XOptions = ((global::Gtk.AttachOptions)(4));
+ w10.YOptions = ((global::Gtk.AttachOptions)(4));
+ // Container child table1.Gtk.Table+TableChild
+ this.label11 = new global::Gtk.Label ();
+ this.label11.Name = "label11";
+ this.label11.LabelProp = "Intervale entre\ntrames DMX (ms)";
+ this.table1.Add (this.label11);
+ global::Gtk.Table.TableChild w11 = ((global::Gtk.Table.TableChild)(this.table1 [this.label11]));
+ w11.TopAttach = ((uint)(3));
+ w11.BottomAttach = ((uint)(4));
+ w11.LeftAttach = ((uint)(2));
+ w11.RightAttach = ((uint)(3));
+ w11.XOptions = ((global::Gtk.AttachOptions)(4));
+ w11.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child table1.Gtk.Table+TableChild
this.label3 = new global::Gtk.Label ();
this.label3.Name = "label3";
this.label3.LabelProp = "Univer associé";
this.table1.Add (this.label3);
- global::Gtk.Table.TableChild w7 = ((global::Gtk.Table.TableChild)(this.table1 [this.label3]));
- w7.LeftAttach = ((uint)(1));
- w7.RightAttach = ((uint)(2));
- w7.XOptions = ((global::Gtk.AttachOptions)(4));
- w7.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w12 = ((global::Gtk.Table.TableChild)(this.table1 [this.label3]));
+ w12.XOptions = ((global::Gtk.AttachOptions)(4));
+ w12.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child table1.Gtk.Table+TableChild
this.label4 = new global::Gtk.Label ();
this.label4.Name = "label4";
- this.label4.LabelProp = "Break";
+ this.label4.LabelProp = "Break (µs)";
this.table1.Add (this.label4);
- global::Gtk.Table.TableChild w8 = ((global::Gtk.Table.TableChild)(this.table1 [this.label4]));
- w8.LeftAttach = ((uint)(2));
- w8.RightAttach = ((uint)(3));
- w8.XOptions = ((global::Gtk.AttachOptions)(4));
- w8.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w13 = ((global::Gtk.Table.TableChild)(this.table1 [this.label4]));
+ w13.TopAttach = ((uint)(1));
+ w13.BottomAttach = ((uint)(2));
+ w13.XOptions = ((global::Gtk.AttachOptions)(4));
+ w13.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child table1.Gtk.Table+TableChild
this.label5 = new global::Gtk.Label ();
this.label5.Name = "label5";
- this.label5.LabelProp = "MAB";
+ this.label5.LabelProp = "MAB (µs)";
this.table1.Add (this.label5);
- global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.table1 [this.label5]));
- w9.LeftAttach = ((uint)(3));
- w9.RightAttach = ((uint)(4));
- w9.XOptions = ((global::Gtk.AttachOptions)(4));
- w9.YOptions = ((global::Gtk.AttachOptions)(4));
- // Container child table1.Gtk.Table+TableChild
- this.label6 = new global::Gtk.Label ();
- this.label6.Name = "label6";
- this.label6.LabelProp = "Block 1";
- this.table1.Add (this.label6);
- global::Gtk.Table.TableChild w10 = ((global::Gtk.Table.TableChild)(this.table1 [this.label6]));
- w10.TopAttach = ((uint)(1));
- w10.BottomAttach = ((uint)(2));
- w10.XOptions = ((global::Gtk.AttachOptions)(4));
- w10.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w14 = ((global::Gtk.Table.TableChild)(this.table1 [this.label5]));
+ w14.TopAttach = ((uint)(1));
+ w14.BottomAttach = ((uint)(2));
+ w14.LeftAttach = ((uint)(2));
+ w14.RightAttach = ((uint)(3));
+ w14.XOptions = ((global::Gtk.AttachOptions)(4));
+ w14.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child table1.Gtk.Table+TableChild
this.label8 = new global::Gtk.Label ();
this.label8.Name = "label8";
this.label8.LabelProp = "Merge";
this.table1.Add (this.label8);
- global::Gtk.Table.TableChild w11 = ((global::Gtk.Table.TableChild)(this.table1 [this.label8]));
- w11.LeftAttach = ((uint)(4));
- w11.RightAttach = ((uint)(5));
- w11.XOptions = ((global::Gtk.AttachOptions)(4));
- w11.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w15 = ((global::Gtk.Table.TableChild)(this.table1 [this.label8]));
+ w15.TopAttach = ((uint)(2));
+ w15.BottomAttach = ((uint)(3));
+ w15.LeftAttach = ((uint)(2));
+ w15.RightAttach = ((uint)(3));
+ w15.XOptions = ((global::Gtk.AttachOptions)(4));
+ w15.YOptions = ((global::Gtk.AttachOptions)(4));
+ // Container child table1.Gtk.Table+TableChild
+ this.label9 = new global::Gtk.Label ();
+ this.label9.Name = "label9";
+ this.label9.LabelProp = "Circuits";
+ this.table1.Add (this.label9);
+ global::Gtk.Table.TableChild w16 = ((global::Gtk.Table.TableChild)(this.table1 [this.label9]));
+ w16.LeftAttach = ((uint)(2));
+ w16.RightAttach = ((uint)(3));
+ w16.XOptions = ((global::Gtk.AttachOptions)(4));
+ w16.YOptions = ((global::Gtk.AttachOptions)(4));
+ // Container child table1.Gtk.Table+TableChild
+ this.labelsync = new global::Gtk.Label ();
+ this.labelsync.Name = "labelsync";
+ this.labelsync.LabelProp = "Syncro\nDMX<->USB";
+ this.table1.Add (this.labelsync);
+ global::Gtk.Table.TableChild w17 = ((global::Gtk.Table.TableChild)(this.table1 [this.labelsync]));
+ w17.TopAttach = ((uint)(2));
+ w17.BottomAttach = ((uint)(3));
+ w17.XOptions = ((global::Gtk.AttachOptions)(4));
+ w17.YOptions = ((global::Gtk.AttachOptions)(4));
this.vbox2.Add (this.table1);
- global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.table1]));
- w12.Position = 1;
+ global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.table1]));
+ w18.Position = 1;
+ w18.Expand = false;
+ w18.Fill = false;
// Container child vbox2.Gtk.Box+BoxChild
this.hbox1 = new global::Gtk.HBox ();
this.hbox1.Name = "hbox1";
@@ -171,10 +253,10 @@ namespace DMX2
this.btnValider.UseUnderline = true;
this.btnValider.Label = "Valider";
this.hbox1.Add (this.btnValider);
- global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnValider]));
- w13.Position = 1;
- w13.Expand = false;
- w13.Fill = false;
+ global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnValider]));
+ w19.Position = 1;
+ w19.Expand = false;
+ w19.Fill = false;
// Container child hbox1.Gtk.Box+BoxChild
this.btnInit = new global::Gtk.Button ();
this.btnInit.CanFocus = true;
@@ -182,16 +264,16 @@ namespace DMX2
this.btnInit.UseUnderline = true;
this.btnInit.Label = "Init Boitier";
this.hbox1.Add (this.btnInit);
- global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnInit]));
- w14.Position = 2;
- w14.Expand = false;
- w14.Fill = false;
+ global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.btnInit]));
+ w20.Position = 2;
+ w20.Expand = false;
+ w20.Fill = false;
this.vbox2.Add (this.hbox1);
- global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1]));
- w15.PackType = ((global::Gtk.PackType)(1));
- w15.Position = 2;
- w15.Expand = false;
- w15.Fill = false;
+ global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1]));
+ w21.PackType = ((global::Gtk.PackType)(1));
+ w21.Position = 2;
+ w21.Expand = false;
+ w21.Fill = false;
this.Add (this.vbox2);
if ((this.Child != null)) {
this.Child.ShowAll ();
diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic
index 2bb4830..64f52c9 100644
--- a/DMX-2.0/gtk-gui/gui.stetic
+++ b/DMX-2.0/gtk-gui/gui.stetic
@@ -2632,7 +2632,7 @@ Licence : GPL V2
-
+
False
@@ -2654,8 +2654,8 @@ Licence : GPL V2
- 3
- 5
+ 5
+ 4
6
6
@@ -2670,9 +2670,6 @@ Licence : GPL V2
-
-
-
@@ -2683,8 +2680,8 @@ Licence : GPL V2
1
2
- 2
- 3
+ 1
+ 2
True
Fill
Fill
@@ -2696,6 +2693,48 @@ Licence : GPL V2
False
+
+
+
+ True
+ True
+ •
+
+
+ 3
+ 4
+ True
+ Fill
+ True
+ True
+ False
+ False
+ True
+ False
+
+
+
+
+
+ True
+ True
+ •
+
+
+ 3
+ 4
+ 3
+ 4
+ True
+ Fill
+ True
+ True
+ False
+ False
+ True
+ False
+
+
@@ -2709,6 +2748,28 @@ Licence : GPL V2
3
4
True
+ Fill
+ True
+ True
+ False
+ False
+ True
+ False
+
+
+
+
+
+ True
+ True
+ •
+
+
+ 3
+ 4
+ 1
+ 2
+ True
Fill
Fill
False
@@ -2726,8 +2787,6 @@ Licence : GPL V2
- 1
- 2
1
2
True
@@ -2751,10 +2810,34 @@ Licence : GPL V2
True
- 1
- 2
- 4
- 5
+ 2
+ 3
+ 3
+ 4
+ True
+ Fill
+ True
+ True
+ False
+ False
+ True
+ False
+
+
+
+
+
+ True
+
+ True
+ True
+ True
+
+
+ 2
+ 3
+ 1
+ 2
True
Fill
Fill
@@ -2767,11 +2850,35 @@ Licence : GPL V2
-
+
- Etat
+ Freq. USB (ms)
+ 3
+ 4
+ True
+ Fill
+ Fill
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+
+
+ Intervale entre
+trames DMX (ms)
+
+
+ 3
+ 4
+ 2
+ 3
True
Fill
Fill
@@ -2789,8 +2896,6 @@ Licence : GPL V2
Univer associé
- 1
- 2
True
Fill
Fill
@@ -2805,11 +2910,11 @@ Licence : GPL V2
- Break
+ Break (µs)
- 2
- 3
+ 1
+ 2
True
Fill
Fill
@@ -2824,30 +2929,13 @@ Licence : GPL V2
- MAB
-
-
- 3
- 4
- True
- Fill
- Fill
- False
- True
- False
- False
- True
- False
-
-
-
-
-
- Block 1
+ MAB (µs)
1
2
+ 2
+ 3
True
Fill
Fill
@@ -2865,8 +2953,49 @@ Licence : GPL V2
Merge
- 4
- 5
+ 2
+ 3
+ 2
+ 3
+ True
+ Fill
+ Fill
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+
+
+ Circuits
+
+
+ 2
+ 3
+ True
+ Fill
+ Fill
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+
+
+ Syncro
+DMX<->USB
+
+
+ 2
+ 3
True
Fill
Fill
@@ -2881,7 +3010,9 @@ Licence : GPL V2
1
- True
+ False
+ False
+ False
diff --git a/dmx512_micro/dmx512_micro.cpp b/dmx512_micro/dmx512_micro.cpp
index 5c52547..95ed6f1 100644
--- a/dmx512_micro/dmx512_micro.cpp
+++ b/dmx512_micro/dmx512_micro.cpp
@@ -5,17 +5,11 @@
int main(void)
{
init();
-
-#if defined(USBCON)
USBDevice.attach();
-#endif
-
setup();
-
for (;;) {
loop();
}
-
return 0;
}
@@ -28,45 +22,48 @@ int main(void)
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
-#define TEMPDMXRX 8
-
-
-// déclaration des tableaux de données
-byte tab_input_pc[514]; // venant du pc
-byte tab_input_dmx[518]; // données venant de l'extérieur : les 512 premiers DMX; les 4 suivant 4x8 bp ;
-byte tab_temp_dmx[TEMPDMXRX];
-byte inbuffer[6];
-
-// reception
-volatile int index_input_pc=0; // entrée serial 0
-volatile int index_output_pc=0; // sortie serial 0
-volatile int index_input_dmx=513; // entrée dmx
-volatile int index_output_dmx=0; //sortie dmx
-
+// définitions
+#define TEMPDMXRX 8 // Longueur de trame mini en reception
#define IOUTDMX_FIN -4
#define IOUTDMX_IDLE -1
#define IOUTDMX_BRK -2
#define IOUTDMX_MAB -3
+#define IINUSB_IDLE 0
+#define IINUSB_ESC 1
+#define IINUSB_DATA 2
+#define IINUSB_PARAM 10
-volatile int etat_input_pc=0; // 0 raz ; 1 esc reçu ; 2 D reçu : pret à recevoir ; 3 prèt à emmetre
-
-int tx1pin = 1; // pin DMX serial 1
-
-int ledPin = 13; // led interne
-unsigned int blkl = 0, blkcpt=0, rxledcpt=0 ,txledcpt=0;
+#define TX1PIN 1 // pin DMX serial 1
+#define LEDPIN 13 // led interne
#define RX_TX_LED_TIME 3
-byte brk_timer_end=75; // def : 150us
-byte mab_timer_end=25; //def : 50us
-int nb_circuits=512;
-int flag_merge1=1;
-volatile bool emissionPc=0;
-// Fonctions
+// tableaux de données
+byte tab_input_pc[514]; // venant du pc
+byte tab_input_dmx[518]; // données venant de l'extérieur : les 512 premiers DMX; les 4 suivant 4x8 bp ;
+byte tab_temp_dmx[TEMPDMXRX];
+byte inbuffer[7];
-void ecritUSB();
-void CDC_accept();
+// Variables d'état et compteurs
+volatile int index_input_pc=0; // entrée USB
+volatile int index_output_pc=0; // sortie USB
+volatile int index_input_dmx=513; // entrée dmx
+volatile int index_output_dmx=0; // sortie dmx
+volatile int etat_input_pc=IINUSB_IDLE; // etat entrée USB
+volatile bool emissionPc=0; // flag : emission USB en attente
+unsigned int blkl = 0, blkcpt=0, rxledcpt=0 ,txledcpt=0; // Gestion des leds
+unsigned int blinkon, blinkp, interbrk=0; // idem
+// Paramètres
+byte brk_timer_end=75; // Duree Break (par 2µs) def : 150us
+byte mab_timer_end=25; // Duree MAB (par 2µs) def : 50us
+int nb_circuits=512; // Nombre de circuits DMX emis
+int dmx_frame_interval=40; // Intervale entre trames DMX emises
+bool flag_merge1=1;
+bool flag_sync=0;
+
+
+// ********************************** USB ***************************** //
// lancé par interruption USB sur reception d'un char <- Cette fonction nécessite une modif de la lib arduino
// l'interet est de ne pas utiliser le buffer de la classe Serial, trop petit (64o)
void CDC_accept()
@@ -77,25 +74,26 @@ void CDC_accept()
switch (etat_input_pc) {
- case 0:
+ case IINUSB_IDLE:
USB_Recv(CDC_RX,&c,1);
// on attend un 'esc' pour commencer
- if (c==27) { etat_input_pc=1; break;}
+ if (c==27) { etat_input_pc=IINUSB_ESC; break;}
break;
- case 1:
+ case IINUSB_ESC:
USB_Recv(CDC_RX,&c,1);
// on attend 'D' pour recevoir
if (c==68) {
- etat_input_pc=2;
+ etat_input_pc=IINUSB_DATA;
index_input_pc=1;
tab_input_dmx[517]=68;
index_output_pc=1; // on init l'index d'emmission vers le pc ( le 0 n'est pas emit => start code)
emissionPc=1; // activation de l'intéruption registre emmission
+ break;
}
// Esc 'C' réinit
if (c==67) {
- etat_input_pc=0;
+ etat_input_pc=IINUSB_IDLE;
pe=tab_input_pc+514;
for(pb=tab_input_pc;pb 512) {
etat_input_pc=0;
+ if(flag_sync && (index_output_dmx==IOUTDMX_IDLE)) interbrk=1000;
}
break;
- case 10:
- index_input_pc+=USB_Recv(CDC_RX,inbuffer+index_input_pc,4-index_input_pc);
- if(index_input_pc<4) return;
+ case IINUSB_PARAM:
+ index_input_pc+=USB_Recv(CDC_RX,inbuffer+index_input_pc,5-index_input_pc);
+ if(index_input_pc<5) return;
- //nb_circuits= ((int)inbuffer[0])*2 + 2;
+ nb_circuits= ((int)inbuffer[0])*2 + 2;
brk_timer_end = (inbuffer[1]/2);
mab_timer_end = (inbuffer[2]/2);
flag_merge1 = inbuffer[3] & 1;
+ flag_sync = inbuffer[3] & 2;
+ dmx_frame_interval = inbuffer[4];
etat_input_pc=0;
@@ -159,173 +165,194 @@ void CDC_accept()
void ecritUSB()
{
- TXLED1; txledcpt=RX_TX_LED_TIME;
- if(index_output_pc > 516){
- USB_Send(CDC_TX,tab_input_dmx+index_output_pc,1);
- emissionPc=0;
- return;
- }
- index_output_pc+= USB_Send(CDC_TX,tab_input_dmx+index_output_pc, 517-index_output_pc);
- if (index_output_pc>516) {
- emissionPc=0;
- }
+ TXLED1; txledcpt=RX_TX_LED_TIME;
+ if(index_output_pc > 516){ // Emission d'un seul caractere (code etat)
+ USB_Send(CDC_TX,tab_input_dmx+index_output_pc,1);
+ emissionPc=0;
+ return;
+ }
+ // Emission du tableau complet
+ index_output_pc+= USB_Send(CDC_TX,tab_input_dmx+index_output_pc, 517-index_output_pc);
+ if (index_output_pc>516) {
+ emissionPc=0;
+ }
}
+// ********************************** RECEPTION DMX ********************************* //
+
// vecteur d'intéruption pour reception dmx
+// sur reception d'un caractere / erreur
ISR(USART1_RX_vect)
{
- char c,r;
- r = UCSR1A;
- c = UDR1;
- if (r & (1< doit etre 0
+
+ if ( index_input_dmx on copie ce qu'on a déja recu
+ for(int i=0;i Permet d'attendre que tout soit parti avant de déclancher le break
ISR(USART1_TX_vect)
{
- // si l'USART 1 est vide => break
- if(index_output_dmx==IOUTDMX_FIN){
- index_output_dmx=IOUTDMX_IDLE;
- }
+ // si l'USART 1 est vide => break
+ if(index_output_dmx==IOUTDMX_FIN)
+ index_output_dmx=IOUTDMX_IDLE;
}
+
// vecteur : USART 1 transmission registre vide
ISR(USART1_UDRE_vect)
{
- if (index_output_dmx>=0) { //si index >=0 caratère suivant
- if (flag_merge1==1) {UDR1 = max(tab_input_pc[index_output_dmx],tab_input_dmx[index_output_dmx]);}
- else {UDR1 = tab_input_pc[index_output_dmx];}
- index_output_dmx++;
- }
- // si 512 transmits => mise en attente de fin de transmission
- // desactivation de l'intéruption sur le registre
- if (index_output_dmx>nb_circuits) {index_output_dmx=IOUTDMX_FIN;cbi(UCSR1B, UDRIE1);}
-
+ if (flag_merge1==1) {
+ UDR1 = max(tab_input_pc[index_output_dmx],tab_input_dmx[index_output_dmx]);
+ }
+ else {
+ UDR1 = tab_input_pc[index_output_dmx];
+ }
+ index_output_dmx++;
+
+ // si 512 transmits => mise en attente de fin de transmission
+ // desactivation de l'interruption sur le registre
+ if (index_output_dmx>nb_circuits) {
+ index_output_dmx=IOUTDMX_FIN;
+ cbi(UCSR1B, UDRIE1);
+ }
}
+// Timer 4 : gestion des temps de break et mab
ISR(TIMER4_COMPA_vect) {
- if (index_output_dmx==IOUTDMX_BRK ) {
- digitalWrite(tx1pin, HIGH); // on met la broche à 1
-
- index_output_dmx=IOUTDMX_MAB;
- OCR4A = mab_timer_end ;
- TCNT4 = 0 ;// RAZ compteur timer
- TIFR4 = 0 ; //Clear Flags timer
- return;
- }
- if (index_output_dmx==IOUTDMX_MAB ) {
- sbi(UCSR1B, TXEN1); // on redémarre la transmission
- index_output_dmx=0; // on se prépare à émmettre à partir du stat code ( 513 octets )
- sbi(UCSR1B, UDRIE1); // on réactive l'intéruption du registre
- TIMSK4= 0 ; //desactivation intéruption A &B
- TCCR4B = 0;
- }
+ if (index_output_dmx==IOUTDMX_BRK ) { // en cours de break
+ index_output_dmx=IOUTDMX_MAB;
+ digitalWrite(TX1PIN, HIGH); // on met la broche à 1
+ // on relance le timer sur le temps du mab
+ OCR4A = mab_timer_end ;
+ TCNT4 = 0 ; // RAZ compteur timer
+ TIFR4 = 0 ; //Clear Flags timer
+ return;
+ }
+ if (index_output_dmx==IOUTDMX_MAB ) { // en cours de mab
+ //TXLED1; txledcpt=RX_TX_LED_TIME;
+ sbi(UCSR1B, TXEN1); // on reactive la transmission USART
+ index_output_dmx=0; // on se prépare à émmettre à partir du stat code ( 513 octets )
+ sbi(UCSR1B, UDRIE1); // on réactive l'intéruption du registre
+
+ // Arret du timer
+ TIMSK4= 0 ; //desactivation intéruption
+ TCCR4B = 0; // arret du timer
+ TIFR4 = 0 ; //Clear Flags timer
+ }
}
+// ********************************** INIT ********************************* //
+
void setup() {
- // initialisation du stat code à 0
- etat_input_pc=0;
- tab_input_pc[0]=0;
+ // Le startcode n'est jamais recu. On l'initialise ici
+ tab_input_pc[0]=0;
- // init pin led interne en sortie
- pinMode(ledPin, OUTPUT);
+ // init pin led interne en sortie
+ pinMode(LEDPIN, OUTPUT);
+
+ // init USART
+ // baudrate à 250k
+ UCSR1A = 1 << U2X1;
+ UBRR1H=0;
+ UBRR1L = 7;
- // initialisation à 250k de serial 1
- // baudrate
- UCSR1A = 1 << U2X1;
- UBRR1H=0;
- UBRR1L = 7;
-
- // 2 bit de stop; pas de parité; 8 bits de données
- UCSR1C = 14;
-
-
-
- // activation transmission et intéruption serial 1
- sbi(UCSR1B, RXEN1); //Reception
- sbi(UCSR1B, TXEN1); //Transmission
- sbi(UCSR1B, RXCIE1); //Interruption sur reception
- sbi(UCSR1B, TXCIE1); //Interruption pour fin de transmission
+ // 2 bit de stop; pas de parité; 8 bits de données
+ UCSR1C = 14;
- // init timer break
- TIMSK4 = 0;
- TCCR4C = 0;
- TCCR4B = 0;
- TCCR4A = 0; // 00000000
- TCNT4 = 0; // compteur
- TC4H=0;
+ // activation reception et intéruptions serial 1
+ sbi(UCSR1B, RXEN1); //Reception
+ cbi(UCSR1B, TXEN1); //Pas de transmission avant 1er Break
+ sbi(UCSR1B, RXCIE1); //Interruption sur reception
+ sbi(UCSR1B, TXCIE1); //Interruption pour fin de transmission
- sei();
-
- // préparation du premier break
- index_output_dmx=IOUTDMX_IDLE;
+ // init timer 4 (break)
+ TIMSK4 = 0;
+ TCCR4C = 0;
+ TCCR4B = 0;
+ TCCR4A = 0; // 00000000
+ TCNT4 = 0; // compteur
+ TC4H=0;
+
+ sei();
+ // préparation du premier break
+ index_output_dmx=IOUTDMX_IDLE;
}
-int blinkon = 350, blinkp=400;
+// ********************************** BOUCLE ********************************* //
+
+
void loop() {
- // lancement du break
+
+ // Lancement du Break : après fin de transmisson et ecoulement de "dmx_frame_interval" ms depuis le dernier break
+ if (index_output_dmx==IOUTDMX_IDLE && interbrk >= dmx_frame_interval ) {
+ index_output_dmx=IOUTDMX_BRK;
+ interbrk=0;
+ pinMode(TX1PIN, OUTPUT); // on met la broche en mode sortie
+ cbi(UCSR1B, TXEN1); //on stop la transmission
+ digitalWrite(TX1PIN, LOW); // on met la broche à 0
+ OCR4A = brk_timer_end ; // val 120 µs
+ TCNT4 = 0 ; // RAZ compteur timer
+ TIFR4 = 0 ; //Clear Flags timer
+ TIMSK4 = 64 ; //activation intéruption A &B
+ TCCR4B = 6; // 00000110 division par 32 de l'horloge base => 2µs
+ }
+ // octets d'état. Pour le moment, tous à 0
+ tab_input_dmx[513]= 0;
+ tab_input_dmx[514]= 0;
+ tab_input_dmx[515]= 0;
+ tab_input_dmx[516]= 0;
- if (index_output_dmx==IOUTDMX_IDLE ) {
- index_output_dmx=IOUTDMX_BRK;
- pinMode(tx1pin, OUTPUT); // on met la broche en mode sortie
- cbi(UCSR1B, TXEN1); //on stop la transmission
- digitalWrite(tx1pin, LOW); // on met la broche à 0
- OCR4A = brk_timer_end ; // val 120 µs
- TCNT4 = 0 ;// RAZ compteur timer
- TIFR4 = 0 ; //Clear Flags timer
- TIMSK4 = 64 ; //activation intéruption A &B
- TCCR4B = 6; // 00000110 division par 32 de l'horloge base => 2µs
- }
+ if(_usbLineInfo.lineState) { // Si port serie USB ouvert
+ blinkp=10, blinkon=6; // la led clignote plus vite
+ if(emissionPc!=0)
+ ecritUSB();
+ } else {
+ blinkon = 350, blinkp=400;
+ // dans le doute, on force l'etat d'entree
+ etat_input_pc=IINUSB_IDLE;
+ }
- // octets d'état. Pour le moment, tous à 0
- tab_input_dmx[513]= 0;
- tab_input_dmx[514]= 0;
- tab_input_dmx[515]=0;
- tab_input_dmx[516]=0;
-
- if(_usbLineInfo.lineState) { // Si port serie USB ouvert
- blinkp=10, blinkon=6; // led clignote plus vite
- if(emissionPc!=0) {
- ecritUSB();
- }
- } else {
- blinkon = 350, blinkp=400;
- etat_input_pc=0;
- }
-
- int m = millis()>>3;
- if (m-blkl) {
- blkcpt++; blkl = m;
- if(rxledcpt) rxledcpt--;
- else RXLED0;
- if(txledcpt) txledcpt--;
- else TXLED0;
- if(blkcpt>=blinkon) { digitalWrite(ledPin, HIGH); }
- if(blkcpt>=blinkp){ digitalWrite(ledPin, LOW); blkcpt=0; }
- }
+ int m = millis()>>3;
+ if (m-blkl) { // Toutes les 8ms
+ interbrk+=8;
+ blkcpt++; blkl = m;
+ if(rxledcpt) rxledcpt--;
+ else RXLED0;
+ if(txledcpt) txledcpt--;
+ else TXLED0;
+ if(blkcpt>=blinkon) { digitalWrite(LEDPIN, HIGH); }
+ if(blkcpt>=blinkp){ digitalWrite(LEDPIN, LOW); blkcpt=0; }
+ }
}