/*
DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC
DC DC
DC CONTAGIRI COMPLETO DC
DC DC
DC DC
DC Autore: Domenico Cillo DC
DC DC
DC Ultima Modifica: 21 01 2023 DC
DC DC
DCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDC*/
//#define SIMULAZIONE
#include "Variabili.h"
#include "Funz_Timer.h"
#include <EEPROM.h>
#include "Funzioni.h"
#include <SPI.h> // Libreria per comunicazione seriale SPI
#include <Wire.h> // Libreria per I2C
#include <Adafruit_GFX.h> // ver. 1.10.10 (Adafruit BusIO ver 1.9.8)
#include <Adafruit_SSD1306.h> // ver. 2.5.0
#include "OneButton.h" // ver. 2.0.2
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // Istanza dell'OLED SSD1306 connesso con I2C
#include "Funz_display.h"
#include "Logo.h"
#include "Stati.h"
//(const int pin, const boolean activeLow, const bool pullupActive)
OneButton buttonSu(su_pin, true, true); // Pulsante SU
OneButton buttonOk(ok_pin, true, true); // Pulsante GIU'
OneButton buttonGiu(giu_pin, true, true); // Pulsante OK
void setup() {
//Serial.begin(115200);
//DDRB = 0;
//PORTB = 2;
pinMode(ALIM_IR, OUTPUT);
while (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
// Serial.println(F("SSD1306 allocation failed"));
abort();
}
display.clearDisplay(); // Svuota il buffer del display
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK); // Imposta il colore del testo BIANCO su sfondo NERO
display.drawBitmap(39, 17, Logo_Creative, 49, 48, SSD1306_WHITE, SSD1306_BLACK);
//display.drawBitmap(38, 17, Logo_Electronic_Creative, 50, 50, SSD1306_WHITE, SSD1306_BLACK);
//display.drawBitmap(41, 17, LogoDC, 46, 48, SSD1306_WHITE, SSD1306_BLACK);
printMsg (titolo_logo1, 1, CX, 0);
printMsg (titolo_logo2, 1, CX, 9);
display.display();
//display.setRotation(0);
buttonSu.setClickTicks(50); // Imposto il tempo di singola pressione del pulsante Su
buttonOk.setClickTicks(50); // Imposto il tempo di singola pressione del pulsante Ok
buttonGiu.setClickTicks(50); // Imposto il tempo di singola pressione del pulsante Giu
buttonSu.attachClick(up);
buttonGiu.attachClick(down);
buttonOk.attachClick(ok);
buttonSu.attachDuringLongPress(AumentaVeloce);
buttonGiu.attachDuringLongPress(DiminuisceVeloce);
buttonOk.attachLongPressStart(OkLungo);
delay(5000);
display.clearDisplay();
//printMsg(titolo1[0], 2, CX, 0); // display.setTextSize(2);display.setCursor(28, 0);display.print("STROBO");
display.display();
}
void loop() {
buttonSu.tick();
buttonOk.tick();
buttonGiu.tick();
if (ok_btn) {
//if (menu != 3) {
menu++;
menu = menu % 3;
imposta_stato = true;
ok_btn = false;
} /*
else {
F_osc_m = ((float)(prescaler[sel_prescaler] * (OCR1A + 1)) * rpm); // F_osc = ((float)(prescaler[sel_prescaler] * (OCR1A + 1)) * rpm) / 60.0f;
Fquarzo = F_osc_m / 60.0f;
to_eeprom(&rpm, 4, 0); // memorizzo gli rpm impostati nella EEPROM
to_eeprom(&F_osc_m, 4, 4); // memorizzo 60 * F_CPU nella EEPROM
to_eeprom(&Fquarzo, 4, 8); // F_CPU nella EEPROM
menu = 0;
}
//imposta_stato = true;
//ok_btn = false;
}*/
// stati[menu]();
switch (menu) {
case 0:
Strobo();
break;
case 1:
Contagiri_Magnetico();
break;
case 2:
Contagiri_IR();
break;
}
}
void up () {
up_btn = true;
}
void down () {
down_btn = true;
}
void AumentaVeloce() {
piuVeloce = true;
}
void DiminuisceVeloce() {
menoVeloce = true;
}
void ok () {
ok_btn = true;
}
void OkLungo () {
ok_btn_lungo = true;
}