102 lines
3.1 KiB
C
102 lines
3.1 KiB
C
#include <Arduino.h>
|
|
#include "train.h"
|
|
#include "relais.h"
|
|
#include "taster.h"
|
|
#include "leds.h"
|
|
#include "mp3.h"
|
|
#include "display.h"
|
|
#include <TridentTD_ESP32NVS.h>
|
|
//#include "eeprom.h"
|
|
|
|
//eeprom flash;
|
|
///---- OLED ----
|
|
const int PIN_MONI_SDA = 21 ; //12
|
|
const int PIN_MONI_SCL = 22 ; //14
|
|
const uint8_t ADDR_MONI = 0x3c;
|
|
display moni(ADDR_MONI, PIN_MONI_SDA, PIN_MONI_SCL);
|
|
///---- MP3 ----
|
|
const size_t PIN_MP3_RX = 25 ; //D2;
|
|
const size_t PIN_MP3_TX = 26 ; //D3;
|
|
mp3 mp3ply(PIN_MP3_RX, PIN_MP3_TX);
|
|
///---- RELAIS ----
|
|
const size_t PIN_RELAIS_HAUESER = 5;
|
|
const size_t PIN_RELAIS_STERNE = 17;
|
|
const size_t PIN_RELAIS_SPIEGELBALL = 16;
|
|
const size_t PIN_RELAIS_OTHER = 4;
|
|
relais relais_haeuser(PIN_RELAIS_HAUESER);
|
|
relais relais_sterne(PIN_RELAIS_STERNE);
|
|
relais relais_spiegel(PIN_RELAIS_SPIEGELBALL);
|
|
relais relais_other(PIN_RELAIS_OTHER);
|
|
///---- Spannungsregler
|
|
const size_t PIN_TRAIN_UNTEN = 32;
|
|
const size_t PIN_TRAIN_OBEN = 33;
|
|
#define PWM_CHANNEL_OBEN 5
|
|
#define PWM_CHANNEL_UNTEN 6
|
|
train zugunten(PIN_TRAIN_UNTEN, PWM_CHANNEL_UNTEN );
|
|
train zugoben(PIN_TRAIN_OBEN, PWM_CHANNEL_OBEN );
|
|
///--- Taster ----
|
|
const size_t PIN_TASTER_AUSSEN_LICHT = 36;
|
|
const size_t PIN_TASTER_AUSSEN_MOVE = 39;
|
|
const size_t PIN_TASTER_TRAIN_UNTEN = 34;
|
|
const size_t PIN_TASTER_TRAIN_OBEN = 35;
|
|
|
|
const unsigned long BOUNCING_TIME_MS = 300;
|
|
unsigned long last_pressed_1, last_pressed_2, last_pressed_3, last_pressed_4;
|
|
unsigned long number_pressed_1, number_pressed_2, number_pressed_3, number_pressed_4;
|
|
/*
|
|
void IRAM_ATTR ISR_1()
|
|
{
|
|
if(millis()-last_pressed_1 > BOUNCING_TIME_MS)
|
|
{
|
|
last_pressed_1 = millis();
|
|
number_pressed_1 += 1;
|
|
}
|
|
}
|
|
|
|
void IRAM_ATTR ISR_2()
|
|
{
|
|
if(millis()-last_pressed_2 > BOUNCING_TIME_MS)
|
|
{
|
|
last_pressed_2 = millis();
|
|
number_pressed_2 += 1;
|
|
}
|
|
}
|
|
|
|
void IRAM_ATTR ISR_3()
|
|
{
|
|
if(millis()-last_pressed_3 > BOUNCING_TIME_MS)
|
|
{
|
|
last_pressed_3 = millis();
|
|
number_pressed_3 += 1;
|
|
}
|
|
}
|
|
|
|
void IRAM_ATTR ISR_4()
|
|
{
|
|
if(millis()-last_pressed_4 > BOUNCING_TIME_MS)
|
|
{
|
|
last_pressed_4 = millis();
|
|
number_pressed_4 += 1;
|
|
}
|
|
}
|
|
|
|
taster taster_aussen_licht(PIN_TASTER_AUSSEN_LICHT, &ISR_1, &number_pressed_1);
|
|
taster taster_aussen_move(PIN_TASTER_AUSSEN_MOVE, &ISR_2, &number_pressed_2);
|
|
taster taster_train_unten(PIN_TASTER_TRAIN_UNTEN, &ISR_3, &number_pressed_3);
|
|
taster taster_train_oben(PIN_TASTER_TRAIN_OBEN, &ISR_4, &number_pressed_4);
|
|
*/
|
|
taster taster_aussen_licht(PIN_TASTER_AUSSEN_LICHT);
|
|
taster taster_aussen_move(PIN_TASTER_AUSSEN_MOVE);
|
|
taster taster_train_unten(PIN_TASTER_TRAIN_UNTEN);
|
|
taster taster_train_oben(PIN_TASTER_TRAIN_OBEN);
|
|
///--- RGB LEDs ---
|
|
uint16_t rgbled_state_flag = 0;
|
|
const size_t PIN_RGBLEDS = 19;
|
|
#define NUMRGBLEDS 25
|
|
Adafruit_NeoPixel rgb_leds(NUMRGBLEDS, PIN_RGBLEDS, NEO_GRB + NEO_KHZ800);
|
|
|
|
enum led_t {LTANNE=1, LBACK=2, LSTERNE=4, LTEICH=8};
|
|
leds led_tanne(&rgb_leds, &rgbled_state_flag, LTANNE, 5000,220, 0, 5 );
|
|
leds led_teich(&rgb_leds, &rgbled_state_flag, LTEICH, 5000,220, 6, 10 );
|
|
leds led_sterne(&rgb_leds, &rgbled_state_flag, LSTERNE, 5000,220, 11, 24 );
|