ajustes can
This commit is contained in:
parent
9e68f310c3
commit
8374f8618e
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -733,7 +733,7 @@ namespace AgroBase.Forms.IHM
|
|||
bool Inicializado = Modulo.MovMotor.Inicializado;
|
||||
idx = PreencheDadosLinha(grid, Testes, idx, Inicializado ? 1 : 0);
|
||||
|
||||
var SensorTmp = Modulo_Sen.Sensores.FirstOrDefault(x => x.Componente == S_Code.sTMP && x.ID.Contains(Modulo.Modulo_ID));
|
||||
var SensorTmp = Modulo_Sen.Sensores.FirstOrDefault(x => x.Componente == S_Code.sNTC && x.ID.Contains(Modulo.Modulo_ID));
|
||||
|
||||
bool TempIniciado = SensorTmp != null && SensorTmp.Inicializado;
|
||||
idx = PreencheDadosLinha(grid, Testes, idx, TempIniciado ? 1 : 0);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ namespace AgroBase.Forms
|
|||
|
||||
foreach (var Modulo in DispMvd.Dados.Modulos)
|
||||
{
|
||||
var sTMP = Variaveis.OperacaoEmAndamento.DispSen?.Dados?.DadosLeitura?.SensoresTemperatura?.FirstOrDefault(x => x.ID.Contains(Modulo.Modulo_ID));
|
||||
var sTMP = Variaveis.OperacaoEmAndamento.DispSen?.Dados?.DadosLeitura?.SensoresTemperaturaNTC?.FirstOrDefault(x => x.ID.Contains(Modulo.Modulo_ID));
|
||||
|
||||
Label lblTitulo = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lblM_" + Modulo.Modulo_ID);
|
||||
lblTitulo.ForeColor = Modulo.MovMotor.Comandar ? Modulo.MovMotor.Inicializado ? Color.Green : Color.Red : Color.Black;
|
||||
|
|
|
|||
|
|
@ -76,46 +76,48 @@
|
|||
this.cmb2 = new System.Windows.Forms.ComboBox();
|
||||
this.cmb1 = new System.Windows.Forms.ComboBox();
|
||||
this.cbTipo = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_B7 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_B6 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_B5 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_B4 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_B3 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_B2 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_B1 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_B0 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_A7 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_A6 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_A5 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_A4 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_A3 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_A2 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_A1 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP1_A0 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_B7 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_B6 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_B5 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_B4 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_B3 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_B2 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_B1 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_B0 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_A7 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_A6 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_A5 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_A4 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_A3 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_A2 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_A1 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbMCP_A0 = new System.Windows.Forms.ComboBox();
|
||||
this.lblB1 = new System.Windows.Forms.Label();
|
||||
this.lblA1 = new System.Windows.Forms.Label();
|
||||
this.txtMCP1 = new System.Windows.Forms.TextBox();
|
||||
this.lblMCP1 = new System.Windows.Forms.Label();
|
||||
this.gpbMCP1 = new System.Windows.Forms.GroupBox();
|
||||
this.chbMCP1 = new System.Windows.Forms.CheckBox();
|
||||
this.gpbMCP = new System.Windows.Forms.GroupBox();
|
||||
this.chbMCP = new System.Windows.Forms.CheckBox();
|
||||
this.picMCP = new System.Windows.Forms.PictureBox();
|
||||
this.gpbADS1 = new System.Windows.Forms.GroupBox();
|
||||
this.gpbADS = new System.Windows.Forms.GroupBox();
|
||||
this.cmbADSendereco = new System.Windows.Forms.ComboBox();
|
||||
this.lblADS_A3 = new System.Windows.Forms.Label();
|
||||
this.lblADS_A2 = new System.Windows.Forms.Label();
|
||||
this.lblADS_A1 = new System.Windows.Forms.Label();
|
||||
this.lblADS_A0 = new System.Windows.Forms.Label();
|
||||
this.cmbADS1_A0 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbADS1_A1 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbADS1_A2 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbADS1_A3 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbADS_A0 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbADS_A1 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbADS_A2 = new System.Windows.Forms.ComboBox();
|
||||
this.cmbADS_A3 = new System.Windows.Forms.ComboBox();
|
||||
this.lblADS1 = new System.Windows.Forms.Label();
|
||||
this.txtADS1 = new System.Windows.Forms.TextBox();
|
||||
this.picADS = new System.Windows.Forms.PictureBox();
|
||||
this.chbADS1 = new System.Windows.Forms.CheckBox();
|
||||
this.chbADS = new System.Windows.Forms.CheckBox();
|
||||
this.imgESP32 = new System.Windows.Forms.PictureBox();
|
||||
this.gpbMCP1.SuspendLayout();
|
||||
this.cmbMCPendereco = new System.Windows.Forms.ComboBox();
|
||||
this.btnADSfixar = new System.Windows.Forms.Button();
|
||||
this.btnMCPfixar = new System.Windows.Forms.Button();
|
||||
this.gpbMCP.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picMCP)).BeginInit();
|
||||
this.gpbADS1.SuspendLayout();
|
||||
this.gpbADS.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picADS)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.imgESP32)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
|
|
@ -646,181 +648,181 @@
|
|||
this.cbTipo.TabIndex = 228;
|
||||
this.cbTipo.SelectedIndexChanged += new System.EventHandler(this.cbTipo_SelectedIndexChanged);
|
||||
//
|
||||
// cmbMCP1_B7
|
||||
// cmbMCP_B7
|
||||
//
|
||||
this.cmbMCP1_B7.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_B7.Enabled = false;
|
||||
this.cmbMCP1_B7.FormattingEnabled = true;
|
||||
this.cmbMCP1_B7.Location = new System.Drawing.Point(224, 271);
|
||||
this.cmbMCP1_B7.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_B7.Name = "cmbMCP1_B7";
|
||||
this.cmbMCP1_B7.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_B7.TabIndex = 237;
|
||||
this.cmbMCP_B7.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_B7.Enabled = false;
|
||||
this.cmbMCP_B7.FormattingEnabled = true;
|
||||
this.cmbMCP_B7.Location = new System.Drawing.Point(224, 271);
|
||||
this.cmbMCP_B7.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_B7.Name = "cmbMCP_B7";
|
||||
this.cmbMCP_B7.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_B7.TabIndex = 237;
|
||||
//
|
||||
// cmbMCP1_B6
|
||||
// cmbMCP_B6
|
||||
//
|
||||
this.cmbMCP1_B6.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_B6.Enabled = false;
|
||||
this.cmbMCP1_B6.FormattingEnabled = true;
|
||||
this.cmbMCP1_B6.Location = new System.Drawing.Point(224, 247);
|
||||
this.cmbMCP1_B6.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_B6.Name = "cmbMCP1_B6";
|
||||
this.cmbMCP1_B6.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_B6.TabIndex = 236;
|
||||
this.cmbMCP_B6.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_B6.Enabled = false;
|
||||
this.cmbMCP_B6.FormattingEnabled = true;
|
||||
this.cmbMCP_B6.Location = new System.Drawing.Point(224, 247);
|
||||
this.cmbMCP_B6.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_B6.Name = "cmbMCP_B6";
|
||||
this.cmbMCP_B6.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_B6.TabIndex = 236;
|
||||
//
|
||||
// cmbMCP1_B5
|
||||
// cmbMCP_B5
|
||||
//
|
||||
this.cmbMCP1_B5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_B5.Enabled = false;
|
||||
this.cmbMCP1_B5.FormattingEnabled = true;
|
||||
this.cmbMCP1_B5.Location = new System.Drawing.Point(224, 223);
|
||||
this.cmbMCP1_B5.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_B5.Name = "cmbMCP1_B5";
|
||||
this.cmbMCP1_B5.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_B5.TabIndex = 235;
|
||||
this.cmbMCP_B5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_B5.Enabled = false;
|
||||
this.cmbMCP_B5.FormattingEnabled = true;
|
||||
this.cmbMCP_B5.Location = new System.Drawing.Point(224, 223);
|
||||
this.cmbMCP_B5.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_B5.Name = "cmbMCP_B5";
|
||||
this.cmbMCP_B5.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_B5.TabIndex = 235;
|
||||
//
|
||||
// cmbMCP1_B4
|
||||
// cmbMCP_B4
|
||||
//
|
||||
this.cmbMCP1_B4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_B4.Enabled = false;
|
||||
this.cmbMCP1_B4.FormattingEnabled = true;
|
||||
this.cmbMCP1_B4.Location = new System.Drawing.Point(224, 198);
|
||||
this.cmbMCP1_B4.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_B4.Name = "cmbMCP1_B4";
|
||||
this.cmbMCP1_B4.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_B4.TabIndex = 234;
|
||||
this.cmbMCP_B4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_B4.Enabled = false;
|
||||
this.cmbMCP_B4.FormattingEnabled = true;
|
||||
this.cmbMCP_B4.Location = new System.Drawing.Point(224, 198);
|
||||
this.cmbMCP_B4.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_B4.Name = "cmbMCP_B4";
|
||||
this.cmbMCP_B4.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_B4.TabIndex = 234;
|
||||
//
|
||||
// cmbMCP1_B3
|
||||
// cmbMCP_B3
|
||||
//
|
||||
this.cmbMCP1_B3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_B3.Enabled = false;
|
||||
this.cmbMCP1_B3.FormattingEnabled = true;
|
||||
this.cmbMCP1_B3.Location = new System.Drawing.Point(224, 173);
|
||||
this.cmbMCP1_B3.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_B3.Name = "cmbMCP1_B3";
|
||||
this.cmbMCP1_B3.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_B3.TabIndex = 233;
|
||||
this.cmbMCP_B3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_B3.Enabled = false;
|
||||
this.cmbMCP_B3.FormattingEnabled = true;
|
||||
this.cmbMCP_B3.Location = new System.Drawing.Point(224, 173);
|
||||
this.cmbMCP_B3.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_B3.Name = "cmbMCP_B3";
|
||||
this.cmbMCP_B3.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_B3.TabIndex = 233;
|
||||
//
|
||||
// cmbMCP1_B2
|
||||
// cmbMCP_B2
|
||||
//
|
||||
this.cmbMCP1_B2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_B2.Enabled = false;
|
||||
this.cmbMCP1_B2.FormattingEnabled = true;
|
||||
this.cmbMCP1_B2.Location = new System.Drawing.Point(224, 150);
|
||||
this.cmbMCP1_B2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_B2.Name = "cmbMCP1_B2";
|
||||
this.cmbMCP1_B2.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_B2.TabIndex = 232;
|
||||
this.cmbMCP_B2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_B2.Enabled = false;
|
||||
this.cmbMCP_B2.FormattingEnabled = true;
|
||||
this.cmbMCP_B2.Location = new System.Drawing.Point(224, 150);
|
||||
this.cmbMCP_B2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_B2.Name = "cmbMCP_B2";
|
||||
this.cmbMCP_B2.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_B2.TabIndex = 232;
|
||||
//
|
||||
// cmbMCP1_B1
|
||||
// cmbMCP_B1
|
||||
//
|
||||
this.cmbMCP1_B1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_B1.Enabled = false;
|
||||
this.cmbMCP1_B1.FormattingEnabled = true;
|
||||
this.cmbMCP1_B1.Location = new System.Drawing.Point(224, 125);
|
||||
this.cmbMCP1_B1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_B1.Name = "cmbMCP1_B1";
|
||||
this.cmbMCP1_B1.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_B1.TabIndex = 231;
|
||||
this.cmbMCP_B1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_B1.Enabled = false;
|
||||
this.cmbMCP_B1.FormattingEnabled = true;
|
||||
this.cmbMCP_B1.Location = new System.Drawing.Point(224, 125);
|
||||
this.cmbMCP_B1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_B1.Name = "cmbMCP_B1";
|
||||
this.cmbMCP_B1.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_B1.TabIndex = 231;
|
||||
//
|
||||
// cmbMCP1_B0
|
||||
// cmbMCP_B0
|
||||
//
|
||||
this.cmbMCP1_B0.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_B0.Enabled = false;
|
||||
this.cmbMCP1_B0.FormattingEnabled = true;
|
||||
this.cmbMCP1_B0.Location = new System.Drawing.Point(224, 101);
|
||||
this.cmbMCP1_B0.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_B0.Name = "cmbMCP1_B0";
|
||||
this.cmbMCP1_B0.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_B0.TabIndex = 230;
|
||||
this.cmbMCP_B0.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_B0.Enabled = false;
|
||||
this.cmbMCP_B0.FormattingEnabled = true;
|
||||
this.cmbMCP_B0.Location = new System.Drawing.Point(224, 101);
|
||||
this.cmbMCP_B0.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_B0.Name = "cmbMCP_B0";
|
||||
this.cmbMCP_B0.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_B0.TabIndex = 230;
|
||||
//
|
||||
// cmbMCP1_A7
|
||||
// cmbMCP_A7
|
||||
//
|
||||
this.cmbMCP1_A7.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_A7.Enabled = false;
|
||||
this.cmbMCP1_A7.FormattingEnabled = true;
|
||||
this.cmbMCP1_A7.Location = new System.Drawing.Point(351, 271);
|
||||
this.cmbMCP1_A7.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_A7.Name = "cmbMCP1_A7";
|
||||
this.cmbMCP1_A7.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_A7.TabIndex = 245;
|
||||
this.cmbMCP_A7.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_A7.Enabled = false;
|
||||
this.cmbMCP_A7.FormattingEnabled = true;
|
||||
this.cmbMCP_A7.Location = new System.Drawing.Point(351, 271);
|
||||
this.cmbMCP_A7.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_A7.Name = "cmbMCP_A7";
|
||||
this.cmbMCP_A7.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_A7.TabIndex = 245;
|
||||
//
|
||||
// cmbMCP1_A6
|
||||
// cmbMCP_A6
|
||||
//
|
||||
this.cmbMCP1_A6.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_A6.Enabled = false;
|
||||
this.cmbMCP1_A6.FormattingEnabled = true;
|
||||
this.cmbMCP1_A6.Location = new System.Drawing.Point(351, 247);
|
||||
this.cmbMCP1_A6.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_A6.Name = "cmbMCP1_A6";
|
||||
this.cmbMCP1_A6.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_A6.TabIndex = 244;
|
||||
this.cmbMCP_A6.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_A6.Enabled = false;
|
||||
this.cmbMCP_A6.FormattingEnabled = true;
|
||||
this.cmbMCP_A6.Location = new System.Drawing.Point(351, 247);
|
||||
this.cmbMCP_A6.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_A6.Name = "cmbMCP_A6";
|
||||
this.cmbMCP_A6.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_A6.TabIndex = 244;
|
||||
//
|
||||
// cmbMCP1_A5
|
||||
// cmbMCP_A5
|
||||
//
|
||||
this.cmbMCP1_A5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_A5.Enabled = false;
|
||||
this.cmbMCP1_A5.FormattingEnabled = true;
|
||||
this.cmbMCP1_A5.Location = new System.Drawing.Point(351, 223);
|
||||
this.cmbMCP1_A5.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_A5.Name = "cmbMCP1_A5";
|
||||
this.cmbMCP1_A5.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_A5.TabIndex = 243;
|
||||
this.cmbMCP_A5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_A5.Enabled = false;
|
||||
this.cmbMCP_A5.FormattingEnabled = true;
|
||||
this.cmbMCP_A5.Location = new System.Drawing.Point(351, 223);
|
||||
this.cmbMCP_A5.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_A5.Name = "cmbMCP_A5";
|
||||
this.cmbMCP_A5.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_A5.TabIndex = 243;
|
||||
//
|
||||
// cmbMCP1_A4
|
||||
// cmbMCP_A4
|
||||
//
|
||||
this.cmbMCP1_A4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_A4.Enabled = false;
|
||||
this.cmbMCP1_A4.FormattingEnabled = true;
|
||||
this.cmbMCP1_A4.Location = new System.Drawing.Point(351, 198);
|
||||
this.cmbMCP1_A4.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_A4.Name = "cmbMCP1_A4";
|
||||
this.cmbMCP1_A4.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_A4.TabIndex = 242;
|
||||
this.cmbMCP_A4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_A4.Enabled = false;
|
||||
this.cmbMCP_A4.FormattingEnabled = true;
|
||||
this.cmbMCP_A4.Location = new System.Drawing.Point(351, 198);
|
||||
this.cmbMCP_A4.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_A4.Name = "cmbMCP_A4";
|
||||
this.cmbMCP_A4.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_A4.TabIndex = 242;
|
||||
//
|
||||
// cmbMCP1_A3
|
||||
// cmbMCP_A3
|
||||
//
|
||||
this.cmbMCP1_A3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_A3.Enabled = false;
|
||||
this.cmbMCP1_A3.FormattingEnabled = true;
|
||||
this.cmbMCP1_A3.Location = new System.Drawing.Point(351, 173);
|
||||
this.cmbMCP1_A3.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_A3.Name = "cmbMCP1_A3";
|
||||
this.cmbMCP1_A3.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_A3.TabIndex = 241;
|
||||
this.cmbMCP_A3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_A3.Enabled = false;
|
||||
this.cmbMCP_A3.FormattingEnabled = true;
|
||||
this.cmbMCP_A3.Location = new System.Drawing.Point(351, 173);
|
||||
this.cmbMCP_A3.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_A3.Name = "cmbMCP_A3";
|
||||
this.cmbMCP_A3.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_A3.TabIndex = 241;
|
||||
//
|
||||
// cmbMCP1_A2
|
||||
// cmbMCP_A2
|
||||
//
|
||||
this.cmbMCP1_A2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_A2.Enabled = false;
|
||||
this.cmbMCP1_A2.FormattingEnabled = true;
|
||||
this.cmbMCP1_A2.Location = new System.Drawing.Point(351, 150);
|
||||
this.cmbMCP1_A2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_A2.Name = "cmbMCP1_A2";
|
||||
this.cmbMCP1_A2.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_A2.TabIndex = 240;
|
||||
this.cmbMCP_A2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_A2.Enabled = false;
|
||||
this.cmbMCP_A2.FormattingEnabled = true;
|
||||
this.cmbMCP_A2.Location = new System.Drawing.Point(351, 150);
|
||||
this.cmbMCP_A2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_A2.Name = "cmbMCP_A2";
|
||||
this.cmbMCP_A2.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_A2.TabIndex = 240;
|
||||
//
|
||||
// cmbMCP1_A1
|
||||
// cmbMCP_A1
|
||||
//
|
||||
this.cmbMCP1_A1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_A1.Enabled = false;
|
||||
this.cmbMCP1_A1.FormattingEnabled = true;
|
||||
this.cmbMCP1_A1.Location = new System.Drawing.Point(351, 125);
|
||||
this.cmbMCP1_A1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_A1.Name = "cmbMCP1_A1";
|
||||
this.cmbMCP1_A1.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_A1.TabIndex = 239;
|
||||
this.cmbMCP_A1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_A1.Enabled = false;
|
||||
this.cmbMCP_A1.FormattingEnabled = true;
|
||||
this.cmbMCP_A1.Location = new System.Drawing.Point(351, 125);
|
||||
this.cmbMCP_A1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_A1.Name = "cmbMCP_A1";
|
||||
this.cmbMCP_A1.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_A1.TabIndex = 239;
|
||||
//
|
||||
// cmbMCP1_A0
|
||||
// cmbMCP_A0
|
||||
//
|
||||
this.cmbMCP1_A0.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP1_A0.Enabled = false;
|
||||
this.cmbMCP1_A0.FormattingEnabled = true;
|
||||
this.cmbMCP1_A0.Location = new System.Drawing.Point(351, 101);
|
||||
this.cmbMCP1_A0.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP1_A0.Name = "cmbMCP1_A0";
|
||||
this.cmbMCP1_A0.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP1_A0.TabIndex = 238;
|
||||
this.cmbMCP_A0.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCP_A0.Enabled = false;
|
||||
this.cmbMCP_A0.FormattingEnabled = true;
|
||||
this.cmbMCP_A0.Location = new System.Drawing.Point(351, 101);
|
||||
this.cmbMCP_A0.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbMCP_A0.Name = "cmbMCP_A0";
|
||||
this.cmbMCP_A0.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCP_A0.TabIndex = 238;
|
||||
//
|
||||
// lblB1
|
||||
//
|
||||
|
|
@ -844,17 +846,6 @@
|
|||
this.lblA1.TabIndex = 247;
|
||||
this.lblA1.Text = "A";
|
||||
//
|
||||
// txtMCP1
|
||||
//
|
||||
this.txtMCP1.Enabled = false;
|
||||
this.txtMCP1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txtMCP1.Location = new System.Drawing.Point(351, 42);
|
||||
this.txtMCP1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.txtMCP1.Name = "txtMCP1";
|
||||
this.txtMCP1.Size = new System.Drawing.Size(112, 26);
|
||||
this.txtMCP1.TabIndex = 248;
|
||||
this.txtMCP1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// lblMCP1
|
||||
//
|
||||
this.lblMCP1.AutoSize = true;
|
||||
|
|
@ -866,50 +857,51 @@
|
|||
this.lblMCP1.TabIndex = 249;
|
||||
this.lblMCP1.Text = "Endereço I2C";
|
||||
//
|
||||
// gpbMCP1
|
||||
// gpbMCP
|
||||
//
|
||||
this.gpbMCP1.Controls.Add(this.chbMCP1);
|
||||
this.gpbMCP1.Controls.Add(this.picMCP);
|
||||
this.gpbMCP1.Controls.Add(this.lblMCP1);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_B0);
|
||||
this.gpbMCP1.Controls.Add(this.txtMCP1);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_B1);
|
||||
this.gpbMCP1.Controls.Add(this.lblA1);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_B2);
|
||||
this.gpbMCP1.Controls.Add(this.lblB1);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_B3);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_A7);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_B4);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_A6);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_B5);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_A5);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_B6);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_A4);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_B7);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_A3);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_A0);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_A2);
|
||||
this.gpbMCP1.Controls.Add(this.cmbMCP1_A1);
|
||||
this.gpbMCP1.Location = new System.Drawing.Point(569, 10);
|
||||
this.gpbMCP1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbMCP1.Name = "gpbMCP1";
|
||||
this.gpbMCP1.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbMCP1.Size = new System.Drawing.Size(474, 313);
|
||||
this.gpbMCP1.TabIndex = 250;
|
||||
this.gpbMCP1.TabStop = false;
|
||||
this.gpbMCP1.Text = "Expansor de GPIO";
|
||||
this.gpbMCP.Controls.Add(this.btnMCPfixar);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCPendereco);
|
||||
this.gpbMCP.Controls.Add(this.chbMCP);
|
||||
this.gpbMCP.Controls.Add(this.picMCP);
|
||||
this.gpbMCP.Controls.Add(this.lblMCP1);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_B0);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_B1);
|
||||
this.gpbMCP.Controls.Add(this.lblA1);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_B2);
|
||||
this.gpbMCP.Controls.Add(this.lblB1);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_B3);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_A7);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_B4);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_A6);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_B5);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_A5);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_B6);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_A4);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_B7);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_A3);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_A0);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_A2);
|
||||
this.gpbMCP.Controls.Add(this.cmbMCP_A1);
|
||||
this.gpbMCP.Location = new System.Drawing.Point(569, 10);
|
||||
this.gpbMCP.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbMCP.Name = "gpbMCP";
|
||||
this.gpbMCP.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbMCP.Size = new System.Drawing.Size(474, 313);
|
||||
this.gpbMCP.TabIndex = 250;
|
||||
this.gpbMCP.TabStop = false;
|
||||
this.gpbMCP.Text = "Expansor de GPIO";
|
||||
//
|
||||
// chbMCP1
|
||||
// chbMCP
|
||||
//
|
||||
this.chbMCP1.AutoSize = true;
|
||||
this.chbMCP1.Location = new System.Drawing.Point(11, 19);
|
||||
this.chbMCP1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.chbMCP1.Name = "chbMCP1";
|
||||
this.chbMCP1.Size = new System.Drawing.Size(133, 17);
|
||||
this.chbMCP1.TabIndex = 250;
|
||||
this.chbMCP1.Text = "MCP23017 conectado";
|
||||
this.chbMCP1.UseVisualStyleBackColor = true;
|
||||
this.chbMCP1.CheckedChanged += new System.EventHandler(this.chbExpansor_CheckedChanged);
|
||||
this.chbMCP.AutoSize = true;
|
||||
this.chbMCP.Location = new System.Drawing.Point(11, 19);
|
||||
this.chbMCP.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.chbMCP.Name = "chbMCP";
|
||||
this.chbMCP.Size = new System.Drawing.Size(133, 17);
|
||||
this.chbMCP.TabIndex = 250;
|
||||
this.chbMCP.Text = "MCP23017 conectado";
|
||||
this.chbMCP.UseVisualStyleBackColor = true;
|
||||
this.chbMCP.CheckedChanged += new System.EventHandler(this.chbExpansor_CheckedChanged);
|
||||
//
|
||||
// picMCP
|
||||
//
|
||||
|
|
@ -922,26 +914,37 @@
|
|||
this.picMCP.TabIndex = 229;
|
||||
this.picMCP.TabStop = false;
|
||||
//
|
||||
// gpbADS1
|
||||
// gpbADS
|
||||
//
|
||||
this.gpbADS1.Controls.Add(this.lblADS_A3);
|
||||
this.gpbADS1.Controls.Add(this.lblADS_A2);
|
||||
this.gpbADS1.Controls.Add(this.lblADS_A1);
|
||||
this.gpbADS1.Controls.Add(this.lblADS_A0);
|
||||
this.gpbADS1.Controls.Add(this.cmbADS1_A0);
|
||||
this.gpbADS1.Controls.Add(this.cmbADS1_A1);
|
||||
this.gpbADS1.Controls.Add(this.cmbADS1_A2);
|
||||
this.gpbADS1.Controls.Add(this.cmbADS1_A3);
|
||||
this.gpbADS1.Controls.Add(this.lblADS1);
|
||||
this.gpbADS1.Controls.Add(this.txtADS1);
|
||||
this.gpbADS1.Controls.Add(this.picADS);
|
||||
this.gpbADS1.Controls.Add(this.chbADS1);
|
||||
this.gpbADS1.Location = new System.Drawing.Point(569, 328);
|
||||
this.gpbADS1.Name = "gpbADS1";
|
||||
this.gpbADS1.Size = new System.Drawing.Size(474, 321);
|
||||
this.gpbADS1.TabIndex = 251;
|
||||
this.gpbADS1.TabStop = false;
|
||||
this.gpbADS1.Text = "Expansor ADC";
|
||||
this.gpbADS.Controls.Add(this.btnADSfixar);
|
||||
this.gpbADS.Controls.Add(this.cmbADSendereco);
|
||||
this.gpbADS.Controls.Add(this.lblADS_A3);
|
||||
this.gpbADS.Controls.Add(this.lblADS_A2);
|
||||
this.gpbADS.Controls.Add(this.lblADS_A1);
|
||||
this.gpbADS.Controls.Add(this.lblADS_A0);
|
||||
this.gpbADS.Controls.Add(this.cmbADS_A0);
|
||||
this.gpbADS.Controls.Add(this.cmbADS_A1);
|
||||
this.gpbADS.Controls.Add(this.cmbADS_A2);
|
||||
this.gpbADS.Controls.Add(this.cmbADS_A3);
|
||||
this.gpbADS.Controls.Add(this.lblADS1);
|
||||
this.gpbADS.Controls.Add(this.picADS);
|
||||
this.gpbADS.Controls.Add(this.chbADS);
|
||||
this.gpbADS.Location = new System.Drawing.Point(569, 328);
|
||||
this.gpbADS.Name = "gpbADS";
|
||||
this.gpbADS.Size = new System.Drawing.Size(474, 321);
|
||||
this.gpbADS.TabIndex = 251;
|
||||
this.gpbADS.TabStop = false;
|
||||
this.gpbADS.Text = "Expansor ADC";
|
||||
//
|
||||
// cmbADSendereco
|
||||
//
|
||||
this.cmbADSendereco.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbADSendereco.FormattingEnabled = true;
|
||||
this.cmbADSendereco.Location = new System.Drawing.Point(351, 43);
|
||||
this.cmbADSendereco.Name = "cmbADSendereco";
|
||||
this.cmbADSendereco.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbADSendereco.TabIndex = 263;
|
||||
this.cmbADSendereco.SelectedIndexChanged += new System.EventHandler(this.cmbADSendereco_SelectedIndexChanged);
|
||||
//
|
||||
// lblADS_A3
|
||||
//
|
||||
|
|
@ -987,49 +990,49 @@
|
|||
this.lblADS_A0.TabIndex = 259;
|
||||
this.lblADS_A0.Text = "A0";
|
||||
//
|
||||
// cmbADS1_A0
|
||||
// cmbADS_A0
|
||||
//
|
||||
this.cmbADS1_A0.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbADS1_A0.Enabled = false;
|
||||
this.cmbADS1_A0.FormattingEnabled = true;
|
||||
this.cmbADS1_A0.Location = new System.Drawing.Point(351, 205);
|
||||
this.cmbADS1_A0.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbADS1_A0.Name = "cmbADS1_A0";
|
||||
this.cmbADS1_A0.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbADS1_A0.TabIndex = 255;
|
||||
this.cmbADS_A0.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbADS_A0.Enabled = false;
|
||||
this.cmbADS_A0.FormattingEnabled = true;
|
||||
this.cmbADS_A0.Location = new System.Drawing.Point(351, 205);
|
||||
this.cmbADS_A0.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbADS_A0.Name = "cmbADS_A0";
|
||||
this.cmbADS_A0.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbADS_A0.TabIndex = 255;
|
||||
//
|
||||
// cmbADS1_A1
|
||||
// cmbADS_A1
|
||||
//
|
||||
this.cmbADS1_A1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbADS1_A1.Enabled = false;
|
||||
this.cmbADS1_A1.FormattingEnabled = true;
|
||||
this.cmbADS1_A1.Location = new System.Drawing.Point(351, 230);
|
||||
this.cmbADS1_A1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbADS1_A1.Name = "cmbADS1_A1";
|
||||
this.cmbADS1_A1.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbADS1_A1.TabIndex = 256;
|
||||
this.cmbADS_A1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbADS_A1.Enabled = false;
|
||||
this.cmbADS_A1.FormattingEnabled = true;
|
||||
this.cmbADS_A1.Location = new System.Drawing.Point(351, 230);
|
||||
this.cmbADS_A1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbADS_A1.Name = "cmbADS_A1";
|
||||
this.cmbADS_A1.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbADS_A1.TabIndex = 256;
|
||||
//
|
||||
// cmbADS1_A2
|
||||
// cmbADS_A2
|
||||
//
|
||||
this.cmbADS1_A2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbADS1_A2.Enabled = false;
|
||||
this.cmbADS1_A2.FormattingEnabled = true;
|
||||
this.cmbADS1_A2.Location = new System.Drawing.Point(351, 255);
|
||||
this.cmbADS1_A2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbADS1_A2.Name = "cmbADS1_A2";
|
||||
this.cmbADS1_A2.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbADS1_A2.TabIndex = 257;
|
||||
this.cmbADS_A2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbADS_A2.Enabled = false;
|
||||
this.cmbADS_A2.FormattingEnabled = true;
|
||||
this.cmbADS_A2.Location = new System.Drawing.Point(351, 255);
|
||||
this.cmbADS_A2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbADS_A2.Name = "cmbADS_A2";
|
||||
this.cmbADS_A2.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbADS_A2.TabIndex = 257;
|
||||
//
|
||||
// cmbADS1_A3
|
||||
// cmbADS_A3
|
||||
//
|
||||
this.cmbADS1_A3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbADS1_A3.Enabled = false;
|
||||
this.cmbADS1_A3.FormattingEnabled = true;
|
||||
this.cmbADS1_A3.Location = new System.Drawing.Point(351, 280);
|
||||
this.cmbADS1_A3.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbADS1_A3.Name = "cmbADS1_A3";
|
||||
this.cmbADS1_A3.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbADS1_A3.TabIndex = 258;
|
||||
this.cmbADS_A3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbADS_A3.Enabled = false;
|
||||
this.cmbADS_A3.FormattingEnabled = true;
|
||||
this.cmbADS_A3.Location = new System.Drawing.Point(351, 280);
|
||||
this.cmbADS_A3.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbADS_A3.Name = "cmbADS_A3";
|
||||
this.cmbADS_A3.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbADS_A3.TabIndex = 258;
|
||||
//
|
||||
// lblADS1
|
||||
//
|
||||
|
|
@ -1042,17 +1045,6 @@
|
|||
this.lblADS1.TabIndex = 254;
|
||||
this.lblADS1.Text = "Endereço I2C";
|
||||
//
|
||||
// txtADS1
|
||||
//
|
||||
this.txtADS1.Enabled = false;
|
||||
this.txtADS1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txtADS1.Location = new System.Drawing.Point(351, 41);
|
||||
this.txtADS1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.txtADS1.Name = "txtADS1";
|
||||
this.txtADS1.Size = new System.Drawing.Size(112, 26);
|
||||
this.txtADS1.TabIndex = 253;
|
||||
this.txtADS1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// picADS
|
||||
//
|
||||
this.picADS.Image = global::AgroBase.Properties.Resources.ads;
|
||||
|
|
@ -1064,17 +1056,17 @@
|
|||
this.picADS.TabIndex = 252;
|
||||
this.picADS.TabStop = false;
|
||||
//
|
||||
// chbADS1
|
||||
// chbADS
|
||||
//
|
||||
this.chbADS1.AutoSize = true;
|
||||
this.chbADS1.Location = new System.Drawing.Point(11, 20);
|
||||
this.chbADS1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.chbADS1.Name = "chbADS1";
|
||||
this.chbADS1.Size = new System.Drawing.Size(126, 17);
|
||||
this.chbADS1.TabIndex = 251;
|
||||
this.chbADS1.Text = "ADS1115 conectado";
|
||||
this.chbADS1.UseVisualStyleBackColor = true;
|
||||
this.chbADS1.CheckedChanged += new System.EventHandler(this.chbExpansor_CheckedChanged);
|
||||
this.chbADS.AutoSize = true;
|
||||
this.chbADS.Location = new System.Drawing.Point(11, 20);
|
||||
this.chbADS.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.chbADS.Name = "chbADS";
|
||||
this.chbADS.Size = new System.Drawing.Size(126, 17);
|
||||
this.chbADS.TabIndex = 251;
|
||||
this.chbADS.Text = "ADS1115 conectado";
|
||||
this.chbADS.UseVisualStyleBackColor = true;
|
||||
this.chbADS.CheckedChanged += new System.EventHandler(this.chbExpansor_CheckedChanged);
|
||||
//
|
||||
// imgESP32
|
||||
//
|
||||
|
|
@ -1087,14 +1079,44 @@
|
|||
this.imgESP32.TabIndex = 181;
|
||||
this.imgESP32.TabStop = false;
|
||||
//
|
||||
// cmbMCPendereco
|
||||
//
|
||||
this.cmbMCPendereco.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbMCPendereco.FormattingEnabled = true;
|
||||
this.cmbMCPendereco.Location = new System.Drawing.Point(351, 44);
|
||||
this.cmbMCPendereco.Name = "cmbMCPendereco";
|
||||
this.cmbMCPendereco.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbMCPendereco.TabIndex = 264;
|
||||
this.cmbMCPendereco.SelectedIndexChanged += new System.EventHandler(this.cmbMCPendereco_SelectedIndexChanged);
|
||||
//
|
||||
// btnADSfixar
|
||||
//
|
||||
this.btnADSfixar.Location = new System.Drawing.Point(388, 14);
|
||||
this.btnADSfixar.Name = "btnADSfixar";
|
||||
this.btnADSfixar.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnADSfixar.TabIndex = 264;
|
||||
this.btnADSfixar.Text = "Fixar";
|
||||
this.btnADSfixar.UseVisualStyleBackColor = true;
|
||||
this.btnADSfixar.Click += new System.EventHandler(this.btnADSfixar_Click);
|
||||
//
|
||||
// btnMCPfixar
|
||||
//
|
||||
this.btnMCPfixar.Location = new System.Drawing.Point(388, 15);
|
||||
this.btnMCPfixar.Name = "btnMCPfixar";
|
||||
this.btnMCPfixar.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnMCPfixar.TabIndex = 265;
|
||||
this.btnMCPfixar.Text = "Fixar";
|
||||
this.btnMCPfixar.UseVisualStyleBackColor = true;
|
||||
this.btnMCPfixar.Click += new System.EventHandler(this.btnMCPfixar_Click);
|
||||
//
|
||||
// frmPinout
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.ClientSize = new System.Drawing.Size(1056, 697);
|
||||
this.Controls.Add(this.gpbADS1);
|
||||
this.Controls.Add(this.gpbMCP1);
|
||||
this.Controls.Add(this.gpbADS);
|
||||
this.Controls.Add(this.gpbMCP);
|
||||
this.Controls.Add(this.cbTipo);
|
||||
this.Controls.Add(this.lblPinout);
|
||||
this.Controls.Add(this.cmb22);
|
||||
|
|
@ -1149,11 +1171,11 @@
|
|||
this.Text = "Pinout";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmPinout_FormClosing);
|
||||
this.Load += new System.EventHandler(this.frmPinout_Load);
|
||||
this.gpbMCP1.ResumeLayout(false);
|
||||
this.gpbMCP1.PerformLayout();
|
||||
this.gpbMCP.ResumeLayout(false);
|
||||
this.gpbMCP.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picMCP)).EndInit();
|
||||
this.gpbADS1.ResumeLayout(false);
|
||||
this.gpbADS1.PerformLayout();
|
||||
this.gpbADS.ResumeLayout(false);
|
||||
this.gpbADS.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picADS)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.imgESP32)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
|
@ -1212,40 +1234,42 @@
|
|||
private System.Windows.Forms.PictureBox imgESP32;
|
||||
private System.Windows.Forms.ComboBox cbTipo;
|
||||
private System.Windows.Forms.PictureBox picMCP;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_B7;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_B6;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_B5;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_B4;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_B3;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_B2;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_B1;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_B0;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_A7;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_A6;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_A5;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_A4;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_A3;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_A2;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_A1;
|
||||
private System.Windows.Forms.ComboBox cmbMCP1_A0;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_B7;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_B6;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_B5;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_B4;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_B3;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_B2;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_B1;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_B0;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_A7;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_A6;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_A5;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_A4;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_A3;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_A2;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_A1;
|
||||
private System.Windows.Forms.ComboBox cmbMCP_A0;
|
||||
private System.Windows.Forms.Label lblB1;
|
||||
private System.Windows.Forms.Label lblA1;
|
||||
private System.Windows.Forms.TextBox txtMCP1;
|
||||
private System.Windows.Forms.Label lblMCP1;
|
||||
private System.Windows.Forms.GroupBox gpbMCP1;
|
||||
private System.Windows.Forms.CheckBox chbMCP1;
|
||||
private System.Windows.Forms.GroupBox gpbADS1;
|
||||
private System.Windows.Forms.CheckBox chbADS1;
|
||||
private System.Windows.Forms.GroupBox gpbMCP;
|
||||
private System.Windows.Forms.CheckBox chbMCP;
|
||||
private System.Windows.Forms.GroupBox gpbADS;
|
||||
private System.Windows.Forms.CheckBox chbADS;
|
||||
private System.Windows.Forms.PictureBox picADS;
|
||||
private System.Windows.Forms.Label lblADS1;
|
||||
private System.Windows.Forms.TextBox txtADS1;
|
||||
private System.Windows.Forms.Label lblADS_A0;
|
||||
private System.Windows.Forms.ComboBox cmbADS1_A0;
|
||||
private System.Windows.Forms.ComboBox cmbADS1_A1;
|
||||
private System.Windows.Forms.ComboBox cmbADS1_A2;
|
||||
private System.Windows.Forms.ComboBox cmbADS1_A3;
|
||||
private System.Windows.Forms.ComboBox cmbADS_A0;
|
||||
private System.Windows.Forms.ComboBox cmbADS_A1;
|
||||
private System.Windows.Forms.ComboBox cmbADS_A2;
|
||||
private System.Windows.Forms.ComboBox cmbADS_A3;
|
||||
private System.Windows.Forms.Label lblADS_A3;
|
||||
private System.Windows.Forms.Label lblADS_A2;
|
||||
private System.Windows.Forms.Label lblADS_A1;
|
||||
private System.Windows.Forms.ComboBox cmbADSendereco;
|
||||
private System.Windows.Forms.ComboBox cmbMCPendereco;
|
||||
private System.Windows.Forms.Button btnMCPfixar;
|
||||
private System.Windows.Forms.Button btnADSfixar;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ using System.Linq;
|
|||
using System.Windows.Forms;
|
||||
using static AgroBase.Models.Enums;
|
||||
using AgroBase.Services;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace AgroBase.Forms
|
||||
{
|
||||
|
|
@ -156,11 +157,17 @@ namespace AgroBase.Forms
|
|||
}
|
||||
}
|
||||
|
||||
chbMCP1.Checked = Pinout.ExpansorGPIO;
|
||||
txtMCP1.Text = Pinout.EnderecoGPIO;
|
||||
cmbMCPendereco.Items.Clear();
|
||||
cmbMCPendereco.Items.AddRange(new string[] { "0x20 (GND)" });
|
||||
cmbMCPendereco.SelectedIndex = 0;
|
||||
chbMCP.Checked = Pinout.ExpansorGPIO;
|
||||
//txtMCP1.Text = Pinout.EnderecoGPIO;
|
||||
|
||||
chbADS1.Checked = Pinout.ExpansorADS;
|
||||
txtADS1.Text = Pinout.EnderecoADS;
|
||||
cmbADSendereco.Items.Clear();
|
||||
cmbADSendereco.Items.AddRange(new string[] { "0x48 (GND)", "0x49 (VCC)", "0x4A (SDA)", "0x4B (SCL)" });
|
||||
cmbADSendereco.SelectedIndex = 0;
|
||||
chbADS.Checked = Pinout.ExpansorADS;
|
||||
//txtADS1.Text = Pinout.EnderecoADS;
|
||||
|
||||
Funcoes.ForEach(x => Pinos.Add(TipoDisp.ToString() + " " + Enum.GetName(typeof(FuncoesPinout), x)));
|
||||
|
||||
|
|
@ -169,9 +176,18 @@ namespace AgroBase.Forms
|
|||
Dispositivo.Funcoes?.ForEach(x => Pinos.Add(Dispositivo.ID + " " + Enum.GetName(typeof(FuncoesPinout), x)));
|
||||
}
|
||||
|
||||
List<ComboBox> cmbs = this.Controls.OfType<ComboBox>().Where(x => x.Name.Contains("cmb")).ToList();
|
||||
cmbs.AddRange(gpbMCP1.Controls.OfType<ComboBox>().ToList());
|
||||
cmbs.AddRange(gpbADS1.Controls.OfType<ComboBox>().ToList());
|
||||
List<ComboBox> cmbsControlador = this.Controls.OfType<ComboBox>().Where(x => x.Name.Contains("cmb")).ToList();
|
||||
AtualizarPinoutBarramento(cmbsControlador);
|
||||
List<ComboBox> cmbsMcp = gpbMCP.Controls.OfType<ComboBox>().Where(x => !x.Name.Contains("endereco")).ToList();
|
||||
AtualizarPinoutBarramento(cmbsMcp);
|
||||
List<ComboBox> cmbsAds = gpbADS.Controls.OfType<ComboBox>().Where(x => !x.Name.Contains("endereco")).ToList();
|
||||
AtualizarPinoutBarramento(cmbsAds);
|
||||
|
||||
AtualizaTipoControlador(Pinout.Pinos.FirstOrDefault().Controlador, false);
|
||||
}
|
||||
|
||||
private void AtualizarPinoutBarramento(List<ComboBox> cmbs)
|
||||
{
|
||||
foreach (var cmb in cmbs)
|
||||
{
|
||||
cmb.SelectedIndexChanged -= Cmb_SelectedIndexChanged;
|
||||
|
|
@ -180,14 +196,14 @@ namespace AgroBase.Forms
|
|||
Pinos.ForEach(x => cmb.Items.Add(x));
|
||||
cmb.SelectedIndex = 0;
|
||||
|
||||
string pino = cmb.Name.Replace("cmb", "").Replace("MCP1_", "").Replace("ADS1_", "");
|
||||
string pino = cmb.Name.Replace("cmb", "");
|
||||
var Selecionado = Pinout.Pinos.FirstOrDefault(x => x.Descricao == pino);
|
||||
if (Selecionado != null)
|
||||
{
|
||||
cmb.Enabled =
|
||||
(Selecionado.Barramento == TiposBarramentos.CONTROLADOR && Selecionado.Habilitado) ||
|
||||
(Selecionado.Barramento == TiposBarramentos.EXPANSOR_GPIO && chbMCP1.Checked && cmb.Name.Contains("MCP")) ||
|
||||
(Selecionado.Barramento == TiposBarramentos.EXPANSOR_ADS && chbADS1.Checked && cmb.Name.Contains("ADS"));
|
||||
(Selecionado.Barramento == TiposBarramentos.EXPANSOR_GPIO && chbMCP.Checked && cmb.Name.Contains("MCP")) ||
|
||||
(Selecionado.Barramento == TiposBarramentos.EXPANSOR_ADS && chbADS.Checked && cmb.Name.Contains("ADS"));
|
||||
|
||||
if (Selecionado.Habilitado && cmb.Enabled)
|
||||
{
|
||||
|
|
@ -195,8 +211,6 @@ namespace AgroBase.Forms
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
AtualizaTipoControlador(Pinout.Pinos.FirstOrDefault().Controlador, false);
|
||||
}
|
||||
|
||||
private void frmPinout_FormClosing(object sender, FormClosingEventArgs e)
|
||||
|
|
@ -212,36 +226,26 @@ namespace AgroBase.Forms
|
|||
|
||||
private void btnSalvar_Click(object sender, EventArgs e)
|
||||
{
|
||||
Pinout.Pinos.ForEach(x =>
|
||||
List<ComboBox> cmbsControlador = this.Controls.OfType<ComboBox>().Where(x => x.Name.Contains("cmb") && x.Enabled && x.Visible).ToList();
|
||||
SalvarPinoutBarramento(cmbsControlador);
|
||||
/*for (int i = 0; i < cmbMCPendereco.Items.Count; i++)
|
||||
{
|
||||
x.ComponenteID = "";
|
||||
x.Funcao = FuncoesPinout.NaoConectado;
|
||||
});
|
||||
|
||||
List<ComboBox> cmbs = this.Controls.OfType<ComboBox>().Where(x => x.Name.Contains("cmb") && x.Enabled && x.Visible).ToList();
|
||||
cmbs.AddRange(gpbMCP1.Controls.OfType<ComboBox>().ToList());
|
||||
cmbs.AddRange(gpbADS1.Controls.OfType<ComboBox>().ToList());
|
||||
foreach (var cmb in cmbs)
|
||||
{
|
||||
string ComponenteID = cmb.SelectedItem.ToString().Split(' ').Length > 1 ? cmb.SelectedItem.ToString().Split(' ')[0] : "";
|
||||
FuncoesPinout Funcao = (FuncoesPinout)Enum.Parse(typeof(FuncoesPinout), ComponenteID != "" ? (cmb.SelectedItem.ToString().Split(' ')[1]) : cmb.SelectedItem.ToString());
|
||||
string pino = cmb.Name.Replace("cmb", "").Replace("MCP1_", "").Replace("ADS1_", "");
|
||||
if (Pinout.Pinos.Any(x => x.Descricao == pino))
|
||||
{
|
||||
Pinout.Pinos.FirstOrDefault(x => x.Descricao == pino).Funcao = Funcao;
|
||||
Pinout.Pinos.FirstOrDefault(x => x.Descricao == pino).ComponenteID = ComponenteID;
|
||||
Pinout.Pinos.FirstOrDefault(x => x.Descricao == pino).Barramento =
|
||||
cmb.Name.Contains("MCP") ? TiposBarramentos.EXPANSOR_GPIO :
|
||||
cmb.Name.Contains("ADS") ? TiposBarramentos.EXPANSOR_ADS :
|
||||
TiposBarramentos.CONTROLADOR;
|
||||
}
|
||||
atualizarPinosMCP(i);
|
||||
List<ComboBox> cmbsMcp = gpbMCP.Controls.OfType<ComboBox>().Where(x => !x.Name.Contains("endereco")).ToList();
|
||||
SalvarPinoutBarramento(cmbsMcp);
|
||||
}
|
||||
for (int i = 0; i < cmbADSendereco.Items.Count; i++)
|
||||
{
|
||||
atualizarPinosADS(i);
|
||||
List<ComboBox> cmbsAds = gpbADS.Controls.OfType<ComboBox>().Where(x => !x.Name.Contains("endereco")).ToList();
|
||||
SalvarPinoutBarramento(cmbsAds);
|
||||
}*/
|
||||
|
||||
Pinout.ExpansorGPIO = chbMCP1.Checked;
|
||||
Pinout.EnderecoGPIO = txtMCP1.Text;
|
||||
Pinout.ExpansorGPIO = chbMCP.Checked;
|
||||
//Pinout.EnderecoGPIO = txtMCP1.Text;
|
||||
|
||||
Pinout.ExpansorADS = chbADS1.Checked;
|
||||
Pinout.EnderecoADS = txtADS1.Text;
|
||||
Pinout.ExpansorADS = chbADS.Checked;
|
||||
//Pinout.EnderecoADS = txtADS1.Text;
|
||||
|
||||
VersaoArquivoModel arquivo = VersionamentoService.ArquivoPinout(TipoDisp);
|
||||
if (arquivo != null)
|
||||
|
|
@ -263,6 +267,37 @@ namespace AgroBase.Forms
|
|||
}
|
||||
}
|
||||
|
||||
private void SalvarPinoutBarramento(List<ComboBox> cmbs)
|
||||
{
|
||||
foreach (var cmb in cmbs)
|
||||
{
|
||||
string ComponenteID = cmb.SelectedItem.ToString().Split(' ').Length > 1 ? cmb.SelectedItem.ToString().Split(' ')[0] : "";
|
||||
FuncoesPinout Funcao = (FuncoesPinout)Enum.Parse(typeof(FuncoesPinout), ComponenteID != "" ? (cmb.SelectedItem.ToString().Split(' ')[1]) : cmb.SelectedItem.ToString());
|
||||
string pino = cmb.Name.Replace("cmb", "");
|
||||
var _pino = Pinout.Pinos.FirstOrDefault(x => x.Descricao == pino);
|
||||
if (_pino == null)
|
||||
{
|
||||
_pino = new PinoutModel()
|
||||
{
|
||||
Controlador = TiposControladores.TODOS,
|
||||
Descricao = pino,
|
||||
Habilitado = true,
|
||||
Pino = Convert.ToInt32(Regex.Match(pino, @"\d+").Value),
|
||||
Barramento = TiposBarramentos.CONTROLADOR,
|
||||
ComponenteID = "",
|
||||
Funcao = FuncoesPinout.NaoConectado
|
||||
};
|
||||
Pinout.Pinos.Add(_pino);
|
||||
}
|
||||
_pino.Funcao = Funcao;
|
||||
_pino.ComponenteID = ComponenteID;
|
||||
_pino.Barramento =
|
||||
cmb.Name.Contains("MCP") ? TiposBarramentos.EXPANSOR_GPIO :
|
||||
cmb.Name.Contains("ADS") ? TiposBarramentos.EXPANSOR_ADS :
|
||||
TiposBarramentos.CONTROLADOR;
|
||||
}
|
||||
}
|
||||
|
||||
private void cbTipo_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
TiposControladores Tipo = (TiposControladores)(((ComboBox)sender).SelectedIndex);
|
||||
|
|
@ -315,8 +350,8 @@ namespace AgroBase.Forms
|
|||
|
||||
cbTipo.SelectedIndex = (int)TipoControlador;
|
||||
|
||||
chbMCP1.Checked = Pinout.ExpansorGPIO;
|
||||
chbADS1.Checked = Pinout.ExpansorADS;
|
||||
chbMCP.Checked = Pinout.ExpansorGPIO;
|
||||
chbADS.Checked = Pinout.ExpansorADS;
|
||||
}
|
||||
|
||||
private void chbExpansor_CheckedChanged(object sender, EventArgs e)
|
||||
|
|
@ -360,8 +395,65 @@ namespace AgroBase.Forms
|
|||
{
|
||||
cmb.Enabled = chb.Checked;
|
||||
}
|
||||
TextBox txt = gpb.Controls.OfType<TextBox>().FirstOrDefault(x => x.Name == "txtADS" + ID);
|
||||
txt.Enabled = chb.Checked;
|
||||
ComboBox cmbAddr = gpb.Controls.OfType<ComboBox>().FirstOrDefault(x => x.Name.Contains("endereco"));
|
||||
cmbAddr.Enabled = chb.Checked;
|
||||
}
|
||||
|
||||
private void cmbADSendereco_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
atualizarPinosADS(cmbADSendereco.SelectedIndex);
|
||||
}
|
||||
|
||||
private void atualizarPinosADS(int addr)
|
||||
{
|
||||
cmbADS_A0.Name = $"cmbADS_A{addr}{0}";
|
||||
cmbADS_A1.Name = $"cmbADS_A{addr}{1}";
|
||||
cmbADS_A2.Name = $"cmbADS_A{addr}{2}";
|
||||
cmbADS_A3.Name = $"cmbADS_A{addr}{3}";
|
||||
|
||||
List<ComboBox> cmbsAds = gpbADS.Controls.OfType<ComboBox>().Where(x => !x.Name.Contains("endereco")).ToList();
|
||||
AtualizarPinoutBarramento(cmbsAds);
|
||||
}
|
||||
|
||||
private void cmbMCPendereco_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
atualizarPinosMCP(cmbMCPendereco.SelectedIndex);
|
||||
}
|
||||
|
||||
private void atualizarPinosMCP(int addr)
|
||||
{
|
||||
cmbMCP_A0.Name = $"cmbMCP_A{addr}{0}";
|
||||
cmbMCP_A1.Name = $"cmbMCP_A{addr}{1}";
|
||||
cmbMCP_A2.Name = $"cmbMCP_A{addr}{2}";
|
||||
cmbMCP_A3.Name = $"cmbMCP_A{addr}{3}";
|
||||
cmbMCP_A4.Name = $"cmbMCP_A{addr}{4}";
|
||||
cmbMCP_A5.Name = $"cmbMCP_A{addr}{5}";
|
||||
cmbMCP_A6.Name = $"cmbMCP_A{addr}{6}";
|
||||
cmbMCP_A7.Name = $"cmbMCP_A{addr}{7}";
|
||||
|
||||
cmbMCP_B0.Name = $"cmbMCP_B{addr}{0}";
|
||||
cmbMCP_B1.Name = $"cmbMCP_B{addr}{1}";
|
||||
cmbMCP_B2.Name = $"cmbMCP_B{addr}{2}";
|
||||
cmbMCP_B3.Name = $"cmbMCP_B{addr}{3}";
|
||||
cmbMCP_B4.Name = $"cmbMCP_B{addr}{4}";
|
||||
cmbMCP_B5.Name = $"cmbMCP_B{addr}{5}";
|
||||
cmbMCP_B6.Name = $"cmbMCP_B{addr}{6}";
|
||||
cmbMCP_B7.Name = $"cmbMCP_B{addr}{7}";
|
||||
|
||||
List<ComboBox> cmbsMcp = gpbMCP.Controls.OfType<ComboBox>().Where(x => !x.Name.Contains("endereco")).ToList();
|
||||
AtualizarPinoutBarramento(cmbsMcp);
|
||||
}
|
||||
|
||||
private void btnADSfixar_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<ComboBox> cmbsAds = gpbADS.Controls.OfType<ComboBox>().Where(x => !x.Name.Contains("endereco")).ToList();
|
||||
SalvarPinoutBarramento(cmbsAds);
|
||||
}
|
||||
|
||||
private void btnMCPfixar_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<ComboBox> cmbsMcp = gpbMCP.Controls.OfType<ComboBox>().Where(x => !x.Name.Contains("endereco")).ToList();
|
||||
SalvarPinoutBarramento(cmbsMcp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@
|
|||
sRPM = 1,
|
||||
sTST = 2,
|
||||
sCFG = 3,
|
||||
sTMP = 4,
|
||||
sNTC = 4,
|
||||
sENC = 5,
|
||||
sCOR = 6,
|
||||
sTEN = 7,
|
||||
|
|
@ -112,6 +112,12 @@
|
|||
sIMU = 25,
|
||||
sLRA = 26,
|
||||
sTOD = 27,
|
||||
sGAS = 28,
|
||||
sSHT = 29,
|
||||
sLUZ = 30,
|
||||
sIUV = 31,
|
||||
sQAR = 32,
|
||||
sCHV = 33,
|
||||
}
|
||||
|
||||
public enum BotoesJoystick
|
||||
|
|
@ -312,5 +318,12 @@
|
|||
INA228_100A = 3,
|
||||
}
|
||||
|
||||
public enum TipoSensorGas
|
||||
{
|
||||
MQ2 = 0,
|
||||
MQ7 = 1,
|
||||
MQ135 = 2,
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -449,14 +449,14 @@ namespace AgroBase.Models.Modules
|
|||
{
|
||||
var _Sensores = Variaveis.OperacaoEmAndamento.DispSen.Dados.DadosLeitura;
|
||||
|
||||
var sensorTmp = _Sensores.SensoresTemperatura.FirstOrDefault(x => x.ID.Contains(Modulo_ID));
|
||||
var sensorTmp = _Sensores.SensoresTemperaturaNTC.FirstOrDefault(x => x.ID.Contains(Modulo_ID));
|
||||
if (sensorTmp != null)
|
||||
{
|
||||
MovMotor.Temperatura = sensorTmp.Temperatura;
|
||||
|
||||
AlarmeModel _Alarme = new AlarmeModel()
|
||||
{
|
||||
Tipo = S_Code.sTMP,
|
||||
Tipo = S_Code.sNTC,
|
||||
Valor = sensorTmp.Temperatura,
|
||||
Maximo = sensorTmp.Temperatura > sensorTmp.LimiteMaximo,
|
||||
Minimo = sensorTmp.Temperatura < sensorTmp.LimiteMinimo,
|
||||
|
|
|
|||
|
|
@ -410,6 +410,9 @@ namespace AgroBase.Models.Modules
|
|||
M0,
|
||||
M1,
|
||||
Aux,
|
||||
Gas,
|
||||
LuzUV,
|
||||
Chuva,
|
||||
}
|
||||
|
||||
public static class PinoutUtils
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1950,7 +1950,7 @@ namespace AgroBase.Models
|
|||
Mod_ID = senLeitura.Mod_ID,
|
||||
Reles = new List<FirmwareRele>(senLeitura.Reles),
|
||||
SensoresCorrente = new List<FirmwareSensorCorrente>(senLeitura.SensoresCorrente),
|
||||
SensoresTemperatura = new List<FirmwareSensorTemperatura>(senLeitura.SensoresTemperatura),
|
||||
SensoresTemperaturaNTC = new List<FirmwareSensorTemperaturaNTC>(senLeitura.SensoresTemperaturaNTC),
|
||||
ServoFreios = new List<FirmwareServoFreio>(senLeitura.ServoFreios),
|
||||
Sinaleiros = new List<FirmwareSinaleiro>(senLeitura.Sinaleiros),
|
||||
SensoresIMU = new List<FirmwareSensorIMU>(senLeitura.SensoresIMU),
|
||||
|
|
|
|||
|
|
@ -377,7 +377,8 @@ namespace AgroBase.Services
|
|||
.Where(x =>
|
||||
(!x.ComResposta && x.Enviado) ||
|
||||
(x.ComResposta && x.Respondido) ||
|
||||
(x.ComResposta && x.Enviado && !x.Respondido && x.EnviadoEm < agora.AddSeconds(-1))
|
||||
(x.ComResposta && x.Enviado && !x.Respondido && x.EnviadoEm < agora.AddSeconds(-1)) ||
|
||||
(x.Momento < agora.AddSeconds(-30))
|
||||
)
|
||||
.ToList();
|
||||
foreach (var item in mensagens)
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
{"tmrRegistrador":{"_uiControl":null,"State":2,"IsRunning":false,"IsStopped":true,"IsCreated":false,"Interval":1000,"StackTrace":"AtuadorModel.IniciarRegistrador","Id":"tmrRegistrador_Atu","TimeTick":"00:00:00.0029930"},"_AtuHandler":{"Dispositivo":103},"Dispositivo":103,"Modulo_ID":"Atu","_EnderecoCAN_Tx":19,"_EnderecoCAN_Rx":20,"_TaxaAmostragem":1000,"RequisitarDados":true,"Conectado":false,"QuantidadeBicos":4,"DensidadeHerbicida":1.1,"BicosPulverizadores":[{"ID":"B01","ID_Num":71,"Posicao":1,"Componente":11,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B02","ID_Num":72,"Posicao":2,"Componente":11,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B03","ID_Num":73,"Posicao":3,"Componente":11,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B04","ID_Num":74,"Posicao":4,"Componente":11,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0}],"BombasPressurizadoras":[{"ID":"BOMBA","ID_Num":51,"ComandoAtuar":false,"Componente":14,"LeituraEstado":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[14,35,36,37,5],"LeituraPotencia":0.0,"LeituraPressaoSP":0.0,"LeituraPressao":0.0,"Leitura":null,"Inicializado":false}],"Sensores":[{"LogGrafico":[],"ID":"FLXLN","ID_Num":61,"Descricao":"Fluxo na linha principal","Componente":8,"Aferir":true,"Mandatorio":false,"Liberado":true,"Leitura":null,"Inicializado":false,"Funcoes":[25],"Parametros":[],"UnidadeMedida":"mL/s","LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"MASRS","ID_Num":62,"Descricao":"Massa do reservatório de herbicida","Componente":10,"Aferir":true,"Mandatorio":false,"Liberado":true,"Leitura":null,"Inicializado":false,"Funcoes":[22,23],"Parametros":[],"UnidadeMedida":"Kg","LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"PRSLN","ID_Num":63,"Descricao":"Pressão na linha principal","Componente":12,"Aferir":true,"Mandatorio":false,"Liberado":true,"Leitura":null,"Inicializado":false,"Funcoes":[24],"Parametros":[{"Descricao":"Vmin","Valor":"0","QtdBytes":1,"Escalar":false,"Enviar":false},{"Descricao":"Vmax","Valor":"4.5","QtdBytes":1,"Escalar":true,"Enviar":false},{"Descricao":"Pmax","Valor":"174","QtdBytes":1,"Escalar":false,"Enviar":false}],"UnidadeMedida":"psi","LimiteMaximo":0.0,"LimiteMinimo":0.0}],"BombaPressurizadora":{"ID":"BOMBA","ID_Num":51,"ComandoAtuar":false,"Componente":14,"LeituraEstado":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[14,35,36,37,5],"LeituraPotencia":0.0,"LeituraPressaoSP":0.0,"LeituraPressao":0.0,"Leitura":null,"Inicializado":false},"ScriptDeteccaoErvas":"weed_detector_oak-1_0.py","DadosLeitura":{"Momento":"0001-01-01T00:00:00","Conectado":false,"Dispositivo":0,"Versao":0,"Mod_ID":null,"QualidadeWifi":0,"LatenciaLoop":0,"BicosPulverizadores":[],"BombasPressurizadoras":[],"SensoresFluxo":[],"SensoresMassa":[],"SensoresPressao":[],"UltimoComandoRespondido":"0001-01-01T00:00:00"},"_MassaRef":0.8,"_MassaLeituraRef":40876.37,"_MassaLeituraExtra":1895800.0,"MassaReservatorio":0.0,"VolumeReservatorio":0.0,"PercentualReservatorio":0.0,"VolumeVazaoAferido":0.0,"_FluxoMlRef":600.0,"_FluxoPulsoRef":538.0,"VazaoFluxoMLpSInstantanea":0.0,"VazaoFluxoMLpSMedia":0.0,"VolumeVazaoML":0.0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0,"_PressaoVmin":0.0,"_PressaoVmax":4.5,"_PressaoMax":174.045,"PressaoLinha":0.0,"PressaoLinhaCalc":0.0,"PercentualErvasTerreno":0.0}
|
||||
{"tmrRegistrador":{"_uiControl":null,"State":2,"IsRunning":false,"IsStopped":true,"IsCreated":false,"Interval":1000,"StackTrace":"AtuadorModel.IniciarRegistrador","Id":"tmrRegistrador_Atu","TimeTick":"00:00:00"},"_AtuHandler":{"Dispositivo":103},"Dispositivo":103,"Modulo_ID":"Atu","_EnderecoCAN_Tx":19,"_EnderecoCAN_Rx":20,"_TaxaAmostragem":1000,"RequisitarDados":true,"Conectado":false,"QuantidadeBicos":4,"DensidadeHerbicida":1.1,"BicosPulverizadores":[{"ID":"B01","ID_Num":71,"Posicao":1,"Componente":11,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B02","ID_Num":72,"Posicao":2,"Componente":11,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B03","ID_Num":73,"Posicao":3,"Componente":11,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0},{"ID":"B04","ID_Num":74,"Posicao":4,"Componente":11,"AtuacaoNivelAlto":true,"ComandoAtuar":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[21],"LeituraStatusBico":false,"MediaNivelFluxo":0.0,"Leitura":null,"Inicializado":false,"Atuacoes":0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0}],"BombasPressurizadoras":[{"ID":"BOMBA","ID_Num":51,"ComandoAtuar":false,"Componente":14,"LeituraEstado":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[14,35,36,37,5],"LeituraPotencia":0.0,"LeituraPressaoSP":0.0,"LeituraPressao":0.0,"Leitura":null,"Inicializado":false}],"Sensores":[{"LogGrafico":[],"ID":"FLXLN","ID_Num":61,"Descricao":"Fluxo na linha principal","Componente":8,"Aferir":true,"Mandatorio":false,"Liberado":true,"Leitura":null,"Inicializado":false,"Funcoes":[25],"Parametros":[],"UnidadeMedida":"mL/s","LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"MASRS","ID_Num":62,"Descricao":"Massa do reservatório de herbicida","Componente":10,"Aferir":true,"Mandatorio":false,"Liberado":true,"Leitura":null,"Inicializado":false,"Funcoes":[22,23],"Parametros":[],"UnidadeMedida":"Kg","LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"PRSLN","ID_Num":63,"Descricao":"Pressão na linha principal","Componente":12,"Aferir":true,"Mandatorio":false,"Liberado":true,"Leitura":null,"Inicializado":false,"Funcoes":[24],"Parametros":[{"Descricao":"Vmin","Valor":"0","QtdBytes":1,"Escalar":false,"Enviar":false},{"Descricao":"Vmax","Valor":"4.5","QtdBytes":1,"Escalar":true,"Enviar":false},{"Descricao":"Pmax","Valor":"174","QtdBytes":1,"Escalar":false,"Enviar":false}],"UnidadeMedida":"psi","LimiteMaximo":0.0,"LimiteMinimo":0.0}],"BombaPressurizadora":{"ID":"BOMBA","ID_Num":51,"ComandoAtuar":false,"Componente":14,"LeituraEstado":false,"Comandar":true,"Mandatorio":false,"Liberado":true,"Testando":false,"Funcoes":[14,35,36,37,5],"LeituraPotencia":0.0,"LeituraPressaoSP":0.0,"LeituraPressao":0.0,"Leitura":null,"Inicializado":false},"ScriptDeteccaoErvas":"weed_detector_oak-1_0.py","DadosLeitura":{"Momento":"0001-01-01T00:00:00","Conectado":false,"Dispositivo":0,"Versao":0,"Mod_ID":null,"QualidadeWifi":0,"LatenciaLoop":0,"BicosPulverizadores":[],"BombasPressurizadoras":[],"SensoresFluxo":[],"SensoresMassa":[],"SensoresPressao":[],"UltimoComandoRespondido":"0001-01-01T00:00:00"},"_MassaRef":0.8,"_MassaLeituraRef":40876.37,"_MassaLeituraExtra":1895800.0,"MassaReservatorio":0.0,"VolumeReservatorio":0.0,"PercentualReservatorio":0.0,"VolumeVazaoAferido":0.0,"_FluxoMlRef":600.0,"_FluxoPulsoRef":538.0,"VazaoFluxoMLpSInstantanea":0.0,"VazaoFluxoMLpSMedia":0.0,"VolumeVazaoML":0.0,"InicioAtuacao":"0001-01-01T00:00:00","TempoAtuado":0.0,"_PressaoVmin":0.0,"_PressaoVmax":4.5,"_PressaoMax":174.045,"PressaoLinha":0.0,"PressaoLinhaCalc":0.0,"PercentualErvasTerreno":0.0}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -90,11 +90,25 @@ CanService* CanService::instance = nullptr;
|
|||
#include <driver/twai.h>
|
||||
|
||||
class CanService {
|
||||
|
||||
typedef void (*OnReceiveCallback)(int packetSize, int senderId, CanMessagePosicaoDados posicao, byte* data, int dataLength);
|
||||
|
||||
typedef struct {
|
||||
OnReceiveCallback callback;
|
||||
int packetSize;
|
||||
int senderId;
|
||||
CanMessagePosicaoDados posicao;
|
||||
byte data[7];
|
||||
int dataLength;
|
||||
long idMsg;
|
||||
} CallbackPayload;
|
||||
|
||||
static TaskHandle_t handleCallbackTask;
|
||||
|
||||
public:
|
||||
uint8_t ID_Num_sMOD = 0;
|
||||
uint8_t ID_Num_sTOD = 250;
|
||||
uint8_t ID_Num_sLRA = 251;
|
||||
typedef void (*OnReceiveCallback)(int packetSize, int senderId, CanMessagePosicaoDados posicao, byte* data, int dataLength);
|
||||
|
||||
CanService(uint8_t nodeId, uint32_t baudRate = 500000) {
|
||||
_nodeId = nodeId;
|
||||
|
|
@ -168,38 +182,40 @@ class CanService {
|
|||
|
||||
bool MensagemTx = message.identifier == static_cast<uint32_t>(_nodeId + 1);
|
||||
|
||||
PrintTela("[CAN ", false);
|
||||
PrintTela(MensagemTx ? "TX" : "RX", false);
|
||||
PrintTela("] ID: 0x", false);
|
||||
PrintTela(String(message.identifier, HEX), false);
|
||||
PrintTela(" Len: ", false);
|
||||
PrintTela(String(message.data_length_code), false);
|
||||
PrintTela(" Data: ", false);
|
||||
for (int i = 0; i < message.data_length_code; i++) {
|
||||
PrintTela(String(message.data[i], HEX), false);
|
||||
PrintTela(" ", false);
|
||||
if (DebugMode) {
|
||||
PrintTela("[CAN ", false);
|
||||
PrintTela(MensagemTx ? "TX" : "RX", false);
|
||||
PrintTela("] ID: 0x", false);
|
||||
PrintTela(String(message.identifier, HEX), false);
|
||||
PrintTela(" Len: ", false);
|
||||
PrintTela(String(message.data_length_code), false);
|
||||
PrintTela(" Data: ", false);
|
||||
for (int i = 0; i < message.data_length_code; i++) {
|
||||
PrintTela(String(message.data[i], HEX), false);
|
||||
PrintTela(" ", false);
|
||||
}
|
||||
PrintTela("");
|
||||
}
|
||||
PrintTela("");
|
||||
|
||||
if (MensagemTx) {
|
||||
PrintTela("[CAN] Ouviu a própria resposta!");
|
||||
PrintTela("[CAN RX] Ouviu a própria resposta!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mensagemJaNaFila(canQueueRx, message)) {
|
||||
|
||||
if (uxQueueSpacesAvailable(canQueueRx) < 5) {
|
||||
PrintTela("[CAN] Alerta: Fila RX quase cheia (" + String(uxQueueSpacesAvailable(canQueueRx)) + " mensagens restantes)");
|
||||
PrintTela("[CAN RX] Alerta: Fila RX quase cheia (" + String(uxQueueSpacesAvailable(canQueueRx)) + " mensagens restantes)");
|
||||
}
|
||||
|
||||
if (xQueueSend(canQueueRx, &message, 0) != pdTRUE) {
|
||||
PrintTela("[CAN] Fila RX cheia! Mensagem descartada.");
|
||||
PrintTela("[CAN RX] Fila RX cheia! Mensagem descartada.");
|
||||
}
|
||||
else {
|
||||
//PrintTela("[CAN] Mensagem adicionada na fila RX");
|
||||
//PrintTela("[CAN RX] Mensagem adicionada na fila RX");
|
||||
}
|
||||
} else {
|
||||
PrintTela("[CAN] Mensagem duplicada ignorada.");
|
||||
PrintTela("[CAN RX] Mensagem duplicada ignorada.");
|
||||
}
|
||||
}
|
||||
vTaskDelay(1);
|
||||
|
|
@ -219,12 +235,12 @@ class CanService {
|
|||
twai_message_t msg;
|
||||
while (true) {
|
||||
if (xQueueReceive(service->canQueueTx, &msg, portMAX_DELAY) == pdTRUE) {
|
||||
//PrintTela("[CAN] Mensagem recebida da fila TX");
|
||||
//PrintTela("[CAN TX] Mensagem recebida da fila TX");
|
||||
if (service->enviarDadosCan(msg)) {
|
||||
//PrintTela("[CAN] Mensagem enviada via CAN com sucesso");
|
||||
//PrintTela("[CAN TX] Mensagem enviada via CAN com sucesso");
|
||||
}
|
||||
else {
|
||||
PrintTela("[CAN] Erro ao enviar mensagem via CAN");
|
||||
PrintTela("[CAN TX] Erro ao enviar mensagem via CAN");
|
||||
}
|
||||
}
|
||||
vTaskDelay(1);
|
||||
|
|
@ -238,24 +254,90 @@ class CanService {
|
|||
}
|
||||
|
||||
void CanTaskProcess(void* pvParameters) {
|
||||
//PrintTela("[CAN] Task de Processamento iniciada");
|
||||
CanService *service = static_cast<CanService*>(pvParameters);
|
||||
twai_message_t msg;
|
||||
|
||||
while (true) {
|
||||
while (uxQueueMessagesWaiting(service->canQueueRx) > 0) {
|
||||
if (xQueueReceive(service->canQueueRx, &msg, portMAX_DELAY) == pdTRUE) {
|
||||
//PrintTela("[CAN] Mensagem recebida da fila RX");
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)msg.data[0];
|
||||
|
||||
if (service->_callback) {
|
||||
service->_callback(msg.data_length_code, msg.identifier, posicao, &msg.data[1], msg.data_length_code - 1);
|
||||
String frameEmProcessamento = "";
|
||||
for (int i = 0; i < msg.data_length_code; i++) {
|
||||
frameEmProcessamento += String(msg.data[i], HEX) + " ";
|
||||
}
|
||||
|
||||
idmsg++;
|
||||
|
||||
CallbackPayload* payload = new CallbackPayload();
|
||||
payload->idMsg = idmsg;
|
||||
payload->callback = service->_callback;
|
||||
payload->packetSize = msg.data_length_code;
|
||||
payload->senderId = msg.identifier;
|
||||
payload->posicao = posicao;
|
||||
memcpy(payload->data, &msg.data[1], msg.data_length_code - 1);
|
||||
payload->dataLength = msg.data_length_code - 1;
|
||||
|
||||
// Captura o handle da task atual (quem vai esperar a notificação)
|
||||
TaskHandle_t callingTaskHandle = xTaskGetCurrentTaskHandle();
|
||||
|
||||
// Cria um pacote com o payload + handle do notificador
|
||||
auto* bundle = new std::pair<CallbackPayload*, TaskHandle_t>(payload, callingTaskHandle);
|
||||
|
||||
PrintTela("[CAN Process] Processando frame: " + frameEmProcessamento);
|
||||
|
||||
String taskName = "TaskCallbackTimeout_" + String(idmsg);
|
||||
|
||||
TaskHandle_t handleTask = nullptr;
|
||||
|
||||
// Cria a task do callback
|
||||
BaseType_t status = xTaskCreatePinnedToCore(
|
||||
TaskCallbackWrapper,
|
||||
taskName.c_str(),
|
||||
8192,
|
||||
bundle,
|
||||
5,
|
||||
&handleTask,
|
||||
APP_CPU_NUM
|
||||
);
|
||||
|
||||
if (status != pdPASS) {
|
||||
PrintTela("[CAN Process] ❌ Falha ao criar task de callback!");
|
||||
delete payload;
|
||||
delete bundle;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false && msg.data[1] == ID_Num_sLRA) {
|
||||
// Comandos para o LoRa nao precisam aguardar, podem ser processados sem tempo
|
||||
}
|
||||
else {
|
||||
// Aguarda até 5000ms pela notificação de término
|
||||
BaseType_t sinal = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(5000));
|
||||
|
||||
if (sinal == 0) {
|
||||
PrintTela("[CAN Process] ⚠️ Callback demorou demais: " + String(payload->idMsg) + " — timeout ao executar comando: " + frameEmProcessamento);
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(10)); // dá tempo da task morrer sozinha
|
||||
eTaskState estado = eTaskGetState(handleTask);
|
||||
|
||||
if (estado != eDeleted && estado != eInvalid) {
|
||||
vTaskDelete(handleTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool mensagemJaNaFila(QueueHandle_t fila, const twai_message_t& novaMsg) {
|
||||
twai_message_t msgTmp;
|
||||
UBaseType_t items = uxQueueMessagesWaiting(fila);
|
||||
|
|
@ -343,16 +425,50 @@ class CanService {
|
|||
std::vector<uint8_t> data;
|
||||
data.push_back(static_cast<uint8_t>(CanMessagePosicaoDados::DadosAll));
|
||||
data.push_back(ID_Num_sTOD);
|
||||
data.push_back(latencia);
|
||||
data.push_back(latencia >> 8); data.push_back(latencia & 0xFF);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void TaskCallbackWrapper(void* param) {
|
||||
auto bundle = static_cast<std::pair<CallbackPayload*, TaskHandle_t>*>(param);
|
||||
CallbackPayload* payload = bundle->first;
|
||||
TaskHandle_t notifyTo = bundle->second;
|
||||
|
||||
payload->callback(
|
||||
payload->packetSize,
|
||||
payload->senderId,
|
||||
payload->posicao,
|
||||
payload->data,
|
||||
payload->dataLength
|
||||
);
|
||||
|
||||
PrintTela("[CAN Callback] Processamento finalizado: " + String(payload->idMsg));
|
||||
|
||||
// Notifica a task principal que terminou
|
||||
xTaskNotifyGive(notifyTo);
|
||||
|
||||
// Limpa memória
|
||||
delete payload;
|
||||
delete bundle;
|
||||
|
||||
// Encerra a task
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t _nodeId;
|
||||
uint32_t _baudRate;
|
||||
OnReceiveCallback _callback = nullptr;
|
||||
bool DebugMode = false;
|
||||
volatile bool processamentoEmAndamento = false;
|
||||
volatile long idmsg = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
TaskHandle_t CanService::handleCallbackTask = NULL;
|
||||
|
||||
#endif
|
||||
|
|
@ -44,7 +44,7 @@ enum S_Code {
|
|||
sRPM = 1,
|
||||
sTST = 2,
|
||||
sCFG = 3,
|
||||
sTMP = 4,
|
||||
sNTC = 4,
|
||||
sENC = 5,
|
||||
sCOR = 6,
|
||||
sTEN = 7,
|
||||
|
|
@ -68,6 +68,12 @@ enum S_Code {
|
|||
sIMU = 25,
|
||||
sLRA = 26,
|
||||
sTOD = 27,
|
||||
sGAS = 28,
|
||||
sSHT = 29,
|
||||
sLUZ = 30,
|
||||
sIUV = 31,
|
||||
sQAR = 32,
|
||||
sCHV = 33,
|
||||
};
|
||||
|
||||
enum Estado {
|
||||
|
|
|
|||
|
|
@ -18,12 +18,11 @@ class I2CService {
|
|||
static bool AdsIniciado;
|
||||
static int canalAtivo;
|
||||
static int idAtualUsandoI2C;
|
||||
static bool i2cMutexReiniciando;
|
||||
|
||||
static Adafruit_MCP23X17 mcp;
|
||||
static Adafruit_ADS1115 ads;
|
||||
|
||||
static SemaphoreHandle_t i2cMutex;
|
||||
|
||||
static bool DefinirPinos(int sda, int scl) {
|
||||
bool mudou = false;
|
||||
if (_pinoSDA != sda) {
|
||||
|
|
@ -38,13 +37,23 @@ class I2CService {
|
|||
}
|
||||
|
||||
static bool IniciarI2C() {
|
||||
bool wireLiberado = WirePodeFinalizar();
|
||||
if (I2CIniciado) {
|
||||
Wire.end();
|
||||
delay(10);
|
||||
MostrarLog("I2C", "Tentando finalizar Wire...");
|
||||
if (wireLiberado) {
|
||||
Wire.end();
|
||||
vTaskDelay(10);
|
||||
MostrarLog("I2C", "Wire finalizado com sucesso");
|
||||
} else {
|
||||
MostrarLog("I2C", "⚠️ Wire travado (SDA/SCL em LOW), nao foi finalizado");
|
||||
}
|
||||
}
|
||||
if (wireLiberado) {
|
||||
MostrarLog("I2C", "Iniciando Wire...");
|
||||
I2CIniciado = Wire.begin(_pinoSDA, _pinoSCL);
|
||||
//Wire.setTimeout(50);
|
||||
MostrarLog("I2C", "I2C inicializado nos pinos SDA=" + String(_pinoSDA) + " e SCL=" + String(_pinoSCL) + " - Res " + I2CIniciado);
|
||||
}
|
||||
I2CIniciado = Wire.begin(_pinoSDA, _pinoSCL);
|
||||
//Wire.setTimeout(50);
|
||||
MostrarLog("I2C", "I2C inicializado nos pinos SDA=" + String(_pinoSDA) + " e SCL=" + String(_pinoSCL) + " - Res " + I2CIniciado);
|
||||
if (i2cMutex == nullptr) {
|
||||
i2cMutex = xSemaphoreCreateMutex();
|
||||
}
|
||||
|
|
@ -53,7 +62,7 @@ class I2CService {
|
|||
|
||||
if (i2cTaskHandle == NULL) {
|
||||
xTaskCreatePinnedToCore(I2CService::i2cTaskWrapper, "i2cTask", 4096, nullptr, 2, &i2cTaskHandle, tskNO_AFFINITY);
|
||||
}
|
||||
}
|
||||
|
||||
return I2CIniciado;
|
||||
}
|
||||
|
|
@ -81,6 +90,8 @@ class I2CService {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (i2cMutexReiniciando) return false;
|
||||
|
||||
TickType_t timeoutTicks = pdMS_TO_TICKS(timeoutMs);
|
||||
if (xSemaphoreTake(i2cMutex, timeoutTicks) != pdTRUE) {
|
||||
MostrarLog("I2C", "Timeout ao tentar acessar o I2C - ID: " + String(idSensor));
|
||||
|
|
@ -88,7 +99,7 @@ class I2CService {
|
|||
}
|
||||
|
||||
// Troca canal se necessário
|
||||
if (canalMux >= 0 && !SelecionarSensor(canalMux)) {
|
||||
if (canalMux > -1 && !SelecionarCanalMux(canalMux)) {
|
||||
xSemaphoreGive(i2cMutex); // Libera caso a troca de canal falhe
|
||||
return false;
|
||||
}
|
||||
|
|
@ -107,9 +118,47 @@ class I2CService {
|
|||
}
|
||||
|
||||
static void RecriarMutex() {
|
||||
i2cMutexReiniciando = true;
|
||||
vSemaphoreDelete(i2cMutex);
|
||||
i2cMutex = xSemaphoreCreateMutex();
|
||||
xSemaphoreGive(i2cMutex);
|
||||
idAtualUsandoI2C = -1;
|
||||
i2cMutexReiniciando = false;
|
||||
MostrarLog("I2C", "Mutex Recriado");
|
||||
}
|
||||
|
||||
static bool WirePodeFinalizar() {
|
||||
pinMode(_pinoSCL, INPUT_PULLUP);
|
||||
pinMode(_pinoSDA, INPUT_PULLUP);
|
||||
delay(1); // garante leitura estável
|
||||
return (digitalRead(_pinoSCL) == HIGH && digitalRead(_pinoSDA) == HIGH);
|
||||
}
|
||||
|
||||
static void DestravarBarramentoI2C(int sda, int scl) {
|
||||
pinMode(scl, OUTPUT_OPEN_DRAIN);
|
||||
pinMode(sda, INPUT_PULLUP); // SDA como entrada para ler
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
digitalWrite(scl, LOW);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(scl, HIGH);
|
||||
delayMicroseconds(5);
|
||||
}
|
||||
|
||||
// Gera uma condição de STOP manual (SDA sobe enquanto SCL está alto)
|
||||
pinMode(sda, OUTPUT_OPEN_DRAIN);
|
||||
digitalWrite(sda, LOW);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(scl, HIGH);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(sda, HIGH);
|
||||
|
||||
// Espera estabilizar
|
||||
delay(5);
|
||||
|
||||
// Retorna controle ao Wire
|
||||
pinMode(scl, INPUT_PULLUP);
|
||||
pinMode(sda, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
static int QuemEstaUsando() {
|
||||
|
|
@ -127,7 +176,7 @@ class I2CService {
|
|||
MostrarLog("I2C", "Falha ao endTransmission (leitura)");
|
||||
return false;
|
||||
}
|
||||
delay(1); // <----- ADICIONAR este delay aqui
|
||||
vTaskDelay(1); // <----- ADICIONAR este delay aqui
|
||||
}
|
||||
|
||||
size_t received = Wire.requestFrom((int)addr, (int)qtd);
|
||||
|
|
@ -167,8 +216,8 @@ class I2CService {
|
|||
}
|
||||
|
||||
|
||||
static bool SelecionarSensor(uint8_t canalGlobal) {
|
||||
uint8_t _enderecoMux = 0x70 + (canalGlobal / 10);
|
||||
static bool SelecionarCanalMux(uint8_t canalGlobal) {
|
||||
uint8_t _enderecoMux = enderecoMux + (canalGlobal / 10);
|
||||
uint8_t _canal = canalGlobal % 10;
|
||||
return TrocarCanalMux(_enderecoMux, _canal);
|
||||
}
|
||||
|
|
@ -189,6 +238,38 @@ class I2CService {
|
|||
}
|
||||
|
||||
|
||||
static int SelecionarCanalADS(uint8_t canalGlobal) {
|
||||
if (canalGlobal > 33) return -1;
|
||||
uint8_t endereco = enderecoAds + (canalGlobal / 10);
|
||||
uint8_t canal = canalGlobal % 10;
|
||||
if (IniciarADS(endereco)) {
|
||||
return canal;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int RealizarLeituraADS(int canalGlobal, int leituras, int idSensor, int canalMux) {
|
||||
SolicitarAcessoI2C(idSensor, canalMux);
|
||||
int canal = SelecionarCanalADS(canalGlobal);
|
||||
if (canal > -1) {
|
||||
uint16_t l = 0;
|
||||
for (int i = 0; i < leituras; i++) {
|
||||
vTaskDelay(1);
|
||||
int leituraADC = (int)(ads.readADC_SingleEnded(canal));
|
||||
int leitura12bits = map(leituraADC, 0, 32767, 0, 4095);
|
||||
MostrarLog("ADS", "Leitura: " + String(leituraADC) + ", Leitura 12 bits: " + String(leitura12bits));
|
||||
l += leitura12bits;
|
||||
}
|
||||
LiberarAcessoI2C(idSensor);
|
||||
return (int)(l / leituras);
|
||||
}
|
||||
LiberarAcessoI2C(idSensor);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static void IniciarMUX(byte endereco = enderecoMux, bool Mandatorio = false) {
|
||||
if (!I2CIniciado) {
|
||||
MostrarLog("MUX", "Impossivel iniciar TCA9548A, I2C nao iniciado!");
|
||||
|
|
@ -202,7 +283,7 @@ class I2CService {
|
|||
MostrarLog("MUX", "TCA9548A nao Iniciado, endereco " + String(endereco) + " nao encontrado no barramento");
|
||||
if (Mandatorio) {
|
||||
MostrarLog("MUX", "Conexão obrigatória, tentando novamente em 5 segundos...");
|
||||
delay(5000);
|
||||
vTaskDelay(5000);
|
||||
IniciarMUX(endereco, Mandatorio);
|
||||
}
|
||||
else {
|
||||
|
|
@ -235,7 +316,7 @@ class I2CService {
|
|||
MostrarLog("MCP", "Erro ao iniciar MCP23X17!");
|
||||
if (Mandatorio) {
|
||||
MostrarLog("MCP", "Conexão obrigatória, tentando novamente em 5 segundos...");
|
||||
delay(5000);
|
||||
vTaskDelay(5000);
|
||||
IniciarMCP(endereco, Mandatorio);
|
||||
}
|
||||
else {
|
||||
|
|
@ -252,35 +333,27 @@ class I2CService {
|
|||
}
|
||||
}
|
||||
|
||||
static void IniciarADS(byte endereco = enderecoAds, bool Mandatorio = false) {
|
||||
static bool IniciarADS(byte endereco = enderecoAds) {
|
||||
if (!I2CIniciado) {
|
||||
MostrarLog("ADS", "Impossivel iniciar ADS1115, I2C nao iniciado!");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
MostrarLog("ADS", "Iniciando ADS1115...");
|
||||
if (AdsIniciado && endereco == ultimoEnderecoADS) {
|
||||
MostrarLog("ADS", "ADS1115 já iniciado no endereco 0x" + String(endereco, HEX));
|
||||
return true;
|
||||
}
|
||||
MostrarLog("ADS", "Iniciando ADS1115 no endereco 0x" + String(endereco, HEX) + "...");
|
||||
AdsIniciado = ads.begin(endereco, &Wire);
|
||||
if (!AdsIniciado) {
|
||||
SolicitarAcessoI2C();
|
||||
AdsIniciado = ads.begin(endereco, &Wire);
|
||||
if (!AdsIniciado) {
|
||||
MostrarLog("ADS", "Erro ao iniciar ADS1115!");
|
||||
if (Mandatorio) {
|
||||
MostrarLog("ADS", "Conexão obrigatória, tentando novamente em 5 segundos...");
|
||||
delay(5000);
|
||||
IniciarADS(endereco, Mandatorio);
|
||||
}
|
||||
else {
|
||||
MostrarLog("ADS", "ADS1115 nao mandatorio, continuando o fluxo...");
|
||||
}
|
||||
}
|
||||
else {
|
||||
ads.setGain(GAIN_ONE);
|
||||
MostrarLog("ADS", "ADS1115 Iniciado");
|
||||
}
|
||||
LiberarAcessoI2C();
|
||||
ultimoEnderecoADS = 0xFF;
|
||||
MostrarLog("ADS", "Erro ao iniciar ADS1115 no endereco 0x" + String(endereco, HEX));
|
||||
}
|
||||
else {
|
||||
MostrarLog("ADS", "ADS1115 ja Iniciado");
|
||||
ads.setGain(GAIN_ONE);
|
||||
MostrarLog("ADS", "ADS1115 Iniciado no endereco 0x" + String(endereco, HEX));
|
||||
ultimoEnderecoADS = endereco;
|
||||
}
|
||||
return AdsIniciado;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -298,6 +371,9 @@ class I2CService {
|
|||
static unsigned long tempoEntradaI2C;
|
||||
static unsigned long LimiteTempoI2C;
|
||||
|
||||
static byte ultimoEnderecoADS;
|
||||
static SemaphoreHandle_t i2cMutex;
|
||||
|
||||
static TaskHandle_t i2cTaskHandle;
|
||||
static void i2cTaskWrapper(void *pvParameters) {
|
||||
I2CService::i2cTask();
|
||||
|
|
@ -313,27 +389,31 @@ class I2CService {
|
|||
static void VerificarI2CPreso() {
|
||||
if (idAtualUsandoI2C >= 0 && (millis() - tempoEntradaI2C > LimiteTempoI2C)) {
|
||||
MostrarLog("I2C", "Semáforo preso pelo ID " + String(idAtualUsandoI2C) + " — forçando liberação!");
|
||||
RecriarMutex();
|
||||
IniciarI2C();
|
||||
ESP.restart();
|
||||
//RecriarMutex();
|
||||
//DestravarBarramentoI2C(_pinoSDA, _pinoSCL);
|
||||
//IniciarI2C();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
bool I2CService::DebugMode = false;
|
||||
bool I2CService::DebugMode = true;
|
||||
int I2CService::_pinoSDA = 1;
|
||||
int I2CService::_pinoSCL = 2;
|
||||
unsigned long I2CService::LimiteTempoI2C = 200;
|
||||
unsigned long I2CService::LimiteTempoI2C = 2000;
|
||||
bool I2CService::I2CIniciado = false;
|
||||
bool I2CService::MuxIniciado = false;
|
||||
bool I2CService::McpIniciado = false;
|
||||
Adafruit_MCP23X17 I2CService::mcp;
|
||||
Adafruit_ADS1115 I2CService::ads;
|
||||
byte I2CService::ultimoEnderecoADS = 0xFF;
|
||||
bool I2CService::AdsIniciado = false;
|
||||
int I2CService::canalAtivo = -1;
|
||||
int I2CService::idAtualUsandoI2C = -1;
|
||||
unsigned long I2CService::tempoEntradaI2C = 0;
|
||||
SemaphoreHandle_t I2CService::i2cMutex = nullptr;
|
||||
TaskHandle_t I2CService::i2cTaskHandle = NULL;
|
||||
bool I2CService::i2cMutexReiniciando = false;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
bool DebugMode = true;
|
||||
bool DebugMode = false;
|
||||
|
||||
void MostrarLog(String mensagem) {
|
||||
if (DebugMode) {
|
||||
|
|
@ -235,12 +235,12 @@ private:
|
|||
QueueHandle_t lraQueueRx;
|
||||
TaskHandle_t LraTaskRxHandle = NULL;
|
||||
static void LraTaskRxWrapper(void *pvParameters) {
|
||||
LoRaService service = static_cast<LoRaService>(pvParameters);
|
||||
LoRaService* service = static_cast<LoRaService*>(pvParameters);
|
||||
service->LraTaskRx(pvParameters);
|
||||
}
|
||||
|
||||
void LraTaskRx(void* pvParameters) {
|
||||
LoRaService* instance = (LoRaService*)pvParameters;
|
||||
LoRaService* service = static_cast<LoRaService*>(pvParameters);
|
||||
while (true) {
|
||||
if (!Conectado || !Configurado) {
|
||||
vTaskDelay(1000);
|
||||
|
|
@ -250,8 +250,8 @@ private:
|
|||
MostrarLog("Timeout de recebimento. Reiniciando estado.");
|
||||
reiniciarEstado();
|
||||
}
|
||||
while (currentMode == LoRaMode::NORMAL && instance->_serialLoRa->available()) {
|
||||
uint8_t byteRecebido = instance->_serialLoRa->read();
|
||||
while (currentMode == LoRaMode::NORMAL && service->_serialLoRa->available()) {
|
||||
uint8_t byteRecebido = service->_serialLoRa->read();
|
||||
ultimoByteRecebido = millis(); // <- atualiza o tempo
|
||||
MostrarLog("byteRecebido=" + String(byteRecebido));
|
||||
|
||||
|
|
@ -325,12 +325,12 @@ private:
|
|||
QueueHandle_t lraQueueTx;
|
||||
TaskHandle_t LraTaskTxHandle = NULL;
|
||||
static void LraTaskTxWrapper(void *pvParameters) {
|
||||
LoRaService service = static_cast<LoRaService>(pvParameters);
|
||||
LoRaService* service = static_cast<LoRaService*>(pvParameters);
|
||||
service->LraTaskTx(pvParameters);
|
||||
}
|
||||
|
||||
void LraTaskTx(void* pvParameters) {
|
||||
LoRaService service = static_cast<LoRaService>(pvParameters);
|
||||
LoRaService* service = static_cast<LoRaService*>(pvParameters);
|
||||
std::vector<uint8_t> msg;
|
||||
while (true) {
|
||||
if (!Conectado || !Configurado) {
|
||||
|
|
@ -346,12 +346,12 @@ private:
|
|||
|
||||
TaskHandle_t LraTaskProcessHandle = NULL;
|
||||
static void LraTaskProcessWrapper(void *pvParameters) {
|
||||
LoRaService service = static_cast<LoRaService>(pvParameters);
|
||||
LoRaService* service = static_cast<LoRaService*>(pvParameters);
|
||||
service->LraTaskProcess(pvParameters);
|
||||
}
|
||||
|
||||
void LraTaskProcess(void* pvParameters) {
|
||||
LoRaService service = static_cast<LoRaService>(pvParameters);
|
||||
LoRaService* service = static_cast<LoRaService*>(pvParameters);
|
||||
std::vector<uint8_t> msg;
|
||||
while (true) {
|
||||
if (!Conectado || !Configurado) {
|
||||
|
|
|
|||
|
|
@ -14,16 +14,22 @@ class PinoModel {
|
|||
TiposPinos tipo;
|
||||
TiposLeituras leitura;
|
||||
bool Conectado = false;
|
||||
int idSensor;
|
||||
int _CanalMUX;
|
||||
|
||||
PinoModel(int numero = PINO_INVALIDO, TiposBarramentos barr = CONTROLADOR, TiposPinos tp = _INPUT, TiposLeituras lt = DIGITAL) : num(numero), barramento(barr), tipo(tp), leitura(lt) {
|
||||
PinoModel(int numero = PINO_INVALIDO, TiposBarramentos barr = CONTROLADOR, TiposPinos tp = _INPUT, TiposLeituras lt = DIGITAL, int _idSensor = 0, int canalMux = -1) : num(numero), barramento(barr), tipo(tp), leitura(lt), idSensor(_idSensor), _CanalMUX(canalMux) {
|
||||
}
|
||||
|
||||
bool Definido() {
|
||||
bool barramentoIniciado =
|
||||
(barramento == TiposBarramentos::CONTROLADOR) ||
|
||||
(barramento == TiposBarramentos::EXPANSOR_ADS && I2CService::AdsIniciado) ||
|
||||
(barramento == TiposBarramentos::EXPANSOR_GPIO && I2CService::McpIniciado);
|
||||
return num != PINO_INVALIDO;
|
||||
}
|
||||
|
||||
void Conectar(bool statusInicial = false) {
|
||||
Conectado - false;
|
||||
Conectado = false;
|
||||
if (Definido()) {
|
||||
if (barramento == TiposBarramentos::CONTROLADOR) {
|
||||
if (tipo == _INPUT) {
|
||||
|
|
@ -36,21 +42,22 @@ class PinoModel {
|
|||
}
|
||||
else if (barramento == TiposBarramentos::EXPANSOR_GPIO) {
|
||||
if (I2CService::McpIniciado) {
|
||||
I2CService::SolicitarAcessoI2C();
|
||||
I2CService::SolicitarAcessoI2C(idSensor, _CanalMUX);
|
||||
if (tipo == _INPUT) {
|
||||
I2CService::mcp.pinMode(num, INPUT);
|
||||
} else if (tipo == _OUTPUT) {
|
||||
I2CService::mcp.pinMode(num, OUTPUT);
|
||||
set(statusInicial);
|
||||
}
|
||||
I2CService::LiberarAcessoI2C();
|
||||
I2CService::LiberarAcessoI2C(idSensor);
|
||||
Conectado = true;
|
||||
}
|
||||
}
|
||||
else if (barramento == TiposBarramentos::EXPANSOR_ADS) {
|
||||
if (I2CService::AdsIniciado) {
|
||||
/*if (I2CService::AdsIniciado) {
|
||||
Conectado = true;
|
||||
}
|
||||
}*/
|
||||
Conectado = true;
|
||||
}
|
||||
}
|
||||
MostrarLog("Pino " + String(num) + " no barramento " + String(barramento) + " conectado: " + Conectado);
|
||||
|
|
@ -66,9 +73,9 @@ class PinoModel {
|
|||
}
|
||||
else if (barramento == EXPANSOR_GPIO) {
|
||||
if (I2CService::McpIniciado) {
|
||||
I2CService::SolicitarAcessoI2C();
|
||||
I2CService::SolicitarAcessoI2C(idSensor, _CanalMUX);
|
||||
I2CService::mcp.pinMode(num, INPUT);
|
||||
I2CService::LiberarAcessoI2C();
|
||||
I2CService::LiberarAcessoI2C(idSensor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -94,27 +101,14 @@ class PinoModel {
|
|||
}
|
||||
else if (barramento == TiposBarramentos::EXPANSOR_GPIO) {
|
||||
if (I2CService::McpIniciado) {
|
||||
I2CService::SolicitarAcessoI2C();
|
||||
I2CService::SolicitarAcessoI2C(idSensor, _CanalMUX);
|
||||
int leitura = I2CService::mcp.digitalRead(num);
|
||||
I2CService::LiberarAcessoI2C();
|
||||
I2CService::LiberarAcessoI2C(idSensor);
|
||||
return leitura;
|
||||
}
|
||||
}
|
||||
else if (barramento == TiposBarramentos::EXPANSOR_ADS) {
|
||||
if (I2CService::AdsIniciado) {
|
||||
I2CService::SolicitarAcessoI2C();
|
||||
uint16_t l = 0;
|
||||
for (int i = 0; i < leituras; i++) {
|
||||
vTaskDelay(1);
|
||||
int leituraADC = (int)(I2CService::ads.readADC_SingleEnded(num));
|
||||
int leitura12bits = map(leituraADC, 0, 32767, 0, 4095);
|
||||
MostrarLog("Leitura ADS: " + String(leituraADC) + ", Leitura 12 bits: " + String(leitura12bits));
|
||||
l += leitura12bits;
|
||||
|
||||
}
|
||||
I2CService::LiberarAcessoI2C();
|
||||
return (int)(l / leituras);
|
||||
}
|
||||
return I2CService::RealizarLeituraADS(num, leituras, idSensor, _CanalMUX);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
@ -127,9 +121,9 @@ class PinoModel {
|
|||
}
|
||||
else if (barramento == EXPANSOR_GPIO) {
|
||||
if (I2CService::McpIniciado) {
|
||||
I2CService::SolicitarAcessoI2C();
|
||||
I2CService::SolicitarAcessoI2C(idSensor, _CanalMUX);
|
||||
I2CService::mcp.digitalWrite(num, status ? HIGH : LOW);
|
||||
I2CService::LiberarAcessoI2C();
|
||||
I2CService::LiberarAcessoI2C(idSensor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,156 @@
|
|||
#ifndef SensorChuvaModel
|
||||
#define SensorChuvaModel
|
||||
|
||||
#include "SerialService.h"
|
||||
#include "Pinout.h"
|
||||
#include "Utils.h"
|
||||
|
||||
class SensorChuva {
|
||||
public:
|
||||
|
||||
SensorChuva(String _modID, String _id) {
|
||||
Mod_ID = _modID;
|
||||
_ID = _id;
|
||||
}
|
||||
|
||||
String Mod_ID = "";
|
||||
String _ID;
|
||||
int ID_Num;
|
||||
PinoModel _pino;
|
||||
|
||||
double tensao = 0;
|
||||
double percentual = -1;
|
||||
|
||||
bool Iniciado = false;
|
||||
bool Checando = false;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
MostrarLog("Sensor já inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
_pino.Conectar();
|
||||
Iniciado = _pino.Definido();
|
||||
|
||||
MostrarLog(Iniciado ? "Sensor iniciado" : "Sensor nao iniciado");
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
MostrarLog("Sensor nao esta inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
_pino.Desconectar(); // Desconecta o pino
|
||||
|
||||
MostrarLog("Sensor Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
AferirChuva();
|
||||
}
|
||||
|
||||
std::vector<uint8_t> MontarMensagemCAN(CanMessagePosicaoDados posicao) {
|
||||
std::vector<uint8_t> data;
|
||||
data.push_back(static_cast<uint8_t>(posicao));
|
||||
data.push_back(ID_Num);
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Status: {
|
||||
data.push_back(Iniciado ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CanMessagePosicaoDados::Dados1: {
|
||||
int16_t pInt = static_cast<int16_t>(round(percentual * 100.0f));
|
||||
data.push_back((uint8_t)(pInt >> 8));
|
||||
data.push_back((uint8_t)(pInt & 0xFF));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static std::vector<uint8_t> ConfigurarSensor(std::vector<SensorChuva*>& lista, std::vector<uint8_t>& data, const String& Mod_ID) {
|
||||
std::vector<uint8_t> status;
|
||||
if (data.size() < 2) return status;
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[0];
|
||||
uint8_t idNum = data[1];
|
||||
auto it = std::find_if(lista.begin(), lista.end(), [idNum](SensorChuva* s) { return s->ID_Num == idNum; });
|
||||
bool jaExiste = it != lista.end();
|
||||
SensorChuva* sensor;
|
||||
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Config1: {
|
||||
if (data.size() < 7) return status;
|
||||
bool conectar = data[3] == 1;
|
||||
TiposBarramentos tipoBarramento = (TiposBarramentos)data[4];
|
||||
int pino = data[5];
|
||||
int canalMux = (data[6] == 255) ? -1 : data[6];
|
||||
|
||||
if (conectar) {
|
||||
if (!jaExiste) sensor = new SensorChuva(Mod_ID, "sCHV_" + String(idNum));
|
||||
else sensor = *it;
|
||||
|
||||
if (!sensor->Iniciado) {
|
||||
sensor->ID_Num = idNum;
|
||||
sensor->_pino = PinoModel(pino, tipoBarramento, _INPUT, ANALOGICO, idNum, canalMux);
|
||||
sensor->Inicializar();
|
||||
if (!jaExiste) {
|
||||
lista.push_back(sensor);
|
||||
sensor->MostrarLog("Sensor de chuva adicionado via CAN: sCHV_" + String(idNum));
|
||||
}
|
||||
}
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
} else {
|
||||
if (jaExiste) {
|
||||
sensor = *it;
|
||||
sensor->Desligar();
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
sensor->MostrarLog("Sensor de chuva removido via CAN: sCHV_" + String(idNum));
|
||||
delete sensor;
|
||||
lista.erase(it);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool DegugMode = true;
|
||||
|
||||
void MostrarLog(String mensagem) {
|
||||
if (DegugMode) {
|
||||
PrintTela("[CHV " + _ID + "] " + mensagem);
|
||||
}
|
||||
}
|
||||
|
||||
const float Vs = 5.0f; // Tensao de alimentacao do sensor = 5V
|
||||
static constexpr float divisor = 10.0f / (10.0f + 5.6f); // R1 = 5K6, R2 = 10K
|
||||
static constexpr float vOffset = (2.3f / 2.04f); // v real / v ads
|
||||
const float tSeco = 2.24f;
|
||||
const float tMolhado = 1.156f;
|
||||
|
||||
void AferirChuva() {
|
||||
if (!Iniciado) return;
|
||||
|
||||
int leitura = _pino.get();
|
||||
tensao = (float)leitura / 4095.0f * Vs;
|
||||
tensao = tensao * divisor * vOffset;
|
||||
|
||||
percentual = constrain(
|
||||
100.0f * (tSeco - tensao) / (tSeco - tMolhado),
|
||||
0.0f, 100.0f
|
||||
);
|
||||
|
||||
MostrarLog("Leitura: " + String(leitura) + ", Tensao: " + String(tensao) + ", Percentual: " + String(percentual));
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -90,7 +90,7 @@ class SensorCorrente {
|
|||
|
||||
if (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
while (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
delay(10);
|
||||
vTaskDelay(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ class SensorCorrente {
|
|||
bool conectar = data[3] == 1;
|
||||
uint8_t endereco = data[4];
|
||||
TiposShuntCorrente aMax = (TiposShuntCorrente)data[5];
|
||||
int canalMux = data[6];
|
||||
int canalMux = (data[6] == 255) ? -1 : data[6];
|
||||
|
||||
if (conectar) {
|
||||
if (!jaExiste) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,199 @@
|
|||
#ifndef SensorGasModel
|
||||
#define SensorGasModel
|
||||
|
||||
#include "SerialService.h"
|
||||
#include "Pinout.h"
|
||||
#include "Utils.h"
|
||||
|
||||
class SensorGas {
|
||||
public:
|
||||
enum class TipoSensorGas : uint8_t {
|
||||
MQ2 = 0,
|
||||
MQ7 = 1,
|
||||
MQ135 = 2,
|
||||
};
|
||||
|
||||
|
||||
SensorGas(String _modID, String _id) {
|
||||
Mod_ID = _modID;
|
||||
_ID = _id;
|
||||
}
|
||||
|
||||
String Mod_ID = "";
|
||||
String _ID;
|
||||
int ID_Num;
|
||||
PinoModel _pino;
|
||||
TipoSensorGas Tipo;
|
||||
|
||||
float ppm = -1;
|
||||
float tensao = -1;
|
||||
|
||||
bool Iniciado = false;
|
||||
bool Checando = false;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
MostrarLog("Sensor já inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
_pino.Conectar();
|
||||
Iniciado = _pino.Definido();
|
||||
|
||||
MostrarLog(Iniciado ? "Sensor iniciado" : "Sensor nao iniciado");
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
MostrarLog("Sensor nao esta inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
_pino.Desconectar(); // Desconecta o pino
|
||||
|
||||
MostrarLog("Sensor Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
AferirGas();
|
||||
}
|
||||
|
||||
std::vector<uint8_t> MontarMensagemCAN(CanMessagePosicaoDados posicao) {
|
||||
std::vector<uint8_t> data;
|
||||
data.push_back(static_cast<uint8_t>(posicao));
|
||||
data.push_back(ID_Num);
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Status: {
|
||||
data.push_back(Iniciado ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CanMessagePosicaoDados::Dados1: {
|
||||
int32_t leituraInt = static_cast<int32_t>(round(ppm * 100.0f));
|
||||
data.push_back((uint8_t)(leituraInt >> 24));
|
||||
data.push_back((uint8_t)(leituraInt >> 16));
|
||||
data.push_back((uint8_t)(leituraInt >> 8));
|
||||
data.push_back((uint8_t)(leituraInt & 0xFF));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static std::vector<uint8_t> ConfigurarSensor(std::vector<SensorGas*>& lista, std::vector<uint8_t>& data, const String& Mod_ID) {
|
||||
std::vector<uint8_t> status;
|
||||
if (data.size() < 2) return status;
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[0];
|
||||
uint8_t idNum = data[1];
|
||||
auto it = std::find_if(lista.begin(), lista.end(), [idNum](SensorGas* s) { return s->ID_Num == idNum; });
|
||||
bool jaExiste = it != lista.end();
|
||||
SensorGas* sensor;
|
||||
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Config1: {
|
||||
if (data.size() < 8) return status;
|
||||
bool conectar = data[3] == 1;
|
||||
TiposBarramentos tipoBarramento = (TiposBarramentos)data[4];
|
||||
int pino = data[5];
|
||||
TipoSensorGas tipo = (TipoSensorGas)data[6];
|
||||
int canalMux = (data[7] == 255) ? -1 : data[7];
|
||||
|
||||
if (conectar) {
|
||||
if (!jaExiste) sensor = new SensorGas(Mod_ID, "sGAS_" + String(idNum));
|
||||
else sensor = *it;
|
||||
|
||||
if (!sensor->Iniciado) {
|
||||
sensor->ID_Num = idNum;
|
||||
sensor->_pino = PinoModel(pino, tipoBarramento, _INPUT, ANALOGICO, idNum, canalMux);
|
||||
sensor->Tipo = tipo;
|
||||
sensor->Inicializar();
|
||||
if (!jaExiste) {
|
||||
lista.push_back(sensor);
|
||||
sensor->MostrarLog("Sensor de gas adicionado via CAN: sGAS_" + String(idNum));
|
||||
}
|
||||
}
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
} else {
|
||||
if (jaExiste) {
|
||||
sensor = *it;
|
||||
sensor->Desligar();
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
sensor->MostrarLog("Sensor de gas removido via CAN: sGAS_" + String(idNum));
|
||||
delete sensor;
|
||||
lista.erase(it);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool DegugMode = true;
|
||||
|
||||
void MostrarLog(String mensagem) {
|
||||
if (DegugMode) {
|
||||
PrintTela("[GAS " + _ID + "] " + mensagem);
|
||||
}
|
||||
}
|
||||
|
||||
void AferirGas() {
|
||||
if (!Iniciado) return;
|
||||
float leitura = _pino.get();
|
||||
ppm = CalcularPPM(leitura);
|
||||
MostrarLog("Leitura Gas: " + String(leitura) + ", Tensao: " + String(tensao) + ", PPM estimado: " + String(ppm));
|
||||
}
|
||||
|
||||
float CalcularPPM(float leitura) {
|
||||
switch (Tipo) {
|
||||
case TipoSensorGas::MQ2:
|
||||
return CalcularPPM_MQ2(leitura);
|
||||
case TipoSensorGas::MQ7:
|
||||
return CalcularPPM_MQ7(leitura);
|
||||
default:
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Valor de R0 calibrado (ideal seria calibrar em tempo real, aqui é fixo)
|
||||
const float R0_MQ2 = 16.8f;
|
||||
static constexpr float vOffsetMQ2 = (0.471f / 0.64f); // v real / v ads
|
||||
const float R0_MQ7 = 75.1f;
|
||||
static constexpr float vOffsetMQ7 = (0.305f / 0.51f); // v real / v ads
|
||||
|
||||
// Constantes do divisor resistivo
|
||||
const float RL = 10.0; // resistência de carga típica em kΩ
|
||||
const float Vs = 5.0f; // tensão de alimentação do MQ
|
||||
static constexpr float divisor = 10.0f / (10.0f + 5.6f); // R1 = 5K6, R2 = 10K
|
||||
|
||||
|
||||
float CalcularPPM_MQ2(float leituraADC) {
|
||||
float leituraADC_volts = (leituraADC / 4095.0f) * Vs;
|
||||
float Vadc = leituraADC_volts * divisor * vOffsetMQ2;
|
||||
tensao = Vadc;
|
||||
if (Vadc <= 0.01f || Vadc >= Vs) return 0;
|
||||
|
||||
float Rs = (Vs - Vadc) * RL / Vadc;
|
||||
float ratio = Rs / R0_MQ2;
|
||||
float ppm = pow(10.0, (-0.45 * log10(ratio)) + 1.9);
|
||||
return ppm;
|
||||
}
|
||||
|
||||
float CalcularPPM_MQ7(float leituraADC) {
|
||||
float leituraADC_volts = (leituraADC / 4095.0f) * Vs;
|
||||
float Vadc = leituraADC_volts * divisor * vOffsetMQ2;
|
||||
tensao = Vadc;
|
||||
if (Vadc <= 0.01f || Vadc >= Vs) return 0;
|
||||
|
||||
float Rs = (Vs - Vadc) * RL / Vadc;
|
||||
float ratio = Rs / R0_MQ7;
|
||||
float ppm = pow(10.0, (-1.7 * log10(ratio)) + 1.7);
|
||||
return ppm;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -62,6 +62,10 @@ class SensorIMU {
|
|||
mpu.beginAccel();
|
||||
mpu.beginGyro();
|
||||
//mpu.beginMag();
|
||||
|
||||
filterDelay = 1000.0f / filterHz;
|
||||
xTaskCreatePinnedToCore(&SensorIMU::IMUTaskWrapper, "IMUTask", 4096, this, 10, &IMUTaskHandle, tskNO_AFFINITY);
|
||||
|
||||
MostrarLog("MPU9250 iniciado");
|
||||
} else {
|
||||
MostrarLog("MPU9250 nao encontrado no endereco " + String(_EnderecoMPU));
|
||||
|
|
@ -87,9 +91,8 @@ class SensorIMU {
|
|||
}
|
||||
|
||||
Iniciado = MpuIniciado || BmpIniciado;
|
||||
|
||||
if (Iniciado) {
|
||||
filterDelay = 1000.0f / filterHz;
|
||||
xTaskCreatePinnedToCore(&SensorIMU::IMUTaskWrapper, "IMUTask", 4096, this, 10, &IMUTaskHandle, tskNO_AFFINITY);
|
||||
MostrarLog("Sensor iniciado");
|
||||
}
|
||||
|
||||
|
|
@ -103,10 +106,12 @@ class SensorIMU {
|
|||
}
|
||||
|
||||
Iniciado = false;
|
||||
MpuIniciado = false;
|
||||
BmpIniciado = false;
|
||||
|
||||
if (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
while (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
delay(10);
|
||||
vTaskDelay(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +125,7 @@ class SensorIMU {
|
|||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
AferirDadosIMU();
|
||||
AferirDadosTMP();
|
||||
}
|
||||
|
||||
|
|
@ -262,8 +268,8 @@ class SensorIMU {
|
|||
TickType_t xLastWakeTime = xTaskGetTickCount();
|
||||
|
||||
while (1) {
|
||||
if (Iniciado) {
|
||||
AferirDadosIMU();
|
||||
if (MpuIniciado) {
|
||||
AplicarFiltroMahony();
|
||||
vTaskDelayUntil(&xLastWakeTime, filterDelay);
|
||||
}
|
||||
else {
|
||||
|
|
@ -272,27 +278,7 @@ class SensorIMU {
|
|||
}
|
||||
}
|
||||
|
||||
void AferirDadosIMU() {
|
||||
if (!MpuIniciado) return;
|
||||
|
||||
if (!I2CService::SolicitarAcessoI2C(ID_Num, -1, 5)) return;
|
||||
|
||||
mpu.accelUpdate();
|
||||
mpu.gyroUpdate();
|
||||
mpu.magUpdate();
|
||||
|
||||
AccX = mpu.accelX();
|
||||
AccY = mpu.accelY();
|
||||
AccZ = mpu.accelZ();
|
||||
|
||||
GyroX = mpu.gyroX();
|
||||
GyroY = mpu.gyroY();
|
||||
GyroZ = mpu.gyroZ();
|
||||
|
||||
/*MagX = mpu.magX();
|
||||
MagY = mpu.magY();
|
||||
MagZ = mpu.magZ();*/
|
||||
|
||||
void AplicarFiltroMahony() {
|
||||
filter.updateIMU(GyroX, GyroY, GyroZ, AccX, AccY, AccZ);
|
||||
|
||||
// Recupera os quaternions
|
||||
|
|
@ -311,8 +297,32 @@ class SensorIMU {
|
|||
Roll = (Roll > 0) ? Roll - 180 : Roll + 180;
|
||||
Pitch = -(atan2(-upX, sqrt(upY * upY + upZ * upZ)) * RAD_TO_DEG);
|
||||
Yaw = atan2(2.0f * (q1 * q2 + q0 * q3), q0*q0 + q1*q1 - q2*q2 - q3*q3) * RAD_TO_DEG;
|
||||
|
||||
}
|
||||
|
||||
void AferirDadosIMU() {
|
||||
if (!MpuIniciado) return;
|
||||
|
||||
if (!I2CService::SolicitarAcessoI2C(ID_Num)) return;
|
||||
|
||||
mpu.accelUpdate();
|
||||
mpu.gyroUpdate();
|
||||
mpu.magUpdate();
|
||||
|
||||
AccX = mpu.accelX();
|
||||
AccY = mpu.accelY();
|
||||
AccZ = mpu.accelZ();
|
||||
|
||||
GyroX = mpu.gyroX();
|
||||
GyroY = mpu.gyroY();
|
||||
GyroZ = mpu.gyroZ();
|
||||
|
||||
/*MagX = mpu.magX();
|
||||
MagY = mpu.magY();
|
||||
MagZ = mpu.magZ();*/
|
||||
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
|
||||
MostrarLog("AccX: " + String(AccX) + ", AccY: " + String(AccY) + ", AccZ: " + String(AccZ) + ", GyroX: " + String(GyroX) + ", GyroY: " + String(GyroY) + ", GyroZ: " + String(GyroZ));
|
||||
}
|
||||
|
||||
void AferirDadosTMP() {
|
||||
|
|
@ -322,9 +332,11 @@ class SensorIMU {
|
|||
|
||||
Temp = bmp.readTemperature();
|
||||
Pressao = bmp.readPressure();
|
||||
Altitude = bmp.readAltitude();
|
||||
Altitude = bmp.readAltitude();
|
||||
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
|
||||
MostrarLog("Temperatura: " + String(Temp) + ", Pressao: " + String(Pressao) + ", Altitude: " + String(Altitude));
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,180 @@
|
|||
#ifndef SensorLuminosidadeModel
|
||||
#define SensorLuminosidadeModel
|
||||
|
||||
#include "SerialService.h"
|
||||
#include "I2CService.h"
|
||||
#include "Utils.h"
|
||||
#include <vector>
|
||||
#include <Adafruit_TSL2591.h>
|
||||
|
||||
class SensorLuminosidade {
|
||||
public:
|
||||
SensorLuminosidade(String _modID, String _id) {
|
||||
Mod_ID = _modID;
|
||||
_ID = _id;
|
||||
}
|
||||
|
||||
String Mod_ID = "";
|
||||
String _ID;
|
||||
int ID_Num;
|
||||
byte _Endereco;
|
||||
int _CanalMUX;
|
||||
|
||||
bool Iniciado = false;
|
||||
float lux = 0;
|
||||
float infra = 0;
|
||||
float total = 0;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
MostrarLog("Sensor ja inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!I2CService::SolicitarAcessoI2C(ID_Num, _CanalMUX)) return;
|
||||
|
||||
bool encontrado = I2CService::VerificaEnderecoBarramento(_Endereco);
|
||||
if (encontrado) {
|
||||
tsl = Adafruit_TSL2591(ID_Num);
|
||||
Iniciado = tsl.begin();
|
||||
if (Iniciado) {
|
||||
tsl.setGain(TSL2591_GAIN_MED); // GAIN_LOW, MED, HIGH, MAX
|
||||
tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS); // tempo de integração
|
||||
MostrarLog("Sensor iniciado no canal " + String(_CanalMUX));
|
||||
}
|
||||
else {
|
||||
PrintTela("Sensor nao iniciado!");
|
||||
}
|
||||
} else {
|
||||
Iniciado = false;
|
||||
MostrarLog("Sensor nao iniciado, endereco " + String(_Endereco) + " nao encontrado!");
|
||||
}
|
||||
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
MostrarLog("Sensor nao esta inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
if (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
while (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
vTaskDelay(10);
|
||||
}
|
||||
}
|
||||
|
||||
MostrarLog("Sensor Desligado");
|
||||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
if (!Iniciado) return;
|
||||
AferirLuminosidade();
|
||||
}
|
||||
|
||||
std::vector<uint8_t> MontarMensagemCAN(CanMessagePosicaoDados posicao) {
|
||||
std::vector<uint8_t> data;
|
||||
data.push_back(static_cast<uint8_t>(posicao));
|
||||
data.push_back(ID_Num);
|
||||
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Status: {
|
||||
data.push_back(Iniciado ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CanMessagePosicaoDados::Dados1: {
|
||||
uint32_t lux100 = lux * 100;
|
||||
data.push_back((lux100 >> 24) & 0xFF);
|
||||
data.push_back((lux100 >> 16) & 0xFF);
|
||||
data.push_back((lux100 >> 8) & 0xFF);
|
||||
data.push_back(lux100 & 0xFF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static std::vector<uint8_t> ConfigurarSensor(std::vector<SensorLuminosidade*>& lista, std::vector<uint8_t>& data, const String& Mod_ID) {
|
||||
std::vector<uint8_t> status;
|
||||
if (data.size() < 2) return status;
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[0];
|
||||
uint8_t idNum = data[1];
|
||||
auto it = std::find_if(lista.begin(), lista.end(), [idNum](SensorLuminosidade* s) { return s->ID_Num == idNum; });
|
||||
bool jaExiste = it != lista.end();
|
||||
SensorLuminosidade* sensor;
|
||||
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Config1: {
|
||||
if (data.size() < 6) return status;
|
||||
bool conectar = data[3] == 1;
|
||||
uint8_t endereco = data[4];
|
||||
int canalMux = (data[5] == 255) ? -1 : data[5];
|
||||
|
||||
if (conectar) {
|
||||
if (!jaExiste) {
|
||||
sensor = new SensorLuminosidade(Mod_ID, "sLUZ_" + String(idNum));
|
||||
} else {
|
||||
sensor = *it;
|
||||
}
|
||||
if (!sensor->Iniciado) {
|
||||
sensor->ID_Num = idNum;
|
||||
sensor->_Endereco = endereco;
|
||||
sensor->_CanalMUX = canalMux;
|
||||
sensor->Inicializar();
|
||||
if (!jaExiste) {
|
||||
lista.push_back(sensor);
|
||||
sensor->MostrarLog("Sensor de luminosidade adicionado via CAN: sLUZ_" + String(idNum));
|
||||
}
|
||||
}
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
} else {
|
||||
if (jaExiste) {
|
||||
sensor = *it;
|
||||
sensor->Desligar();
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
sensor->MostrarLog("Sensor de luminosidade removido via CAN: sLUZ_" + String(idNum));
|
||||
delete sensor;
|
||||
lista.erase(it);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool DebugMode = true;
|
||||
void MostrarLog(String mensagem) {
|
||||
if (DebugMode) {
|
||||
PrintTela("[LUZ " + _ID + "] " + mensagem);
|
||||
}
|
||||
}
|
||||
|
||||
Adafruit_TSL2591 tsl = Adafruit_TSL2591();
|
||||
|
||||
void AferirLuminosidade() {
|
||||
if (!Iniciado) return;
|
||||
|
||||
if (!I2CService::SolicitarAcessoI2C(ID_Num, _CanalMUX)) return;
|
||||
|
||||
uint32_t lum = tsl.getFullLuminosity();
|
||||
uint16_t ir = lum >> 16;
|
||||
uint16_t full = lum & 0xFFFF;
|
||||
float _lux = tsl.calculateLux(full, ir);
|
||||
|
||||
lux = _lux;
|
||||
infra = ir;
|
||||
total = full;
|
||||
|
||||
MostrarLog("Lux: " + String(lux) + ", Infra: " + String(infra) + ", Total: " + String(total));
|
||||
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
#ifndef SensorLuzUVModel
|
||||
#define SensorLuzUVModel
|
||||
|
||||
#include "SerialService.h"
|
||||
#include "Pinout.h"
|
||||
#include "Utils.h"
|
||||
|
||||
class SensorLuzUV {
|
||||
public:
|
||||
|
||||
SensorLuzUV(String _modID, String _id) {
|
||||
Mod_ID = _modID;
|
||||
_ID = _id;
|
||||
}
|
||||
|
||||
String Mod_ID = "";
|
||||
String _ID;
|
||||
int ID_Num;
|
||||
PinoModel _pino;
|
||||
|
||||
double tensao = 0;
|
||||
double uv_index = -1;
|
||||
|
||||
bool Iniciado = false;
|
||||
bool Checando = false;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
MostrarLog("Sensor já inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
_pino.Conectar();
|
||||
Iniciado = _pino.Definido();
|
||||
|
||||
MostrarLog(Iniciado ? "Sensor iniciado" : "Sensor nao iniciado");
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
MostrarLog("Sensor nao esta inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
_pino.Desconectar(); // Desconecta o pino
|
||||
|
||||
MostrarLog("Sensor Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
AferirUV();
|
||||
}
|
||||
|
||||
std::vector<uint8_t> MontarMensagemCAN(CanMessagePosicaoDados posicao) {
|
||||
std::vector<uint8_t> data;
|
||||
data.push_back(static_cast<uint8_t>(posicao));
|
||||
data.push_back(ID_Num);
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Status: {
|
||||
data.push_back(Iniciado ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CanMessagePosicaoDados::Dados1: {
|
||||
int16_t uvInt = static_cast<int16_t>(round(uv_index * 100.0f));
|
||||
data.push_back((uint8_t)(uvInt >> 8));
|
||||
data.push_back((uint8_t)(uvInt & 0xFF));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static std::vector<uint8_t> ConfigurarSensor(std::vector<SensorLuzUV*>& lista, std::vector<uint8_t>& data, const String& Mod_ID) {
|
||||
std::vector<uint8_t> status;
|
||||
if (data.size() < 2) return status;
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[0];
|
||||
uint8_t idNum = data[1];
|
||||
auto it = std::find_if(lista.begin(), lista.end(), [idNum](SensorLuzUV* s) { return s->ID_Num == idNum; });
|
||||
bool jaExiste = it != lista.end();
|
||||
SensorLuzUV* sensor;
|
||||
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Config1: {
|
||||
if (data.size() < 7) return status;
|
||||
bool conectar = data[3] == 1;
|
||||
TiposBarramentos tipoBarramento = (TiposBarramentos)data[4];
|
||||
int pino = data[5];
|
||||
int canalMux = (data[6] == 255) ? -1 : data[6];
|
||||
|
||||
if (conectar) {
|
||||
if (!jaExiste) sensor = new SensorLuzUV(Mod_ID, "sIUV_" + String(idNum));
|
||||
else sensor = *it;
|
||||
|
||||
if (!sensor->Iniciado) {
|
||||
sensor->ID_Num = idNum;
|
||||
sensor->_pino = PinoModel(pino, tipoBarramento, _INPUT, ANALOGICO, idNum, canalMux);
|
||||
sensor->Inicializar();
|
||||
if (!jaExiste) {
|
||||
lista.push_back(sensor);
|
||||
sensor->MostrarLog("Sensor de luz UV adicionado via CAN: sIUV_" + String(idNum));
|
||||
}
|
||||
}
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
} else {
|
||||
if (jaExiste) {
|
||||
sensor = *it;
|
||||
sensor->Desligar();
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
delete sensor;
|
||||
lista.erase(it);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool DegugMode = true;
|
||||
|
||||
void MostrarLog(String mensagem) {
|
||||
if (DegugMode) {
|
||||
PrintTela("[IUV " + _ID + "] " + mensagem);
|
||||
}
|
||||
}
|
||||
|
||||
const float Vs = 5.0f; // Tensao de alimentacao do sensor = 5V
|
||||
static constexpr float divisor = 10.0f / (10.0f + 5.6f); // R1 = 5K6, R2 = 10K
|
||||
static constexpr float vOffset = (2.9f / 2.24f); // v real / v ads
|
||||
|
||||
void AferirUV() {
|
||||
if (!Iniciado) return;
|
||||
int leitura = _pino.get();
|
||||
float Vadc = (float)leitura / 4095.0f * Vs;
|
||||
Vadc = Vadc * divisor * vOffset;
|
||||
|
||||
// Exemplo: divisor de 2:1 (tipo R1 = 5k6 / R2 = 10k), logo divisor = 0.641
|
||||
float Vout = Vadc / divisor;
|
||||
|
||||
uv_index = max(0.0f, (Vout - 0.99f) * 10.0f); // fórmula do datasheet
|
||||
MostrarLog("Leitura UV: " + String(leitura) + ", Tensao: " + String(Vadc) + ", Indice UV: " + String(uv_index));
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,355 @@
|
|||
#ifndef SensorQualidadeArModel
|
||||
#define SensorQualidadeArModel
|
||||
|
||||
#include "SerialService.h"
|
||||
#include "I2CService.h"
|
||||
#include "Utils.h"
|
||||
#include <vector>
|
||||
#include "ScioSense_ENS160.h"
|
||||
#include <Adafruit_AHTX0.h>
|
||||
|
||||
class SensorQualidadeAr {
|
||||
public:
|
||||
SensorQualidadeAr(String _modID, String _id) {
|
||||
Mod_ID = _modID;
|
||||
_ID = _id;
|
||||
}
|
||||
|
||||
String Mod_ID = "";
|
||||
String _ID;
|
||||
int ID_Num;
|
||||
byte _EnderecoENS = 0x53;
|
||||
byte _EnderecoAHT = 0x38;
|
||||
int _CanalMUX;
|
||||
|
||||
bool Iniciado = false;
|
||||
bool EnsIniciado = false;
|
||||
bool AhtIniciado = false;
|
||||
uint16_t tvoc_ppb;
|
||||
uint16_t eco2_ppm;
|
||||
uint8_t aqi;
|
||||
float temperatura;
|
||||
float umidade;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
MostrarLog("Sensor ja inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!I2CService::SolicitarAcessoI2C(ID_Num, _CanalMUX)) return;
|
||||
|
||||
bool EnsEncontrado = I2CService::VerificaEnderecoBarramento(_EnderecoENS);
|
||||
if (EnsEncontrado) {
|
||||
ens160 = new ScioSense_ENS160(ENS160_I2CADDR_1);
|
||||
ens160->begin();
|
||||
EnsIniciado = ens160->available();
|
||||
if (EnsIniciado) {
|
||||
MostrarLog("Versao ENS160: " +
|
||||
String(ens160->getMajorRev()) + "." +
|
||||
String(ens160->getMinorRev()) + "." +
|
||||
String(ens160->getBuild()));
|
||||
ens160->setMode(ENS160_OPMODE_STD);
|
||||
MostrarLog("ENS160 iniciado com sucesso!");
|
||||
}
|
||||
else {
|
||||
MostrarLog("Erro ao iniciar ENS160");
|
||||
}
|
||||
} else {
|
||||
MostrarLog("ENS160 nao iniciado, endereco " + String(_EnderecoENS) + " nao encontrado!");
|
||||
}
|
||||
|
||||
bool AhtEncontrado = I2CService::VerificaEnderecoBarramento(_EnderecoAHT);
|
||||
if (AhtEncontrado) {
|
||||
AhtIniciado = aht21.begin();
|
||||
MostrarLog("AHT21 iniciado com sucesso!");
|
||||
} else {
|
||||
MostrarLog("AHT21 nao iniciado, endereco " + String(_EnderecoENS) + " nao encontrado!");
|
||||
}
|
||||
|
||||
Iniciado = EnsIniciado || AhtIniciado;
|
||||
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
MostrarLog("Sensor nao esta inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ens160 != nullptr) {
|
||||
delete ens160;
|
||||
ens160 = nullptr;
|
||||
}
|
||||
|
||||
Iniciado = false;
|
||||
EnsIniciado = false;
|
||||
AhtIniciado = false;
|
||||
|
||||
if (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
while (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
vTaskDelay(10);
|
||||
}
|
||||
}
|
||||
|
||||
MostrarLog("Sensor Desligado");
|
||||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
if (!Iniciado) return;
|
||||
if (EnsIniciado) {
|
||||
AferirQualidadeAr();
|
||||
}
|
||||
if (AhtIniciado) {
|
||||
AferirTemperatura();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<uint8_t> MontarMensagemCAN(CanMessagePosicaoDados posicao) {
|
||||
std::vector<uint8_t> data;
|
||||
data.push_back(static_cast<uint8_t>(posicao));
|
||||
data.push_back(ID_Num);
|
||||
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Status: {
|
||||
data.push_back(Iniciado ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CanMessagePosicaoDados::Dados1: {
|
||||
data.push_back(tvoc_ppb >> 8); data.push_back(tvoc_ppb & 0xFF);
|
||||
data.push_back(eco2_ppm >> 8); data.push_back(eco2_ppm & 0xFF);
|
||||
data.push_back(aqi); // 1 byte
|
||||
break;
|
||||
}
|
||||
case CanMessagePosicaoDados::Dados2: {
|
||||
uint16_t tmp = temperatura * 100;
|
||||
uint16_t umd = umidade * 100;
|
||||
data.push_back(tmp >> 8); data.push_back(tmp & 0xFF);
|
||||
data.push_back(umd >> 8); data.push_back(umd & 0xFF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static std::vector<uint8_t> ConfigurarSensor(std::vector<SensorQualidadeAr*>& lista, std::vector<uint8_t>& data, const String& Mod_ID) {
|
||||
std::vector<uint8_t> status;
|
||||
if (data.size() < 2) return status;
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[0];
|
||||
uint8_t idNum = data[1];
|
||||
auto it = std::find_if(lista.begin(), lista.end(), [idNum](SensorQualidadeAr* s) { return s->ID_Num == idNum; });
|
||||
bool jaExiste = it != lista.end();
|
||||
SensorQualidadeAr* sensor;
|
||||
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Config1: {
|
||||
if (data.size() < 5) return status;
|
||||
bool conectar = data[3] == 1;
|
||||
int canalMux = (data[4] == 255) ? -1 : data[4];
|
||||
|
||||
if (conectar) {
|
||||
if (!jaExiste) {
|
||||
sensor = new SensorQualidadeAr(Mod_ID, "sQAR_" + String(idNum));
|
||||
} else {
|
||||
sensor = *it;
|
||||
}
|
||||
if (!sensor->Iniciado) {
|
||||
sensor->ID_Num = idNum;
|
||||
sensor->_CanalMUX = canalMux;
|
||||
sensor->Inicializar();
|
||||
if (!jaExiste) {
|
||||
lista.push_back(sensor);
|
||||
sensor->MostrarLog("Sensor de qualidade do ar adicionado via CAN: sQAR_" + String(idNum));
|
||||
}
|
||||
}
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
} else {
|
||||
if (jaExiste) {
|
||||
sensor = *it;
|
||||
sensor->Desligar();
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
sensor->MostrarLog("Sensor de qualidade do ar removido via CAN: sQAR_" + String(idNum));
|
||||
delete sensor;
|
||||
lista.erase(it);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool DebugMode = true;
|
||||
void MostrarLog(String mensagem) {
|
||||
if (DebugMode) {
|
||||
PrintTela("[QAR " + _ID + "] " + mensagem);
|
||||
}
|
||||
}
|
||||
|
||||
ScioSense_ENS160* ens160;
|
||||
Adafruit_AHTX0 aht21;
|
||||
|
||||
bool ENS160_EstaPronto() {
|
||||
uint8_t buffer[1];
|
||||
if (!I2CService::LeituraSegura(_EnderecoENS, buffer, 1, ENS160_REG_DATA_STATUS)) {
|
||||
MostrarLog("[ENS160] Falha na leitura do DATA_STATUS");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bit 1 = NEWDAT (dados prontos)
|
||||
return (buffer[0] & ENS160_DATA_STATUS_NEWDAT);
|
||||
}
|
||||
|
||||
TaskHandle_t handleLeitura = nullptr;
|
||||
|
||||
struct ENS160LeituraPayload {
|
||||
SensorQualidadeAr* sensor;
|
||||
TaskHandle_t taskParaNotificar;
|
||||
};
|
||||
|
||||
void AferirTemperatura() {
|
||||
if (!AhtIniciado) return;
|
||||
|
||||
if (!I2CService::SolicitarAcessoI2C(ID_Num, _CanalMUX)) return;
|
||||
|
||||
MostrarLog("Aferindo temperatura...");
|
||||
|
||||
ENS160LeituraPayload* payload = new ENS160LeituraPayload{
|
||||
.sensor = this,
|
||||
.taskParaNotificar = xTaskGetCurrentTaskHandle()
|
||||
};
|
||||
|
||||
handleLeitura = nullptr;
|
||||
|
||||
BaseType_t status = xTaskCreatePinnedToCore(
|
||||
TaskLeituraAHT21,
|
||||
"LeituraAHT21",
|
||||
4096,
|
||||
payload,
|
||||
1,
|
||||
&handleLeitura,
|
||||
APP_CPU_NUM
|
||||
);
|
||||
|
||||
if (status != pdPASS) {
|
||||
MostrarLog("❌ Falha ao criar task de leitura!");
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
return;
|
||||
}
|
||||
|
||||
BaseType_t sinal = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(200));
|
||||
|
||||
if (sinal == 0) {
|
||||
MostrarLog("⚠️ AHT21 travou no measure, abortando leitura");
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(10)); // dá tempo da task morrer sozinha
|
||||
eTaskState estado = eTaskGetState(handleLeitura);
|
||||
|
||||
if (estado != eDeleted && estado != eInvalid) {
|
||||
vTaskDelete(handleLeitura);
|
||||
}
|
||||
}
|
||||
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
handleLeitura = nullptr;
|
||||
}
|
||||
|
||||
void AferirQualidadeAr() {
|
||||
if (!EnsIniciado) return;
|
||||
|
||||
if (!I2CService::SolicitarAcessoI2C(ID_Num, _CanalMUX)) return;
|
||||
|
||||
MostrarLog("Aferindo qualidade do ar...");
|
||||
|
||||
ENS160LeituraPayload* payload = new ENS160LeituraPayload{
|
||||
.sensor = this,
|
||||
.taskParaNotificar = xTaskGetCurrentTaskHandle()
|
||||
};
|
||||
|
||||
handleLeitura = nullptr;
|
||||
|
||||
BaseType_t status = xTaskCreatePinnedToCore(
|
||||
TaskLeituraENS160,
|
||||
"LeituraENS160",
|
||||
4096,
|
||||
payload,
|
||||
1,
|
||||
&handleLeitura,
|
||||
APP_CPU_NUM
|
||||
);
|
||||
|
||||
if (status != pdPASS) {
|
||||
MostrarLog("❌ Falha ao criar task de leitura!");
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
return;
|
||||
}
|
||||
|
||||
BaseType_t sinal = ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(200));
|
||||
|
||||
if (sinal == 0) {
|
||||
MostrarLog("⚠️ ENS160 travou no measure, abortando leitura");
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(10)); // dá tempo da task morrer sozinha
|
||||
eTaskState estado = eTaskGetState(handleLeitura);
|
||||
|
||||
if (estado != eDeleted && estado != eInvalid) {
|
||||
vTaskDelete(handleLeitura);
|
||||
}
|
||||
}
|
||||
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
handleLeitura = nullptr;
|
||||
}
|
||||
|
||||
static void TaskLeituraENS160(void* parametro) {
|
||||
ENS160LeituraPayload* payload = static_cast<ENS160LeituraPayload*>(parametro);
|
||||
SensorQualidadeAr* sensor = payload->sensor;
|
||||
|
||||
if (!sensor->ENS160_EstaPronto()) {
|
||||
sensor->MostrarLog("❌ ENS160 não está pronto para medir.");
|
||||
}
|
||||
else {
|
||||
sensor->ens160->measure();
|
||||
if (sensor->ens160->available()) {
|
||||
sensor->tvoc_ppb = sensor->ens160->getTVOC();
|
||||
sensor->eco2_ppm = sensor->ens160->geteCO2();
|
||||
sensor->aqi = sensor->ens160->getAQI();
|
||||
sensor->MostrarLog("TVOC: " + String(sensor->tvoc_ppb) + " ppb, eCO2: " + String(sensor->eco2_ppm) + " ppm, AQI: " + String(sensor->aqi));
|
||||
} else {
|
||||
sensor->MostrarLog("Dados indisponiveis");
|
||||
}
|
||||
}
|
||||
|
||||
if (payload->taskParaNotificar != nullptr) {
|
||||
xTaskNotifyGive(payload->taskParaNotificar);
|
||||
}
|
||||
|
||||
delete payload;
|
||||
vTaskDelete(nullptr);
|
||||
}
|
||||
|
||||
static void TaskLeituraAHT21(void* parametro) {
|
||||
ENS160LeituraPayload* payload = static_cast<ENS160LeituraPayload*>(parametro);
|
||||
SensorQualidadeAr* sensor = payload->sensor;
|
||||
|
||||
sensors_event_t humidity, temp;
|
||||
sensor->aht21.getEvent(&humidity, &temp);
|
||||
sensor->temperatura = temp.temperature;
|
||||
sensor->umidade = humidity.relative_humidity;
|
||||
|
||||
sensor->MostrarLog("Temperatura: " + String(sensor->temperatura) + ", Umidade: " + String(sensor->umidade));
|
||||
|
||||
if (payload->taskParaNotificar != nullptr) {
|
||||
xTaskNotifyGive(payload->taskParaNotificar);
|
||||
}
|
||||
|
||||
delete payload;
|
||||
vTaskDelete(nullptr);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -40,12 +40,7 @@ class SensorTemperatura {
|
|||
|
||||
Iniciado = _pino.Definido();
|
||||
|
||||
if (Iniciado) {
|
||||
MostrarLog("Sensor iniciado");
|
||||
}
|
||||
else {
|
||||
MostrarLog("Sensor nao iniciado");
|
||||
}
|
||||
MostrarLog(Iniciado ? "Sensor iniciado" : "Sensor nao iniciado");
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
|
|
@ -94,10 +89,11 @@ class SensorTemperatura {
|
|||
SensorTemperatura* sensor;
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Config1: {
|
||||
if (data.size() < 6) return status;
|
||||
if (data.size() < 7) return status;
|
||||
bool conectar = data[3] == 1;
|
||||
TiposBarramentos tipoBarramento = (TiposBarramentos)data[4];
|
||||
int pino = data[5];
|
||||
int canalMux = (data[6] == 255) ? -1 : data[6];
|
||||
if (conectar) {
|
||||
if (!jaExiste) {
|
||||
sensor = new SensorTemperatura(Mod_ID, "sTMP_" + String(idNum));
|
||||
|
|
@ -107,7 +103,7 @@ class SensorTemperatura {
|
|||
}
|
||||
if (!sensor->Iniciado) {
|
||||
sensor->ID_Num = idNum;
|
||||
sensor->_pino = PinoModel(pino, tipoBarramento, _INPUT, ANALOGICO);
|
||||
sensor->_pino = PinoModel(pino, tipoBarramento, _INPUT, ANALOGICO, idNum, canalMux);
|
||||
sensor->Inicializar();
|
||||
if (!jaExiste) {
|
||||
lista.push_back(sensor);
|
||||
|
|
@ -144,7 +140,7 @@ class SensorTemperatura {
|
|||
|
||||
void AferirTemperatura() {
|
||||
if (Iniciado) {
|
||||
leitura = _pino.get(3);
|
||||
leitura = _pino.get(1);
|
||||
//leitura = filtro.updateEstimate(leitura);
|
||||
temperatura = CalcularTemperatura((float)leitura);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,172 @@
|
|||
#ifndef SensorTemperaturaSHTModel
|
||||
#define SensorTemperaturaSHTModel
|
||||
|
||||
#include "SerialService.h"
|
||||
#include "I2CService.h"
|
||||
#include "Utils.h"
|
||||
#include <vector>
|
||||
#include <Adafruit_SHT4x.h>
|
||||
|
||||
class SensorTemperaturaSHT {
|
||||
public:
|
||||
SensorTemperaturaSHT(String _modID, String _id) {
|
||||
Mod_ID = _modID;
|
||||
_ID = _id;
|
||||
}
|
||||
|
||||
String Mod_ID = "";
|
||||
String _ID;
|
||||
int ID_Num;
|
||||
byte _Endereco = 0x44;
|
||||
int _CanalMUX;
|
||||
|
||||
bool Iniciado = false;
|
||||
float temperatura = 0;
|
||||
float umidade = 0;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
MostrarLog("Sensor ja inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!I2CService::SolicitarAcessoI2C(ID_Num, _CanalMUX)) return;
|
||||
|
||||
bool encontrado = I2CService::VerificaEnderecoBarramento(_Endereco);
|
||||
if (encontrado) {
|
||||
Iniciado = sht41.begin();
|
||||
if (Iniciado) {
|
||||
sht41.setPrecision(SHT4X_HIGH_PRECISION);
|
||||
sht41.setHeater(SHT4X_NO_HEATER);
|
||||
MostrarLog("Sensor iniciado no canal " + String(_CanalMUX));
|
||||
}
|
||||
else {
|
||||
PrintTela("Sensor nao iniciado!");
|
||||
}
|
||||
} else {
|
||||
Iniciado = false;
|
||||
MostrarLog("Sensor nao iniciado, endereco " + String(_Endereco) + " nao encontrado!");
|
||||
}
|
||||
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
MostrarLog("Sensor nao esta inicializado");
|
||||
return;
|
||||
}
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
if (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
while (I2CService::QuemEstaUsando() == ID_Num) {
|
||||
vTaskDelay(10);
|
||||
}
|
||||
}
|
||||
|
||||
MostrarLog("Sensor Desligado");
|
||||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
if (!Iniciado) return;
|
||||
AferirTemperatura();
|
||||
}
|
||||
|
||||
std::vector<uint8_t> MontarMensagemCAN(CanMessagePosicaoDados posicao) {
|
||||
std::vector<uint8_t> data;
|
||||
data.push_back(static_cast<uint8_t>(posicao));
|
||||
data.push_back(ID_Num);
|
||||
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Status: {
|
||||
data.push_back(Iniciado ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
case CanMessagePosicaoDados::Dados1: {
|
||||
uint16_t tmp = temperatura * 100;
|
||||
uint16_t umd = umidade * 100;
|
||||
data.push_back(tmp >> 8); data.push_back(tmp & 0xFF);
|
||||
data.push_back(umd >> 8); data.push_back(umd & 0xFF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static std::vector<uint8_t> ConfigurarSensor(std::vector<SensorTemperaturaSHT*>& lista, std::vector<uint8_t>& data, const String& Mod_ID) {
|
||||
std::vector<uint8_t> status;
|
||||
if (data.size() < 2) return status;
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[0];
|
||||
uint8_t idNum = data[1];
|
||||
auto it = std::find_if(lista.begin(), lista.end(), [idNum](SensorTemperaturaSHT* s) { return s->ID_Num == idNum; });
|
||||
bool jaExiste = it != lista.end();
|
||||
SensorTemperaturaSHT* sensor;
|
||||
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Config1: {
|
||||
if (data.size() < 5) return status;
|
||||
bool conectar = data[3] == 1;
|
||||
int canalMux = (data[4] == 255) ? -1 : data[4];
|
||||
|
||||
if (conectar) {
|
||||
if (!jaExiste) {
|
||||
sensor = new SensorTemperaturaSHT(Mod_ID, "sSHT_" + String(idNum));
|
||||
} else {
|
||||
sensor = *it;
|
||||
}
|
||||
if (!sensor->Iniciado) {
|
||||
sensor->ID_Num = idNum;
|
||||
sensor->_CanalMUX = canalMux;
|
||||
sensor->Inicializar();
|
||||
if (!jaExiste) {
|
||||
lista.push_back(sensor);
|
||||
sensor->MostrarLog("Sensor de temperatura e umidade adicionado via CAN: sSHT_" + String(idNum));
|
||||
}
|
||||
}
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
} else {
|
||||
if (jaExiste) {
|
||||
sensor = *it;
|
||||
sensor->Desligar();
|
||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||
sensor->MostrarLog("Sensor de temperatura e umidade removido via CAN: sSHT_" + String(idNum));
|
||||
delete sensor;
|
||||
lista.erase(it);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool DebugMode = true;
|
||||
void MostrarLog(String mensagem) {
|
||||
if (DebugMode) {
|
||||
PrintTela("[SHT " + _ID + "] " + mensagem);
|
||||
}
|
||||
}
|
||||
|
||||
Adafruit_SHT4x sht41;
|
||||
|
||||
void AferirTemperatura() {
|
||||
if (!Iniciado) return;
|
||||
|
||||
if (!I2CService::SolicitarAcessoI2C(ID_Num, _CanalMUX)) return;
|
||||
|
||||
sensors_event_t temp, hum;
|
||||
sht41.getEvent(&hum, &temp);
|
||||
|
||||
temperatura = temp.temperature;
|
||||
umidade = hum.relative_humidity;
|
||||
|
||||
MostrarLog("Temperatura: " + String(temperatura) + ", Umidade: " + String(umidade));
|
||||
|
||||
I2CService::LiberarAcessoI2C(ID_Num);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -45,7 +45,7 @@ PinoModel _pinoSDA = PinoModel(21, CONTROLADOR, _INPUT);
|
|||
PinoModel _pinoSCL = PinoModel(22, CONTROLADOR, _INPUT);
|
||||
|
||||
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperatura;
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperaturaNTC;
|
||||
std::vector<SensorCorrente*> listaSensoresCorrente;
|
||||
std::vector<Sinaleiro*> listaSinaleiros;
|
||||
std::vector<Rele*> listaReles;
|
||||
|
|
@ -121,7 +121,7 @@ void enviarDadosSensores() {
|
|||
PrintTela("Atualizando dados dos sensores...");
|
||||
|
||||
// Aferir dados dos sensores
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
sensor->AferirTemperatura();
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ String MontarMensagemSensores() {
|
|||
|
||||
// Array JSON para sensores de temperatura
|
||||
JsonArray sensoresTemperaturaArray = jsonDoc.createNestedArray("SensoresTemperatura");
|
||||
for (const auto* sensor : listaSensoresTemperatura) {
|
||||
for (const auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
JsonObject sensorData = sensoresTemperaturaArray.createNestedObject();
|
||||
sensorData["Id"] = sensor->_ID;
|
||||
sensorData["Iniciado"] = sensor->Iniciado;
|
||||
|
|
@ -278,8 +278,8 @@ void ProcessarCfg(ProtocoloSerial Mensagem) {
|
|||
String config = Partes[2];
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
SensorTemperatura::InicializarLista(listaSensoresTemperatura, config, Mod_ID);
|
||||
case sNTC: {
|
||||
SensorTemperatura::InicializarLista(listaSensoresTemperaturaNTC, config, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sCOR: {
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ private:
|
|||
yield();
|
||||
vTaskDelay(500);
|
||||
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloDHT22(t, h, hic)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloDHT22(t, h, hic)));
|
||||
firstMilis = millis();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ private:
|
|||
Tc = T - 273.15;
|
||||
Tf = Tc * 9 / 5 + 32;
|
||||
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ private:
|
|||
yield();
|
||||
vTaskDelay(500);
|
||||
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloDHT22(t, h, hic)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloDHT22(t, h, hic)));
|
||||
firstMilis = millis();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class SensorTemperatura {
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
PinoModel _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -92,7 +92,7 @@ class SensorTemperatura {
|
|||
void AferirTemperatura() {
|
||||
int leitura = _pino.get();
|
||||
float leituraNormalizada = tempKalman->updateEstimate(leitura);
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -1089,7 +1089,7 @@ void ProcessarCfg(ProtocoloSerial Mensagem) {
|
|||
int pino = Partes[7].toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
if (Conectar) {
|
||||
|
|
@ -1233,7 +1233,7 @@ void ProcessarReq(ProtocoloSerial Mensagem) {
|
|||
S_Code componente = (S_Code)Partes[1].toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
_sensor->AferirTemperatura();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class SensorTemperatura {
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
PinoModel _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -92,7 +92,7 @@ class SensorTemperatura {
|
|||
void AferirTemperatura() {
|
||||
int leitura = _pino.get();
|
||||
float leituraNormalizada = tempKalman->updateEstimate(leitura);
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -1185,7 +1185,7 @@ void ProcessarCfg(ProtocoloSerial Mensagem) {
|
|||
int pino = Partes[7].toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
if (Conectar) {
|
||||
|
|
@ -1334,7 +1334,7 @@ void ProcessarReq(ProtocoloSerial Mensagem) {
|
|||
S_Code componente = (S_Code)Partes[1].toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
_sensor->AferirTemperatura();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -36,20 +36,20 @@ PinoModel _pinoSCL = PinoModel(22, CONTROLADOR, _INPUT);
|
|||
|
||||
|
||||
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperatura;
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperaturaNTC;
|
||||
// Função para inicializar os sensores de temperatura com IDs e pinos específicos
|
||||
void inicializarSensoresTemperatura(String configSensores) {
|
||||
// Verifica se há sensores já na lista
|
||||
if (!listaSensoresTemperatura.empty()) {
|
||||
if (!listaSensoresTemperaturaNTC.empty()) {
|
||||
PrintTela("Limpando lista de sensores de temperatura existente...");
|
||||
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
sensor->Desligar(); // Desliga cada sensor antes de remover
|
||||
PrintTela("Sensor de Temperatura " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
|
||||
listaSensoresTemperatura.clear(); // Limpa a lista após desligar todos os itens
|
||||
listaSensoresTemperaturaNTC.clear(); // Limpa a lista após desligar todos os itens
|
||||
}
|
||||
|
||||
if (configSensores.length() > 0) {
|
||||
|
|
@ -66,7 +66,7 @@ void inicializarSensoresTemperatura(String configSensores) {
|
|||
SensorTemperatura* sensor = new SensorTemperatura(Mod_ID, id);
|
||||
sensor->_pino = PinoModel(pino, pinoB, _INPUT, ANALOGICO);
|
||||
sensor->Inicializar();
|
||||
listaSensoresTemperatura.push_back(sensor);
|
||||
listaSensoresTemperaturaNTC.push_back(sensor);
|
||||
PrintTela("Sensor de temperatura " + id + " inicializado no pino " + String(pino));
|
||||
} else {
|
||||
PrintTela("Configuração inválida para sensor de temperatura: " + config);
|
||||
|
|
@ -284,7 +284,7 @@ void enviarDadosSensores() {
|
|||
PrintTela("Atualizando dados dos sensores...");
|
||||
|
||||
// Aferir dados dos sensores
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
sensor->AferirTemperatura();
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ String MontarMensagemSensores() {
|
|||
|
||||
// Array JSON para sensores de temperatura
|
||||
JsonArray sensoresTemperaturaArray = jsonDoc.createNestedArray("SensoresTemperatura");
|
||||
for (const auto* sensor : listaSensoresTemperatura) {
|
||||
for (const auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
JsonObject sensorData = sensoresTemperaturaArray.createNestedObject();
|
||||
sensorData["Id"] = sensor->_ID;
|
||||
sensorData["Iniciado"] = sensor->Iniciado;
|
||||
|
|
@ -433,7 +433,7 @@ void ProcessarCfg(ProtocoloSerial Mensagem) {
|
|||
String config = Partes[2];
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
inicializarSensoresTemperatura(config);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ PinoModel _pinoSDA = PinoModel(21, CONTROLADOR, _INPUT);
|
|||
PinoModel _pinoSCL = PinoModel(22, CONTROLADOR, _INPUT);
|
||||
|
||||
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperatura;
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperaturaNTC;
|
||||
std::vector<SensorCorrente*> listaSensoresCorrente;
|
||||
std::vector<Sinaleiro*> listaSinaleiros;
|
||||
std::vector<Rele*> listaReles;
|
||||
|
|
@ -121,7 +121,7 @@ void enviarDadosSensores() {
|
|||
PrintTela("Atualizando dados dos sensores...");
|
||||
|
||||
// Aferir dados dos sensores
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
sensor->AferirTemperatura();
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ String MontarMensagemSensores() {
|
|||
|
||||
// Array JSON para sensores de temperatura
|
||||
JsonArray sensoresTemperaturaArray = jsonDoc.createNestedArray("SensoresTemperatura");
|
||||
for (const auto* sensor : listaSensoresTemperatura) {
|
||||
for (const auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
JsonObject sensorData = sensoresTemperaturaArray.createNestedObject();
|
||||
sensorData["Id"] = sensor->_ID;
|
||||
sensorData["Iniciado"] = sensor->Iniciado;
|
||||
|
|
@ -278,8 +278,8 @@ void ProcessarCfg(ProtocoloSerial Mensagem) {
|
|||
String config = Partes[2];
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
SensorTemperatura::InicializarLista(listaSensoresTemperatura, config, Mod_ID);
|
||||
case sNTC: {
|
||||
SensorTemperatura::InicializarLista(listaSensoresTemperaturaNTC, config, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sCOR: {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ PinoModel _pinoSDA = PinoModel(1, CONTROLADOR, _INPUT);
|
|||
PinoModel _pinoSCL = PinoModel(2, CONTROLADOR, _INPUT);
|
||||
|
||||
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperatura;
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperaturaNTC;
|
||||
std::vector<SensorCorrente*> listaSensoresCorrente;
|
||||
std::vector<Sinaleiro*> listaSinaleiros;
|
||||
std::vector<Rele*> listaReles;
|
||||
|
|
@ -133,7 +133,7 @@ void enviarDadosSensores() {
|
|||
//changeWifiStatus(false);
|
||||
|
||||
// Aferir dados dos sensores
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
sensor->AferirTemperatura();
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ String MontarMensagemSensores() {
|
|||
|
||||
// Array JSON para sensores de temperatura
|
||||
JsonArray sensoresTemperaturaArray = jsonDoc.createNestedArray("SensoresTemperatura");
|
||||
for (const auto* sensor : listaSensoresTemperatura) {
|
||||
for (const auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
JsonObject sensorData = sensoresTemperaturaArray.createNestedObject();
|
||||
sensorData["Id"] = sensor->_ID;
|
||||
sensorData["Iniciado"] = sensor->Iniciado;
|
||||
|
|
@ -310,8 +310,8 @@ void ProcessarCfg(ProtocoloSerial Mensagem) {
|
|||
String config = Partes[2];
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
SensorTemperatura::InicializarLista(listaSensoresTemperatura, config, Mod_ID);
|
||||
case sNTC: {
|
||||
SensorTemperatura::InicializarLista(listaSensoresTemperaturaNTC, config, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sCOR: {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ PinoModel _pinoSDA = PinoModel(1, CONTROLADOR, _INPUT);
|
|||
PinoModel _pinoSCL = PinoModel(2, CONTROLADOR, _INPUT);
|
||||
|
||||
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperatura;
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperaturaNTC;
|
||||
std::vector<SensorCorrente*> listaSensoresCorrente;
|
||||
std::vector<Sinaleiro*> listaSinaleiros;
|
||||
std::vector<Rele*> listaReles;
|
||||
|
|
@ -134,7 +134,7 @@ void enviarDadosSensores() {
|
|||
//changeWifiStatus(false);
|
||||
|
||||
// Aferir dados dos sensores
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
sensor->AferirTemperatura();
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ String MontarMensagemSensores() {
|
|||
|
||||
// Array JSON para sensores de temperatura
|
||||
JsonArray sensoresTemperaturaArray = jsonDoc.createNestedArray("SensoresTemperatura");
|
||||
for (const auto* sensor : listaSensoresTemperatura) {
|
||||
for (const auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
JsonObject sensorData = sensoresTemperaturaArray.createNestedObject();
|
||||
sensorData["Id"] = sensor->_ID;
|
||||
sensorData["Iniciado"] = sensor->Iniciado;
|
||||
|
|
@ -311,8 +311,8 @@ void ProcessarCfg(ProtocoloSerial Mensagem) {
|
|||
String config = Partes[2];
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
SensorTemperatura::InicializarLista(listaSensoresTemperatura, config, Mod_ID);
|
||||
case sNTC: {
|
||||
SensorTemperatura::InicializarLista(listaSensoresTemperaturaNTC, config, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sCOR: {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ int latenciaLoop = 0;
|
|||
int qtdEnviosStatus = 0;
|
||||
int maxEnviosStatus = 5;
|
||||
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperatura;
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperaturaNTC;
|
||||
std::vector<SensorCorrente*> listaSensoresCorrente;
|
||||
std::vector<Sinaleiro*> listaSinaleiros;
|
||||
std::vector<Rele*> listaReles;
|
||||
|
|
@ -104,7 +104,7 @@ void enviarDadosSensores() {
|
|||
|
||||
bool enviarStatus = qtdEnviosStatus >= maxEnviosStatus;
|
||||
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
if (sensor != nullptr) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
|
|
@ -256,8 +256,8 @@ void ProcessarCfg(std::vector<uint8_t> data) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case sTMP: {
|
||||
_chkRx = SensorTemperatura::ConfigurarSensor(listaSensoresTemperatura, data, Mod_ID);
|
||||
case sNTC: {
|
||||
_chkRx = SensorTemperatura::ConfigurarSensor(listaSensoresTemperaturaNTC, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sCOR: {
|
||||
|
|
@ -338,12 +338,12 @@ void LimparListasComponentes() {
|
|||
}
|
||||
listaSensoresCorrente.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de Temperatura " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresTemperatura.clear();
|
||||
listaSensoresTemperaturaNTC.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresIMU) {
|
||||
sensor->Desligar();
|
||||
|
|
@ -355,8 +355,8 @@ void LimparListasComponentes() {
|
|||
|
||||
S_Code DetectarComponente(uint8_t idNum) {
|
||||
if (idNum == canService.ID_Num_sMOD) return S_Code::sMOD;
|
||||
for (auto* s : listaSensoresTemperatura) {
|
||||
if (s->ID_Num == idNum) return S_Code::sTMP;
|
||||
for (auto* s : listaSensoresTemperaturaNTC) {
|
||||
if (s->ID_Num == idNum) return S_Code::sNTC;
|
||||
}
|
||||
for (auto* s : listaSensoresCorrente) {
|
||||
if (s->ID_Num == idNum) return S_Code::sCOR;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ int latenciaLoop = 0;
|
|||
int qtdEnviosStatus = 0;
|
||||
int maxEnviosStatus = 5;
|
||||
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperatura;
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperaturaNTC;
|
||||
std::vector<SensorCorrente*> listaSensoresCorrente;
|
||||
std::vector<Sinaleiro*> listaSinaleiros;
|
||||
std::vector<Rele*> listaReles;
|
||||
|
|
@ -51,7 +51,6 @@ void inicializarDependenciasI2C() {
|
|||
I2CService::IniciarI2C();
|
||||
I2CService::IniciarMUX();
|
||||
I2CService::IniciarMCP();
|
||||
I2CService::IniciarADS();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
|
|
@ -119,7 +118,7 @@ void enviarDadosSensores(uint8_t id_num, CanMessagePosicaoDados posicao) {
|
|||
EnviarDadosCAN(loraService.MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
|
|
@ -309,8 +308,8 @@ void ProcessarCfg(std::vector<uint8_t> data) {
|
|||
else {
|
||||
componente = (S_Code)data[2];
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
_chkRx = SensorTemperatura::ConfigurarSensor(listaSensoresTemperatura, data, Mod_ID);
|
||||
case sNTC: {
|
||||
_chkRx = SensorTemperatura::ConfigurarSensor(listaSensoresTemperaturaNTC, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sCOR: {
|
||||
|
|
@ -396,12 +395,12 @@ void LimparListasComponentes() {
|
|||
}
|
||||
listaSensoresCorrente.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresTemperatura) {
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de Temperatura " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresTemperatura.clear();
|
||||
listaSensoresTemperaturaNTC.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresIMU) {
|
||||
sensor->Desligar();
|
||||
|
|
@ -415,8 +414,8 @@ S_Code DetectarComponente(uint8_t idNum) {
|
|||
if (idNum == canService.ID_Num_sMOD) return S_Code::sMOD;
|
||||
if (idNum == canService.ID_Num_sTOD) return S_Code::sTOD;
|
||||
if (idNum == canService.ID_Num_sLRA) return S_Code::sLRA;
|
||||
for (auto* s : listaSensoresTemperatura) {
|
||||
if (s->ID_Num == idNum) return S_Code::sTMP;
|
||||
for (auto* s : listaSensoresTemperaturaNTC) {
|
||||
if (s->ID_Num == idNum) return S_Code::sNTC;
|
||||
}
|
||||
for (auto* s : listaSensoresCorrente) {
|
||||
if (s->ID_Num == idNum) return S_Code::sCOR;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,637 @@
|
|||
// Dispositivo: Sensoriamento
|
||||
// Versão Firmware: 18
|
||||
// Ultima atualização: 13/05/2025
|
||||
// Atualização: Implementado torre de sensores
|
||||
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\CanService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\LoRaService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\EepromService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\I2CService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Utils.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Pinout.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorTemperaturaModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorCorrenteModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorIMUModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SinaleiroModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\ReleModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\ServoFreioModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorGasModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorTemperaturaSHTModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorLuminosidadeModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorLuzUVModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorQualidadeArModel.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorChuvaModel.h"
|
||||
|
||||
|
||||
// Configurações do CAN
|
||||
uint8_t CanID = 0x11;
|
||||
CanService canService(CanID);
|
||||
|
||||
LoRaService loraService(&canService);
|
||||
|
||||
#define D_Code Sen
|
||||
int VERSION = 18;
|
||||
String Mod_ID = "Sen";
|
||||
|
||||
#define _pinoLED RGB_BUILTIN
|
||||
|
||||
bool Conectado = false;
|
||||
bool Conectar = false;
|
||||
|
||||
int _TaxaAmostragem = 1000;
|
||||
volatile bool RequisitarDados = false;
|
||||
int latenciaLoop = 0;
|
||||
int qtdEnviosStatus = 0;
|
||||
int maxEnviosStatus = 5;
|
||||
|
||||
std::vector<SensorTemperatura*> listaSensoresTemperaturaNTC;
|
||||
std::vector<SensorCorrente*> listaSensoresCorrente;
|
||||
std::vector<Sinaleiro*> listaSinaleiros;
|
||||
std::vector<Rele*> listaReles;
|
||||
std::vector<ServoFreio*> listaServoFreios;
|
||||
std::vector<SensorIMU*> listaSensoresIMU;
|
||||
std::vector<SensorGas*> listaSensoresGas;
|
||||
std::vector<SensorTemperaturaSHT*> listaSensoresTemperaturaSHT;
|
||||
std::vector<SensorLuminosidade*> listaSensoresLuminosidade;
|
||||
std::vector<SensorLuzUV*> listaSensoresLuzUV;
|
||||
std::vector<SensorQualidadeAr*> listaSensoresQualidadeAr;
|
||||
std::vector<SensorChuva*> listaSensoresChuva;
|
||||
|
||||
void inicializarDependenciasI2C() {
|
||||
I2CService::IniciarI2C();
|
||||
I2CService::IniciarMUX();
|
||||
I2CService::IniciarMCP();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
delay(5000);
|
||||
|
||||
inicializarDependenciasI2C();
|
||||
|
||||
// Registrar callback para processar mensagens CAN recebidas
|
||||
canService.setReceiveCallback([](int packetSize, int senderId, CanMessagePosicaoDados posicao, byte* data, int dataLength) {
|
||||
std::vector<uint8_t> fullData;
|
||||
fullData.push_back(static_cast<uint8_t>(posicao)); // Primeiro byte é sempre a posicao
|
||||
for (int i = 0; i < dataLength; i++) {
|
||||
fullData.push_back(data[i]);
|
||||
}
|
||||
|
||||
ProcessarFrameCAN(posicao, fullData);
|
||||
});
|
||||
|
||||
canService.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (!RequisitarDados) {
|
||||
enviarLogsPeriodicamente();
|
||||
}
|
||||
|
||||
delay(1);
|
||||
}
|
||||
|
||||
// Função para enviar logs do sensor periodicamente
|
||||
unsigned long ultimoEnvioLogs = 0;
|
||||
const unsigned long intervaloEnvioLogs = 1000; // 1 segundo
|
||||
void enviarLogsPeriodicamente() {
|
||||
unsigned long tempoAtual = millis();
|
||||
// Verifica se o intervalo de 5 segundos já passou
|
||||
if (tempoAtual - ultimoEnvioLogs >= intervaloEnvioLogs) {
|
||||
ultimoEnvioLogs = tempoAtual; // Atualiza o tempo do último envio
|
||||
|
||||
enviarDadosSensores(canService.ID_Num_sTOD, CanMessagePosicaoDados::DadosAll);
|
||||
}
|
||||
}
|
||||
|
||||
void enviarDadosSensores(uint8_t id_num, CanMessagePosicaoDados posicao) {
|
||||
if (Conectado || posicao == CanMessagePosicaoDados::Status) {
|
||||
unsigned long startLoop = millis();
|
||||
|
||||
bool enviarStatus = qtdEnviosStatus >= maxEnviosStatus && posicao != CanMessagePosicaoDados::Status;
|
||||
bool todosDados = posicao == CanMessagePosicaoDados::DadosAll;
|
||||
bool todosIDs = id_num == canService.ID_Num_sTOD;
|
||||
|
||||
if (id_num == canService.ID_Num_sMOD) {
|
||||
EnviarDadosCAN(canService.MontarFrameReqStatusMod(D_Code, Conectado, VERSION));
|
||||
return;
|
||||
}
|
||||
|
||||
if (id_num == canService.ID_Num_sLRA) {
|
||||
EnviarDadosCAN(loraService.MontarMensagemCAN(posicao));
|
||||
return;
|
||||
}
|
||||
|
||||
PrintTela("Atualizando dados dos sensores...");
|
||||
|
||||
if (todosIDs && enviarStatus) {
|
||||
EnviarDadosCAN(canService.MontarFrameReqStatusMod(D_Code, Conectado, VERSION));
|
||||
EnviarDadosCAN(loraService.MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresCorrente) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados2));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSinaleiros) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaReles) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaServoFreios) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresIMU) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (todosDados) {
|
||||
if (sensor->MpuIniciado) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
if (sensor->BmpIniciado) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados2));
|
||||
}
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresGas) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresTemperaturaSHT) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresLuminosidade) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresLuzUV) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresQualidadeAr) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados2));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* sensor : listaSensoresChuva) {
|
||||
if (sensor != nullptr && (todosIDs || sensor->ID_Num == id_num)) {
|
||||
sensor->RequisitarDados();
|
||||
if (enviarStatus) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status));
|
||||
}
|
||||
if (sensor->Iniciado) {
|
||||
if (todosDados) {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(CanMessagePosicaoDados::Dados1));
|
||||
}
|
||||
else {
|
||||
EnviarDadosCAN(sensor->MontarMensagemCAN(posicao));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (enviarStatus) {
|
||||
qtdEnviosStatus = 0;
|
||||
}
|
||||
else {
|
||||
qtdEnviosStatus++;
|
||||
}
|
||||
|
||||
latenciaLoop = millis() - startLoop;
|
||||
|
||||
if (posicao == CanMessagePosicaoDados::DadosAll) {
|
||||
EnviarDadosCAN(canService.MontarFrameReqDadosFim(latenciaLoop));
|
||||
}
|
||||
|
||||
PrintTela("[SEN] Ciclo concluido, latencia de loop: " + String(latenciaLoop));
|
||||
}
|
||||
}
|
||||
|
||||
void EnviarDadosCAN(std::vector<uint8_t> data) {
|
||||
if (data.size() > 2) {
|
||||
canService.adicionarMensagemFila(data);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarFrameCAN(CanMessagePosicaoDados posicao, std::vector<uint8_t> data) {
|
||||
if (data.size() < 1) return;
|
||||
|
||||
F_Code funcao = canService.FuncaoPorPosicao(posicao);
|
||||
|
||||
switch (funcao) {
|
||||
case F_Code::ReqTx: ProcessarReq(data); break;
|
||||
case F_Code::CmdTx: ProcessarCmd(data); break;
|
||||
case F_Code::CfgTx: ProcessarCfg(data); break;
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarReq(std::vector<uint8_t> data) {
|
||||
if (data.size() < 2) return;
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[0];
|
||||
uint8_t id = data[1];
|
||||
enviarDadosSensores(id, posicao);
|
||||
}
|
||||
|
||||
void ProcessarCfg(std::vector<uint8_t> data) {
|
||||
if (data.size() < 4) return;
|
||||
std::vector<uint8_t> _chkRx;
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[0];
|
||||
uint8_t id = data[1];
|
||||
S_Code componente = DetectarComponente(id);
|
||||
if (componente == S_Code::sMOD) {
|
||||
switch (posicao) {
|
||||
case CanMessagePosicaoDados::Config1: {
|
||||
if (data.size() < 8) return;
|
||||
bool conectar = data[2] == 1;
|
||||
int taxa = data[3] * 10;
|
||||
bool requisitar = data[4] == 1;
|
||||
loraService.AddressBase = data[5];
|
||||
int pinoSDA = data[6];
|
||||
int pinoSCL = data[7];
|
||||
|
||||
_TaxaAmostragem = taxa;
|
||||
RequisitarDados = requisitar;
|
||||
|
||||
LimparListasComponentes();
|
||||
|
||||
if (pinoSDA != PINO_INVALIDO && pinoSCL != PINO_INVALIDO) {
|
||||
if (I2CService::DefinirPinos(pinoSDA, pinoSCL) || !I2CService::I2CIniciado) {
|
||||
inicializarDependenciasI2C();
|
||||
}
|
||||
}
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
|
||||
Conectado = conectar;
|
||||
_chkRx = canService.MontarFrameReqStatusMod(D_Code, Conectado, VERSION);
|
||||
|
||||
PrintTela("[SEN] Configuracao do modulo concluida");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (componente == S_Code::sLRA) {
|
||||
_chkRx = loraService.ConfigurarModulo(data);
|
||||
}
|
||||
else {
|
||||
componente = (S_Code)data[2];
|
||||
switch (componente) {
|
||||
case sNTC: {
|
||||
_chkRx = SensorTemperatura::ConfigurarSensor(listaSensoresTemperaturaNTC, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sCOR: {
|
||||
_chkRx = SensorCorrente::ConfigurarSensor(listaSensoresCorrente, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sLED: {
|
||||
_chkRx = Sinaleiro::ConfigurarSinaleiro(listaSinaleiros, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sRLE: {
|
||||
_chkRx = Rele::ConfigurarRele(listaReles, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sFRO: {
|
||||
_chkRx = ServoFreio::ConfigurarServo(listaServoFreios, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sIMU: {
|
||||
_chkRx = SensorIMU::ConfigurarSensor(listaSensoresIMU, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sGAS: {
|
||||
_chkRx = SensorGas::ConfigurarSensor(listaSensoresGas, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sSHT: {
|
||||
_chkRx = SensorTemperaturaSHT::ConfigurarSensor(listaSensoresTemperaturaSHT, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sLUZ: {
|
||||
_chkRx = SensorLuminosidade::ConfigurarSensor(listaSensoresLuminosidade, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sIUV: {
|
||||
_chkRx = SensorLuzUV::ConfigurarSensor(listaSensoresLuzUV, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sQAR: {
|
||||
_chkRx = SensorQualidadeAr::ConfigurarSensor(listaSensoresQualidadeAr, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
case sCHV: {
|
||||
_chkRx = SensorChuva::ConfigurarSensor(listaSensoresChuva, data, Mod_ID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnviarDadosCAN(_chkRx);
|
||||
}
|
||||
|
||||
void ProcessarCmd(std::vector<uint8_t> data) {
|
||||
if (data.size() < 2) return;
|
||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[0];
|
||||
uint8_t id = data[1];
|
||||
S_Code componente = DetectarComponente(id);
|
||||
switch (componente) {
|
||||
case sLED: {
|
||||
Sinaleiro::ComandarSinaleiro(listaSinaleiros, data);
|
||||
break;
|
||||
}
|
||||
case sRLE: {
|
||||
Rele::ComandarRele(listaReles, data);
|
||||
break;
|
||||
}
|
||||
case sFRO: {
|
||||
ServoFreio::ComandarServo(listaServoFreios, data);
|
||||
break;
|
||||
}
|
||||
case sLRA: {
|
||||
loraService.EnviarComando(data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LimparListasComponentes() {
|
||||
for (auto* rele : listaReles) {
|
||||
rele->Desligar();
|
||||
PrintTela("Rele " + rele->_ID + " desligado.");
|
||||
delete rele;
|
||||
}
|
||||
listaReles.clear();
|
||||
|
||||
for (auto* sinaleiro : listaSinaleiros) {
|
||||
sinaleiro->Desligar();
|
||||
PrintTela("Sinaleiro " + sinaleiro->_ID + " desligado.");
|
||||
delete sinaleiro;
|
||||
}
|
||||
listaSinaleiros.clear();
|
||||
|
||||
for (auto* servo : listaServoFreios) {
|
||||
servo->Desligar();
|
||||
PrintTela("Servo " + servo->_ID + " desligado.");
|
||||
delete servo;
|
||||
}
|
||||
listaServoFreios.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresCorrente) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de Corrente " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresCorrente.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresTemperaturaNTC) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de Temperatura " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresTemperaturaNTC.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresIMU) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor IMU " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresIMU.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresGas) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de gas " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresGas.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresTemperaturaSHT) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de temperatura e umidade " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresTemperaturaSHT.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresLuminosidade) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de luminosidade " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresLuminosidade.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresLuzUV) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de luz UV " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresLuzUV.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresQualidadeAr) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de qualidade do ar " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresQualidadeAr.clear();
|
||||
|
||||
for (auto* sensor : listaSensoresChuva) {
|
||||
sensor->Desligar();
|
||||
PrintTela("Sensor de chuva " + sensor->_ID + " desligado.");
|
||||
delete sensor;
|
||||
}
|
||||
listaSensoresChuva.clear();
|
||||
|
||||
}
|
||||
|
||||
S_Code DetectarComponente(uint8_t idNum) {
|
||||
if (idNum == canService.ID_Num_sMOD) return S_Code::sMOD;
|
||||
if (idNum == canService.ID_Num_sTOD) return S_Code::sTOD;
|
||||
if (idNum == canService.ID_Num_sLRA) return S_Code::sLRA;
|
||||
for (auto* s : listaSensoresTemperaturaNTC) {
|
||||
if (s->ID_Num == idNum) return S_Code::sNTC;
|
||||
}
|
||||
for (auto* s : listaSensoresCorrente) {
|
||||
if (s->ID_Num == idNum) return S_Code::sCOR;
|
||||
}
|
||||
for (auto* s : listaSinaleiros) {
|
||||
if (s->ID_Num == idNum) return S_Code::sLED;
|
||||
}
|
||||
for (auto* s : listaReles) {
|
||||
if (s->ID_Num == idNum) return S_Code::sRLE;
|
||||
}
|
||||
for (auto* s : listaServoFreios) {
|
||||
if (s->ID_Num == idNum) return S_Code::sFRO;
|
||||
}
|
||||
for (auto* s : listaSensoresIMU) {
|
||||
if (s->ID_Num == idNum) return S_Code::sIMU;
|
||||
}
|
||||
for (auto* s : listaSensoresGas) {
|
||||
if (s->ID_Num == idNum) return S_Code::sGAS;
|
||||
}
|
||||
for (auto* s : listaSensoresTemperaturaSHT) {
|
||||
if (s->ID_Num == idNum) return S_Code::sSHT;
|
||||
}
|
||||
for (auto* s : listaSensoresLuminosidade) {
|
||||
if (s->ID_Num == idNum) return S_Code::sLUZ;
|
||||
}
|
||||
for (auto* s : listaSensoresLuzUV) {
|
||||
if (s->ID_Num == idNum) return S_Code::sIUV;
|
||||
}
|
||||
for (auto* s : listaSensoresQualidadeAr) {
|
||||
if (s->ID_Num == idNum) return S_Code::sQAR;
|
||||
}
|
||||
for (auto* s : listaSensoresChuva) {
|
||||
if (s->ID_Num == idNum) return S_Code::sCHV;
|
||||
}
|
||||
return S_Code::sVZO;
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
int _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -119,7 +119,7 @@ private:
|
|||
Tc = T - 273.15;
|
||||
Tf = Tc * 9 / 5 + 32;
|
||||
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ void loop() {
|
|||
int prioridade = ((String)Protocolo[20] + (String)Protocolo[21]).toInt();
|
||||
int pino = ((String)Protocolo[23] + (String)Protocolo[24]).toInt();
|
||||
|
||||
if (componente == sTMP) {
|
||||
if (componente == sNTC) {
|
||||
SensorTemperatura* _sensor = ID == "TMVET" ? &TM1 : ID == "TMVEF" ? &TM2 : ID == "TMVDT" ? &TM3 : &TM4;
|
||||
if (sensor_ativado) {
|
||||
if (Conectar) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class SensorTemperatura {
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
int _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -128,7 +128,7 @@ class SensorTemperatura {
|
|||
Tc = T - 273.15;
|
||||
Tf = Tc * 9 / 5 + 32;
|
||||
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -430,7 +430,7 @@ void loop() {
|
|||
int pino = ((String)Protocolo[23] + (String)Protocolo[24]).toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
double _voffset = ((String)Protocolo[26] + (String)Protocolo[27] + (String)Protocolo[28] + (String)Protocolo[29] + (String)Protocolo[30] + (String)Protocolo[31]).toDouble();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class SensorTemperatura {
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
int _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -130,7 +130,7 @@ class SensorTemperatura {
|
|||
Tc = T - 273.15;
|
||||
Tf = Tc * 9 / 5 + 32;
|
||||
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -552,7 +552,7 @@ void loop() {
|
|||
int pino = ((String)Protocolo[23] + (String)Protocolo[24]).toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
double _voffset = ((String)Protocolo[26] + (String)Protocolo[27] + (String)Protocolo[28] + (String)Protocolo[29] + (String)Protocolo[30] + (String)Protocolo[31]).toDouble();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class SensorTemperatura {
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
int _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -130,7 +130,7 @@ class SensorTemperatura {
|
|||
Tc = T - 273.15;
|
||||
Tf = Tc * 9 / 5 + 32;
|
||||
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -553,7 +553,7 @@ void loop() {
|
|||
int pino2 = ((String)Protocolo[26] + (String)Protocolo[27]).toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
double _voffset = ((String)Protocolo[29] + (String)Protocolo[30] + (String)Protocolo[31] + (String)Protocolo[32] + (String)Protocolo[33] + (String)Protocolo[34]).toDouble();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class SensorTemperatura {
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
int _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -139,7 +139,7 @@ class SensorTemperatura {
|
|||
Tc = T - 273.15;
|
||||
Tf = Tc * 9 / 5 + 32;
|
||||
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloNTC10K(Tc)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -676,7 +676,7 @@ void loop() {
|
|||
int pino2 = ((String)Protocolo[26] + (String)Protocolo[27]).toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
double _voffset = ((String)Protocolo[29] + (String)Protocolo[30] + (String)Protocolo[31] + (String)Protocolo[32] + (String)Protocolo[33] + (String)Protocolo[34]).toDouble();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class SensorTemperatura {
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
PinoModel _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -123,7 +123,7 @@ class SensorTemperatura {
|
|||
void AferirTemperatura() {
|
||||
int leitura = _pino.get();
|
||||
float leituraNormalizada = tempKalman->updateEstimate(leitura);
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -973,7 +973,7 @@ void ProcessarProtocolo(String Protocolo, F_Code _funcao) {
|
|||
int pino = ((String)Protocolo[24] + (String)Protocolo[25]).toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
if (Conectar) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class SensorTemperatura {
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
PinoModel _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -123,7 +123,7 @@ class SensorTemperatura {
|
|||
void AferirTemperatura() {
|
||||
int leitura = _pino.get();
|
||||
float leituraNormalizada = tempKalman->updateEstimate(leitura);
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
EnviarDadosSerial(MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -986,7 +986,7 @@ void ProcessarProtocolo(String Protocolo, F_Code _funcao, int idMensagem) {
|
|||
int pino = Partes[7].toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
if (Conectar) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class SensorTemperatura {
|
|||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sTMP;
|
||||
S_Code _componente = sNTC;
|
||||
PinoModel _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
|
@ -94,7 +94,7 @@ class SensorTemperatura {
|
|||
void AferirTemperatura() {
|
||||
int leitura = _pino.get();
|
||||
float leituraNormalizada = tempKalman->updateEstimate(leitura);
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sTMP, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sNTC, _ID, MontarDadosProtocoloLeituraSensor(leituraNormalizada)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -1038,7 +1038,7 @@ void ProcessarCfg(ProtocoloSerial Mensagem) {
|
|||
int pino = Partes[7].toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
if (Conectar) {
|
||||
|
|
@ -1177,7 +1177,7 @@ void ProcessarReq(ProtocoloSerial Mensagem) {
|
|||
S_Code componente = (S_Code)Partes[1].toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sTMP: {
|
||||
case sNTC: {
|
||||
SensorTemperatura* _sensor = STPorID(ID);
|
||||
_sensor->AferirTemperatura();
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue