speeduino-personal/speeduino/comms.h

58 lines
2.4 KiB
C
Raw Normal View History

2015-02-14 05:11:43 -08:00
#ifndef COMMS_H
#define COMMS_H
2015-10-13 15:49:17 -07:00
//These are the page numbers that the Tuner Studio serial protocol uses to transverse the different map and config pages.
#define veMapPage 2
#define veSetPage 1 //Note that this and the veMapPage were swapped in Feb 2019 as the 'algorithm' field must be declared in the ini before it's used in the fuel table
#define ignMapPage 3
2015-10-13 15:49:17 -07:00
#define ignSetPage 4//Config Page 2
#define afrMapPage 5
2015-10-13 15:49:17 -07:00
#define afrSetPage 6//Config Page 3
2017-09-18 21:51:33 -07:00
#define boostvvtPage 7
#define seqFuelPage 8
#define canbusPage 9//Config Page 9
#define warmupPage 10 //Config Page 10
#define SERIAL_PACKET_SIZE 91 //Must match ochBlockSize in ini file
2016-12-26 22:03:27 -08:00
2015-10-13 15:49:17 -07:00
byte currentPage = 1;//Not the same as the speeduino config page numbers
2017-06-02 04:56:21 -07:00
bool isMap = true;
unsigned long requestCount = 0; //The number of times the A command has been issued
byte currentCommand;
bool cmdPending = false;
bool chunkPending = false;
uint16_t chunkComplete = 0;
uint16_t chunkSize = 0;
int valueOffset; //cannot use offset as a variable name, it is a reserved word for several teensy libraries
byte cmdGroup = 0;
byte cmdValue = 0;
int cmdCombined = 0; //the cmdgroup as high byte and cmdvalue as low byte
byte tsCanId = 0; // current tscanid requested
2015-10-13 15:49:17 -07:00
const char pageTitles[] PROGMEM //This is being stored in the avr flash instead of SRAM which there is not very much of
2015-10-10 05:43:45 -07:00
{
"\nVE Map\0"//This is an alternative to using a 2D array which would waste space because of the different lengths of the strings
"\nPg 1 Config\0"// 21-The configuration page titles' indexes are found by counting the chars
"\nIgnition Map\0"//35-The map page titles' indexes are put into a var called currentTitleIndex. That represents the first char of each string.
"\nPg 2 Config\0" //48
"\nAFR Map\0" //56
"\nPg 3 Config\0" //69
"\nPg 4 Config\0" //82
"\nBoost Map\0" //93
"\nVVT Map\0"//102-No need to put a trailing null because it's the last string and the compliler does it for you.
"\nPg 10 Config"
2015-10-10 05:43:45 -07:00
};
2017-02-11 17:31:37 -08:00
2015-10-13 15:49:17 -07:00
void command();//This is the heart of the Command Line Interpeter. All that needed to be done was to make it human readable.
void sendValues(uint16_t, uint16_t,byte, byte);
void sendValuesLegacy();
void receiveValue(uint16_t, byte);
2013-07-08 17:43:41 -07:00
void saveConfig();
void sendPage(bool);
void receiveCalibration(byte);
void sendToothLog(bool);
2013-07-08 17:43:41 -07:00
void testComm();
void commandButtons();
byte getPageValue(byte, uint16_t);
2015-02-14 05:11:43 -08:00
2016-10-15 03:52:20 -07:00
#endif // COMMS_H