agrobot_base/Firmware/Modulos/SerialService.h

112 lines
2.8 KiB
C
Raw Normal View History

2023-10-09 16:06:23 +00:00
#include "Enuns.h"
#ifndef SerialService
#define SerialService
const char EndLine = '$';
const char BeginSensor = '#';
void EnviarDadosSerial(String Mensagem) {
Serial.println(Mensagem);
Serial.flush();
2023-11-30 00:41:22 +00:00
vTaskDelay(pdMS_TO_TICKS(10));
2023-10-09 16:06:23 +00:00
}
String MontarProtocoloVerificacao(T_Code D_Code) {
String Protocolo =
(String)D_Code + ";" +
(String)Chk +
EndLine;
return Protocolo;
}
String MontarProtocoloSensor(S_Code TipoSensor, String Componente, String Dados) {
String Protocolo =
BeginSensor +
(String)TipoSensor + ";" +
Componente + ";" +
Dados +
EndLine;
return Protocolo;
}
String MontarDadosProtocoloTeste(bool Testando, String Componente, String Resultado, String Comando, String Leitura) {
String Protocolo =
(Testando ? "1;" : "0;") +
Componente + ";" +
Resultado + ";" +
Comando + ";" +
Leitura +
EndLine;
return Protocolo;
}
2023-11-30 00:41:22 +00:00
String MontarDadosProtocoloRPM(float rpm, double potencia, StatusMotor aceleracao, Sentido sentido, bool revertendo) {
2023-10-09 16:06:23 +00:00
String Protocolo =
(String)rpm + ";" +
(String)potencia + ";" +
2023-11-30 00:41:22 +00:00
(String)aceleracao + ";" +
(String)sentido + ";" +
(revertendo ? "1" : "0");
2023-10-09 16:06:23 +00:00
return Protocolo;
}
String MontarDadosProtocoloDHT22(float temperatura, float umidade, float indiceCalor) {
String Protocolo =
(String)temperatura + ";" +
(String)umidade + ";" +
(String)indiceCalor;
return Protocolo;
}
2023-11-30 00:41:22 +00:00
String MontarDadosProtocoloEncoder(Sentido sentido, int angulo, bool ref0, bool ref90, bool ref270, bool referenciando, bool referenciado) {
String Protocolo =
(String)sentido + ";" +
(String)angulo + ";" +
(ref0 ? "1" : "0") + ";" +
(ref90 ? "1" : "0") + ";" +
(ref270 ? "1" : "0") + ";" +
(referenciando ? "1" : "0") + ";" +
(referenciado ? "1" : "0");
return Protocolo;
}
2024-01-03 10:52:37 +00:00
String MontarDadosProtocoloBicoPulverizador(bool statusBico, double nivelFluxo) {
String Protocolo =
String(statusBico ? "1" : "0") + ";" +
String(nivelFluxo);
return Protocolo;
}
2023-11-30 00:41:22 +00:00
String MontarDadosProtocoloSensorGenerico(String dados1, String dados2 = "", String dados3 = "", String dados4 = "") {
String Protocolo =
dados1 + ";" +
dados2 + ";" +
dados3 + ";" +
dados4;
return Protocolo;
}
2024-01-18 19:22:28 +00:00
String MontarDadosProtocoloNTC10K(float temperatura) {
String Protocolo =
(String)temperatura;
return Protocolo;
}
2024-01-23 17:10:34 +00:00
String MontarDadosProtocoloTensao(float leitura, float vPin, float vReal) {
String Protocolo =
(String)leitura + ";" +
(String)vPin + ";" +
(String)vReal;
return Protocolo;
}
String MontarDadosProtocoloCorrente(float leitura, float vPin, float corrente) {
String Protocolo =
(String)leitura + ";" +
(String)vPin + ";" +
(String)corrente;
return Protocolo;
}
2023-10-09 16:06:23 +00:00
#endif