899212d7b9
Define AUTH_UID and AUTH_UID_SIZE constants. Introduce motor control pins IN_1‑IN_4 and set them as outputs. Comment out turn‑signal and sonar pin definitions and related code. Refactor Display to remove updateDirection functionality. Extend RFIDReader with reset() and matches() methods; use them to toggle carEnabled based on RFID authentication. Update the main loop to operate only when the RFID tag matches the authorized UID.
66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#include "Display.h"
|
|
|
|
void Display::begin(int cols, int rows) {
|
|
_lcd.begin(cols, rows);
|
|
|
|
_lcd.createChar(CHAR_LEFT, _leftChar);
|
|
_lcd.createChar(CHAR_RIGHT, _rightChar);
|
|
_lcd.createChar(CHAR_LEFT_BLINK, _leftCharBlink);
|
|
_lcd.createChar(CHAR_RIGHT_BLINK, _rightCharBlink);
|
|
|
|
_lcd.setCursor(0, 0);
|
|
_lcd.print("km/h: 000 | ");
|
|
_lcd.write((uint8_t)CHAR_LEFT);
|
|
_lcd.print(" ");
|
|
_lcd.write((uint8_t)CHAR_RIGHT);
|
|
|
|
_lcd.setCursor(0, 1);
|
|
_lcd.print("rpm: 0000 | G:0");
|
|
}
|
|
|
|
void Display::updateSpeed(int kmh) {
|
|
if (kmh < 0) kmh = 0;
|
|
if (kmh > 999) kmh = 999;
|
|
|
|
_lcd.setCursor(6, 0);
|
|
if (kmh < 100) _lcd.print('0');
|
|
if (kmh < 10) _lcd.print('0');
|
|
_lcd.print(kmh);
|
|
}
|
|
|
|
void Display::updateRPM(int rpm) {
|
|
if (rpm < 0) rpm = 0;
|
|
if (rpm > 9999) rpm = 9999;
|
|
|
|
_lcd.setCursor(5, 1);
|
|
if (rpm < 1000) _lcd.print('0');
|
|
if (rpm < 100) _lcd.print('0');
|
|
if (rpm < 10) _lcd.print('0');
|
|
_lcd.print(rpm);
|
|
}
|
|
|
|
void Display::updateGear(char gearChar) {
|
|
_lcd.setCursor(14, 1);
|
|
_lcd.print(gearChar);
|
|
_lcd.print(' ');
|
|
}
|
|
|
|
// void Display::updateDirection(bool leftOn, bool rightOn) {
|
|
// if (leftOn && rightOn) {
|
|
// _lcd.setCursor(12, 0);
|
|
// _lcd.write((uint8_t)CHAR_LEFT);
|
|
// _lcd.print(' ');
|
|
// _lcd.write((uint8_t)CHAR_RIGHT);
|
|
// return;
|
|
// }
|
|
|
|
// unsigned long now = millis();
|
|
// bool leftBlink = leftOn && ((now / 1000UL) % 2 == 0);
|
|
// bool rightBlink = rightOn && ((now / 1000UL) % 2 == 0);
|
|
|
|
// _lcd.setCursor(12, 0);
|
|
// _lcd.write((uint8_t)(leftBlink ? CHAR_LEFT_BLINK : CHAR_LEFT));
|
|
// _lcd.print(' ');
|
|
// _lcd.write((uint8_t)(rightBlink ? CHAR_RIGHT_BLINK : CHAR_RIGHT));
|
|
// }
|