#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#define I2C_SDA 22
#define I2C_SCL 21
#define VERT_PIN 34
#define HORZ_PIN 36
#define SEL_PIN 32
int currentSelection = 0; // 0 = Settings, 1 = Timer
unsigned long lastBlinkTime = 0;
bool cursorVisible = true;
// Screen
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
Serial.begin(115200);
Wire.begin(I2C_SDA, I2C_SCL);
lcd.init();
lcd.backlight();
pinMode(VERT_PIN, INPUT);
pinMode(HORZ_PIN, INPUT);
pinMode(SEL_PIN, INPUT_PULLUP);
Serial.println("System initialized!");
}
void loop() {
int vert = analogRead(VERT_PIN);
int horz = analogRead(HORZ_PIN);
bool selPressed = digitalRead(SEL_PIN) == LOW;
//xyz
bool top = 0;
bool bottom = 0;
if (millis() - lastBlinkTime > 500) {
cursorVisible = !cursorVisible;
if (cursorVisible) {
lcd.cursor();
} else {
lcd.noCursor();
}
lastBlinkTime = millis();
}
lcd.clear();
if (vert == 1023 && horz == 512) {
top = 1;
}
else if (vert == 0 && horz == 512) {
bottom = 1;
}
if (top && currentSelection - 1 >= 0) {
currentSelection -= 1;
}
else if (bottom && currentSelection + 1 <= 4) {
currentSelection += 1;
}
// // Пункт 1: Settings
// lcd.setCursor(0, 0);
// if (currentSelection == 0) {
// lcd.print(">1. Settings");
// } else {
// lcd.print(" 1. Settings");
// }
// // Пункт 2: Timer
// lcd.setCursor(0, 1);
// if (currentSelection == 1) {
// lcd.print(">2. Timer");
// } else {
// lcd.print(" 2. Timer");
// }
// // Устанавливаем курсор на выбранную строку
// lcd.setCursor(0, currentSelection);
delay(5000);
}