Hi all
I'm attempting to build a digital gauge for my car (specifically, my subaru, using the SSM serial protocol). Many of the responses from the ECU require scaling of some kind, the algebraic expressions for which I've conveniently stolen from the open-source tuning tool RomRaider. I was wondering if there was an elegant way to evaluate these without writing a separate function, or switch/case list for each variable? Here's what I would like to make work:
As you can see, they're not just scalar multiples, so I can't just store a multiplier for each. I really want to avoid a big long list (not that long, but it could be if I add more variables), because it's ugly, but I can't see any other way. Thanks for the help.
I'm attempting to build a digital gauge for my car (specifically, my subaru, using the SSM serial protocol). Many of the responses from the ECU require scaling of some kind, the algebraic expressions for which I've conveniently stolen from the open-source tuning tool RomRaider. I was wondering if there was an elegant way to evaluate these without writing a separate function, or switch/case list for each variable? Here's what I would like to make work:
Code:
struct ecuDataObject {
char name[10];
byte a1; //address1
byte a2; //address2
byte a3; //address3
char conversion[20]; //conversion str (no eval, can't use this?)
char units[5];
};
const ecuDataObject ecuData[] = {
{"RPM", 0x00, 0x00, 0x0e, "x/4", "RPM"},
{"VehSpeed", 0x00, 0x00, 0x10, "x*0.621371192", "MPH"},
{"CLT", 0x00, 0x00, 0x08, "32+9*(x-40)/5", "F"},
{"IAT", 0x00, 0x00, 0x12, "32+9*(x-40)/5", "F"},
{"AFR", 0x00, 0x00, 0x46, "x/128*14.7", ":1"},
{"WGDC", 0x00, 0x00, 0x30, "x*100/255", "%"},
{"MRP", 0x00, 0x00, 0x24, "(x-128)*37/255", "psi"},
{"TotTiming", 0x00, 0x00, 0x11, "(x-128)/2", "deg"},
{"KnockSum", 0xFF, 0xBF, 0xAC, "x", ""}
};
As you can see, they're not just scalar multiples, so I can't just store a multiplier for each. I really want to avoid a big long list (not that long, but it could be if I add more variables), because it's ugly, but I can't see any other way. Thanks for the help.