Bugfixes in relais calss
This commit is contained in:
parent
ff64a36e20
commit
5f55011894
4 changed files with 55 additions and 48 deletions
|
@ -2,6 +2,7 @@
|
||||||
#define __display_H__
|
#define __display_H__
|
||||||
|
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
|
#include <Wire.h>
|
||||||
#include "SSD1306Wire.h"
|
#include "SSD1306Wire.h"
|
||||||
|
|
||||||
class display
|
class display
|
||||||
|
@ -43,13 +44,15 @@ void display::_initDisplay()
|
||||||
{
|
{
|
||||||
//initialise OLED and display Welcome Message ...
|
//initialise OLED and display Welcome Message ...
|
||||||
_display->init();
|
_display->init();
|
||||||
_display->flipScreenVertically();
|
//_display->flipScreenVertically();
|
||||||
_display->setTextAlignment(TEXT_ALIGN_CENTER);
|
/* _display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
_display->setFont(Roboto_Condensed_Bold_16);
|
_display->setFont(Roboto_Condensed_Bold_16);
|
||||||
_display->clear();
|
_display->clear();
|
||||||
_display->setContrast(MAX_CONTRAST);
|
_display->setContrast(MAX_CONTRAST);
|
||||||
_display->drawString(64, 32, "Itsblue.de");
|
_display->drawString(64, 32, "Itsblue.de");
|
||||||
_display->display();
|
_display->display();
|
||||||
|
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void display::header(String title, bool wificonected, bool localvalues, bool lastdatasent, bool timesynced)
|
void display::header(String title, bool wificonected, bool localvalues, bool lastdatasent, bool timesynced)
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "train.h"
|
//#include "train.h"
|
||||||
#include "relais.h"
|
#include "relais.h"
|
||||||
#include "taster.h"
|
#include "taster.h"
|
||||||
#include "leds.h"
|
//#include "leds.h"
|
||||||
#include "mp3.h"
|
//#include "mp3.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "eeprom.h"
|
//#include "eeprom.h"
|
||||||
|
|
||||||
eeprom save;
|
//eeprom save;
|
||||||
///---- OLED ----
|
///---- OLED ----
|
||||||
const size_t PIN_MONI_SDA = 21 ; //12
|
const size_t PIN_MONI_SDA = 25 ; //12
|
||||||
const size_t PIN_MONI_SCL = 22 ; //14
|
const size_t PIN_MONI_SCL = 26 ; //14
|
||||||
const unsigned int ADDR_MONI = 0x3c;
|
const unsigned int ADDR_MONI = 0x3c;
|
||||||
display moni(PIN_MONI_SDA, PIN_MONI_SCL, ADDR_MONI);
|
display moni(PIN_MONI_SDA, PIN_MONI_SCL, ADDR_MONI);
|
||||||
///---- MP3 ----
|
///---- MP3 ----
|
||||||
const size_t PIN_MP3_RX = 3 ; //D2;
|
const size_t PIN_MP3_RX = 3 ; //D2;
|
||||||
const size_t PIN_MP3_TX = 1 ; //D3;
|
const size_t PIN_MP3_TX = 1 ; //D3;
|
||||||
mp3 mp3ply(PIN_MP3_RX, PIN_MP3_TX);
|
//mp3 mp3ply(PIN_MP3_RX, PIN_MP3_TX);
|
||||||
///---- RELAIS ----
|
///---- RELAIS ----
|
||||||
const size_t PIN_RELAIS_HAUESER = 9;
|
const size_t PIN_RELAIS_HAUESER = 18;
|
||||||
const size_t PIN_RELAIS_STERNE = 17;
|
const size_t PIN_RELAIS_STERNE = 17;
|
||||||
const size_t PIN_RELAIS_SPIEGELBALL = 16;
|
const size_t PIN_RELAIS_SPIEGELBALL = 16;
|
||||||
const size_t PIN_RELAIS_OTHER = 4;
|
const size_t PIN_RELAIS_OTHER = 4;
|
||||||
relais haeuser(PIN_RELAIS_HAUESER);
|
relais relais_haeuser(PIN_RELAIS_HAUESER);
|
||||||
relais sterne(PIN_RELAIS_STERNE);
|
relais relais_sterne(PIN_RELAIS_STERNE);
|
||||||
relais spiegel(PIN_RELAIS_SPIEGELBALL);
|
relais relais_spiegel(PIN_RELAIS_SPIEGELBALL);
|
||||||
relais other(PIN_RELAIS_OTHER);
|
relais relais_other(PIN_RELAIS_OTHER);
|
||||||
///---- Spannungsregler
|
///---- Spannungsregler
|
||||||
const size_t PIN_TRAIN_UNTEN = 32;
|
const size_t PIN_TRAIN_UNTEN = 32;
|
||||||
const size_t PIN_TRAIN_OBEN = 33;
|
const size_t PIN_TRAIN_OBEN = 33;
|
||||||
#define PWM_CHANNEL_OBEN 5
|
#define PWM_CHANNEL_OBEN 5
|
||||||
#define PWM_CHANNEL_UNTEN 6
|
#define PWM_CHANNEL_UNTEN 6
|
||||||
train zugunten(PIN_TRAIN_UNTEN, PWM_CHANNEL_UNTEN );
|
//train zugunten(PIN_TRAIN_UNTEN, PWM_CHANNEL_UNTEN );
|
||||||
train zugoben(PIN_TRAIN_OBEN, PWM_CHANNEL_OBEN );
|
//train zugoben(PIN_TRAIN_OBEN, PWM_CHANNEL_OBEN );
|
||||||
///--- Taster ----
|
///--- Taster ----
|
||||||
const size_t PIN_TASTER_AUSSEN_LICHT = 36;
|
const size_t PIN_TASTER_AUSSEN_LICHT = 36;
|
||||||
const size_t PIN_TASTER_AUSSEN_MOVE = 39;
|
const size_t PIN_TASTER_AUSSEN_MOVE = 39;
|
||||||
|
@ -46,8 +46,8 @@ taster taster_train_oben(PIN_TASTER_TRAIN_OBEN);
|
||||||
uint16_t rgbled_state_flag = 0;
|
uint16_t rgbled_state_flag = 0;
|
||||||
const size_t PIN_RGBLEDS = 19;
|
const size_t PIN_RGBLEDS = 19;
|
||||||
#define NUMRGBLEDS 20
|
#define NUMRGBLEDS 20
|
||||||
Adafruit_NeoPixel rgb_leds(NUMRGBLEDS, PIN_RGBLEDS, NEO_GRB + NEO_KHZ800);
|
//Adafruit_NeoPixel rgb_leds(NUMRGBLEDS, PIN_RGBLEDS, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
enum led_t {LTANNE=1, LBACK=2, LSTERNE=4, LTEICH=8};
|
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_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_teich(&rgb_leds, &rgbled_state_flag, LTEICH, 5000,220, 6, 10 );
|
|
@ -22,6 +22,7 @@ relais::relais(size_t ctrl_pin)
|
||||||
_ctrl_pin = ctrl_pin;
|
_ctrl_pin = ctrl_pin;
|
||||||
_relais_on = false;
|
_relais_on = false;
|
||||||
pinMode(_ctrl_pin, OUTPUT);
|
pinMode(_ctrl_pin, OUTPUT);
|
||||||
|
off();
|
||||||
}
|
}
|
||||||
|
|
||||||
relais::~relais()
|
relais::~relais()
|
||||||
|
@ -30,13 +31,13 @@ relais::~relais()
|
||||||
|
|
||||||
void relais::on()
|
void relais::on()
|
||||||
{
|
{
|
||||||
digitalWrite(_ctrl_pin, HIGH);
|
digitalWrite(_ctrl_pin, LOW);
|
||||||
_relais_on = true;
|
_relais_on = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void relais::off()
|
void relais::off()
|
||||||
{
|
{
|
||||||
digitalWrite(_ctrl_pin, LOW);
|
digitalWrite(_ctrl_pin, HIGH);
|
||||||
_relais_on = false;
|
_relais_on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +45,12 @@ void relais::toggle()
|
||||||
{
|
{
|
||||||
if(true == _relais_on)
|
if(true == _relais_on)
|
||||||
{
|
{
|
||||||
digitalWrite(_ctrl_pin, LOW);
|
digitalWrite(_ctrl_pin, HIGH);
|
||||||
_relais_on = false;
|
_relais_on = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
digitalWrite(_ctrl_pin, HIGH);
|
digitalWrite(_ctrl_pin, LOW);
|
||||||
_relais_on = true;
|
_relais_on = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
51
src/main.cpp
51
src/main.cpp
|
@ -8,46 +8,48 @@ uint64_t licht_all_count = 0;
|
||||||
uint64_t move_all_count = 0;
|
uint64_t move_all_count = 0;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
//load counters
|
//load counters
|
||||||
save.set_int("licht", 0);
|
// save.set_int("licht", 0);
|
||||||
save.set_int("move", 0);
|
// save.set_int("move", 0);
|
||||||
licht_all_count = save.get_int("licht");
|
// licht_all_count = save.get_int("licht");
|
||||||
move_all_count = save.get_int("move");
|
// move_all_count = save.get_int("move");
|
||||||
// all relais off;
|
// all relais off;
|
||||||
haeuser.off();
|
relais_haeuser.off();
|
||||||
sterne.off();
|
relais_sterne.off();
|
||||||
spiegel.off();
|
relais_spiegel.off();
|
||||||
other.off();
|
relais_other.off();
|
||||||
|
/*
|
||||||
zugoben.stop();
|
zugoben.stop();
|
||||||
zugunten.stop();
|
zugunten.stop();
|
||||||
|
|
||||||
led_tanne.setColor(0x0f0);
|
led_tanne.setColor(0x0f0);
|
||||||
mp3ply.play(1);
|
mp3ply.play(1);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t licht_count = 0;
|
uint8_t licht_count = 0;
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
led_teich.rainbowCycle();
|
//led_teich.rainbowCycle();
|
||||||
rgb_leds.show();
|
//rgb_leds.show();
|
||||||
|
|
||||||
if(taster_aussen_licht.pressed())
|
if(taster_aussen_licht.pressed())
|
||||||
{
|
relais_haeuser.toggle();
|
||||||
licht_all_count++;
|
|
||||||
save.set_int("licht",licht_all_count);
|
|
||||||
licht_count++;
|
|
||||||
if(licht_count > 4)
|
|
||||||
licht_count = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(taster_aussen_move.pressed())
|
if(taster_aussen_move.pressed())
|
||||||
{
|
relais_other.toggle();
|
||||||
move_all_count++;
|
|
||||||
save.set_int("move", move_all_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(taster_train_oben.pressed())
|
||||||
|
relais_sterne.toggle();
|
||||||
|
|
||||||
|
if(taster_train_unten.pressed())
|
||||||
|
relais_spiegel.toggle();
|
||||||
|
|
||||||
|
/*
|
||||||
show_counters(licht_all_count, move_all_count);
|
show_counters(licht_all_count, move_all_count);
|
||||||
|
|
||||||
switch (licht_count)
|
switch (licht_count)
|
||||||
|
@ -83,12 +85,12 @@ void loop() {
|
||||||
other.off();
|
other.off();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void show_counters(uint64_t counter_licht, uint64_t counter_move)
|
void show_counters(uint64_t counter_licht, uint64_t counter_move)
|
||||||
{
|
{
|
||||||
moni.clear();
|
moni.clear();
|
||||||
|
@ -96,4 +98,5 @@ void show_counters(uint64_t counter_licht, uint64_t counter_move)
|
||||||
moni.data(10,15,counter_licht, "Licht:");
|
moni.data(10,15,counter_licht, "Licht:");
|
||||||
moni.data(10,15,counter_move, "Moves:");
|
moni.data(10,15,counter_move, "Moves:");
|
||||||
moni.show();
|
moni.show();
|
||||||
}
|
}
|
||||||
|
*/
|
Loading…
Reference in a new issue