can't push chnages :(

Fork of FBRDash by Michael Allan

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Comms.cpp Source File

Comms.cpp

00001 #include "PCComms.h"
00002 #include "mbed.h"
00003 #include "State.h"
00004 
00005 //Process incoming data from Comms interfaces
00006 
00007 //Initialise members
00008 Comms::Comms(State* _values)
00009 {
00010     values = _values;
00011 }
00012 
00013 //Process an incoming data packet
00014 void Comms::process_packet(unsigned char id, int length, unsigned char data[])
00015 {
00016     switch(id)
00017     {
00018         case 100:
00019             values->rpm = data[0] + (data[1] << 8);
00020             values->throttle_pos = data[2];
00021             values->manifold_pres = data[3];
00022             values->air_temp = data[4];
00023             values->coolant_temp = data[5];
00024             values->lambda = data[6];
00025             break;
00026         case 200:
00027             values->speed = data[0];
00028             values->accel_x = data[1];
00029             values->accel_y = data[2];
00030             values->gear = data[3];
00031             values->oil_temp = data[4];
00032             values->voltage = data[5];
00033             values->warnings = data[6];
00034             break;
00035     }
00036 }