Rename Projekt.ino to Projekt_Arduino.ino
Rename Projekt.ino to Projekt_Arduino.ino - Rename the main sketch file and adjust references accordingly. - Clean up Config.h spacing and delete unused turn‑signal constants. - Remove direction‑related LCD character data and its update logic. - Introduce Display::startOrEnd to control LCD power on/off. - Simplify display initialization and eliminate the old delay in the loop. - Add serial debug output for the car enable state.
This commit is contained in:
@@ -4,13 +4,9 @@
|
|||||||
const int SS_PIN = 10;
|
const int SS_PIN = 10;
|
||||||
const int RST_PIN = 7;
|
const int RST_PIN = 7;
|
||||||
|
|
||||||
const byte AUTH_UID[4] = {145, 136, 97, 102};
|
const byte AUTH_UID[4] = { 145, 136, 97, 102 };
|
||||||
const byte AUTH_UID_SIZE = sizeof(AUTH_UID);
|
const byte AUTH_UID_SIZE = sizeof(AUTH_UID);
|
||||||
|
|
||||||
// // Kierunkowskazy
|
|
||||||
// const int TS_RIGHT = 9;
|
|
||||||
// const int TS_LEFT = 8;
|
|
||||||
|
|
||||||
// // Odległościomierz
|
// // Odległościomierz
|
||||||
// const int TRIG_PIN = 6;
|
// const int TRIG_PIN = 6;
|
||||||
// const int ECHO_PIN = 5;
|
// const int ECHO_PIN = 5;
|
||||||
|
|||||||
+10
-28
@@ -2,22 +2,23 @@
|
|||||||
|
|
||||||
void Display::begin(int cols, int rows) {
|
void Display::begin(int cols, int rows) {
|
||||||
_lcd.begin(cols, rows);
|
_lcd.begin(cols, rows);
|
||||||
|
_lcd.noDisplay();
|
||||||
_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.setCursor(0, 0);
|
||||||
_lcd.print("km/h: 000 | ");
|
_lcd.print("km/h: 000 | ");
|
||||||
_lcd.write((uint8_t)CHAR_LEFT);
|
|
||||||
_lcd.print(" ");
|
|
||||||
_lcd.write((uint8_t)CHAR_RIGHT);
|
|
||||||
|
|
||||||
_lcd.setCursor(0, 1);
|
_lcd.setCursor(0, 1);
|
||||||
_lcd.print("rpm: 0000 | G:0");
|
_lcd.print("rpm: 0000 | G:0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Display::startOrEnd(bool enable) {
|
||||||
|
if (enable) {
|
||||||
|
delay(3000);
|
||||||
|
_lcd.display();
|
||||||
|
} else {
|
||||||
|
_lcd.noDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Display::updateSpeed(int kmh) {
|
void Display::updateSpeed(int kmh) {
|
||||||
if (kmh < 0) kmh = 0;
|
if (kmh < 0) kmh = 0;
|
||||||
if (kmh > 999) kmh = 999;
|
if (kmh > 999) kmh = 999;
|
||||||
@@ -44,22 +45,3 @@ void Display::updateGear(char gearChar) {
|
|||||||
_lcd.print(gearChar);
|
_lcd.print(gearChar);
|
||||||
_lcd.print(' ');
|
_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));
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -13,19 +13,14 @@ class Display {
|
|||||||
public:
|
public:
|
||||||
void begin(int cols, int rows);
|
void begin(int cols, int rows);
|
||||||
|
|
||||||
|
void startOrEnd(bool enable);
|
||||||
|
|
||||||
void updateSpeed(int kmh);
|
void updateSpeed(int kmh);
|
||||||
|
|
||||||
void updateRPM(int rpm);
|
void updateRPM(int rpm);
|
||||||
|
|
||||||
void updateGear(char gearChar);
|
void updateGear(char gearChar);
|
||||||
|
|
||||||
// void updateDirection(bool leftOn, bool rightOn);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rgb_lcd _lcd;
|
rgb_lcd _lcd;
|
||||||
|
|
||||||
byte _leftChar[8] = { 0x00, 0x04, 0x08, 0x1F, 0x1F, 0x08, 0x04, 0x00 };
|
|
||||||
byte _leftCharBlink[8] = { 0x1F, 0x1B, 0x17, 0x00, 0x00, 0x17, 0x1B, 0x1F };
|
|
||||||
byte _rightChar[8] = { 0x00, 0x04, 0x02, 0x1F, 0x1F, 0x02, 0x04, 0x00 };
|
|
||||||
byte _rightCharBlink[8] = { 0x1F, 0x1B, 0x1D, 0x00, 0x00, 0x1D, 0x1B, 0x1F };
|
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-10
@@ -20,9 +20,6 @@ bool carEnabled = false;
|
|||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// pinMode(TS_LEFT, INPUT);
|
|
||||||
// pinMode(TS_RIGHT, INPUT);
|
|
||||||
|
|
||||||
pinMode(IN_1, OUTPUT);
|
pinMode(IN_1, OUTPUT);
|
||||||
pinMode(IN_2, OUTPUT);
|
pinMode(IN_2, OUTPUT);
|
||||||
|
|
||||||
@@ -38,20 +35,16 @@ void loop() {
|
|||||||
bool rfidOk = check && matches;
|
bool rfidOk = check && matches;
|
||||||
|
|
||||||
if (rfid.check() && rfid.matches(AUTH_UID, AUTH_UID_SIZE)) {
|
if (rfid.check() && rfid.matches(AUTH_UID, AUTH_UID_SIZE)) {
|
||||||
delay(3000);
|
|
||||||
carEnabled = !carEnabled;
|
carEnabled = !carEnabled;
|
||||||
|
Serial.print("Auto działa: ");
|
||||||
|
Serial.println(carEnabled);
|
||||||
|
display.startOrEnd(carEnabled);0
|
||||||
};
|
};
|
||||||
|
|
||||||
if (carEnabled) {
|
if (carEnabled) {
|
||||||
Serial.println("Działa");
|
|
||||||
|
|
||||||
if (gear.update())
|
if (gear.update())
|
||||||
display.updateGear(gear.getGearChar());
|
display.updateGear(gear.getGearChar());
|
||||||
|
|
||||||
// display.updateDirection(
|
|
||||||
// digitalRead(TS_LEFT),
|
|
||||||
// digitalRead(TS_RIGHT));
|
|
||||||
|
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
float dt = (now - prevUpdate) / 1000.0f;
|
float dt = (now - prevUpdate) / 1000.0f;
|
||||||
if (dt >= 0.02f) {
|
if (dt >= 0.02f) {
|
||||||
|
|||||||
Reference in New Issue
Block a user