mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-14 17:05:08 +01:00
commit
9f6a23f11b
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -47,4 +47,4 @@ jobs:
|
|||||||
cd Cart_Reader/
|
cd Cart_Reader/
|
||||||
# Select hardware version by uncommenting it (using regular expression)
|
# Select hardware version by uncommenting it (using regular expression)
|
||||||
sed -i 's/^\/\/[\t ]*#define ${{ matrix.hwVersion }}/#define ${{ matrix.hwVersion }}/g' Cart_Reader.ino
|
sed -i 's/^\/\/[\t ]*#define ${{ matrix.hwVersion }}/#define ${{ matrix.hwVersion }}/g' Cart_Reader.ino
|
||||||
arduino-cli compile --fqbn arduino:avr:mega
|
arduino-cli compile --fqbn arduino:avr:mega --warnings all
|
||||||
|
@ -224,22 +224,6 @@ boolean dont_log = false;
|
|||||||
template<class T> int EEPROM_writeAnything(int ee, const T& value);
|
template<class T> int EEPROM_writeAnything(int ee, const T& value);
|
||||||
template<class T> int EEPROM_readAnything(int ee, T& value);
|
template<class T> int EEPROM_readAnything(int ee, T& value);
|
||||||
|
|
||||||
template<class T> int EEPROM_writeAnything(int ee, const T& value) {
|
|
||||||
const byte* p = (const byte*)(const void*)&value;
|
|
||||||
unsigned int i;
|
|
||||||
for (i = 0; i < sizeof(value); i++)
|
|
||||||
EEPROM.write(ee++, *p++);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T> int EEPROM_readAnything(int ee, T& value) {
|
|
||||||
byte* p = (byte*)(void*)&value;
|
|
||||||
unsigned int i;
|
|
||||||
for (i = 0; i < sizeof(value); i++)
|
|
||||||
*p++ = EEPROM.read(ee++);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Graphic SPI LCD
|
// Graphic SPI LCD
|
||||||
#ifdef enable_LCD
|
#ifdef enable_LCD
|
||||||
#include <U8g2lib.h>
|
#include <U8g2lib.h>
|
||||||
@ -302,6 +286,26 @@ void _print_FatalError(void) __attribute__((noreturn));
|
|||||||
void print_FatalError(const __FlashStringHelper* errorMessage) __attribute__((noreturn));
|
void print_FatalError(const __FlashStringHelper* errorMessage) __attribute__((noreturn));
|
||||||
void print_FatalError(byte errorMessage) __attribute__((noreturn));
|
void print_FatalError(byte errorMessage) __attribute__((noreturn));
|
||||||
|
|
||||||
|
/******************************************
|
||||||
|
End of inclusions and forward declarations
|
||||||
|
*****************************************/
|
||||||
|
|
||||||
|
template<class T> int EEPROM_writeAnything(int ee, const T& value) {
|
||||||
|
const byte* p = (const byte*)(const void*)&value;
|
||||||
|
unsigned int i;
|
||||||
|
for (i = 0; i < sizeof(value); i++)
|
||||||
|
EEPROM.write(ee++, *p++);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> int EEPROM_readAnything(int ee, T& value) {
|
||||||
|
byte* p = (byte*)(void*)&value;
|
||||||
|
unsigned int i;
|
||||||
|
for (i = 0; i < sizeof(value); i++)
|
||||||
|
*p++ = EEPROM.read(ee++);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
Common Strings
|
Common Strings
|
||||||
*****************************************/
|
*****************************************/
|
||||||
@ -675,15 +679,26 @@ void get_line(char* str_buf, FsFile* readfile, uint8_t maxi) {
|
|||||||
|
|
||||||
void rewind_line(FsFile& readfile, byte count = 1) {
|
void rewind_line(FsFile& readfile, byte count = 1) {
|
||||||
uint32_t position = readfile.curPosition();
|
uint32_t position = readfile.curPosition();
|
||||||
|
// To seek one line back, this code must step over the first newline it finds
|
||||||
|
// in order to exit the current line and enter the end of the previous one.
|
||||||
|
// Convert <count> from how-many-lines-back into how-many-newlines-to-look-for
|
||||||
|
// by incrementing it by 1.
|
||||||
count++;
|
count++;
|
||||||
for (byte count_newline = 0; count_newline < count; count_newline++) {
|
for (byte count_newline = 0; count_newline < count; count_newline++) {
|
||||||
|
// Go to the strictly previous '\n', or file start.
|
||||||
while (position) {
|
while (position) {
|
||||||
|
// Seek back first (keeping position updated)...
|
||||||
position--;
|
position--;
|
||||||
readfile.seekCur(-1);
|
readfile.seekCur(-1);
|
||||||
|
// ...and check current byte second.
|
||||||
|
// Note: this code assumed all files use ASCII with DOS-style newlines
|
||||||
|
// so \n is encountered first when seeking backwards.
|
||||||
if (readfile.peek() == '\n')
|
if (readfile.peek() == '\n')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If not at file start, the current character is the '\n' just before the
|
||||||
|
// desired line, so advance by one.
|
||||||
if (position)
|
if (position)
|
||||||
readfile.seekCur(1);
|
readfile.seekCur(1);
|
||||||
}
|
}
|
||||||
@ -936,12 +951,10 @@ void mainMenu() {
|
|||||||
if (currPage == 1) {
|
if (currPage == 1) {
|
||||||
option_offset = 0;
|
option_offset = 0;
|
||||||
num_answers = 7;
|
num_answers = 7;
|
||||||
}
|
} else if (currPage == 2) {
|
||||||
if (currPage == 2) {
|
|
||||||
option_offset = 7;
|
option_offset = 7;
|
||||||
num_answers = 7;
|
num_answers = 7;
|
||||||
}
|
} else { // currPage == 3
|
||||||
if (currPage == 3) {
|
|
||||||
option_offset = 14;
|
option_offset = 14;
|
||||||
num_answers = 2;
|
num_answers = 2;
|
||||||
}
|
}
|
||||||
@ -2686,6 +2699,8 @@ int checkButton() {
|
|||||||
else if (incomingByte == 240) {
|
else if (incomingByte == 240) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_serial() {
|
void wait_serial() {
|
||||||
@ -2742,11 +2757,8 @@ int checkButton() {
|
|||||||
return 3;
|
return 3;
|
||||||
else if (eventButton2 > 2)
|
else if (eventButton2 > 2)
|
||||||
return 4;
|
return 4;
|
||||||
else
|
|
||||||
return (checkButton1());
|
|
||||||
#else
|
|
||||||
return (checkButton1());
|
|
||||||
#endif
|
#endif
|
||||||
|
return (checkButton1());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read button 1
|
// Read button 1
|
||||||
@ -2913,26 +2925,17 @@ int checkButton() {
|
|||||||
// Check if rotary encoder has changed
|
// Check if rotary encoder has changed
|
||||||
if (rotaryPos != newPos) {
|
if (rotaryPos != newPos) {
|
||||||
int rotaryDir = (int)encoder.getDirection();
|
int rotaryDir = (int)encoder.getDirection();
|
||||||
if (rotaryDir == 1) {
|
|
||||||
rotaryPos = newPos;
|
rotaryPos = newPos;
|
||||||
|
if (rotaryDir == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (rotaryDir == -1) {
|
} else if (rotaryDir == -1) {
|
||||||
rotaryPos = newPos;
|
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
} else if (reading == buttonState) {
|
} else if (reading != buttonState) {
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// Check if button has changed
|
|
||||||
else {
|
|
||||||
if (reading != lastButtonState) {
|
if (reading != lastButtonState) {
|
||||||
lastDebounceTime = millis();
|
lastDebounceTime = millis();
|
||||||
}
|
lastButtonState = reading;
|
||||||
// Debounce button
|
} else if ((millis() - lastDebounceTime) > debounceDelay) {
|
||||||
if ((millis() - lastDebounceTime) > debounceDelay) {
|
|
||||||
if (reading != buttonState) {
|
|
||||||
buttonState = reading;
|
buttonState = reading;
|
||||||
// Button was pressed down
|
// Button was pressed down
|
||||||
if (buttonState == 0) {
|
if (buttonState == 0) {
|
||||||
@ -2941,10 +2944,10 @@ int checkButton() {
|
|||||||
// Wait until button was let go again
|
// Wait until button was let go again
|
||||||
while ((PING & (1 << PING2)) >> PING2 == 0) {
|
while ((PING & (1 << PING2)) >> PING2 == 0) {
|
||||||
// Signal long press delay reached
|
// Signal long press delay reached
|
||||||
if ((millis() - pushTime) > 2000)
|
if ((millis() - pushTime) > 2000) {
|
||||||
rgbLed(green_color);
|
rgbLed(green_color);
|
||||||
}
|
}
|
||||||
lastButtonState = reading;
|
}
|
||||||
|
|
||||||
// 2 second long press
|
// 2 second long press
|
||||||
if ((millis() - pushTime) > 2000) {
|
if ((millis() - pushTime) > 2000) {
|
||||||
@ -2955,15 +2958,9 @@ int checkButton() {
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
lastButtonState = reading;
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lastButtonState = reading;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for user to push button
|
// Wait for user to push button
|
||||||
|
@ -562,7 +562,9 @@ void getMapping() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!database.available()) {
|
if (database.available()) {
|
||||||
|
browseDatabase = false;
|
||||||
|
} else {
|
||||||
// File searched until end but nothing found
|
// File searched until end but nothing found
|
||||||
println_Msg(F(""));
|
println_Msg(F(""));
|
||||||
println_Msg(F("CRC not found in database"));
|
println_Msg(F("CRC not found in database"));
|
||||||
|
Loading…
Reference in New Issue
Block a user