diff --git a/.docs/AlphaReader.zip b/.docs/AlphaReader.zip new file mode 100644 index 0000000..edfc747 Binary files /dev/null and b/.docs/AlphaReader.zip differ diff --git a/.docs/ArduinoCore-avr b/.docs/ArduinoCore-avr new file mode 160000 index 0000000..2cebe62 --- /dev/null +++ b/.docs/ArduinoCore-avr @@ -0,0 +1 @@ +Subproject commit 2cebe625833afcdb76cc941ccf90e5f5fefc27a9 diff --git a/.docs/DCL_communication_map (1).pdf b/.docs/DCL_communication_map (1).pdf new file mode 100644 index 0000000..0b3baea Binary files /dev/null and b/.docs/DCL_communication_map (1).pdf differ diff --git a/.docs/EECIVDiag.zip b/.docs/EECIVDiag.zip new file mode 100644 index 0000000..e6a43bd Binary files /dev/null and b/.docs/EECIVDiag.zip differ diff --git a/.docs/captures/arduino_2stopbits.sal b/.docs/captures/arduino_2stopbits.sal new file mode 100644 index 0000000..f357444 Binary files /dev/null and b/.docs/captures/arduino_2stopbits.sal differ diff --git a/.docs/captures/fault-code-mondeo.sal b/.docs/captures/fault-code-mondeo.sal new file mode 100644 index 0000000..713636b Binary files /dev/null and b/.docs/captures/fault-code-mondeo.sal differ diff --git a/.docs/captures/fault-code-workbench.sal b/.docs/captures/fault-code-workbench.sal new file mode 100644 index 0000000..08ea6c3 Binary files /dev/null and b/.docs/captures/fault-code-workbench.sal differ diff --git a/.docs/captures/first_baud_change_after_sync.sal b/.docs/captures/first_baud_change_after_sync.sal new file mode 100644 index 0000000..8f6c2b5 Binary files /dev/null and b/.docs/captures/first_baud_change_after_sync.sal differ diff --git a/.docs/captures/first_e0_response.sal b/.docs/captures/first_e0_response.sal new file mode 100644 index 0000000..2d32273 Binary files /dev/null and b/.docs/captures/first_e0_response.sal differ diff --git a/.docs/captures/first_response_hurray.sal b/.docs/captures/first_response_hurray.sal new file mode 100644 index 0000000..9f541b0 Binary files /dev/null and b/.docs/captures/first_response_hurray.sal differ diff --git a/.docs/captures/koeo-mondeo.sal b/.docs/captures/koeo-mondeo.sal new file mode 100644 index 0000000..5e670b4 Binary files /dev/null and b/.docs/captures/koeo-mondeo.sal differ diff --git a/.docs/captures/usb_2stopbits.sal b/.docs/captures/usb_2stopbits.sal new file mode 100644 index 0000000..b69c76c Binary files /dev/null and b/.docs/captures/usb_2stopbits.sal differ diff --git a/.docs/fdocuments.in_lhbh1.pdf b/.docs/fdocuments.in_lhbh1.pdf new file mode 100644 index 0000000..b1ba6a8 Binary files /dev/null and b/.docs/fdocuments.in_lhbh1.pdf differ diff --git a/.docs/ford-eec-iv-diagnostic b/.docs/ford-eec-iv-diagnostic new file mode 160000 index 0000000..004d6fe --- /dev/null +++ b/.docs/ford-eec-iv-diagnostic @@ -0,0 +1 @@ +Subproject commit 004d6fe61d46388954cc529b11f322e2224021e8 diff --git a/.docs/ford_eectch98.pdf b/.docs/ford_eectch98.pdf new file mode 100644 index 0000000..692dbcb Binary files /dev/null and b/.docs/ford_eectch98.pdf differ diff --git a/.docs/ford_eectec10.pdf b/.docs/ford_eectec10.pdf new file mode 100644 index 0000000..0071ecb Binary files /dev/null and b/.docs/ford_eectec10.pdf differ diff --git a/.gitignore b/.gitignore index 10611a9..a7fdaac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ -.vscode/ -.docs/ -build/ \ No newline at end of file +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch + +docs + diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/EecIv.cpp b/EecIv.cpp deleted file mode 100644 index ec36e29..0000000 --- a/EecIv.cpp +++ /dev/null @@ -1,522 +0,0 @@ -#include "EecIv.h" - -const unsigned char EecIv::syncSig[4][4] = { - {0x00, 0x00, 0x00, 0xa0 }, - {0x00, 0x00, 0x00, 0xb1 }, - {0x00, 0x00, 0x00, 0x82 }, - {0x00, 0x00, 0x00, 0x93 } -}; - -const unsigned char EecIv::startSig[18] = { - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x01, 0x04, 0x00, 0x00, - 0x00, 0x05 -}; - -EecIv::EecIv(int di, int ro, int re) { - pin_re = re; - - initBuffer(); - softwareSerial = new SoftwareSerial(di, ro); -} - -void EecIv::restartReading() { - debugPrint("Restart reading"); - currentState = ENABLE_READING_SLOW_SYNC; // if there is already a sync signal, we start here and not send the start message -} - -void EecIv::setup() { - pinMode(pin_re,OUTPUT); -} - -void EecIv::answer(unsigned char message[], int delay) { - enableWriteMode(); - softwareSerial->write(message[0]); - delayMicroseconds(delay); - softwareSerial->write(message[1]); - enableReadMode(); -} - -void EecIv::sendStartMessage() { - softwareSerial->begin(2400); - enableWriteMode(); - - for(int i = 0; iwrite(startSig[i]); // using softwareSerial as it can be timed better! - delayMicroseconds(420); // try and error. Off delay has to be ~850 us - } -} - -void EecIv::rxMode(int baudrate) { - softwareSerial->begin(baudrate); - enableReadMode(); -} - -void EecIv::enableWriteMode() { - digitalWrite(pin_re, HIGH); -} - -void EecIv::enableReadMode() { - digitalWrite(pin_re, LOW); -} - -void EecIv::setModeFaultCode() { - this->mode = READ_FAULTS; -} - -void EecIv::setModeKoeo() { - this->mode = KOEO; -} - -void EecIv::setModeLiveData() { - this->mode = LIVE_DATA; -} - - -int EecIv::mainLoop() { - switch(currentState) { - case IDLE: - break; - - case SEND_START_MESSAGE: - sendStartMessage(); - debugPrint("Send start message"); - currentState = ENABLE_READING_FAST_SYNC; - break; - - case ENABLE_READING_FAST_SYNC: - rxMode(9600); - initTimeoutTimer(); - currentState = WAIT_FAST_SYNC; - case WAIT_FAST_SYNC: - if (waitSyncLoop()) { - currentState = ANSWER_FAST_SYNC; - } else { - if(exceededTimeout()) { - debugPrint("Exceeded fast sync timeout"); - currentState = SEND_START_MESSAGE; - } - } - break; - - case ANSWER_FAST_SYNC: - if (answerFastSyncLoop()) { - currentState = ENABLE_READING_SLOW_SYNC; - } - break; - case ENABLE_READING_SLOW_SYNC: - rxMode(2400); - initTimeoutTimer(); - currentState = ANSWER_SLOW_SYNC; - case ANSWER_SLOW_SYNC: - if(answerSlowSyncLoop()) { - loopCounter++; - if(loopCounter >= 2) { - loopCounter = 0; - if (mode == READ_FAULTS) { - currentState = ANSWER_REQUEST_FAULT_CODE; - } else if (mode == KOEO) { - currentState = ANSWER_REQUEST_KOEO; - } else if (mode == LIVE_DATA) { - currentState = ANSWER_REQUEST_LIVE_DATA; - } else { - currentState = IDLE; - } - } - } else { - if(exceededTimeout()) { - debugPrint("Exceeded slow sync timeout"); - currentState = SEND_START_MESSAGE; - } - } - break; - - case ANSWER_REQUEST_FAULT_CODE: - if (answerRequestFaultCode()) { - loopCounter++; - if (loopCounter > 1) { // try different values - currentState = ANSWER_REQUEST_FAULT_CODE_SHORT; - loopCounter = 0; - } - } - break; - case ANSWER_REQUEST_FAULT_CODE_SHORT: - if (answerRequestFaultCodeShort()) { - currentState = READ_REQUEST_FAULT_CODE; - } - break; - case READ_REQUEST_FAULT_CODE: - if (readRequestFaultCode()) { - currentState = IDLE; - } - break; - - case ANSWER_REQUEST_KOEO: // Answer sync with koeo command for 8 times - if (answerRequestKoeo()) { - loopCounter++; - if (loopCounter > 7) { - currentState = ANSWER_REQUEST_KOEO_SHORT; - loopCounter = 0; - } - } - break; - case ANSWER_REQUEST_KOEO_SHORT: // Answer only one sync message with koeo command - if (answerRequestKoeoShort()) { - currentState = READ_REQUEST_KOEO; - } - break; - case READ_REQUEST_KOEO: // Read koeo fault code - if (readRequestKoeo()) { - currentState = ANSWER_REQUEST_KOEO_SHORT; - loopCounter++; - if (loopCounter > 3) { - loopCounter = 0; - currentState = WAIT_REQUEST_KOEO_SHORT; - } - } - break; - case WAIT_REQUEST_KOEO_SHORT: // Wait for 6 bytes from ecu - if (waitByte()) { - loopCounter++; - if (loopCounter > 5) { - loopCounter = 0; - currentState = READ_REQUEST_KOEO_AFTER_ANSWER; - } - } - break; - case READ_REQUEST_KOEO_AFTER_ANSWER: // Read koeo code and stop after 8 codes - if (readRequestKoeo()) { - currentState = WAIT_REQUEST_KOEO_SHORT; - koeoCounter++; - if (koeoCounter > 7) { - onKoeoFinished(); - koeoCounter = 0; - currentState = IDLE; - } - } - break; - - case ANSWER_REQUEST_LIVE_DATA: - if (answerRequestLiveData()) { - currentState = ANSWER_REQUEST_LIVE_DATA_SHORT; - } - break; - case ANSWER_REQUEST_LIVE_DATA_SHORT: - if (answerRequestFaultCodeShort()) { - currentState = ANSWER_REQUEST_LIVE_DATA_INIT_SHIT; - } - break; - case ANSWER_REQUEST_LIVE_DATA_INIT_SHIT: - - break; - } -} - -int EecIv::exceededTimeout() { - if (millis() > timeoutTimer + timeoutMax) { - return 1; - } - return 0; -} - -void EecIv::initTimeoutTimer() { - timeoutTimer = millis(); -} - -int EecIv::pushAvailableToBuffer() { - if (softwareSerial->available()) { - pushBuffer(softwareSerial->read()); - return 1; - } else { - return 0; - } -} - -int EecIv::waitSyncLoop() { - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - syncPointer++; - // clearBuffer(); - - if (syncPointer > 3) { - syncPointer = 0; - return 1; - } - } - } - - return 0; -} - -int EecIv::waitSyncLoopShort() { - unsigned char syncSig[4] = {0x00, 0x00, 0x00, 0xa0 }; - - if (softwareSerial->available()) { - pushBuffer(softwareSerial->read()); - - if (!memcmp(syncSig, buffer, 4)) { - return 1; - } - } - - return 0; -} - -int EecIv::answerFastSyncLoop() { - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x81, 0x74 }, - {0x00, 0xa0 } - }; - - - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(426); - answer(answerSig[syncPointer], 15); - - syncPointer++; - //clearBuffer(); - - if (syncPointer > 3) { - syncPointer = 0; - return 1; - } - } - } - - return 0; -} - -int EecIv::answerSlowSyncLoop() { - - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x01, 0xF4 }, - {0x00, 0xa0 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[syncPointer], 60); - - syncPointer++; - - if (syncPointer > 3) { - syncPointer = 0; - return 1; - } - } - } - - return 0; -} -int EecIv::answerRequestFaultCode() { - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x26, 0xa4 }, - {0x00, 0xa0 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[syncPointer], 60); - - syncPointer++; - - if (syncPointer > 3) { - syncPointer = 0; - return 1; - } - } - } - - return 0; -} - -int EecIv::answerRequestKoeo() { - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x25, 0x94 }, - {0x00, 0xa0 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[syncPointer], 60); - - syncPointer++; - - if (syncPointer > 3) { - syncPointer = 0; - return 1; - } - } - } - - return 0; -} - -int EecIv::answerRequestLiveData() { - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x41, 0x96 }, - {0x00, 0xa0 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[syncPointer], 60); - - syncPointer++; - - if (syncPointer > 3) { - syncPointer = 0; - return 1; - } - } - } - - return 0; -} - -int EecIv::answerRequestLiveDataShort() { - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x41, 0x96 }, - {0x00, 0xa0 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[syncPointer], 60); - - syncPointer++; - - if (syncPointer > 3) { - syncPointer = 0; - } - - return 1; - } - } - - return 0; -} - -int EecIv::answerRequestFaultCodeShort() { - unsigned char answerSig[2] = {0x01, 0xb0 }; - - if (softwareSerial->available()) { - pushBuffer(softwareSerial->read()); - - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig, 60); - - syncPointer++; - return 1; - } - } - - return 0; -} - -int EecIv::answerRequestKoeoShort() { - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x25, 0x94 }, - {0x00, 0xa0 } - }; - - if (softwareSerial->available()) { - pushBuffer(softwareSerial->read()); - - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[syncPointer], 60); - - syncPointer++; - if (syncPointer > 3) { - syncPointer = 0; - } - return 1; - } - } - - return 0; -} - -int EecIv::readRequestKoeo() { - if (pushAvailableToBuffer()) { - errorCodePointer++; - - if(errorCodePointer >= 2) { - errorCodePointer = 0; - - sprintf(printBuffer, "Koeo Code: %01X%02X", buffer[3] & 0xF, buffer[2]); - debugPrint(printBuffer); - - sprintf(printBuffer, "%01X%02X", buffer[3] & 0xF, buffer[2]); - onKoeoReadCode(printBuffer); - return 1; - } - } - - return 0; -} - -int EecIv::waitByte() { - if (softwareSerial->available()) { - softwareSerial->read(); - return 1; - } - return 0; -} - -int EecIv::readRequestFaultCode() { - - if (pushAvailableToBuffer()) { - errorCodePointer++; - - if(errorCodePointer >= 2) { - errorCodePointer = 0; - - sprintf(printBuffer, "Error Code: %01X%02X", buffer[3] & 0xF, buffer[2]); - debugPrint(printBuffer); - sprintf(printBuffer, "%01X%02X", buffer[3] & 0xF, buffer[2]); - onFaultCodeFinished(printBuffer); - return 1; - } - } - - return 0; -} - - -void EecIv::pushBuffer(unsigned char val) { - buffer[0] = buffer[1]; - buffer[1] = buffer[2]; - buffer[2] = buffer[3]; - buffer[3] = val; -} - -void EecIv::initBuffer() { - for (int i = 0; i < sizeof(buffer); i++) { - buffer[i] = 0; - } -} \ No newline at end of file diff --git a/EecIv.h b/EecIv.h deleted file mode 100644 index adfeb20..0000000 --- a/EecIv.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef EEC_IV_H -#define EEC_IV_H - -#include "arduino.h" -#include - - -class EecIv { - public: - typedef void (*callback_t)(char []); - typedef void (*callback_empty_t)(void); - - EecIv(int di, int ro, int re); - - void setup(); - - void setModeFaultCode(); - void setModeKoeo(); - void setModeLiveData(); - - void restartReading(); - - int mainLoop(); - - callback_t debugPrint; - callback_t onFaultCodeFinished; - callback_t onKoeoReadCode; - callback_empty_t onKoeoFinished; - - enum OperationMode { - READ_FAULTS, - KOEO, - LIVE_DATA - }; - - private: - - enum State { - IDLE, - SEND_START_MESSAGE, - ENABLE_READING_FAST_SYNC, - WAIT_FAST_SYNC, - ANSWER_FAST_SYNC, - WAIT_FAST_SYNC_SHORT, - ENABLE_READING_SLOW_SYNC, - ANSWER_SLOW_SYNC, - - ANSWER_REQUEST_FAULT_CODE, - ANSWER_REQUEST_FAULT_CODE_SHORT, - READ_REQUEST_FAULT_CODE, - - ANSWER_REQUEST_KOEO, - ANSWER_REQUEST_KOEO_SHORT, - WAIT_REQUEST_KOEO_SHORT, - READ_REQUEST_KOEO, - READ_REQUEST_KOEO_AFTER_ANSWER, - - ANSWER_REQUEST_LIVE_DATA, - ANSWER_REQUEST_LIVE_DATA_SHORT, - ANSWER_REQUEST_LIVE_DATA_INIT_SHIT - }; - - State currentState = IDLE; - OperationMode mode = READ_FAULTS; - - int pin_re; - - int syncPointer = 0; - int errorCodePointer = 0; - int errorCodeCounter = 0; - int loopCounter = 0; - int koeoCounter = 0; - unsigned long timeoutTimer = 0L; - const unsigned long timeoutMax = 2000UL; - - char out_buf[90]; - - void sendStartMessage(); - - int waitSyncLoop(); - int waitSyncLoopShort(); - int answerFastSyncLoop(); - int answerSlowSyncLoop(); - - int answerRequestFaultCode(); - int answerRequestFaultCodeShort(); - int readRequestFaultCode(); - - int answerRequestKoeo(); - int answerRequestKoeoShort(); - int waitByte(); - int readRequestKoeo(); - - int answerRequestLiveData(); - int answerRequestLiveDataShort(); - int answerRequestLiveDataInitShit(); - - int exceededTimeout(); - void initTimeoutTimer(); - - void answer(unsigned char message[], int delay); - - - void rxMode(int baudrate); - void enableWriteMode(); - void enableReadMode(); - - unsigned char errorCodeBuffer[2]; - - char printBuffer[90]; - - unsigned char buffer[4]; - void pushBuffer(unsigned char val); - void initBuffer(); - int pushAvailableToBuffer(); - - - const static unsigned char syncSig[4][4]; - const static unsigned char startSig[18]; - - SoftwareSerial *softwareSerial; -}; - -#endif /* EEC_IV_H */ diff --git a/EecIvCommon.cpp b/EecIvCommon.cpp deleted file mode 100644 index 2080060..0000000 --- a/EecIvCommon.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "EecIvCommon.h" - -const unsigned char EecIvCommon::syncSig[4][4] = { - {0x00, 0x00, 0x00, 0xa0 }, - {0x00, 0x00, 0x00, 0xb1 }, - {0x00, 0x00, 0x00, 0x82 }, - {0x00, 0x00, 0x00, 0x93 } -}; - -void EecIvCommon::answer(unsigned char message[], int delay) { - enableWriteMode(); - softwareSerial->write(message[0]); - delayMicroseconds(delay); - softwareSerial->write(message[1]); - enableReadMode(); -} - -void EecIvCommon::rxMode(int baudrate) { - softwareSerial->begin(baudrate); - enableReadMode(); -} - -void EecIvCommon::enableWriteMode() { - digitalWrite(pin_re, HIGH); -} - -void EecIvCommon::enableReadMode() { - digitalWrite(pin_re, LOW); -} diff --git a/EecIvCommon.h b/EecIvCommon.h deleted file mode 100644 index 6649eda..0000000 --- a/EecIvCommon.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef EEC_IV_COMMON_H -#define EEC_IV_COMMON_H - -#include "arduino.h" -#include - -class EecIvCommon { - public: - typedef void (*callback_t)(char []); - - protected: - void answer(unsigned char message[], int delay); - - void rxMode(int baudrate); - void enableWriteMode(); - void enableReadMode(); - void doNothing(char []); - - - int pin_re; - SoftwareSerial *softwareSerial; - - const static unsigned char syncSig[4][4]; -}; - - -#endif /* EEC_IV_COMMON_H */ \ No newline at end of file diff --git a/FaultCode.cpp b/FaultCode.cpp deleted file mode 100644 index fb7b646..0000000 --- a/FaultCode.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "FaultCode.h" - -void doNothingHere(char []) {} - -FaultCode::FaultCode(SoftwareSerial *softwareSerial, int re, callback_t printCallback) { - this->softwareSerial = softwareSerial; - this->pin_re = re; - this->print = printCallback; - - this->onFaultCode = doNothingHere; -} - -void FaultCode::setOnFaultCode(callback_t onFaultCode) { - this->onFaultCode = onFaultCode; -} - -int FaultCode::mainLoop() { - switch(currentState) { - case ANSWER_REQUEST_FAULT_CODE: - if (answerRequestFaultCode()) { - currentState = ANSWER_REQUEST_FAULT_CODE_SHORT; - } - break; - case ANSWER_REQUEST_FAULT_CODE_SHORT: - if (answerRequestFaultCodeShort()) { - currentState = READ_REQUEST_FAULT_CODE; - } - break; - case READ_REQUEST_FAULT_CODE: - if (readRequestFaultCode()) { - currentState = ANSWER_REQUEST_FAULT_CODE; - return 1; - } - break; - } - return 0; -} - -int FaultCode::answerRequestFaultCode() { - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x26, 0xa4 }, - {0x00, 0xa0 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[syncPointer], 60); - - syncPointer++; - - if (syncPointer > 3) { - syncPointer = 0; - return 1; - } - } - } - - return 0; -} - -int FaultCode::answerRequestFaultCodeShort() { - unsigned char answerSig[2] = {0x01, 0xb0 }; - - if (softwareSerial->available()) { - pushBuffer(softwareSerial->read()); - - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig, 60); - - syncPointer++; - return 1; - } - } - - return 0; -} - -int FaultCode::readRequestFaultCode() { - - if (pushAvailableToBuffer()) { - errorCodePointer++; - - if(errorCodePointer >= 2) { - errorCodePointer = 0; - - sprintf(printBuffer, "Error Code: %01X%02X", buffer[3] & 0xF, buffer[2]); - print(printBuffer); - onFaultCode(printBuffer); - return 1; - } - } - - return 0; -} - - -// move to base class - -void FaultCode::pushBuffer(unsigned char val) { - buffer[0] = buffer[1]; - buffer[1] = buffer[2]; - buffer[2] = buffer[3]; - buffer[3] = val; -} - -void FaultCode::initBuffer() { - for (int i = 0; i < sizeof(buffer); i++) { - buffer[i] = 0; - } -} - -int FaultCode::pushAvailableToBuffer() { - if (softwareSerial->available()) { - pushBuffer(softwareSerial->read()); - return 1; - } else { - return 0; - } -} diff --git a/FaultCode.h b/FaultCode.h deleted file mode 100644 index 183a007..0000000 --- a/FaultCode.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef FAULT_CODE_H -#define FAULT_CODE_H - -#include "arduino.h" -#include -#include "EecIvCommon.h" - -class FaultCode : EecIvCommon { - public: - FaultCode(SoftwareSerial *softwareSerial, int re, EecIvCommon::callback_t printCallback); - - int mainLoop(); - void setOnFaultCode(callback_t onFaultCode); - - private: - callback_t print; - callback_t onFaultCode; - - enum State { - ANSWER_REQUEST_FAULT_CODE, - ANSWER_REQUEST_FAULT_CODE_SHORT, - READ_REQUEST_FAULT_CODE - }; - - State currentState = ANSWER_REQUEST_FAULT_CODE; - - int pin_re; - - int syncPointer = 0; - int errorCodePointer = 0; - - char printBuffer[90]; - - int answerRequestFaultCode(); - int answerRequestFaultCodeShort(); - int readRequestFaultCode(); - - unsigned char buffer[4]; - void pushBuffer(unsigned char val); - void initBuffer(); - int pushAvailableToBuffer(); -}; - -#endif \ No newline at end of file diff --git a/Koeo.cpp b/Koeo.cpp deleted file mode 100644 index c2e1dbe..0000000 --- a/Koeo.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "Koeo.h" - -Koeo::Koeo(SoftwareSerial *softwareSerial, int re, EecIvCommon::callback_t printCallback) { - this->softwareSerial = softwareSerial; - this->pin_re = re; - this->print = printCallback; -} - -int Koeo::mainLoop() { - switch(currentState) { - case ANSWER_REQUEST_KOEO: // Answer sync with koeo command for 8 times - if (answerRequestKoeo()) { - loopCounter++; - if (loopCounter > 7) { - currentState = ANSWER_REQUEST_KOEO_SHORT; - loopCounter = 0; - } - } - break; - case ANSWER_REQUEST_KOEO_SHORT: // Answer only one sync message with koeo command - if (answerRequestKoeoShort()) { - currentState = READ_REQUEST_KOEO; - } - break; - case READ_REQUEST_KOEO: // Read koeo fault code - if (readRequestKoeo()) { - currentState = ANSWER_REQUEST_KOEO_SHORT; - loopCounter++; - if (loopCounter > 3) { - loopCounter = 0; - currentState = WAIT_REQUEST_KOEO_SHORT; - } - } - break; - case WAIT_REQUEST_KOEO_SHORT: // Wait for 6 bytes from ecu - if (waitByte()) { - loopCounter++; - if (loopCounter > 5) { - loopCounter = 0; - currentState = READ_REQUEST_KOEO_AFTER_ANSWER; - } - } - break; - case READ_REQUEST_KOEO_AFTER_ANSWER: // Read koeo code and stop after 8 codes - if (readRequestKoeo()) { - currentState = WAIT_REQUEST_KOEO_SHORT; - koeoCounter++; - if (koeoCounter > 7) { - koeoCounter = 0; - currentState = ANSWER_REQUEST_KOEO; - return 1; - } - } - break; - } - - return 0; -} - -int Koeo::answerRequestKoeo() { - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x25, 0x94 }, - {0x00, 0xa0 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[syncPointer], 60); - - syncPointer++; - - if (syncPointer > 3) { - syncPointer = 0; - return 1; - } - } - } - - return 0; -} - -int Koeo::answerRequestKoeoShort() { - unsigned char answerSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x25, 0x94 }, - {0x00, 0xa0 } - }; - - if (softwareSerial->available()) { - pushBuffer(softwareSerial->read()); - - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[syncPointer], 60); - - syncPointer++; - if (syncPointer > 3) { - syncPointer = 0; - } - return 1; - } - } - - return 0; -} - -int Koeo::readRequestKoeo() { - if (pushAvailableToBuffer()) { - errorCodePointer++; - - if(errorCodePointer >= 2) { - errorCodePointer = 0; - - sprintf(printBuffer, "Koeo Code: %01X%02X", buffer[3] & 0xF, buffer[2]); - print(printBuffer); - return 1; - } - } - - return 0; -} - -int Koeo::pushAvailableToBuffer() { - if (softwareSerial->available()) { - pushBuffer(softwareSerial->read()); - return 1; - } else { - return 0; - } -} - -int Koeo::waitByte() { - if (softwareSerial->available()) { - softwareSerial->read(); - return 1; - } - return 0; -} - -void Koeo::pushBuffer(unsigned char val) { - buffer[0] = buffer[1]; - buffer[1] = buffer[2]; - buffer[2] = buffer[3]; - buffer[3] = val; -} - -void Koeo::initBuffer(unsigned char buffer[]) { - for (int i = 0; i < sizeof(buffer); i++) { - buffer[i] = 0; - } -} \ No newline at end of file diff --git a/Koeo.h b/Koeo.h deleted file mode 100644 index 9f22ded..0000000 --- a/Koeo.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef KOEO_H -#define KOEO_H - -#include "arduino.h" -#include -#include "EecIvCommon.h" - -class Koeo : EecIvCommon { - public: - Koeo(SoftwareSerial *softwareSerial, int re, EecIvCommon::callback_t printCallback); - - int mainLoop(); - - private: - callback_t print; - - enum State { - ANSWER_REQUEST_KOEO, - ANSWER_REQUEST_KOEO_SHORT, - WAIT_REQUEST_KOEO_SHORT, - READ_REQUEST_KOEO, - READ_REQUEST_KOEO_AFTER_ANSWER, - }; - - State currentState = ANSWER_REQUEST_KOEO; - - int loopCounter = 0; - int koeoCounter = 0; - int syncPointer = 0; - int errorCodePointer = 0; - - char printBuffer[90]; - - int answerRequestKoeo(); - int answerRequestKoeoShort(); - int waitByte(); - int readRequestKoeo(); - - unsigned char buffer[4]; - void pushBuffer(unsigned char val); - void initBuffer(unsigned char buffer[]); - int pushAvailableToBuffer(); -}; - -#endif /* KOEO_H */ \ No newline at end of file diff --git a/LiveData.cpp b/LiveData.cpp deleted file mode 100644 index 04e0615..0000000 --- a/LiveData.cpp +++ /dev/null @@ -1,235 +0,0 @@ -#include "LiveData.h" - -LiveData::LiveData(SoftwareSerial *softwareSerial, int re, EecIvCommon::callback_t printCallback) { - this->softwareSerial = softwareSerial; - this->pin_re = re; - this->print = printCallback; -} - -int LiveData::mainLoop() { - switch(currentState) { - case REQUEST_LIVE_DATA: - if (requestLiveData()) { - currentState = INIT_LIVE_DATA_MESSAGE_1; - } - break; - case INIT_LIVE_DATA_MESSAGE_1: - if (initLiveDataMessage1()) { - currentState = INIT_LIVE_DATA_MESSAGE_2; - } - break; - case INIT_LIVE_DATA_MESSAGE_2: - if (initLiveDataMessage2()) { - currentState = INIT_LIVE_DATA_MESSAGE_3; - } - break; - case INIT_LIVE_DATA_MESSAGE_3: - if (initLiveDataMessage3()) { - currentState = INIT_LIVE_DATA_MESSAGE_4; - } - break; - case INIT_LIVE_DATA_MESSAGE_4: - if (initLiveDataMessage4()) { - currentState = INIT_LIVE_DATA_MESSAGE_1; - //return 1; - } - break; - - } - - return 0; -} - - -int LiveData::requestLiveData() { - unsigned char requestLiveDataSig[4][2] = { - {0x01, 0xb0 }, - {0xff, 0x5f }, - {0x41, 0x96 }, - {0x00, 0xa0 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(syncSig[syncPointer], buffer, 4)) { - delayMicroseconds(1420); - answer(requestLiveDataSig[syncPointer], 60); - - syncPointer++; - - if (syncPointer > 3) { - syncPointer = 0; - return 1; - } - } - } - - return 0; -} - -int LiveData::initLiveDataMessage1() { - unsigned char readSig[4] = { - 0x00, 0x00, 0x00, 0xA0 - }; - - unsigned char answerSig[6][2] = { - {0x01, 0xb0 }, - {0x01 }, - {0x38, 0x11 }, - {0x28, 0x08 }, - {0xa8, 0x09 }, - {0xb8 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(readSig, buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[0], 60); - - delayMicroseconds(5000); - softwareSerial->write(answerSig[1][0]); - - delayMicroseconds(1420); - answer(answerSig[2], 60); - delayMicroseconds(1420); - answer(answerSig[3], 60); - delayMicroseconds(1420); - answer(answerSig[4], 60); - delayMicroseconds(1420); - softwareSerial->write(answerSig[5][0]); - - return 1; - } - } - - return 0; -} - -int LiveData::initLiveDataMessage2() { - unsigned char readSig[4] = { - 0x00, 0x00, 0x00, 0xB1 - }; - - unsigned char answerSig[6][2] = { - {0xff, 0x5f }, - {0x0d }, - {0xf8, 0x10 }, - {0x38, 0x0f }, // ? - {0xd8, 0x15 }, - {0x68 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(readSig, buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[0], 60); - delayMicroseconds(5000); - softwareSerial->write(answerSig[1][0]); - - delayMicroseconds(1420); - answer(answerSig[2], 60); - delayMicroseconds(1420); - answer(answerSig[3], 60); - delayMicroseconds(1420); - answer(answerSig[4], 60); - delayMicroseconds(1420); - softwareSerial->write(answerSig[5][0]); - return 1; - } - } - - return 0; -} - -int LiveData::initLiveDataMessage3() { - unsigned char readSig[4] = { - 0x00, 0x00, 0x00, 0x82 - }; - - unsigned char answerSig[6][2] = { - {0x21, 0xf6 }, - {0x26 }, - {0x68, 0x0c }, - {0xe8, 0x04 }, - {0x68, 0x0e }, // ? - {0xc8 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(readSig, buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[0], 60); - delayMicroseconds(5000); - softwareSerial->write(answerSig[1][0]); - - delayMicroseconds(1420); - answer(answerSig[2], 60); - delayMicroseconds(1420); - answer(answerSig[3], 60); - delayMicroseconds(1420); - answer(answerSig[4], 60); - delayMicroseconds(1420); - softwareSerial->write(answerSig[5][0]); - return 1; - } - } - - return 0; -} - -int LiveData::initLiveDataMessage4() { - unsigned char readSig[4] = { - 0x00, 0x00, 0x00, 0x93 - }; - - unsigned char answerSig[6][2] = { - {0x00, 0xa0 }, - {0x16 }, - {0x58, 0x1b }, - {0x88, 0x1a }, - {0x98, 0x20 }, - {0x08 } - }; - - if (pushAvailableToBuffer()) { - if (!memcmp(readSig, buffer, 4)) { - delayMicroseconds(1420); - answer(answerSig[0], 60); - delayMicroseconds(5000); - softwareSerial->write(answerSig[1][0]); - - delayMicroseconds(1420); - answer(answerSig[2], 60); - delayMicroseconds(1420); - answer(answerSig[3], 60); - delayMicroseconds(1420); - answer(answerSig[4], 60); - delayMicroseconds(1420); - softwareSerial->write(answerSig[5][0]); - return 1; - } - } - - return 0; -} - -int LiveData::pushAvailableToBuffer() { - if (softwareSerial->available()) { - pushBuffer(softwareSerial->read()); - return 1; - } else { - return 0; - } -} - -void LiveData::pushBuffer(unsigned char val) { - buffer[0] = buffer[1]; - buffer[1] = buffer[2]; - buffer[2] = buffer[3]; - buffer[3] = val; -} - -void LiveData::initBuffer() { - for (int i = 0; i < sizeof(buffer); i++) { - buffer[i] = 0; - } -} diff --git a/LiveData.h b/LiveData.h deleted file mode 100644 index b93f861..0000000 --- a/LiveData.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef LIVE_DATA_H -#define LIVE_DATA_H - -#include "arduino.h" -#include -#include "EecIvCommon.h" - -class LiveData : EecIvCommon { - public: - LiveData(SoftwareSerial *softwareSerial, int re, EecIvCommon::callback_t printCallback); - - int mainLoop(); - - private: - callback_t print; - - int syncPointer = 0; - unsigned char buffer[4]; - void pushBuffer(unsigned char val); - void initBuffer(); - int pushAvailableToBuffer(); - - enum State { - REQUEST_LIVE_DATA, - INIT_LIVE_DATA_MESSAGE_1, - INIT_LIVE_DATA_MESSAGE_2, - INIT_LIVE_DATA_MESSAGE_3, - INIT_LIVE_DATA_MESSAGE_4 - }; - - State currentState = REQUEST_LIVE_DATA; - - int requestLiveData(); - int initLiveDataMessage1(); - int initLiveDataMessage2(); - int initLiveDataMessage3(); - int initLiveDataMessage4(); - -}; - -#endif /* LIVE_DATA_H */ \ No newline at end of file diff --git a/TftConsole.cpp b/TftConsole.cpp deleted file mode 100644 index 9bfd464..0000000 --- a/TftConsole.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "TftConsole.h" - -TftConsole::TftConsole(int cs, int dc, int rst) { - tft = new TFT(cs, dc, rst); -} - -void TftConsole::setup() { - tft->begin(); - tft->background(0, 0, 0); - tft->stroke(255, 255, 255); - tft->setTextSize(1); -} - -void TftConsole::printHexValue(int value) { - nextLineIfLineIsFull(); - nextPageIfPageIsFull(); - - sprintf(hexBuffer, "%02X ", value); - tft->text(hexBuffer, signCounter*signWidth, lineCounter * lineHeight); - signCounter+=3; -} - -void TftConsole::printLine(char text[]) { - nextLineIfLineIsStarted(); - nextPageIfPageIsFull(); - tft->text(text, 0, lineCounter * lineHeight); - lineCounter++; - signCounter = 0; -} - -void TftConsole::nextPageIfPageIsFull() { - if (lineCounter >= maxLine) { - lineCounter = 0; - tft->background(0,0,0); - } -} - -void TftConsole::nextLineIfLineIsFull() { - if (signCounter >= maxSign) { - signCounter = 0; - lineCounter++; - } -} - -void TftConsole::nextLineIfLineIsStarted() { - if (signCounter != 0) { - lineCounter++; - signCounter = 0; - } -} diff --git a/TftConsole.h b/TftConsole.h deleted file mode 100644 index d2d57c7..0000000 --- a/TftConsole.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef TFT_CONSOLE_H -#define TFT_CONSOLE_H - -#include -#include - -class TftConsole { - private: - int lineCounter = 0; - int signCounter = 0; - int lineHeight = 10; - int signWidth = 5; - - int maxLine = 13; - int maxSign = 26; - - char hexBuffer[6]; - TFT *tft; - - public: - TftConsole(int cs, int dc, int rst); - void setup(); - void printHexValue(int value); - void printLine(char text[]); - - private: - void nextPageIfPageIsFull(); - void nextLineIfLineIsFull(); - void nextLineIfLineIsStarted(); -}; - -#endif /* TFT_CONSOLE_H */ diff --git a/eec-iv-reader.ino b/eec-iv-reader.ino deleted file mode 100644 index 48064bd..0000000 --- a/eec-iv-reader.ino +++ /dev/null @@ -1,218 +0,0 @@ -#include -#include -#include - -//using namespace Menu; - -#include "EecIv.h" - -#include - -// Pins RS485 -#define DI 2 -#define RE 3 -#define RO 4 -// first board -//#define DI 3 -//#define RE 6 -//#define RO 2 - -// Pins Buttons -#define BTN_1 7 -#define BTN_2 8 -#define BTN_3 9 - - -EasyButton button1(BTN_1); -EasyButton button2(BTN_2); -EasyButton button3(BTN_3); - -#define UP_SIGN '\x8c' -#define DOWN_SIGN '\x8e' -#define SELECT_SIGN '\xbb' -#define BACK_SIGN '\xab' -#define NO_SIGN ' ' -#define NUM_COLUMN 16 -#define NUM_ROW 8 -#define HEADING_SELECT "Select Mode" - -U8X8_SH1106_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); - -void serialPrint(char message[]) { - Serial.println(message); -} - -void onFaultCodeFinished(char message[]); - -EecIv eecIv = EecIv(DI, RO, RE); - -#define NUM_MODES 2 -enum MODE { - FAULT_CODE, - KOEO -}; -int mode = FAULT_CODE; - -enum SCREEN_MODE { - SELECT_MODE, - READING_FAULT_CODE, - RESULT_FAULT_CODE, - RUNNING_KOEO, - RESULT_KOEO -}; -int screenMode = SELECT_MODE; - - -char koeo_codes[12][4]; -int koeo_counter = 0; -int koeo_code = 0; - -void setup() { - Serial.begin(19200); - - Wire.begin(); - u8x8.begin(); - - - button1.begin(); - button1.onPressed(onButtonUp); - button2.begin(); - button2.onPressed(onButtonSelect); - button3.begin(); - button3.onPressed(onButtonDown); - - eecIv.debugPrint = &serialPrint; - eecIv.onFaultCodeFinished = &onFaultCodeFinished; - eecIv.onKoeoReadCode = &onKoeoReadCode; - eecIv.onKoeoFinished = &onKoeoFinished; - eecIv.setup(); - - initSelectMode(); -} - -void drawWaitingScreen() { - u8x8.clear(); - - u8x8.setFont(u8x8_font_8x13_1x2_f); - u8x8.drawString(1, 3, "Reading..."); -} - -void drawMenuScreen(char selectSign, char upSign, char downSign, char heading[], char bodyLine1[], char bodyLine2[], char bodyLine3[]) { - u8x8.clear(); - - u8x8.setFont(u8x8_font_8x13B_1x2_f); - u8x8.drawString(1, 0, heading); // 15 - u8x8.setFont(u8x8_font_8x13_1x2_f); - u8x8.drawString(0, 2, bodyLine1); // 15 - u8x8.drawString(0, 4, bodyLine2); // 15 - u8x8.drawString(0, 6, bodyLine3); // 14 - - u8x8.setFont(u8x8_font_amstrad_cpc_extended_f); - u8x8.drawGlyph(NUM_COLUMN - 1, NUM_ROW/2 - 1, selectSign); - u8x8.drawGlyph(NUM_COLUMN - 2, NUM_ROW - 1, upSign); - u8x8.drawGlyph(NUM_COLUMN - 1, NUM_ROW - 1, downSign); -} - -void loop() { - button1.read(); - button2.read(); - button3.read(); - - eecIv.mainLoop(); -} - -void onButtonUp() { - switch(screenMode) { - case SELECT_MODE: - switchMode(false); - break; - case RESULT_KOEO: - switchKoeoCode(false); - break; - } -} - -void onButtonDown() { - switch(screenMode) { - case SELECT_MODE: - switchMode(true); - break; - case RESULT_KOEO: - switchKoeoCode(true); - break; - } -} - -void onButtonSelect() { - switch(screenMode) { - case SELECT_MODE: - selectMode(); - break; - case RESULT_KOEO: - case RESULT_FAULT_CODE: - initSelectMode(); - break; - } -} - -void initSelectMode() { - eecIv.setModeFaultCode(); - screenMode = SELECT_MODE; - mode = FAULT_CODE; - drawMenuScreen(SELECT_SIGN, UP_SIGN, DOWN_SIGN, HEADING_SELECT, "Read Fault-", "Code", ""); -} - -void switchKoeoCode(bool down) { - koeo_code = down ? (koeo_code+12-1)%12 : (koeo_code+1)%12; - char code_buf[16]; - sprintf(code_buf, "[%0d] %s", koeo_code+1, koeo_codes[koeo_code]); - drawMenuScreen(BACK_SIGN, UP_SIGN, DOWN_SIGN, "Fault Code", code_buf, "", ""); -} - -void switchMode(bool down) { - mode = down ? (mode+NUM_MODES-1)%NUM_MODES : (mode+1)%NUM_MODES; - switch (mode) { - case FAULT_CODE: - drawMenuScreen(SELECT_SIGN, UP_SIGN, DOWN_SIGN, HEADING_SELECT, "Read Fault-", "Code", ""); - break; - case KOEO: - drawMenuScreen(SELECT_SIGN, UP_SIGN, DOWN_SIGN, HEADING_SELECT, "Run KOEO", "", ""); - break; - } -} - -void selectMode() { - switch (mode) { - case FAULT_CODE: - eecIv.setModeFaultCode(); - eecIv.restartReading(); - screenMode = READING_FAULT_CODE; - drawWaitingScreen(); - break; - case KOEO: - eecIv.setModeKoeo(); - eecIv.restartReading(); - screenMode = RUNNING_KOEO; - drawWaitingScreen(); - break; - } -} - -void onKoeoReadCode(char message[]) { - sprintf(koeo_codes[koeo_counter], message); - koeo_counter++; -} - -void onKoeoFinished() { - koeo_counter = 0; - koeo_code = 0; - screenMode = RESULT_KOEO; - char code_buf[16]; - sprintf(code_buf, "[%0d] %s", koeo_code+1, koeo_codes[koeo_code]); - drawMenuScreen(BACK_SIGN, UP_SIGN, DOWN_SIGN, "Fault Code", code_buf, "", ""); -} - -void onFaultCodeFinished(char message[]) { - screenMode = RESULT_FAULT_CODE; - drawMenuScreen(BACK_SIGN, NO_SIGN, NO_SIGN, "Fault Code", message, "", ""); -} \ No newline at end of file diff --git a/include/README b/include/README new file mode 100644 index 0000000..45496b1 --- /dev/null +++ b/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..8c9c29c --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..95bb688 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,17 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:eec-iv-reader] +platform = atmelavr +board = uno +framework = arduino +lib_deps = + evert-arias/EasyButton@^2.0.1 + olikraus/U8g2@^2.34.4 diff --git a/src b/src new file mode 160000 index 0000000..49a23ba --- /dev/null +++ b/src @@ -0,0 +1 @@ +Subproject commit 49a23ba56781d3651bbbe8e85cf5959df6c42c73 diff --git a/test/README b/test/README new file mode 100644 index 0000000..b0416ad --- /dev/null +++ b/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html