From 17f888a11c3ce0f1a37ed498efa953d49d3c4ba5 Mon Sep 17 00:00:00 2001 From: GarandPLG Date: Tue, 16 Jun 2026 22:32:39 +0200 Subject: [PATCH] Rename Projekt.ino to Projekt_Arduino.ino Rename Projekt.ino to Projekt_Arduino.ino MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- Config.h | 6 +----- Display.cpp | 38 ++++++++++---------------------------- Display.h | 9 ++------- Projekt_Arduino.ino | 13 +++---------- 4 files changed, 16 insertions(+), 50 deletions(-) diff --git a/Config.h b/Config.h index 88c8494..9f878ad 100644 --- a/Config.h +++ b/Config.h @@ -4,13 +4,9 @@ const int SS_PIN = 10; 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); -// // Kierunkowskazy -// const int TS_RIGHT = 9; -// const int TS_LEFT = 8; - // // Odległościomierz // const int TRIG_PIN = 6; // const int ECHO_PIN = 5; diff --git a/Display.cpp b/Display.cpp index 9bb6ce2..62faacc 100644 --- a/Display.cpp +++ b/Display.cpp @@ -2,22 +2,23 @@ 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.noDisplay(); _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::startOrEnd(bool enable) { + if (enable) { + delay(3000); + _lcd.display(); + } else { + _lcd.noDisplay(); + } +} + void Display::updateSpeed(int kmh) { if (kmh < 0) kmh = 0; if (kmh > 999) kmh = 999; @@ -44,22 +45,3 @@ void Display::updateGear(char gearChar) { _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)); -// } diff --git a/Display.h b/Display.h index 613706c..41dd24d 100644 --- a/Display.h +++ b/Display.h @@ -13,19 +13,14 @@ class Display { public: void begin(int cols, int rows); + void startOrEnd(bool enable); + void updateSpeed(int kmh); void updateRPM(int rpm); void updateGear(char gearChar); - // void updateDirection(bool leftOn, bool rightOn); - private: 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 }; }; diff --git a/Projekt_Arduino.ino b/Projekt_Arduino.ino index 29cf450..588042c 100644 --- a/Projekt_Arduino.ino +++ b/Projekt_Arduino.ino @@ -20,9 +20,6 @@ bool carEnabled = false; void setup() { Serial.begin(9600); - // pinMode(TS_LEFT, INPUT); - // pinMode(TS_RIGHT, INPUT); - pinMode(IN_1, OUTPUT); pinMode(IN_2, OUTPUT); @@ -38,20 +35,16 @@ void loop() { bool rfidOk = check && matches; if (rfid.check() && rfid.matches(AUTH_UID, AUTH_UID_SIZE)) { - delay(3000); carEnabled = !carEnabled; + Serial.print("Auto działa: "); + Serial.println(carEnabled); + display.startOrEnd(carEnabled);0 }; if (carEnabled) { - Serial.println("Działa"); - if (gear.update()) display.updateGear(gear.getGearChar()); - // display.updateDirection( - // digitalRead(TS_LEFT), - // digitalRead(TS_RIGHT)); - unsigned long now = millis(); float dt = (now - prevUpdate) / 1000.0f; if (dt >= 0.02f) {