Compare commits
19
Commits
3d13e761f4
..
FSM1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a398d9ba0 | ||
|
|
f28aa2df8b | ||
|
|
754da9f931 | ||
|
|
df2a8fa1e3 | ||
|
|
dc159a35d0 | ||
|
|
2378ca80b9 | ||
|
|
79ff1f0d33 | ||
|
|
6a36971406 | ||
|
|
714fcb4b18 | ||
|
|
712acf3541 | ||
|
|
df89c9716c | ||
|
|
66e8ddb2d9 | ||
|
|
5b197288bc | ||
|
|
a9f098097c | ||
|
|
a0f6a5aec3 | ||
|
|
633b99f818 | ||
|
|
5d32392844 | ||
|
|
50e714e5f8 | ||
|
|
e0bc75826f |
No files matched your search
@@ -1,5 +1,7 @@
|
||||
.pio
|
||||
.vscode
|
||||
.vscode/*
|
||||
.vscode/**
|
||||
compress
|
||||
data_gz
|
||||
platformio.ini
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
Vendored
-53
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"random": "cpp",
|
||||
"array": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"string": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"string_view": "cpp",
|
||||
"memory": "cpp",
|
||||
"ranges": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"utility": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
},
|
||||
"python.pythonPath": "C:\\Users\\simon\\AppData\\Local\\Programs\\Python\\Python37\\python.exe"
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Ich bin ein komrpimierter Test</title>
|
||||
I bims der Head
|
||||
</head>
|
||||
<body>
|
||||
I bims der Body
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+2
-2
@@ -62,9 +62,9 @@
|
||||
|
||||
<div class="terminal">
|
||||
<input type="button" id="clear_term" value="clear" onclick="clearTerminal();">
|
||||
<input type="checkbox" id="scroll" name="scroll" value="scroll">
|
||||
<input type="checkbox" id="scroll" name="scroll" value="scroll" checked>
|
||||
<label for="scroll"> autoscroll </label>
|
||||
<textarea id="term"> waiting for log messages ... </textarea>
|
||||
<textarea id="term">waiting for log messages ... </textarea>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ xhr.onreadystatechange = function(){
|
||||
console.log(xhr.responseText);
|
||||
terminal = document.getElementById("term");
|
||||
autoscroll = document.getElementById("scroll");
|
||||
terminal.innerHTML += xhr.responseText + '\n';
|
||||
terminal.innerHTML += xhr.responseText;
|
||||
if(autoscroll.checked)
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
}
|
||||
|
||||
+1
-3
@@ -67,8 +67,6 @@ input[type=range]::-webkit-slider-thumb{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -116,7 +114,7 @@ input:checked + .slider:before {
|
||||
#term {
|
||||
font-size: large;
|
||||
width: 100%;
|
||||
height: 10em;
|
||||
height: 20em;
|
||||
}
|
||||
|
||||
#clear_term {
|
||||
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "httpserver.h"
|
||||
|
||||
|
||||
bool HTTPServer::start() {
|
||||
if(!mount_fs()) {
|
||||
logf("cant mount filesystem, EXIT !\n\r");
|
||||
return false;
|
||||
}
|
||||
logf("[HTTPServer] LittleFS mounted !\n\r");
|
||||
logf("[HTTPServer] root:\n\r");
|
||||
logf("LittleFS mounted !\n\r");
|
||||
logf("root:\n\r");
|
||||
this->listRoot();
|
||||
logf("\n\r");
|
||||
|
||||
@@ -29,14 +30,39 @@ bool HTTPServer::start() {
|
||||
|
||||
// add static root file handler for http
|
||||
this->serveStatic("/", LittleFS, "/");
|
||||
this->begin();
|
||||
Serial.printf("Server active on Port 80 !\n\r");
|
||||
return true;
|
||||
}
|
||||
|
||||
void HTTPServer::logf(const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
char temp[64];
|
||||
size_t len = vsnprintf(temp, sizeof(temp), format, args);
|
||||
Serial.print(log_prefix);
|
||||
Serial.write(temp, len);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void HTTPServer::logt(const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
// append logging string to local buffer
|
||||
if(tbuf_head < TBUF_LEN) {
|
||||
size_t len = vsnprintf(tbuf+tbuf_head, TBUF_LEN-tbuf_head, format, args);
|
||||
tbuf_head += len;
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void HTTPServer::start_apps() {
|
||||
// application handler
|
||||
this->on("/app=terminal", HTTP_POST, [this]() {
|
||||
String log_msg = "terminal: millis: ";
|
||||
log_msg += millis();
|
||||
send(200, "text/plain", log_msg);
|
||||
if(tbuf_head) {
|
||||
send(200, "text/plain", tbuf);
|
||||
tbuf_head = 0;
|
||||
}
|
||||
});
|
||||
|
||||
this->begin();
|
||||
Serial.printf("[HTTPServer] Server active on Port 80 !\n\r");
|
||||
}
|
||||
@@ -9,24 +9,21 @@
|
||||
// debug log <ESP8266WebServer.h>
|
||||
// #define DEBUGV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
||||
|
||||
#define LOG_STR "[HTTPServer]"
|
||||
#define TBUF_LEN 256
|
||||
|
||||
|
||||
class HTTPServer : public ESP8266WebServer {
|
||||
|
||||
private:
|
||||
const char* rootDir = "/";
|
||||
const char* log_prefix = "[HTTPServer] ";
|
||||
|
||||
size_t tbuf_head = 0;
|
||||
char tbuf[TBUF_LEN];
|
||||
|
||||
void listRoot() {
|
||||
ls(rootDir);
|
||||
}
|
||||
void logf(const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
Serial.print(LOG_STR);
|
||||
Serial.printf(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
public:
|
||||
HTTPServer(const int _port, const char* _rootDir) :
|
||||
@@ -38,4 +35,8 @@ public:
|
||||
}
|
||||
|
||||
bool start();
|
||||
void start_apps();
|
||||
|
||||
void logf(const char *format, ...);
|
||||
void logt(const char *format, ...);
|
||||
};
|
||||
@@ -0,0 +1,170 @@
|
||||
//
|
||||
// Academic License - for use in teaching, academic research, and meeting
|
||||
// course requirements at degree granting institutions only. Not for
|
||||
// government, commercial, or other organizational use.
|
||||
//
|
||||
// File: FSMTreppe.cpp
|
||||
//
|
||||
// Code generated for Simulink model 'FSMTreppe'.
|
||||
//
|
||||
// Model version : 1.22
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Fri Jul 2 17:45:36 2021
|
||||
//
|
||||
// Target selection: ert.tlc
|
||||
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
|
||||
// Code generation objectives: Unspecified
|
||||
// Validation result: Not run
|
||||
//
|
||||
#include "FSMTreppe.h"
|
||||
|
||||
// Named constants for Chart: '<Root>/FSMTreppe'
|
||||
const uint8_t FSMTreppe_IN_animation_down = 1U;
|
||||
const uint8_t FSMTreppe_IN_animation_up = 2U;
|
||||
const uint8_t FSMTreppe_IN_idle = 3U;
|
||||
|
||||
// Model step function
|
||||
void FSMTreppeModelClass::step()
|
||||
{
|
||||
// Chart: '<Root>/FSMTreppe' incorporates:
|
||||
// Inport: '<Root>/anim_finished'
|
||||
// Inport: '<Root>/sensor_oben'
|
||||
// Inport: '<Root>/sensor_unten'
|
||||
|
||||
if (FSMTreppe_DW.temporalCounter_i1 < 511U) {
|
||||
FSMTreppe_DW.temporalCounter_i1 = static_cast<uint16_t>
|
||||
(FSMTreppe_DW.temporalCounter_i1 + 1U);
|
||||
}
|
||||
|
||||
if (FSMTreppe_DW.is_active_c3_FSMTreppe == 0U) {
|
||||
FSMTreppe_DW.is_active_c3_FSMTreppe = 1U;
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle;
|
||||
|
||||
// Outport: '<Root>/anim_active'
|
||||
FSMTreppe_Y.anim_active = 0U;
|
||||
FSMTreppe_DW.got_sensor = 0U;
|
||||
FSMTreppe_DW.got_anim_finished = 0U;
|
||||
FSMTreppe_DW.finished_up = 0U;
|
||||
FSMTreppe_DW.finished_dn = 0U;
|
||||
} else {
|
||||
switch (FSMTreppe_DW.is_c3_FSMTreppe) {
|
||||
case FSMTreppe_IN_animation_down:
|
||||
// Outport: '<Root>/anim_active'
|
||||
FSMTreppe_Y.anim_active = 2U;
|
||||
if ((FSMTreppe_DW.finished_dn == 1) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
300U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle;
|
||||
|
||||
// Outport: '<Root>/anim_active'
|
||||
FSMTreppe_Y.anim_active = 0U;
|
||||
FSMTreppe_DW.got_sensor = 0U;
|
||||
FSMTreppe_DW.got_anim_finished = 0U;
|
||||
FSMTreppe_DW.finished_up = 0U;
|
||||
FSMTreppe_DW.finished_dn = 0U;
|
||||
} else {
|
||||
if (FSMTreppe_U.sensor_unten) {
|
||||
FSMTreppe_DW.got_sensor = 1U;
|
||||
}
|
||||
|
||||
if (FSMTreppe_U.anim_finished) {
|
||||
FSMTreppe_DW.got_anim_finished = 1U;
|
||||
}
|
||||
|
||||
if ((FSMTreppe_DW.got_anim_finished == 1) && (FSMTreppe_DW.got_sensor ==
|
||||
1)) {
|
||||
FSMTreppe_DW.finished_dn = 1U;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_animation_up:
|
||||
// Outport: '<Root>/anim_active'
|
||||
FSMTreppe_Y.anim_active = 1U;
|
||||
if ((FSMTreppe_DW.finished_up == 1) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
300U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_idle;
|
||||
|
||||
// Outport: '<Root>/anim_active'
|
||||
FSMTreppe_Y.anim_active = 0U;
|
||||
FSMTreppe_DW.got_sensor = 0U;
|
||||
FSMTreppe_DW.got_anim_finished = 0U;
|
||||
FSMTreppe_DW.finished_up = 0U;
|
||||
FSMTreppe_DW.finished_dn = 0U;
|
||||
} else {
|
||||
if (FSMTreppe_U.sensor_oben) {
|
||||
FSMTreppe_DW.got_sensor = 1U;
|
||||
}
|
||||
|
||||
if (FSMTreppe_U.anim_finished) {
|
||||
FSMTreppe_DW.got_anim_finished = 1U;
|
||||
}
|
||||
|
||||
if ((FSMTreppe_DW.got_anim_finished == 1) && (FSMTreppe_DW.got_sensor ==
|
||||
1)) {
|
||||
FSMTreppe_DW.finished_up = 1U;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Outport: '<Root>/anim_active'
|
||||
// case IN_idle:
|
||||
FSMTreppe_Y.anim_active = 0U;
|
||||
if (FSMTreppe_U.sensor_oben) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_animation_down;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/anim_active'
|
||||
FSMTreppe_Y.anim_active = 2U;
|
||||
FSMTreppe_DW.got_sensor = 0U;
|
||||
FSMTreppe_DW.got_anim_finished = 0U;
|
||||
FSMTreppe_DW.finished_dn = 0U;
|
||||
} else if (FSMTreppe_U.sensor_unten) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_animation_up;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/anim_active'
|
||||
FSMTreppe_Y.anim_active = 1U;
|
||||
FSMTreppe_DW.got_sensor = 0U;
|
||||
FSMTreppe_DW.got_anim_finished = 0U;
|
||||
FSMTreppe_DW.finished_up = 0U;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// End of Chart: '<Root>/FSMTreppe'
|
||||
}
|
||||
|
||||
// Model initialize function
|
||||
void FSMTreppeModelClass::initialize()
|
||||
{
|
||||
// (no initialization code required)
|
||||
}
|
||||
|
||||
// Model terminate function
|
||||
void FSMTreppeModelClass::terminate()
|
||||
{
|
||||
// (no terminate code required)
|
||||
}
|
||||
|
||||
// Constructor
|
||||
FSMTreppeModelClass::FSMTreppeModelClass() :
|
||||
FSMTreppe_DW(),
|
||||
FSMTreppe_U(),
|
||||
FSMTreppe_Y()
|
||||
{
|
||||
// Currently there is no constructor body generated.
|
||||
}
|
||||
|
||||
// Destructor
|
||||
FSMTreppeModelClass::~FSMTreppeModelClass()
|
||||
{
|
||||
// Currently there is no destructor body generated.
|
||||
}
|
||||
|
||||
//
|
||||
// File trailer for generated code.
|
||||
//
|
||||
// [EOF]
|
||||
//
|
||||
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// Academic License - for use in teaching, academic research, and meeting
|
||||
// course requirements at degree granting institutions only. Not for
|
||||
// government, commercial, or other organizational use.
|
||||
//
|
||||
// File: FSMTreppe.h
|
||||
//
|
||||
// Code generated for Simulink model 'FSMTreppe'.
|
||||
//
|
||||
// Model version : 1.22
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Fri Jul 2 17:45:36 2021
|
||||
//
|
||||
// Target selection: ert.tlc
|
||||
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
|
||||
// Code generation objectives: Unspecified
|
||||
// Validation result: Not run
|
||||
//
|
||||
#ifndef RTW_HEADER_FSMTreppe_h_
|
||||
#define RTW_HEADER_FSMTreppe_h_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Class declaration for model FSMTreppe
|
||||
class FSMTreppeModelClass {
|
||||
// public data and function members
|
||||
public:
|
||||
// Block states (default storage) for system '<Root>'
|
||||
struct DW_FSMTreppe_T {
|
||||
uint16_t temporalCounter_i1; // '<Root>/FSMTreppe'
|
||||
uint8_t is_active_c3_FSMTreppe; // '<Root>/FSMTreppe'
|
||||
uint8_t is_c3_FSMTreppe; // '<Root>/FSMTreppe'
|
||||
uint8_t got_anim_finished; // '<Root>/FSMTreppe'
|
||||
uint8_t finished_up; // '<Root>/FSMTreppe'
|
||||
uint8_t finished_dn; // '<Root>/FSMTreppe'
|
||||
uint8_t got_sensor; // '<Root>/FSMTreppe'
|
||||
};
|
||||
|
||||
// External inputs (root inport signals with default storage)
|
||||
struct ExtU_FSMTreppe_T {
|
||||
bool sensor_unten; // '<Root>/sensor_unten'
|
||||
bool sensor_oben; // '<Root>/sensor_oben'
|
||||
bool anim_finished; // '<Root>/anim_finished'
|
||||
};
|
||||
|
||||
// External outputs (root outports fed by signals with default storage)
|
||||
struct ExtY_FSMTreppe_T {
|
||||
uint8_t anim_active; // '<Root>/anim_active'
|
||||
};
|
||||
|
||||
// model initialize function
|
||||
void initialize();
|
||||
|
||||
// model step function
|
||||
void step();
|
||||
|
||||
// model terminate function
|
||||
void terminate();
|
||||
|
||||
// Constructor
|
||||
FSMTreppeModelClass();
|
||||
|
||||
// Destructor
|
||||
~FSMTreppeModelClass();
|
||||
|
||||
// Root-level structure-based inputs set method
|
||||
|
||||
// Root inports set method
|
||||
void setExternalInputs(const ExtU_FSMTreppe_T* pExtU_FSMTreppe_T)
|
||||
{
|
||||
FSMTreppe_U = *pExtU_FSMTreppe_T;
|
||||
}
|
||||
|
||||
// Root-level structure-based outputs get method
|
||||
|
||||
// Root outports get method
|
||||
const FSMTreppeModelClass::ExtY_FSMTreppe_T & getExternalOutputs() const
|
||||
{
|
||||
return FSMTreppe_Y;
|
||||
}
|
||||
|
||||
// private data and function members
|
||||
private:
|
||||
// Block states
|
||||
DW_FSMTreppe_T FSMTreppe_DW;
|
||||
|
||||
// External inputs
|
||||
ExtU_FSMTreppe_T FSMTreppe_U;
|
||||
|
||||
// External outputs
|
||||
ExtY_FSMTreppe_T FSMTreppe_Y;
|
||||
};
|
||||
|
||||
//-
|
||||
// The generated code includes comments that allow you to trace directly
|
||||
// back to the appropriate location in the model. The basic format
|
||||
// is <system>/block_name, where system is the system number (uniquely
|
||||
// assigned by Simulink) and block_name is the name of the block.
|
||||
//
|
||||
// Note that this particular code originates from a subsystem build,
|
||||
// and has its own system numbers different from the parent model.
|
||||
// Refer to the system hierarchy for this subsystem below, and use the
|
||||
// MATLAB hilite_system command to trace the generated code back
|
||||
// to the parent model. For example,
|
||||
//
|
||||
// hilite_system('FSM_Treppenlicht/FSMTreppe') - opens subsystem FSM_Treppenlicht/FSMTreppe
|
||||
// hilite_system('FSM_Treppenlicht/FSMTreppe/Kp') - opens and selects block Kp
|
||||
//
|
||||
// Here is the system hierarchy for this model
|
||||
//
|
||||
// '<Root>' : 'FSM_Treppenlicht'
|
||||
// '<S1>' : 'FSM_Treppenlicht/FSMTreppe'
|
||||
|
||||
#endif // RTW_HEADER_FSMTreppe_h_
|
||||
|
||||
//
|
||||
// File trailer for generated code.
|
||||
//
|
||||
// [EOF]
|
||||
//
|
||||
@@ -86,7 +86,7 @@ void Treppe::rampe()
|
||||
{
|
||||
if(state) {
|
||||
finish = 0;
|
||||
state = 0; // set parameter memory
|
||||
state = 0;// set parameter memory
|
||||
}
|
||||
|
||||
if(!finish) {
|
||||
@@ -140,17 +140,22 @@ void Treppe::setup(){
|
||||
// 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.init(PCA9685_PhaseBalancer_Linear);
|
||||
pwmController.setPWMFrequency(100);
|
||||
pwmController.setAllChannelsPWM(idle_brightness);
|
||||
|
||||
pinMode(A0, INPUT);
|
||||
pinMode(SENSOR1, INPUT);
|
||||
pinMode(SENSOR2, INPUT);
|
||||
pinMode(OE, OUTPUT);
|
||||
digitalWrite(OE, 0);
|
||||
Serial.println("Hello from Treppe");
|
||||
Serial.print("Treppe: initial parameters: stairs=");
|
||||
Serial.println(stairs);
|
||||
}
|
||||
|
||||
void Treppe::task(){
|
||||
FSMTreppe_Obj.step();
|
||||
|
||||
if(finish){
|
||||
direction = switch_direction;
|
||||
@@ -194,6 +199,7 @@ void Treppe::task(){
|
||||
last_sensor_state[1] = current_sensor_state[1];
|
||||
|
||||
ledsequence();
|
||||
//Serial.printf("LDR: %f\n", ((float)analogRead(A0))/1023.*3.68);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
-6
@@ -1,18 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "FSMTreppe/FSMTreppe.h"
|
||||
#include "PCA9685.h"
|
||||
|
||||
#define SENSOR1 15
|
||||
#define SENSOR1 2
|
||||
#define SENSOR2 12
|
||||
#define OE 14
|
||||
|
||||
#define INT_TIME 20 // interrupt intervall [ms]
|
||||
|
||||
class Treppe {
|
||||
private:
|
||||
// initialize with i2c-Address 0, use Wire Library
|
||||
PCA9685 pwmController;
|
||||
FSMTreppeModelClass FSMTreppe_Obj;// Instance of model class
|
||||
|
||||
uint8_t stairs;
|
||||
uint16_t time_per_stair = 300; // dimmtime per stair [ms]
|
||||
uint16_t idle_brightness = 0;
|
||||
uint16_t active_brightness = 500;
|
||||
uint16_t idle_brightness = 100;
|
||||
uint16_t active_brightness = 2048;
|
||||
|
||||
uint8_t direction = 0;
|
||||
uint8_t switch_direction = 0;
|
||||
@@ -30,21 +36,23 @@ private:
|
||||
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){
|
||||
FSMTreppe_Obj.initialize();
|
||||
|
||||
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;
|
||||
}
|
||||
~Treppe() {
|
||||
FSMTreppe_Obj.terminate();
|
||||
}
|
||||
|
||||
void setup();
|
||||
void task(); // call periodically
|
||||
|
||||
+25
-10
@@ -27,6 +27,13 @@ Treppe stairs(16);
|
||||
const char* ssid = STASSID;
|
||||
const char* password = STAPSK;
|
||||
|
||||
// port 80, root directory of server '/'
|
||||
HTTPServer httpServer(80, "/");
|
||||
|
||||
uint32_t _t=0;
|
||||
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us")
|
||||
#define TIMEIF_US(_f, _l, _str) _t=micros(); _f; _t=micros()-_t; if(_t > _l) { SP_US(_str, _t); }
|
||||
|
||||
|
||||
void timerCallback(void *pArg)
|
||||
{
|
||||
@@ -34,27 +41,23 @@ void timerCallback(void *pArg)
|
||||
stairs.task();
|
||||
}
|
||||
|
||||
// port 80, root directory of server '/'
|
||||
HTTPServer httpServer(80, "/");
|
||||
|
||||
uint32_t _t=0;
|
||||
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us")
|
||||
#define TIMEIF_US(_f, _l, _str) _t=micros(); _f; _t=micros()-_t; if(_t > _l) { SP_US(_str, _t); }
|
||||
// ===============================================
|
||||
|
||||
|
||||
uint8_t inter = 0;
|
||||
ICACHE_RAM_ATTR void int_test(){
|
||||
inter = 1;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
#ifdef WITH_DEBUGGING_ON
|
||||
Serial.begin(460800);
|
||||
gdbstub_init();
|
||||
#else
|
||||
Serial.begin(115200);
|
||||
Serial.begin(76800);
|
||||
#endif
|
||||
|
||||
Serial.println(F("Booting ...."));
|
||||
|
||||
pinMode(NODEMCU_LED, OUTPUT);
|
||||
//pinMode(NODEMCU_LED, OUTPUT);
|
||||
pinMode(ESP12_LED, OUTPUT);
|
||||
|
||||
Wire.begin(); // Wire must be started first
|
||||
@@ -78,10 +81,14 @@ void setup() {
|
||||
ota_setup();
|
||||
|
||||
httpServer.start();
|
||||
httpServer.start_apps();
|
||||
|
||||
Serial.println("HTTP server started !");
|
||||
|
||||
stairs.setup();
|
||||
Serial.println("PCA9685 connected !");
|
||||
//attachInterrupt(digitalPinToInterrupt(2), int_test, RISING);
|
||||
//attachInterrupt(digitalPinToInterrupt(12), int_test, RISING);
|
||||
|
||||
os_timer_setfn(&timer1, timerCallback, &timer_flag);
|
||||
os_timer_arm(&timer1, 20, true);
|
||||
@@ -89,6 +96,8 @@ void setup() {
|
||||
|
||||
#include <random>
|
||||
|
||||
uint32_t c = 0;
|
||||
|
||||
void loop() {
|
||||
// if(stairs.getState() == 0) {
|
||||
// delay(1000);
|
||||
@@ -102,6 +111,12 @@ void loop() {
|
||||
// stairs.setDirection(!stairs.getDirection());
|
||||
// stairs.setState(1);
|
||||
// }
|
||||
if(inter){
|
||||
Serial.printf("interrupt\n");
|
||||
inter = 0;
|
||||
}
|
||||
if(c++%1000000 == 0)
|
||||
httpServer.logt("[%d] starting :)\n", c);
|
||||
|
||||
TIMEIF_US(ArduinoOTA.handle(), 10000, "OTA");
|
||||
TIMEIF_US(httpServer.handleClient(), 10000, "HTTP");
|
||||
|
||||
Reference in new issue
Block a user