Parse CAN messges
This commit is contained in:
@ -5,38 +5,35 @@
|
||||
#include "tx_api.h"
|
||||
#include "ui.h"
|
||||
#include "vehicle.h"
|
||||
|
||||
#include <gui/model/Model.hpp>
|
||||
#include <gui/model/ModelListener.hpp>
|
||||
|
||||
Model::Model() : modelListener(0) {}
|
||||
|
||||
void Model::tick() {
|
||||
static int incs = 0;
|
||||
if ((HAL_GetTick() / 10) % 5 == 0) {
|
||||
tireTemps.fl++;
|
||||
if (tireTemps.fl > 90) {
|
||||
tireTemps.fl = 0;
|
||||
VehicleUpdate msg;
|
||||
while (tx_queue_receive(&vehicle_update_queue, &msg, TX_NO_WAIT) ==
|
||||
TX_SUCCESS) {
|
||||
switch (msg) {
|
||||
case VEH_UPD_AMS:
|
||||
modelListener->amsUpdated();
|
||||
break;
|
||||
case VEH_UPD_MISSION:
|
||||
modelListener->missionUpdated();
|
||||
break;
|
||||
case VEH_UPD_STATUS:
|
||||
modelListener->statusUpdated();
|
||||
break;
|
||||
case VEH_UPD_TS_CURRENT:
|
||||
modelListener->tsCurrentUpdated();
|
||||
break;
|
||||
case VEH_UPD_TS_VOLTAGE_VEH:
|
||||
modelListener->tsVoltageVehicleUpdated();
|
||||
break;
|
||||
case VEH_UPD_TS_VOLTAGE_BAT:
|
||||
modelListener->tsVoltageBatteryUpdated();
|
||||
break;
|
||||
}
|
||||
if (incs % 2 == 0) {
|
||||
tireTemps.fr++;
|
||||
if (tireTemps.fr > 90) {
|
||||
tireTemps.fr = 0;
|
||||
}
|
||||
}
|
||||
if (incs % 3 == 0) {
|
||||
tireTemps.rl++;
|
||||
if (tireTemps.rl > 90) {
|
||||
tireTemps.rl = 0;
|
||||
}
|
||||
}
|
||||
if (incs % 4 == 0) {
|
||||
tireTemps.rr++;
|
||||
if (tireTemps.rr > 90) {
|
||||
tireTemps.rr = 0;
|
||||
}
|
||||
}
|
||||
incs++;
|
||||
|
||||
modelListener->tireTempsUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user