Partial implementation of the receive value megasquirt command
This commit is contained in:
parent
9c86bc9387
commit
a4b5e0db17
49
comms.ino
49
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<page_size; x++)
|
||||
{
|
||||
response[offset] = *(pnt_configPage + offset + x); //Each byte is simply the location in memory of configPage1 + the offset + the variable number (x)
|
||||
}
|
||||
|
@ -177,7 +216,7 @@ void sendPage()
|
|||
response[124] = 0;
|
||||
*/
|
||||
|
||||
Serial.write((uint8_t *)&response, sizeof(response));
|
||||
Serial.write((byte *)&response, sizeof(response));
|
||||
break;
|
||||
|
||||
case ignPage:
|
||||
|
@ -187,9 +226,9 @@ void sendPage()
|
|||
for(byte y=72;y<80;y++) { response[y] = ignitionTable.axisY[7-(y-72)]; }
|
||||
|
||||
//All other bytes can simply be copied from the config table
|
||||
pnt_configPage = (byte *)&configPage2; //Create a pointer to Page 1 in memory
|
||||
pnt_configPage = (byte *)&configPage2; //Create a pointer to Page 2 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<page_size; x++)
|
||||
{
|
||||
response[offset] = *(pnt_configPage + offset + x); //Each byte is simply the location in memory of configPage + the offset + the variable number (x)
|
||||
}
|
||||
|
|
15
globals.h
15
globals.h
|
@ -1,7 +1,8 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
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"
|
||||
|
|
|
@ -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 |
|
||||
|---------------------------------------------------|
|
||||
|
|
Loading…
Reference in New Issue