This commit is contained in:
parent
a21161ed8b
commit
c6e8d45679
5 changed files with 149 additions and 96 deletions
|
|
@ -42,7 +42,7 @@ namespace DMX2
|
||||||
Fin
|
Fin
|
||||||
}
|
}
|
||||||
|
|
||||||
const int timeout = 50;
|
const int timeout = 500;
|
||||||
|
|
||||||
// tampons Entrée/Sortie
|
// tampons Entrée/Sortie
|
||||||
public byte[] inputbuffer = new byte[516];
|
public byte[] inputbuffer = new byte[516];
|
||||||
|
|
@ -64,7 +64,7 @@ namespace DMX2
|
||||||
byte flags = 0;
|
byte flags = 0;
|
||||||
byte dmxinterval= 40;
|
byte dmxinterval= 40;
|
||||||
int usbrefresh = 40;
|
int usbrefresh = 40;
|
||||||
|
bool sync=false;
|
||||||
|
|
||||||
bool reinit=false ;
|
bool reinit=false ;
|
||||||
|
|
||||||
|
|
@ -102,15 +102,16 @@ namespace DMX2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool Sync {
|
public bool Sync {
|
||||||
get {
|
get {
|
||||||
return (flags & 2)>0;
|
return sync;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
flags = (byte)((flags & 0xFD) | (value?2:0));
|
sync = value;
|
||||||
paramFlag = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int NbCircuits {
|
public int NbCircuits {
|
||||||
get {
|
get {
|
||||||
return nbc1;
|
return nbc1;
|
||||||
|
|
@ -231,6 +232,30 @@ namespace DMX2
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DmxSync ()
|
||||||
|
{
|
||||||
|
if (!serial.IsOpen) {
|
||||||
|
etat = etatAutomate.Erreur;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] tmpBuffer = new byte[2];
|
||||||
|
|
||||||
|
tmpBuffer [0] = 27; // Esc
|
||||||
|
tmpBuffer [1] = 69; // 'E'
|
||||||
|
|
||||||
|
serial.Write (tmpBuffer, 0, tmpBuffer.Length);
|
||||||
|
|
||||||
|
if(!WaitForData (1)) {
|
||||||
|
etat = etatAutomate.Erreur;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
serial.Read(tmpBuffer,0,1);
|
||||||
|
if(tmpBuffer[0] != 69)
|
||||||
|
etat = etatAutomate.Erreur;
|
||||||
|
}
|
||||||
|
|
||||||
volatile etatAutomate etat = etatAutomate.Deconnecte;
|
volatile etatAutomate etat = etatAutomate.Deconnecte;
|
||||||
DateTime finAttente = DateTime.Now;
|
DateTime finAttente = DateTime.Now;
|
||||||
int compteErreur = 0;
|
int compteErreur = 0;
|
||||||
|
|
@ -249,6 +274,7 @@ namespace DMX2
|
||||||
finAttente = DateTime.Now.AddMilliseconds (usbrefresh);
|
finAttente = DateTime.Now.AddMilliseconds (usbrefresh);
|
||||||
//Console.WriteLine(DateTime.Now-t);
|
//Console.WriteLine(DateTime.Now-t);
|
||||||
//t = DateTime.Now;
|
//t = DateTime.Now;
|
||||||
|
if(sync)DmxSync();
|
||||||
EnvoiTrame ();
|
EnvoiTrame ();
|
||||||
Reception ();
|
Reception ();
|
||||||
Attente (finAttente);
|
Attente (finAttente);
|
||||||
|
|
@ -355,8 +381,8 @@ namespace DMX2
|
||||||
}
|
}
|
||||||
|
|
||||||
serial.Read(inputbuffer,0,inputbuffer.Length);
|
serial.Read(inputbuffer,0,inputbuffer.Length);
|
||||||
if (flag_input != inputbuffer[0]) {
|
if (flag_input != inputbuffer[513]) {
|
||||||
flag_input = inputbuffer[0];
|
flag_input = inputbuffer[513];
|
||||||
Console.WriteLine(flag_input );
|
Console.WriteLine(flag_input );
|
||||||
}
|
}
|
||||||
if(serial.BytesToRead>0)
|
if(serial.BytesToRead>0)
|
||||||
|
|
@ -582,7 +608,7 @@ namespace DMX2
|
||||||
el.SetAttribute("mab",mab.ToString());
|
el.SetAttribute("mab",mab.ToString());
|
||||||
el.SetAttribute("brk",brk.ToString());
|
el.SetAttribute("brk",brk.ToString());
|
||||||
el.SetAttribute("merge1",((flags&1)>0).ToString());
|
el.SetAttribute("merge1",((flags&1)>0).ToString());
|
||||||
el.SetAttribute("sync",((flags&2)>0).ToString());
|
el.SetAttribute("sync",sync.ToString());
|
||||||
el.SetAttribute("dmxinterval",dmxinterval.ToString());
|
el.SetAttribute("dmxinterval",dmxinterval.ToString());
|
||||||
el.SetAttribute("usbrefresh",usbrefresh.ToString());
|
el.SetAttribute("usbrefresh",usbrefresh.ToString());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ namespace DMX2
|
||||||
chkMerge1.Active = drv.Merge;
|
chkMerge1.Active = drv.Merge;
|
||||||
chkSync.Active = drv.Sync;
|
chkSync.Active = drv.Sync;
|
||||||
|
|
||||||
|
//caseDMXInt.IsEditable = drv.Sync;
|
||||||
|
|
||||||
cbUnivers1.Model = lsCbUnivers1;
|
cbUnivers1.Model = lsCbUnivers1;
|
||||||
var cellCbUnivers1 = new CellRendererText ();
|
var cellCbUnivers1 = new CellRendererText ();
|
||||||
cbUnivers1.PackStart (cellCbUnivers1, false);
|
cbUnivers1.PackStart (cellCbUnivers1, false);
|
||||||
|
|
@ -88,7 +90,6 @@ namespace DMX2
|
||||||
drv.patch1 = lsCbUnivers1.GetValue (iter, 0) as UniversDMX;
|
drv.patch1 = lsCbUnivers1.GetValue (iter, 0) as UniversDMX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int a, b, c,d, f;
|
int a, b, c,d, f;
|
||||||
if (!int.TryParse (caseBrk.Text, out a))
|
if (!int.TryParse (caseBrk.Text, out a))
|
||||||
return;
|
return;
|
||||||
|
|
@ -106,8 +107,8 @@ namespace DMX2
|
||||||
if (a < 92) a = 92;
|
if (a < 92) a = 92;
|
||||||
if (b < 12) b = 12;
|
if (b < 12) b = 12;
|
||||||
if (c < 8 || c > 512 ) c = 512;
|
if (c < 8 || c > 512 ) c = 512;
|
||||||
if (d < 22 ) d = 22;
|
if (d < 5 ) d = 22;
|
||||||
if (f < 22 || f > 255 ) f = 22;
|
if (f < 5 || f > 255 ) f = 22;
|
||||||
|
|
||||||
drv.Break = a;
|
drv.Break = a;
|
||||||
drv.Mab = b;
|
drv.Mab = b;
|
||||||
|
|
@ -123,6 +124,18 @@ namespace DMX2
|
||||||
{
|
{
|
||||||
drv.ReInit();
|
drv.ReInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void OnChkSyncToggled (object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//SyncCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnCaseUSBRefChanged (object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//SyncCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ namespace DMX2
|
||||||
private global::Gtk.CheckButton chkMerge1;
|
private global::Gtk.CheckButton chkMerge1;
|
||||||
private global::Gtk.CheckButton chkSync;
|
private global::Gtk.CheckButton chkSync;
|
||||||
private global::Gtk.Label label10;
|
private global::Gtk.Label label10;
|
||||||
private global::Gtk.Label label11;
|
|
||||||
private global::Gtk.Label label3;
|
private global::Gtk.Label label3;
|
||||||
private global::Gtk.Label label4;
|
private global::Gtk.Label label4;
|
||||||
private global::Gtk.Label label5;
|
private global::Gtk.Label label5;
|
||||||
private global::Gtk.Label label8;
|
private global::Gtk.Label label8;
|
||||||
private global::Gtk.Label label9;
|
private global::Gtk.Label label9;
|
||||||
private global::Gtk.Label labelsync;
|
private global::Gtk.Label labelsync;
|
||||||
|
private global::Gtk.Label lblDMX;
|
||||||
private global::Gtk.HBox hbox1;
|
private global::Gtk.HBox hbox1;
|
||||||
private global::Gtk.Button btnValider;
|
private global::Gtk.Button btnValider;
|
||||||
private global::Gtk.Button btnInit;
|
private global::Gtk.Button btnInit;
|
||||||
|
|
@ -164,77 +164,77 @@ namespace DMX2
|
||||||
w10.XOptions = ((global::Gtk.AttachOptions)(4));
|
w10.XOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
w10.YOptions = ((global::Gtk.AttachOptions)(4));
|
w10.YOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
// Container child table1.Gtk.Table+TableChild
|
// 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 = new global::Gtk.Label ();
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.LabelProp = "Univer associé";
|
this.label3.LabelProp = "Univer associé";
|
||||||
this.table1.Add (this.label3);
|
this.table1.Add (this.label3);
|
||||||
global::Gtk.Table.TableChild w12 = ((global::Gtk.Table.TableChild)(this.table1 [this.label3]));
|
global::Gtk.Table.TableChild w11 = ((global::Gtk.Table.TableChild)(this.table1 [this.label3]));
|
||||||
w12.XOptions = ((global::Gtk.AttachOptions)(4));
|
w11.XOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
w12.YOptions = ((global::Gtk.AttachOptions)(4));
|
w11.YOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
// Container child table1.Gtk.Table+TableChild
|
// Container child table1.Gtk.Table+TableChild
|
||||||
this.label4 = new global::Gtk.Label ();
|
this.label4 = new global::Gtk.Label ();
|
||||||
this.label4.Name = "label4";
|
this.label4.Name = "label4";
|
||||||
this.label4.LabelProp = "Break (µs)";
|
this.label4.LabelProp = "Break (µs)";
|
||||||
this.table1.Add (this.label4);
|
this.table1.Add (this.label4);
|
||||||
global::Gtk.Table.TableChild w13 = ((global::Gtk.Table.TableChild)(this.table1 [this.label4]));
|
global::Gtk.Table.TableChild w12 = ((global::Gtk.Table.TableChild)(this.table1 [this.label4]));
|
||||||
w13.TopAttach = ((uint)(1));
|
w12.TopAttach = ((uint)(1));
|
||||||
w13.BottomAttach = ((uint)(2));
|
w12.BottomAttach = ((uint)(2));
|
||||||
w13.XOptions = ((global::Gtk.AttachOptions)(4));
|
w12.XOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
w13.YOptions = ((global::Gtk.AttachOptions)(4));
|
w12.YOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
// Container child table1.Gtk.Table+TableChild
|
// Container child table1.Gtk.Table+TableChild
|
||||||
this.label5 = new global::Gtk.Label ();
|
this.label5 = new global::Gtk.Label ();
|
||||||
this.label5.Name = "label5";
|
this.label5.Name = "label5";
|
||||||
this.label5.LabelProp = "MAB (µs)";
|
this.label5.LabelProp = "MAB (µs)";
|
||||||
this.table1.Add (this.label5);
|
this.table1.Add (this.label5);
|
||||||
global::Gtk.Table.TableChild w14 = ((global::Gtk.Table.TableChild)(this.table1 [this.label5]));
|
global::Gtk.Table.TableChild w13 = ((global::Gtk.Table.TableChild)(this.table1 [this.label5]));
|
||||||
w14.TopAttach = ((uint)(1));
|
w13.TopAttach = ((uint)(1));
|
||||||
w14.BottomAttach = ((uint)(2));
|
w13.BottomAttach = ((uint)(2));
|
||||||
w14.LeftAttach = ((uint)(2));
|
w13.LeftAttach = ((uint)(2));
|
||||||
w14.RightAttach = ((uint)(3));
|
w13.RightAttach = ((uint)(3));
|
||||||
w14.XOptions = ((global::Gtk.AttachOptions)(4));
|
w13.XOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
w14.YOptions = ((global::Gtk.AttachOptions)(4));
|
w13.YOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
// Container child table1.Gtk.Table+TableChild
|
// Container child table1.Gtk.Table+TableChild
|
||||||
this.label8 = new global::Gtk.Label ();
|
this.label8 = new global::Gtk.Label ();
|
||||||
this.label8.Name = "label8";
|
this.label8.Name = "label8";
|
||||||
this.label8.LabelProp = "Merge";
|
this.label8.LabelProp = "Merge";
|
||||||
this.table1.Add (this.label8);
|
this.table1.Add (this.label8);
|
||||||
global::Gtk.Table.TableChild w15 = ((global::Gtk.Table.TableChild)(this.table1 [this.label8]));
|
global::Gtk.Table.TableChild w14 = ((global::Gtk.Table.TableChild)(this.table1 [this.label8]));
|
||||||
w15.TopAttach = ((uint)(2));
|
w14.TopAttach = ((uint)(2));
|
||||||
w15.BottomAttach = ((uint)(3));
|
w14.BottomAttach = ((uint)(3));
|
||||||
w15.LeftAttach = ((uint)(2));
|
w14.LeftAttach = ((uint)(2));
|
||||||
w15.RightAttach = ((uint)(3));
|
w14.RightAttach = ((uint)(3));
|
||||||
w15.XOptions = ((global::Gtk.AttachOptions)(4));
|
w14.XOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
w15.YOptions = ((global::Gtk.AttachOptions)(4));
|
w14.YOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
// Container child table1.Gtk.Table+TableChild
|
// Container child table1.Gtk.Table+TableChild
|
||||||
this.label9 = new global::Gtk.Label ();
|
this.label9 = new global::Gtk.Label ();
|
||||||
this.label9.Name = "label9";
|
this.label9.Name = "label9";
|
||||||
this.label9.LabelProp = "Circuits";
|
this.label9.LabelProp = "Circuits";
|
||||||
this.table1.Add (this.label9);
|
this.table1.Add (this.label9);
|
||||||
global::Gtk.Table.TableChild w16 = ((global::Gtk.Table.TableChild)(this.table1 [this.label9]));
|
global::Gtk.Table.TableChild w15 = ((global::Gtk.Table.TableChild)(this.table1 [this.label9]));
|
||||||
w16.LeftAttach = ((uint)(2));
|
w15.LeftAttach = ((uint)(2));
|
||||||
w16.RightAttach = ((uint)(3));
|
w15.RightAttach = ((uint)(3));
|
||||||
w16.XOptions = ((global::Gtk.AttachOptions)(4));
|
w15.XOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
w16.YOptions = ((global::Gtk.AttachOptions)(4));
|
w15.YOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
// Container child table1.Gtk.Table+TableChild
|
// Container child table1.Gtk.Table+TableChild
|
||||||
this.labelsync = new global::Gtk.Label ();
|
this.labelsync = new global::Gtk.Label ();
|
||||||
this.labelsync.Name = "labelsync";
|
this.labelsync.Name = "labelsync";
|
||||||
this.labelsync.LabelProp = "Syncro\nDMX<->USB";
|
this.labelsync.LabelProp = "Syncro\nDMX<->USB";
|
||||||
this.table1.Add (this.labelsync);
|
this.table1.Add (this.labelsync);
|
||||||
global::Gtk.Table.TableChild w17 = ((global::Gtk.Table.TableChild)(this.table1 [this.labelsync]));
|
global::Gtk.Table.TableChild w16 = ((global::Gtk.Table.TableChild)(this.table1 [this.labelsync]));
|
||||||
w17.TopAttach = ((uint)(2));
|
w16.TopAttach = ((uint)(2));
|
||||||
w17.BottomAttach = ((uint)(3));
|
w16.BottomAttach = ((uint)(3));
|
||||||
|
w16.XOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
|
w16.YOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
|
// Container child table1.Gtk.Table+TableChild
|
||||||
|
this.lblDMX = new global::Gtk.Label ();
|
||||||
|
this.lblDMX.Name = "lblDMX";
|
||||||
|
this.lblDMX.LabelProp = "Intervale entre\ntrames DMX (ms)";
|
||||||
|
this.table1.Add (this.lblDMX);
|
||||||
|
global::Gtk.Table.TableChild w17 = ((global::Gtk.Table.TableChild)(this.table1 [this.lblDMX]));
|
||||||
|
w17.TopAttach = ((uint)(3));
|
||||||
|
w17.BottomAttach = ((uint)(4));
|
||||||
|
w17.LeftAttach = ((uint)(2));
|
||||||
|
w17.RightAttach = ((uint)(3));
|
||||||
w17.XOptions = ((global::Gtk.AttachOptions)(4));
|
w17.XOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
w17.YOptions = ((global::Gtk.AttachOptions)(4));
|
w17.YOptions = ((global::Gtk.AttachOptions)(4));
|
||||||
this.vbox2.Add (this.table1);
|
this.vbox2.Add (this.table1);
|
||||||
|
|
@ -279,6 +279,8 @@ namespace DMX2
|
||||||
this.Child.ShowAll ();
|
this.Child.ShowAll ();
|
||||||
}
|
}
|
||||||
this.Hide ();
|
this.Hide ();
|
||||||
|
this.chkSync.Toggled += new global::System.EventHandler (this.OnChkSyncToggled);
|
||||||
|
this.caseUSBRef.Changed += new global::System.EventHandler (this.OnCaseUSBRefChanged);
|
||||||
this.btnValider.Clicked += new global::System.EventHandler (this.OnButtonValider);
|
this.btnValider.Clicked += new global::System.EventHandler (this.OnButtonValider);
|
||||||
this.btnInit.Clicked += new global::System.EventHandler (this.OnBtnInitClicked);
|
this.btnInit.Clicked += new global::System.EventHandler (this.OnBtnInitClicked);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2763,6 +2763,7 @@ Licence : GPL V2</property>
|
||||||
<property name="CanFocus">True</property>
|
<property name="CanFocus">True</property>
|
||||||
<property name="IsEditable">True</property>
|
<property name="IsEditable">True</property>
|
||||||
<property name="InvisibleChar">•</property>
|
<property name="InvisibleChar">•</property>
|
||||||
|
<signal name="Changed" handler="OnCaseUSBRefChanged" />
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="TopAttach">3</property>
|
<property name="TopAttach">3</property>
|
||||||
|
|
@ -2832,6 +2833,7 @@ Licence : GPL V2</property>
|
||||||
<property name="DrawIndicator">True</property>
|
<property name="DrawIndicator">True</property>
|
||||||
<property name="HasLabel">True</property>
|
<property name="HasLabel">True</property>
|
||||||
<property name="UseUnderline">True</property>
|
<property name="UseUnderline">True</property>
|
||||||
|
<signal name="Toggled" handler="OnChkSyncToggled" />
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="TopAttach">2</property>
|
<property name="TopAttach">2</property>
|
||||||
|
|
@ -2868,28 +2870,6 @@ Licence : GPL V2</property>
|
||||||
<property name="YShrink">False</property>
|
<property name="YShrink">False</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<widget class="Gtk.Label" id="label11">
|
|
||||||
<property name="MemberName" />
|
|
||||||
<property name="LabelProp" translatable="yes">Intervale entre
|
|
||||||
trames DMX (ms)</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="TopAttach">3</property>
|
|
||||||
<property name="BottomAttach">4</property>
|
|
||||||
<property name="LeftAttach">2</property>
|
|
||||||
<property name="RightAttach">3</property>
|
|
||||||
<property name="AutoSize">True</property>
|
|
||||||
<property name="XOptions">Fill</property>
|
|
||||||
<property name="YOptions">Fill</property>
|
|
||||||
<property name="XExpand">False</property>
|
|
||||||
<property name="XFill">True</property>
|
|
||||||
<property name="XShrink">False</property>
|
|
||||||
<property name="YExpand">False</property>
|
|
||||||
<property name="YFill">True</property>
|
|
||||||
<property name="YShrink">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="Gtk.Label" id="label3">
|
<widget class="Gtk.Label" id="label3">
|
||||||
<property name="MemberName" />
|
<property name="MemberName" />
|
||||||
|
|
@ -3007,6 +2987,28 @@ DMX<->USB</property>
|
||||||
<property name="YShrink">False</property>
|
<property name="YShrink">False</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="Gtk.Label" id="lblDMX">
|
||||||
|
<property name="MemberName" />
|
||||||
|
<property name="LabelProp" translatable="yes">Intervale entre
|
||||||
|
trames DMX (ms)</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="TopAttach">3</property>
|
||||||
|
<property name="BottomAttach">4</property>
|
||||||
|
<property name="LeftAttach">2</property>
|
||||||
|
<property name="RightAttach">3</property>
|
||||||
|
<property name="AutoSize">True</property>
|
||||||
|
<property name="XOptions">Fill</property>
|
||||||
|
<property name="YOptions">Fill</property>
|
||||||
|
<property name="XExpand">False</property>
|
||||||
|
<property name="XFill">True</property>
|
||||||
|
<property name="XShrink">False</property>
|
||||||
|
<property name="YExpand">False</property>
|
||||||
|
<property name="YFill">True</property>
|
||||||
|
<property name="YShrink">False</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="Position">1</property>
|
<property name="Position">1</property>
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ int main(void)
|
||||||
|
|
||||||
#define TX1PIN 1 // pin DMX serial 1
|
#define TX1PIN 1 // pin DMX serial 1
|
||||||
#define LEDPIN 13 // led interne
|
#define LEDPIN 13 // led interne
|
||||||
#define RX_TX_LED_TIME 3
|
#define RX_TX_LED_TIME 12
|
||||||
|
|
||||||
|
|
||||||
// tableaux de données
|
// tableaux de données
|
||||||
|
|
@ -50,7 +50,7 @@ volatile int index_output_pc=0; // sortie USB
|
||||||
volatile int index_input_dmx=513; // entrée dmx
|
volatile int index_input_dmx=513; // entrée dmx
|
||||||
volatile int index_output_dmx=0; // sortie dmx
|
volatile int index_output_dmx=0; // sortie dmx
|
||||||
volatile int etat_input_pc=IINUSB_IDLE; // etat entrée USB
|
volatile int etat_input_pc=IINUSB_IDLE; // etat entrée USB
|
||||||
volatile bool emissionPc=0; // flag : emission USB en attente
|
volatile int emissionPc=0; // flag : emission USB en attente
|
||||||
unsigned int blkl = 0, blkcpt=0, rxledcpt=0 ,txledcpt=0; // Gestion des leds
|
unsigned int blkl = 0, blkcpt=0, rxledcpt=0 ,txledcpt=0; // Gestion des leds
|
||||||
unsigned int blinkon, blinkp, interbrk=0; // idem
|
unsigned int blinkon, blinkp, interbrk=0; // idem
|
||||||
|
|
||||||
|
|
@ -60,8 +60,7 @@ byte mab_timer_end=25; // Duree MAB (par 2µs) def : 50us
|
||||||
int nb_circuits=512; // Nombre de circuits DMX emis
|
int nb_circuits=512; // Nombre de circuits DMX emis
|
||||||
int dmx_frame_interval=40; // Intervale entre trames DMX emises
|
int dmx_frame_interval=40; // Intervale entre trames DMX emises
|
||||||
bool flag_merge1=1;
|
bool flag_merge1=1;
|
||||||
bool flag_sync=0;
|
bool syncflag=false;
|
||||||
|
|
||||||
|
|
||||||
// ********************************** USB ***************************** //
|
// ********************************** USB ***************************** //
|
||||||
// lancé par interruption USB sur reception d'un char <- Cette fonction nécessite une modif de la lib arduino
|
// lancé par interruption USB sur reception d'un char <- Cette fonction nécessite une modif de la lib arduino
|
||||||
|
|
@ -88,7 +87,7 @@ void CDC_accept()
|
||||||
index_input_pc=1;
|
index_input_pc=1;
|
||||||
tab_input_dmx[517]=68;
|
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)
|
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
|
emissionPc=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Esc 'C' réinit
|
// Esc 'C' réinit
|
||||||
|
|
@ -122,6 +121,16 @@ void CDC_accept()
|
||||||
emissionPc=1;
|
emissionPc=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Esc 'E' SYNC
|
||||||
|
if (c==69) {
|
||||||
|
etat_input_pc=IINUSB_IDLE;
|
||||||
|
tab_input_dmx[517]=69;
|
||||||
|
index_output_pc=517; // on init l'index d'emmission vers le pc ( uniquement etat : 65 'A' )
|
||||||
|
emissionPc=1;
|
||||||
|
syncflag=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// si aucune commande n'est trouvée (toujours à 1) on repart à 0
|
// si aucune commande n'est trouvée (toujours à 1) on repart à 0
|
||||||
etat_input_pc=IINUSB_IDLE;
|
etat_input_pc=IINUSB_IDLE;
|
||||||
|
|
@ -133,7 +142,6 @@ void CDC_accept()
|
||||||
// si on arrive à 512
|
// si on arrive à 512
|
||||||
if (index_input_pc > 512) {
|
if (index_input_pc > 512) {
|
||||||
etat_input_pc=0;
|
etat_input_pc=0;
|
||||||
if(flag_sync && (index_output_dmx==IOUTDMX_IDLE)) interbrk=1000;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -145,7 +153,6 @@ void CDC_accept()
|
||||||
brk_timer_end = (inbuffer[1]/2);
|
brk_timer_end = (inbuffer[1]/2);
|
||||||
mab_timer_end = (inbuffer[2]/2);
|
mab_timer_end = (inbuffer[2]/2);
|
||||||
flag_merge1 = inbuffer[3] & 1;
|
flag_merge1 = inbuffer[3] & 1;
|
||||||
flag_sync = inbuffer[3] & 2;
|
|
||||||
dmx_frame_interval = inbuffer[4];
|
dmx_frame_interval = inbuffer[4];
|
||||||
|
|
||||||
etat_input_pc=0;
|
etat_input_pc=0;
|
||||||
|
|
@ -241,6 +248,7 @@ ISR(USART1_UDRE_vect)
|
||||||
if (index_output_dmx>nb_circuits) {
|
if (index_output_dmx>nb_circuits) {
|
||||||
index_output_dmx=IOUTDMX_FIN;
|
index_output_dmx=IOUTDMX_FIN;
|
||||||
cbi(UCSR1B, UDRIE1);
|
cbi(UCSR1B, UDRIE1);
|
||||||
|
syncflag=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,13 +317,14 @@ void setup() {
|
||||||
|
|
||||||
// ********************************** BOUCLE ********************************* //
|
// ********************************** BOUCLE ********************************* //
|
||||||
|
|
||||||
|
int tmptime;
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
// Lancement du Break : après fin de transmisson et ecoulement de "dmx_frame_interval" ms depuis le dernier 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 ) {
|
if (index_output_dmx==IOUTDMX_IDLE && interbrk >= dmx_frame_interval ) {
|
||||||
index_output_dmx=IOUTDMX_BRK;
|
index_output_dmx=IOUTDMX_BRK;
|
||||||
interbrk=0;
|
tab_input_dmx[514]= (byte)tmptime ;
|
||||||
|
tmptime= interbrk=0;
|
||||||
pinMode(TX1PIN, OUTPUT); // on met la broche en mode sortie
|
pinMode(TX1PIN, OUTPUT); // on met la broche en mode sortie
|
||||||
cbi(UCSR1B, TXEN1); //on stop la transmission
|
cbi(UCSR1B, TXEN1); //on stop la transmission
|
||||||
digitalWrite(TX1PIN, LOW); // on met la broche à 0
|
digitalWrite(TX1PIN, LOW); // on met la broche à 0
|
||||||
|
|
@ -327,24 +336,26 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// octets d'état. Pour le moment, tous à 0
|
// octets d'état. Pour le moment, tous à 0
|
||||||
tab_input_dmx[513]= 0;
|
//tab_input_dmx[513]= 0;
|
||||||
tab_input_dmx[514]= 0;
|
//tab_input_dmx[514]= 0;
|
||||||
tab_input_dmx[515]= 0;
|
//tab_input_dmx[515]= 0;
|
||||||
tab_input_dmx[516]= 0;
|
//tab_input_dmx[516]= 0;
|
||||||
|
|
||||||
if(_usbLineInfo.lineState) { // Si port serie USB ouvert
|
if(_usbLineInfo.lineState) { // Si port serie USB ouvert
|
||||||
blinkp=10, blinkon=6; // la led clignote plus vite
|
blinkp=100, blinkon=70; // la led clignote plus vite
|
||||||
if(emissionPc!=0)
|
if(!syncflag && emissionPc!=0)
|
||||||
|
{
|
||||||
ecritUSB();
|
ecritUSB();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
blinkon = 350, blinkp=400;
|
blinkon = 3500, blinkp=4000;
|
||||||
// dans le doute, on force l'etat d'entree
|
// dans le doute, on force l'etat d'entree
|
||||||
etat_input_pc=IINUSB_IDLE;
|
etat_input_pc=IINUSB_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int m = millis()>>3;
|
int m = millis();
|
||||||
if (m-blkl) { // Toutes les 8ms
|
if (m-blkl) { // Toutes les ms
|
||||||
interbrk+=8;
|
interbrk+=(m-blkl) ; tmptime+=(m-blkl);
|
||||||
blkcpt++; blkl = m;
|
blkcpt++; blkl = m;
|
||||||
if(rxledcpt) rxledcpt--;
|
if(rxledcpt) rxledcpt--;
|
||||||
else RXLED0;
|
else RXLED0;
|
||||||
|
|
@ -356,4 +367,3 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue