diff --git a/comms.ino b/comms.ino index 8d9d22af..29e69975 100644 --- a/comms.ino +++ b/comms.ino @@ -110,6 +110,45 @@ void sendValues(int length) void receiveValue(byte offset, byte newValue) { + byte* pnt_configPage; + + switch (currentPage) + { + case vePage: + pnt_configPage = (byte *)&configPage1; + if (offset < 64) //New value is part of the fuel map + { + + } + else if (offset < 80) //New value is one of the X or Y axis bins + { + + } + else //New value is one of the remaining config items + { + *(pnt_configPage + offset) = newValue; + } + break; + + case ignPage: //Ignition settings page (Page 2) + pnt_configPage = (byte *)&configPage2; + if (offset < 64) //New value is part of the ignition map + { + + } + else if (offset < 80) //New value is one of the X or Y axis bins + { + + } + else //New value is one of the remaining config items + { + *(pnt_configPage + offset) = newValue; + } + break; + + default: + break; + } } void saveConfig() @@ -119,7 +158,7 @@ void saveConfig() void sendPage() { - byte response[125]; + byte response[page_size]; byte offset; byte* pnt_configPage; @@ -135,7 +174,7 @@ void sendPage() //All other bytes can simply be copied from the config table pnt_configPage = (byte *)&configPage1; //Create a pointer to Page 1 in memory offset = 80; //Offset is based on the amount already copied above (table + bins) - for(byte x=offset;x<125;x++) + for(byte x=offset; x -byte ms_version = 20; -byte data_structure_version = 1; //This identifies the data structure when reading / writing. +const byte ms_version = 20; +const byte data_structure_version = 1; //This identifies the data structure when reading / writing. +const byte page_size = 125; //The status struct contains the current values for all 'live' variables //In current version this is 64 bytes @@ -27,9 +28,9 @@ struct config1 { byte engineDwell; 3000 //The spark dwell time in uS */ - byte crankCold; - byte crankHot; - byte asePct; + byte crankCold; //Cold cranking pulsewidth modifier. This is added to the fuel pulsewidth when cranking under a certain temp threshold (ms) + byte crankHot; //Warm cranking pulsewidth modifier. This is added to the fuel pulsewidth when cranking (ms) + byte asePct; //Afterstart enrichment (%) byte aseCount; //Afterstart enrichment cycles. This is the number of ignition cycles that the afterstart enrichment % lasts for byte wueBins[10]; //Warm up enrichment array (10 bytes) byte taeBins1; //TPS based acceleration enrichment bin 1 of 4 (ms) @@ -57,10 +58,10 @@ struct config1 { byte mapType; byte strokes; byte injType; - byte nCylinders; + byte nCylinders; //Number of cylinders byte cltType; byte matType; - byte nInjectors; + byte nInjectors; //Number of injectors byte engineType; byte egoType; byte algorithm; //"Speed Density", "Alpha-N" diff --git a/storage.h b/storage.h index b412b495..1d62d176 100644 --- a/storage.h +++ b/storage.h @@ -7,7 +7,7 @@ void loadConfig(); void loadTables(); /* -Current layout of data (Version 1) is as follows (All sizes are in bytes): +Current layout of EEPROM data (Version 1) is as follows (All sizes are in bytes): |---------------------------------------------------| |Byte # |Size | Description | |---------------------------------------------------|