Actualización para recoger bateria y revoluciones del CAN

This commit is contained in:
adrigongv23 2026-03-07 16:18:26 +01:00
parent e64a08326c
commit 73ddffe252
3 changed files with 16 additions and 3 deletions

View file

@ -22,9 +22,11 @@ void TaskUdpSender(void *pvParameters){
//Obtenemos el dato actual
int tempActual = dataProcessor.current_ect_value;
int rpmActual = dataProcessor.current_rpm_value;
float battActual = dataProcessor.current_vbatt_value;
//Pasamos el dato actual a mensaje para enviarlo
String mensaje = String(tempActual);
String mensaje = String(tempActual) + "|" + String(rpmActual) + "|" + String(battActual, 1);
//Enviamos el paquete a través de UDP
udp.beginPacket(pc_ip, UDP_PORT);

View file

@ -12,6 +12,8 @@ public:
//Variable publica para el CAN
volatile int current_ect_value = 0;
volatile int current_rpm_value = 0;
volatile float current_vbatt_value = 0.0
//Métodos de recepción de CAN

View file

@ -16,10 +16,19 @@ void DataProcessor::send_serial(byte type, unsigned int value) {
//RPM + TPS + vBatt + ECT
void DataProcessor::send_serial_frame_0(int rpmh, int rpml, int tpsh, int tpsl, int vbatth, int vbattl, int ect){
//Calculos necesarios para obtener bien el formato de los valores necesarios
int rpm = (rpmh * 256) + rpml
double vbatt = ((vbatth * 256) + vbattl) / 100.0;
Serial.println("send_serial_frame_0");
this -> current_ect_value = ect; //Actualizamos el valor de ECT para que pueda ser usado por otras clases
//Serial.printf("CAN RX -> ECT: %d \n", ect);
// Actualizamos las variables globales para que puedan ser leidas por el protocolo UDP
this -> current_ect_value = ect;
this->current_rpm_value = rpm;
this->current_vbatt_value = vbatt;
// Serial.printf("CAN RX -> ECT: %d | RPM: %d | BATT: %.1f \n", ect, rpm, vbatt);;
}
/*