Compare commits

20 Commits
Author SHA1 Message Date
schmidtsi76327 e8329f2587 moved files, this in on callback for httpserver class 2021-06-26 09:02:55 +02:00
schmidtsi76327 014aa028d7 move http and ota to lib/ for testing, add #pragma once include guards 2021-06-26 07:33:12 +02:00
schmidtsi76327 b47f778fc1 weitere anpassungen an pwm 2021-06-25 21:10:07 +02:00
schmidtsi76327 c7eaffda00 moved to treppe.h instead of pwm.h :) 2021-06-25 19:23:02 +02:00
schmidtsi76327 69e1e869a5 old pwm 2021-06-25 19:14:30 +02:00
schmidtsi76327 1a284080e8 typo 2021-06-25 19:13:04 +02:00
schmidtsi76327 3490e7ba44 Merge branch 'master' into test 2021-06-25 19:11:58 +02:00
schmidtsi76327 d059c3d72d working, but need to write test 2021-06-25 18:35:16 +02:00
bartschdo76253 33499beb32 zero duty cycle fix 2021-06-25 15:41:34 +02:00
bartschdo76253 38c81ae182 main cleanup 2021-06-25 15:25:09 +02:00
bartschdo76253 a8ceb258b8 leds light up at boot 2021-06-25 15:17:38 +02:00
bartschdo76253 7e5a6fac9f doku 2021-06-25 11:03:17 +02:00
bartschdo76253 b7ba521c59 first approach with sensor controlled led sequence 2021-06-25 10:55:27 +02:00
schmidtsi76327 55ebd21975 test 2021-06-25 04:53:06 +02:00
schmidtsi76327 2b2a135bd5 reorganzie main 2021-06-24 19:46:24 +02:00
bartschdo76253 a400b0464d deleted Wire setClock 2021-06-24 19:34:26 +02:00
schmidtsi76327 2d9be85b09 added lib submodule 2021-06-24 18:38:30 +02:00
schmidtsi76327 33b9f0150e nicht so :) 2021-06-24 18:32:38 +02:00
schmidtsi76327 48d0dc50f7 added library 2021-06-24 18:28:00 +02:00
schmidtsi76327 cdb34a3cbf make it clear what happens with new pca lib 2021-06-24 16:51:38 +02:00
17 changed files with 452 additions and 244 deletions

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
[submodule "lib/PCA9685-Arduino"]
path = lib/PCA9685-Arduino
url = https://github.com/NachtRaveVL/PCA9685-Arduino
+2 -1
View File
@@ -48,5 +48,6 @@
"streambuf": "cpp", "streambuf": "cpp",
"cinttypes": "cpp", "cinttypes": "cpp",
"typeinfo": "cpp" "typeinfo": "cpp"
} },
"python.pythonPath": "C:\\Users\\simon\\AppData\\Local\\Programs\\Python\\Python37\\python.exe"
} }
Binary file not shown.
+9
View File
@@ -54,6 +54,12 @@ else
server.streamFile(f, mime::getContentType(SRH::_path), requestMethod); server.streamFile(f, mime::getContentType(SRH::_path), requestMethod);
``` ```
LED_sequence_v1:
TODO:
- disable led stripes after defined time (webserver paramter?)
- define what to do if people enter stairs from different directions
- CAUTION: Sensor-Deadtime at LEAST 8 seconds
- --> switch off with person leaving stairs might not be possible
Webserver on v0.3.0 now working with LittleFS Webserver on v0.3.0 now working with LittleFS
TODO: TODO:
@@ -66,3 +72,6 @@ LED Flickering issue
https://github.com/NachtRaveVL/PCA9685-Arduino/issues/15 https://github.com/NachtRaveVL/PCA9685-Arduino/issues/15
PlatformIO Library veraltet PlatformIO Library veraltet
###TIMER in OTA unterbrechen !!!!!
+6 -6
View File
@@ -1,5 +1,8 @@
#ifndef __OTA_H #pragma once
#define __OTA_H
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
void ota_setup() { void ota_setup() {
ArduinoOTA.setPort(8266); ArduinoOTA.setPort(8266);
@@ -42,7 +45,4 @@ void ota_setup() {
}); });
ArduinoOTA.begin(); ArduinoOTA.begin();
} }
#endif // __OTA_H
-38
View File
@@ -1,38 +0,0 @@
#pragma once
#include "PCA9685.h"
class Treppe {
private:
uint8_t stairs;
uint16_t time_per_stair = 300; // dimmtime per stair [ms]
uint16_t idle_brightness = 200;
uint16_t active_brightness = 2048;
uint8_t direction = 0;
uint8_t state = 0;
uint8_t switch_state = 0;
PCA9685 pwmController;
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval);
void ledsequence();
public:
Treppe(uint8_t _stairs) : stairs(_stairs){}
void task(); // call periodically
void setup();
// Parameter section
uint16_t setIdle(uint16_t _idle_brightness);
uint16_t setActive(uint16_t _active_brightness);
uint16_t setTime(uint16_t _time_per_stair);
// Runtime Parameter section
uint8_t setDirection(uint8_t _direction);
uint8_t setState(uint8_t _state);
uint8_t getState() { return state;};
uint8_t getDirection() {return direction;};
};
Submodule lib/PCA9685-Arduino added at a70be39257.
@@ -4,7 +4,7 @@
// deleteFile("/hello.txt"); // deleteFile("/hello.txt");
// writeFile("/hello.txt", "Hello "); // writeFile("/hello.txt", "Hello ");
// appendFile("/hello.txt", "World!\n\r"); // appendFile("/hello.txt", "World!\n\r");
// readFile("/hello.txt"); // printFile("/hello.txt");
// listDir("/"); // listDir("/");
FSInfo fsinfo; FSInfo fsinfo;
@@ -58,7 +58,12 @@ void ls(const char * dirname) {
Serial.println(); Serial.println();
} }
void readFile(const char * path) { File open(const char * path) {
return LittleFS.open(path, "r");
}
void printFile(const char * path) {
Serial.printf("Reading file: %s\n\r", path); Serial.printf("Reading file: %s\n\r", path);
File file = LittleFS.open(path, "r"); File file = LittleFS.open(path, "r");
@@ -1,16 +1,15 @@
#ifndef __FILESYS_H #pragma once
#define __FILESYS_H
#include <LittleFS.h> #include <LittleFS.h>
bool mount_fs(); bool mount_fs();
bool format_fs(); bool format_fs();
File open(const char * path);
void ls(const char * dirname); void ls(const char * dirname);
void readFile(const char * path); void printFile(const char * path);
void writeFile(const char * path, const char * message); void writeFile(const char * path, const char * message);
void appendFile(const char * path, const char * message); void appendFile(const char * path, const char * message);
void renameFile(const char * path1, const char * path2); void renameFile(const char * path1, const char * path2);
void deleteFile(const char * path); void deleteFile(const char * path);
#endif // __FILESYS_H
@@ -14,4 +14,4 @@ bool HTTPServer::addRootFileHandler() {
this->serveStatic("/favicon.png", LittleFS, "/favicon.png"); this->serveStatic("/favicon.png", LittleFS, "/favicon.png");
return true; return true;
} }
@@ -1,10 +1,8 @@
#ifndef __HTTPSERVER_H #pragma once
#define __HTTPSERVER_H
#include "filesys.h" #include "filesys.h"
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
class HTTPServer : public ESP8266WebServer { class HTTPServer : public ESP8266WebServer {
private: private:
const char* rootDir; const char* rootDir;
@@ -35,6 +33,20 @@ public:
this->listRoot(); this->listRoot();
Serial.printf("\n\r"); Serial.printf("\n\r");
// https://stackoverflow.com/questions/7627098/what-is-a-lambda-expression-in-c11
on("/compress.html", [this]() {
File f = open("/compress.html.gz");
if (!f) {
Serial.println("Failed to open file for reading");
}
else
{
Serial.println("Streaming /compress.html.gz to client");
const String cont = "text/html";
streamFile(f, cont);
}
});
if( this->addRootFileHandler() ){ if( this->addRootFileHandler() ){
this->begin(); this->begin();
Serial.printf("[HTTPServer] Server active on Port 80 !\n\r"); Serial.printf("[HTTPServer] Server active on Port 80 !\n\r");
@@ -44,5 +56,3 @@ public:
return false; return false;
} }
}; };
#endif // __HTTPSERVER_H
+232
View File
@@ -0,0 +1,232 @@
#include "treppe.h"
uint8_t Treppe::softstart_led(uint8_t led, uint16_t startval, uint16_t stopval){
/*
softstart task
- get's called at regular intervals (1ms at the moment)
- dimms single led (0 - 15, PCA9685 outputs) with linear intervals vom startval to stopval
- calculates pwm steps depending on startval, stopval and timeinterval
- -> results in constanst speed
- returns 1 if led dimming is running
- returns 0 if led dimming is finished
*/
static uint8_t lastled = 255;
static float current_pwm = 0;
static float stepsize = 1.0;
if(led != lastled){
pwmController.setChannelPWM(led, (uint16_t)startval);
lastled = led;
current_pwm = startval;
stepsize = INT_TIME*abs(stopval - startval)/(float)time_per_stair; // only valid at 1ms function call interval
return 1;
}
if(startval > stopval){
current_pwm -= stepsize;
}
else {
current_pwm += stepsize;
}
// Serial.println((uint16_t)current_pwm);
pwmController.setChannelPWM(led, (uint16_t)current_pwm);
if(current_pwm > stopval - stepsize && current_pwm < stopval + stepsize){
if(stopval == 0) pwmController.setChannelPWM(led, 0);
return 0;
}
return 1;
}
void Treppe::ledsequence(){
static int8_t led = 0;
static uint16_t brightness = 0;
static uint16_t lastbrightness = 0;
static uint16_t status = 0;
uint16_t status_build = 0;
status_build |= direction << 8;
status_build |= state;
if(status_build != status){ // check if any parameter changed
finish = 0; // set state unfinished -> start action
if(direction) led = 0; // reset led counter depending of direction
else led = stairs-1;
if(state){
brightness = active_brightness; // set brightness value depending of on/off
lastbrightness = idle_brightness;
}
else{
brightness = idle_brightness;
lastbrightness = active_brightness;
}
status = status_build; // set parameter memory
Serial.printf("----Status Changed! onoff: %d, dir: %d\n", state, direction);
}
if(!finish){ // finish == 0 -> action pending
if(!softstart_led(led,lastbrightness, brightness)){
Serial.printf("one LED finished: led: %d, last: %d, curr %d\n",
led, lastbrightness, brightness);
if(direction){
led++;
if(led >= stairs)
finish = 1;
}
else{
led--;
if(led < 0)
finish = 1;
}
}
}
}
void Treppe::rampe()
{
if(state) {
finish = 0;
state = 0; // set parameter memory
}
if(!finish) {
if(direction) { // aufwärts
if(tick >= ticks_treppe-1) { // ziel erreicht
Serial.println("[Treppe] oberster tick !");
finish = 1;
return;
}
tick++; // eins hoch
}
else { // abwärts
if(tick <= 0) { // ziel erreicht
Serial.println("[Treppe] unterster tick !");
finish = 1;
return;
}
tick--; // eins runter
}
stufe = tick / ticks_pro_stufe;
float new_pwm = 0.0;
if(an_aus) {
new_pwm = differenz_pwm_pro_tick * (tick - ticks_pro_stufe*stufe);
new_pwm += idle_brightness;
if(direction) new_pwm += differenz_pwm_pro_tick;
}
else {
new_pwm = active_brightness - differenz_pwm_pro_tick * (tick - ticks_pro_stufe*stufe);
new_pwm += idle_brightness;
if(direction) new_pwm -= differenz_pwm_pro_tick;
}
pwmController.setChannelPWM(stufe, (uint16_t) new_pwm);
Serial.printf("tick %04u, led %02d:%02u, pwm %4.1f\n",
tick,
stufe,
(tick - ticks_pro_stufe*stufe),
new_pwm
);
}
}
void Treppe::setup(){
Serial.printf("differenz_pwm_pro_tick %f\n", differenz_pwm_pro_tick);
pwmController.resetDevices();
// Deactive PCA9685 Phase Balancer due to LED Flickering
// https://github.com/NachtRaveVL/PCA9685-Arduino/issues/15
// see also lib/PCA9685-Arduin/PCA9685.h:204
pwmController.init(PCA9685_PhaseBalancer_None);
pwmController.setPWMFrequency(200);
pwmController.setAllChannelsPWM(idle_brightness);
pinMode(SENSOR1, INPUT);
pinMode(SENSOR2, INPUT);
Serial.println("Hello from Treppe");
Serial.print("Treppe: initial parameters: stairs=");
Serial.println(stairs);
}
void Treppe::task(){
if(finish){
direction = switch_direction;
state = switch_state;
}
static uint8_t last_sensor_state[2] = {0,0};
uint8_t current_sensor_state[2] = {0,0};
current_sensor_state[0] = digitalRead(SENSOR1);
current_sensor_state[1] = digitalRead(SENSOR2);
if(current_sensor_state[0] && !last_sensor_state[0] && state == 0){
setTick(0);
setAnAus(1);
setDirection(1);
setState(1);
}
if(current_sensor_state[1] && !last_sensor_state[1] && state == 0){
setTick(0);
setAnAus(0);
setDirection(0);
setState(1);
}
// first switch - off approach, use timer later
if(!current_sensor_state[0] && last_sensor_state[0] && state == 1){
setTick(ticks_treppe);
setAnAus(1);
setDirection(1);
setState(0);
}
if(!current_sensor_state[1] && last_sensor_state[1] && state == 1){
setTick(ticks_treppe);
setAnAus(1);
setDirection(0);
setState(0);
}
last_sensor_state[0] = current_sensor_state[0];
last_sensor_state[1] = current_sensor_state[1];
ledsequence();
}
uint16_t Treppe::setIdle(uint16_t _idle_brightness){
idle_brightness = _idle_brightness;
Serial.println("Treppe: idle brightness changed!");
return idle_brightness;
}
uint16_t Treppe::setActive(uint16_t _active_brightness){
active_brightness = _active_brightness;
Serial.println("Treppe: active brightness changed!");
return active_brightness;
}
uint16_t Treppe::setTime(uint16_t _time_per_stair){
time_per_stair = _time_per_stair;
Serial.println("Treppe: time changed!");
return time_per_stair;
}
void Treppe::setDirection(uint8_t _direction){
switch_direction = _direction;
Serial.printf("Treppe: switch_direction=%d!\n", switch_direction);
if(finish) Serial.println("apply direction request immediately");
else Serial.println("currently active, dir change afterwards");
// to do: implement state command variable to determine dimm-state
}
void Treppe::setState(uint8_t _state){
if(state == _state) return;
else {
switch_state = _state;
Serial.printf("Treppe: switch_state=%d!\n", switch_state);
if(finish) Serial.println("apply state request immediately");
else Serial.println("currently active, state changes after activity");
}
}
+75
View File
@@ -0,0 +1,75 @@
#pragma once
#include "PCA9685.h"
#define SENSOR1 15
#define SENSOR2 12
#define INT_TIME 20 // interrupt intervall [ms]
class Treppe {
private:
uint8_t stairs;
uint16_t time_per_stair = 300; // dimmtime per stair [ms]
uint16_t idle_brightness = 0;
uint16_t active_brightness = 500;
uint8_t direction = 0;
uint8_t switch_direction = 0;
uint8_t state = 0;
uint8_t switch_state = 0;
uint8_t finish = 1;
// alternative
uint32_t tick = 0;
uint32_t stufe = 0;
uint8_t an_aus = 0;
uint32_t ticks_treppe = 0;
uint32_t ticks_pro_stufe = 0;
float differenz_pwm_pro_tick = 0.0;
// alternative
// initialize with i2c-Address 0, use Wire Library
PCA9685 pwmController;
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval);
void ledsequence();
void rampe();
public:
Treppe(uint8_t _stairs) : stairs(_stairs){
ticks_pro_stufe = time_per_stair / 20; // [ms]
ticks_treppe = ticks_pro_stufe * stairs;
differenz_pwm_pro_tick = (float) (active_brightness - idle_brightness)
/ (float) ticks_pro_stufe;
}
void setup();
void task(); // call periodically
// Parameter section
uint16_t setIdle(uint16_t _idle_brightness);
uint16_t setActive(uint16_t _active_brightness);
uint16_t setTime(uint16_t _time_per_stair);
void setTick(uint32_t _tick) {
tick = _tick;
Serial.printf("Treppe: Tick: %u!\n", tick);
}
uint32_t getTicks() {
return ticks_treppe;
}
// Runtime Parameter section
void setDirection(uint8_t _direction);
void setState(uint8_t _state);
void setAnAus(uint8_t _an_aus) {
an_aus = _an_aus;
}
uint8_t getState() { return state;};
uint8_t getFinished() { return finish;};
uint8_t getDirection() {return direction;};
};
+20 -20
View File
@@ -9,12 +9,8 @@ extern "C" {
#include "user_interface.h" #include "user_interface.h"
} }
// OTA & WEB // OTA & WEB
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "ota.h"
#include "wifi_credentials.h" #include "wifi_credentials.h"
#include "ota.h"
#include "httpserver.h" #include "httpserver.h"
// BOARD // BOARD
@@ -22,13 +18,10 @@ extern "C" {
#define NODEMCU_LED 16 #define NODEMCU_LED 16
// PWM // PWM
#include "treppe.h"
#include "pwm.h"
os_timer_t timer1; os_timer_t timer1;
uint8_t timer_flag = 0; uint8_t timer_flag = 0;
Treppe stairs(16);
Treppe stairs(13);
// WIFI // WIFI
const char* ssid = STASSID; const char* ssid = STASSID;
@@ -110,17 +103,24 @@ void setup() {
os_timer_setfn(&timer1, timerCallback, &timer_flag); os_timer_setfn(&timer1, timerCallback, &timer_flag);
os_timer_arm(&timer1, 20, true); os_timer_arm(&timer1, 20, true);
stairs.setState(1);
stairs.setDirection(1);
} }
#include <random>
void loop() { void loop() {
if(millis() > 25000 && stairs.getState() == 1 && stairs.getDirection() == 1) stairs.setState(0); // if(stairs.getState() == 0) {
if(millis() > 45000 && stairs.getDirection() == 1){ // delay(1000);
stairs.setState(1);
stairs.setDirection(0); // // uint32_t t = rand() % stairs.getTicks();
} // // uint32_t d = rand() % 2;
TIMEIF_US(ArduinoOTA.handle(), 1000, "OTA");
TIMEIF_US(httpServer.handleClient(), 1000, "HTTP"); // // stairs.setTick(t);
// // stairs.setDirection(d);
// stairs.setDirection(!stairs.getDirection());
// stairs.setState(1);
// }
TIMEIF_US(ArduinoOTA.handle(), 10000, "OTA");
TIMEIF_US(httpServer.handleClient(), 10000, "HTTP");
} }
-136
View File
@@ -1,136 +0,0 @@
#include "pwm.h"
uint8_t Treppe::softstart_led(uint8_t led, uint16_t startval, uint16_t stopval){
/*
softstart task
- get's called at regular intervals (1ms at the moment)
- dimms single led (0 - 15, PCA9685 outputs) with linear intervals vom startval to stopval
- calculates pwm steps depending on startval, stopval and timeinterval
- -> results in constanst speed
- returns 1 if led dimming is running
- returns 0 if led dimming is finished
*/
static uint8_t lastled = 255;
static float current_pwm = 0;
static float stepsize = 1.0;
if(led != lastled){
pwmController.setChannelPWM(led, (uint16_t)startval);
lastled = led;
current_pwm = startval;
stepsize = 20*abs(stopval - startval)/(float)time_per_stair; // only valid at 1ms function call interval
return 1;
}
if(current_pwm > stopval - stepsize && current_pwm < stopval + stepsize) return 0;
// todo: duty cycle zero!
if(startval > stopval){
current_pwm -= stepsize;
}
else {
current_pwm += stepsize;
}
Serial.println((uint16_t)current_pwm);
pwmController.setChannelPWM(led, (uint16_t)current_pwm);
return 1;
}
void Treppe::ledsequence(){
static int8_t led = 0;
static uint16_t brightness = 0;
static uint16_t lastbrightness = 0;
static uint8_t finish = 1;
static uint16_t status = 0;
uint16_t status_build = 0;
status_build |= direction << 8;
status_build |= state;
if(status_build != status){ // check if any parameter changed
finish = 0; // set state unfinished -> start action
if(direction) led = 0; // reset led counter depending of direction
else led = stairs-1;
if(state){
brightness = active_brightness; // set brightness value depending of on/off
lastbrightness = idle_brightness;
}
else{
brightness = idle_brightness;
lastbrightness = active_brightness;
}
status = status_build; // set parameter memory
Serial.print("----Status Changed! onoff: ");
Serial.print(state);
Serial.print(" dir: ");
Serial.println(direction);
}
if(!finish){ // finish == 0 -> action pending
if(!softstart_led(led,lastbrightness, brightness)){
Serial.print("one LED finished: ");
Serial.print(led);
Serial.print(" last: ");
Serial.print(lastbrightness);
Serial.print(" curr: ");
Serial.println(brightness);
if(direction){
led++;
if(led >= stairs) {
finish = 1;
//lastbrightness = brightness;
}
}
else{
led--;
if(led < 0){
//lastbrightness = brightness;
finish = 1;
}
}
}
}
}
void Treppe::setup(){
pwmController.resetDevices();
pwmController.init();
pwmController.setPWMFrequency(200);
Serial.println("Hello from Treppe");
Serial.print("Treppe: initial parameters: stairs=");
Serial.println(stairs);
}
void Treppe::task(){
ledsequence();
}
uint16_t Treppe::setIdle(uint16_t _idle_brightness){
idle_brightness = _idle_brightness;
Serial.println("Treppe: idle brightness changed!");
return idle_brightness;
}
uint16_t Treppe::setActive(uint16_t _active_brightness){
active_brightness = _active_brightness;
Serial.println("Treppe: active brightness changed!");
return active_brightness;
}
uint16_t Treppe::setTime(uint16_t _time_per_stair){
time_per_stair = _time_per_stair;
Serial.println("Treppe: time changed!");
return time_per_stair;
}
uint8_t Treppe::setDirection(uint8_t _direction){
direction = _direction;
Serial.println("Treppe: Direction changed!");
// to do: implement state command variable to determine dimm-state
return direction;
}
uint8_t Treppe::setState(uint8_t _state){
if(state == _state) return 1;
else{
state = _state;
Serial.println("Treppe: State changed!");
}
return 0;
}
+30 -30
View File
@@ -1,40 +1,40 @@
#include <Arduino.h> // #include <Arduino.h>
#include <unity.h> // #include <unity.h>
String STR_TO_TEST; // String STR_TO_TEST;
void setUp(void) { // // void setUp(void) {
// set stuff up here // // // set stuff up here
STR_TO_TEST = "Hello, world!"; // // STR_TO_TEST = "Hello, world!";
} // // }
void tearDown(void) { // // void tearDown(void) {
// clean stuff up here // // // clean stuff up here
STR_TO_TEST = ""; // // STR_TO_TEST = "";
} // // }
void test_led_builtin_pin_number(void) { // void test_led_builtin_pin_number(void) {
TEST_ASSERT_EQUAL(2, LED_BUILTIN); // TEST_ASSERT_EQUAL(2, LED_BUILTIN);
} // }
void test_string_concat(void) { // void test_string_concat(void) {
String hello = "Hello, "; // String hello = "Hello, ";
String world = "world!"; // String world = "world!";
TEST_ASSERT_EQUAL_STRING(STR_TO_TEST.c_str(), (hello + world).c_str()); // TEST_ASSERT_EQUAL_STRING(STR_TO_TEST.c_str(), (hello + world).c_str());
} // }
void setup() // void setup()
{ // {
delay(2000); // service delay // delay(2000); // service delay
UNITY_BEGIN(); // UNITY_BEGIN();
RUN_TEST(test_led_builtin_pin_number); // RUN_TEST(test_led_builtin_pin_number);
RUN_TEST(test_string_concat); // RUN_TEST(test_string_concat);
UNITY_END(); // stop unit testing // UNITY_END(); // stop unit testing
} // }
void loop() // void loop()
{ // {
} // }
+47
View File
@@ -0,0 +1,47 @@
// #include <Arduino.h>
#include "treppe.h"
#include <unity.h>
Treppe stairs(10);
void setUp(void) {
// run before each test
// set stuff up here
stairs.setup();
Serial.println("Treppe initialized !");
Serial.println("PCA9685 connected !");
}
void tearDown(void) {
// clean stuff up here
}
void test_set_state(void) {
stairs.setState(1);
TEST_ASSERT_EQUAL(1, stairs.getState());
stairs.setState(0);
TEST_ASSERT_EQUAL(0, stairs.getState());
}
void test_set_direction(void) {
stairs.setDirection(1);
TEST_ASSERT_EQUAL(1, stairs.getDirection());
stairs.setDirection(0);
TEST_ASSERT_EQUAL(0, stairs.getDirection());
}
void setup()
{
delay(2000); // service delay
UNITY_BEGIN();
RUN_TEST(test_set_state);
RUN_TEST(test_set_direction);
UNITY_END(); // stop unit testing
}
void loop()
{
}