Compare commits
149 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d6f35b82be | |||
| 3821724a06 | |||
| bcad1369af | |||
|
|
e4ad92ca99 | ||
|
|
89dcbf27ae | ||
|
|
a0f5ec26d2 | ||
|
|
c95ea1ed22 | ||
|
|
392f2c1bbc | ||
|
|
79e88d29c3 | ||
|
|
1686b9ea2a | ||
| 8c45c65d00 | |||
| 6bd0844927 | |||
| b309c0b207 | |||
| 767df957cc | |||
| 0d6f0b28e2 | |||
| 937f7f09e7 | |||
| 6ae3f5690f | |||
| 7c770a7802 | |||
| 6807d0f0af | |||
| 770c2436fd | |||
| 3145949020 | |||
| ca938ef3dd | |||
| f8fac7acfb | |||
| 9ed1b24316 | |||
| 125b39a418 | |||
| e47cae30a8 | |||
| b2ff66d44c | |||
| c23b9f2bc6 | |||
| 31c268487c | |||
| ad21d73fbb | |||
| 42a927e383 | |||
| 13db3da082 | |||
| 9518c06fd9 | |||
| 2820869e14 | |||
| 6e810fad59 | |||
| 79a9eecaad | |||
| 1189b7c3a4 | |||
| 7643961ed2 | |||
| 6cc52dc460 | |||
| d3ed19e639 | |||
| d55da4e6d7 | |||
| f677f18681 | |||
| f027478e2e | |||
| 5986beb10c | |||
|
|
f57e875a17 | ||
|
|
d16f3823b8 | ||
|
|
a5ac7d358b | ||
| 0cd46a3c9f | |||
| 3a93b8a002 | |||
| 0e5085c008 | |||
| 7177472ea6 | |||
| 03d0cfedd1 | |||
| 66d220cdb0 | |||
| 2754bd5247 | |||
| f62a18fe66 | |||
| 2139ff5943 | |||
| 6a04a4d1c9 | |||
| 630250da78 | |||
| 35ba3e7573 | |||
| 53efb0c309 | |||
| c1e24d633b | |||
| 5e36ef55df | |||
| 6b5cabb1f4 | |||
| 37380cbebc | |||
| 8c507083a7 | |||
| 2f6502ce20 | |||
| 278179fa6e | |||
| f38ef0ed0e | |||
| f2a9ed2888 | |||
| 1662079547 | |||
| 1e8d24dc40 | |||
| af40298378 | |||
| 8351a6430c | |||
| b2ddc978b6 | |||
| 22f141e2cd | |||
| f5d6e376c6 | |||
| eeac10c66f | |||
| e9d16a80d4 | |||
| dcae074b55 | |||
| 472eba7977 | |||
| 6a398d9ba0 | |||
| f28aa2df8b | |||
| 754da9f931 | |||
| df2a8fa1e3 | |||
| dc159a35d0 | |||
| 2378ca80b9 | |||
| 79ff1f0d33 | |||
| 6a36971406 | |||
| 714fcb4b18 | |||
| 712acf3541 | |||
| df89c9716c | |||
| 66e8ddb2d9 | |||
| 5b197288bc | |||
| a9f098097c | |||
| a0f6a5aec3 | |||
| 633b99f818 | |||
| 5d32392844 | |||
| 50e714e5f8 | |||
| e0bc75826f | |||
| 3d13e761f4 | |||
| 3c824bfc92 | |||
| 9ea541a1b4 | |||
| b89604edc3 | |||
| 4e6445fea8 | |||
| 10b57ca516 | |||
| e8329f2587 | |||
| 014aa028d7 | |||
| b47f778fc1 | |||
| c7eaffda00 | |||
| 69e1e869a5 | |||
| 1a284080e8 | |||
| 3490e7ba44 | |||
| d059c3d72d | |||
| 33499beb32 | |||
| 38c81ae182 | |||
| a8ceb258b8 | |||
| 7e5a6fac9f | |||
| b7ba521c59 | |||
| 55ebd21975 | |||
| 2b2a135bd5 | |||
| a400b0464d | |||
| 2d9be85b09 | |||
| 33b9f0150e | |||
| 48d0dc50f7 | |||
| cdb34a3cbf | |||
| 1b34714d27 | |||
|
|
90a9213a3c | ||
|
|
7976f5258f | ||
|
|
bb3a735d37 | ||
|
|
3c186771fe | ||
|
|
c40e7f80e5 | ||
| 9d1105cb80 | |||
| 4130b64370 | |||
| bff8cdbeb7 | |||
| d8343ea91f | |||
| 78f09b3a3b | |||
| bd0e364d22 | |||
| 32266b5f37 | |||
| b62f4f9f95 | |||
| a8af7543ba | |||
| 85f8da3476 | |||
| f323bd4cf9 | |||
|
|
708bb2cda4 | ||
|
|
a4196bb579 | ||
| 908c4298be | |||
| 6e885673b8 | |||
| 93cc958800 | |||
| 9d30423ca3 | |||
| b3b11d0818 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,5 +1,9 @@
|
||||
.pio
|
||||
.vscode
|
||||
.vscode/*
|
||||
.vscode/**
|
||||
compress
|
||||
data_gz
|
||||
platformio.ini
|
||||
include/wifi_credentials.h
|
||||
include/*.gz.h
|
||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "lib/PCA9685-Arduino"]
|
||||
path = lib/PCA9685-Arduino
|
||||
url = https://github.com/NachtRaveVL/PCA9685-Arduino
|
||||
7
.vscode/extensions.json
vendored
7
.vscode/extensions.json
vendored
@ -1,7 +0,0 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
52
.vscode/settings.json
vendored
52
.vscode/settings.json
vendored
@ -1,52 +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"
|
||||
}
|
||||
}
|
||||
52
README.md
52
README.md
@ -1,8 +1,9 @@
|
||||
### Steps to run it
|
||||
### __How-To use this Project__
|
||||
|
||||
https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html
|
||||
|
||||
##### create "include/wifi_credentials.h"
|
||||
1. Download and install [Visual Studio Code](https://code.visualstudio.com/download)
|
||||
2. Install [PlatformIO IDE extension](https://platformio.org/install/ide?install=vscode) for Visual Studio Code
|
||||
3. Download sources from master branch, "zip" or "git clone"
|
||||
4. Create [wifi_credentials.h](include/wifi_credentials.h) from [templ_wifi_credentials.h](include/templ_wifi_credentials.h) in include/
|
||||
|
||||
```cpp
|
||||
#ifndef __WIFI_CREDENTIALS_H
|
||||
@ -16,24 +17,31 @@ https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html
|
||||
#endif // __WIFI_CREDENTIALS_H
|
||||
```
|
||||
|
||||
##### platformio.ini
|
||||
see templ_platformio_ini
|
||||
5. Create [platformio.ini](platformio.ini) from [templ_platformio_ini](templ_platformio_ini)
|
||||
|
||||
```ini
|
||||
[env:<BOARD>]
|
||||
platform = espressif8266
|
||||
board = <BOARD>
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
|
||||
extra_scripts = pre:extra_script.py
|
||||
|
||||
; stuff for OTA
|
||||
; https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
|
||||
upload_protocol = espota
|
||||
upload_port = <IPADRESS>
|
||||
upload_flags =
|
||||
--port=8266
|
||||
--auth=admin
|
||||
```sh
|
||||
$ cp templ_platformio_ini platformio.ini
|
||||
```
|
||||
|
||||
6. __Uploading new firmware__
|
||||
|
||||
```sh
|
||||
# upload program via ota
|
||||
$ pio run -t upload
|
||||
# upload file system via ota
|
||||
$ pio run -t uploadfs
|
||||
|
||||
# upload program via Serial Port
|
||||
# Serial Port needs to be selected in platformio.ini
|
||||
$ pio run -t upload -e serial
|
||||
# upload file system via Serial Port
|
||||
$ pio run -t uploadfs -e serial
|
||||
```
|
||||
|
||||
------
|
||||
|
||||
Additional used sources and libraries in this project and [DOKU.md](DOKU.md)
|
||||
- https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html
|
||||
- https://github.com/NachtRaveVL/PCA9685-Arduino
|
||||
- https://arduino-esp8266.readthedocs.io/en/latest/gdb.html
|
||||
- check different environments inside [platformio.ini](platformio.ini)
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
// filename: favicon.png.gz.h
|
||||
#define favicon_png_gz_len 554
|
||||
const char favicon_png_gz[] = {
|
||||
0x1F, 0x8B, 0x08, 0x00, 0xB2, 0x41, 0xD3, 0x60, 0x02, 0xFF,
|
||||
0x01, 0x13, 0x02, 0xEC, 0xFD, 0x89, 0x50, 0x4E, 0x47, 0x0D,
|
||||
0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44,
|
||||
0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08,
|
||||
0x06, 0x00, 0x00, 0x00, 0x1F, 0xF3, 0xFF, 0x61, 0x00, 0x00,
|
||||
0x01, 0xDA, 0x49, 0x44, 0x41, 0x54, 0x38, 0x4F, 0x85, 0x93,
|
||||
0x4F, 0x68, 0x13, 0x41, 0x14, 0x87, 0xBF, 0xB7, 0xD9, 0xFC,
|
||||
0xB1, 0x0A, 0xD5, 0x56, 0x8A, 0x20, 0xA8, 0xA1, 0xBA, 0x49,
|
||||
0x05, 0x7B, 0x89, 0x20, 0xEA, 0x41, 0x04, 0x8F, 0xE2, 0x55,
|
||||
0x29, 0x78, 0xB3, 0x60, 0x0F, 0xA2, 0x07, 0x3D, 0x6E, 0x90,
|
||||
0xA4, 0x37, 0x3D, 0xE9, 0x41, 0xD4, 0xB3, 0x07, 0x3D, 0x79,
|
||||
0x15, 0xC1, 0x83, 0x60, 0x35, 0xC5, 0x4B, 0xD4, 0xA6, 0x26,
|
||||
0x39, 0x94, 0x1E, 0xA4, 0x20, 0x82, 0xB5, 0x75, 0xDB, 0x24,
|
||||
0xBB, 0x3B, 0x23, 0xBB, 0x21, 0xD5, 0xAE, 0x9B, 0x74, 0x4E,
|
||||
0x33, 0xEF, 0xFD, 0x7E, 0xDF, 0xCC, 0x7B, 0x33, 0x23, 0xC4,
|
||||
0x0C, 0xFD, 0x75, 0xF6, 0x24, 0xA2, 0xEF, 0x00, 0x67, 0x00,
|
||||
0x03, 0x98, 0x47, 0xEB, 0xFB, 0x92, 0x2F, 0xBE, 0x8B, 0xCA,
|
||||
0x25, 0x1A, 0xD0, 0xCD, 0xD2, 0x35, 0x94, 0x3C, 0x02, 0xCC,
|
||||
0x48, 0x4E, 0xA1, 0xB8, 0x25, 0x13, 0xF6, 0xC3, 0x7F, 0xE3,
|
||||
0xDB, 0x00, 0x7A, 0xB1, 0x54, 0xC0, 0x90, 0x0F, 0x31, 0xE6,
|
||||
0xAE, 0x47, 0xC4, 0x07, 0x75, 0x56, 0xAC, 0x62, 0xA5, 0x07,
|
||||
0xD9, 0x0E, 0x68, 0x94, 0x9F, 0xA1, 0x99, 0x8A, 0x2B, 0x6B,
|
||||
0x2B, 0xA6, 0x79, 0x2E, 0x79, 0xFB, 0x4A, 0x3F, 0x40, 0x03,
|
||||
0xCD, 0x31, 0xB4, 0x0B, 0xDE, 0x2F, 0x48, 0xEE, 0xEF, 0xEA,
|
||||
0xDC, 0x1F, 0x60, 0x0E, 0x83, 0x24, 0x41, 0x68, 0x8A, 0x65,
|
||||
0x5B, 0xF1, 0x80, 0x7A, 0xB9, 0x06, 0x4C, 0xA0, 0x15, 0x6C,
|
||||
0xD6, 0xC1, 0xDC, 0xDB, 0xD5, 0x79, 0xAB, 0xB0, 0x2B, 0x07,
|
||||
0x12, 0xF4, 0x93, 0x45, 0xC9, 0xD9, 0xC7, 0xFB, 0x01, 0x9E,
|
||||
0x00, 0xD3, 0x61, 0xB2, 0x07, 0x09, 0xE6, 0x7F, 0xCD, 0xC1,
|
||||
0x09, 0x1E, 0x8B, 0x65, 0x5F, 0x8F, 0x07, 0x34, 0xCB, 0xE3,
|
||||
0x28, 0x3E, 0x07, 0x96, 0x50, 0xD0, 0x59, 0x09, 0x3A, 0x07,
|
||||
0xA9, 0x03, 0x3D, 0xBD, 0x83, 0xE6, 0x84, 0xE4, 0xED, 0xA5,
|
||||
0x58, 0x40, 0xB8, 0x71, 0xA3, 0x74, 0x1B, 0x2D, 0xF7, 0x62,
|
||||
0x01, 0xA2, 0x6F, 0x8A, 0x55, 0x7C, 0xD0, 0xF7, 0x1A, 0x43,
|
||||
0x40, 0xF3, 0x46, 0x1A, 0x35, 0xF6, 0x0D, 0x18, 0x8D, 0x9C,
|
||||
0x60, 0x05, 0xCB, 0x3F, 0x24, 0x72, 0xD7, 0x1B, 0x08, 0x08,
|
||||
0x21, 0xF5, 0xF2, 0x6B, 0xE0, 0x42, 0x00, 0xD0, 0x18, 0xB4,
|
||||
0x93, 0x47, 0x71, 0x18, 0x99, 0x1F, 0xCD, 0x5D, 0x3D, 0x2D,
|
||||
0x22, 0x6A, 0x20, 0xE0, 0xA3, 0xD6, 0x49, 0xA7, 0x52, 0x79,
|
||||
0x6F, 0x26, 0xA4, 0x90, 0x49, 0x9B, 0x78, 0x64, 0xD8, 0x68,
|
||||
0x2B, 0x7C, 0xE5, 0xD7, 0xC6, 0xC7, 0x86, 0x0B, 0xD9, 0x6C,
|
||||
0xB6, 0x35, 0x10, 0xF0, 0x62, 0x61, 0x21, 0x95, 0xF9, 0xBE,
|
||||
0x3E, 0xF7, 0x7B, 0x63, 0xB3, 0xD0, 0xEE, 0xB8, 0x98, 0x66,
|
||||
0x82, 0x4C, 0x3A, 0xC5, 0x9E, 0xA1, 0xA1, 0x5A, 0xFE, 0xE0,
|
||||
0xC8, 0xCE, 0x80, 0x6A, 0xB5, 0xBA, 0x7B, 0xD5, 0x33, 0xBF,
|
||||
0x24, 0x0C, 0xE3, 0x48, 0xB0, 0x53, 0xAB, 0xD3, 0xA1, 0xD5,
|
||||
0x6A, 0xE3, 0x6B, 0xF5, 0xF6, 0xD2, 0xB9, 0x53, 0xE7, 0x77,
|
||||
0x2C, 0x21, 0x30, 0xBD, 0x7C, 0x33, 0x37, 0xD5, 0x6A, 0xBB,
|
||||
0xB3, 0x86, 0x48, 0x36, 0x7C, 0x88, 0x9E, 0xBF, 0xB4, 0xE6,
|
||||
0x38, 0x33, 0x33, 0x97, 0x2F, 0xBE, 0x8A, 0x3E, 0xF3, 0xFF,
|
||||
0x7E, 0x63, 0x4F, 0xF0, 0x69, 0x79, 0x79, 0x9F, 0xEB, 0xB8,
|
||||
0xD3, 0x41, 0xC7, 0xD2, 0x5E, 0xF2, 0xE9, 0xE4, 0xE4, 0xE1,
|
||||
0x9F, 0x51, 0x73, 0xB0, 0xFE, 0x03, 0xD7, 0x38, 0xAF, 0x11,
|
||||
0x77, 0x41, 0x94, 0x64, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
|
||||
0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82, 0xF3, 0x2E, 0x2C, 0x55,
|
||||
0x13, 0x02, 0x00, 0x00};
|
||||
@ -1,46 +0,0 @@
|
||||
// filename: index.html.gz.h
|
||||
#define index_html_gz_len 428
|
||||
const char index_html_gz[] = {
|
||||
0x1F, 0x8B, 0x08, 0x00, 0xB2, 0x41, 0xD3, 0x60, 0x02, 0xFF,
|
||||
0xB5, 0x54, 0xC1, 0x4E, 0xE3, 0x30, 0x10, 0xBD, 0x23, 0xED,
|
||||
0x3F, 0x0C, 0xBE, 0xB7, 0xA1, 0x2B, 0x6D, 0xC5, 0x21, 0xED,
|
||||
0x05, 0x38, 0x83, 0xB4, 0x5C, 0xF6, 0x54, 0x39, 0xCE, 0x34,
|
||||
0x31, 0x38, 0xB6, 0x65, 0x4F, 0x4B, 0xBB, 0x5F, 0x8F, 0x33,
|
||||
0x71, 0x69, 0x60, 0xB3, 0x88, 0x0B, 0x97, 0x78, 0xEC, 0xF7,
|
||||
0xFC, 0xDE, 0x1B, 0x27, 0x4E, 0x79, 0x79, 0x7B, 0x7F, 0xF3,
|
||||
0xF8, 0xE7, 0xE1, 0x0E, 0x5A, 0xEA, 0xCC, 0xFA, 0xC7, 0x45,
|
||||
0x99, 0x47, 0x80, 0xB2, 0x45, 0x59, 0x73, 0x95, 0x6A, 0xD2,
|
||||
0x64, 0x70, 0x7D, 0xF7, 0xFB, 0xE1, 0xFA, 0xE7, 0x72, 0x09,
|
||||
0x8F, 0x01, 0xBD, 0x47, 0x6B, 0xB4, 0x6A, 0xA9, 0x2C, 0x06,
|
||||
0x2C, 0x13, 0x2F, 0x67, 0x33, 0xE8, 0xA4, 0xB6, 0x10, 0xE9,
|
||||
0x68, 0x10, 0x62, 0x8B, 0x48, 0x30, 0x9B, 0x9D, 0x60, 0xA3,
|
||||
0xED, 0x33, 0xB4, 0x01, 0xB7, 0x2B, 0x51, 0x6C, 0xE5, 0x5E,
|
||||
0x2B, 0x67, 0xE7, 0xDE, 0x36, 0x02, 0x02, 0x9A, 0x95, 0xE8,
|
||||
0xA7, 0x02, 0xE8, 0xE8, 0x31, 0xD5, 0x9D, 0x6C, 0xB0, 0x60,
|
||||
0x2C, 0xEA, 0xBF, 0x18, 0x57, 0x62, 0xB1, 0x3C, 0x2C, 0x96,
|
||||
0x62, 0x4A, 0x89, 0xBD, 0xE6, 0x2A, 0xC6, 0xAC, 0xC3, 0x73,
|
||||
0xB6, 0x3E, 0xA9, 0x11, 0x1E, 0xA8, 0xE8, 0x09, 0x69, 0x3B,
|
||||
0x37, 0x57, 0xBC, 0x75, 0x57, 0x56, 0xAE, 0x3E, 0x9E, 0x54,
|
||||
0x6B, 0xBD, 0x07, 0x65, 0x64, 0x4C, 0x76, 0xE4, 0x7C, 0x25,
|
||||
0xC3, 0xC9, 0x0F, 0x60, 0xAA, 0x79, 0xB8, 0x71, 0x96, 0x82,
|
||||
0x33, 0x06, 0x43, 0x16, 0x28, 0x92, 0xC2, 0x84, 0x98, 0x1A,
|
||||
0x78, 0x67, 0xB5, 0x31, 0x58, 0x05, 0xDD, 0xB4, 0x64, 0x71,
|
||||
0x88, 0x97, 0xF1, 0x91, 0xD0, 0x7B, 0xB6, 0xB3, 0x6E, 0xBB,
|
||||
0x3D, 0x13, 0x01, 0xC8, 0x35, 0x4D, 0x3A, 0x6A, 0x69, 0xCC,
|
||||
0x79, 0xAD, 0x34, 0xB2, 0x42, 0x03, 0xBA, 0x5E, 0x09, 0xB3,
|
||||
0xC9, 0x3B, 0xCA, 0x82, 0x17, 0xD7, 0xFF, 0xB0, 0xB2, 0x70,
|
||||
0x7C, 0xD1, 0xA4, 0xDA, 0xB1, 0x72, 0x62, 0x68, 0xEB, 0x77,
|
||||
0x94, 0x0F, 0x51, 0xB5, 0xA8, 0x9E, 0x2B, 0x77, 0xF8, 0x40,
|
||||
0x89, 0x5E, 0xDA, 0x37, 0x0D, 0xA3, 0x6B, 0x0C, 0x10, 0xDC,
|
||||
0xCE, 0xD6, 0xBD, 0x63, 0x8F, 0x8D, 0x0D, 0x3F, 0x44, 0xF8,
|
||||
0x7F, 0x97, 0xFE, 0xA5, 0x13, 0xEB, 0xE9, 0x7E, 0xFA, 0x6A,
|
||||
0xC3, 0xF8, 0x44, 0x47, 0xE3, 0xBC, 0x41, 0xDA, 0x06, 0x05,
|
||||
0x74, 0xDA, 0xA6, 0x8F, 0x27, 0x8D, 0xF2, 0x90, 0xC6, 0xAB,
|
||||
0x2B, 0x01, 0x7B, 0x69, 0x76, 0x09, 0xFF, 0x95, 0xCA, 0x6C,
|
||||
0xC7, 0xD4, 0x21, 0xBC, 0x60, 0x17, 0x5E, 0x58, 0x7C, 0xE5,
|
||||
0x7D, 0x90, 0xEE, 0x30, 0x7C, 0x9A, 0x35, 0x33, 0xBE, 0x31,
|
||||
0x2D, 0x3B, 0x6C, 0x06, 0x85, 0xC9, 0xC8, 0xE3, 0x9A, 0x9F,
|
||||
0xC3, 0x25, 0xC8, 0x9F, 0x3E, 0x4F, 0xA2, 0x0A, 0xDA, 0x13,
|
||||
0xC4, 0xA0, 0xD2, 0x8D, 0xE2, 0x60, 0xF3, 0xA7, 0xC8, 0xEF,
|
||||
0x90, 0x01, 0xA6, 0xA5, 0x6B, 0x33, 0xFC, 0x1E, 0x5E, 0x01,
|
||||
0xA6, 0x28, 0x83, 0xDC, 0x38, 0x04, 0x00, 0x00};
|
||||
@ -1,24 +0,0 @@
|
||||
// filename: input.js.gz.h
|
||||
#define input_js_gz_len 205
|
||||
const char input_js_gz[] = {
|
||||
0x1F, 0x8B, 0x08, 0x00, 0xB2, 0x41, 0xD3, 0x60, 0x02, 0xFF,
|
||||
0x7D, 0xCF, 0x31, 0x0B, 0xC2, 0x30, 0x10, 0x05, 0xE0, 0x3D,
|
||||
0x90, 0xFF, 0x70, 0x38, 0xB5, 0x4B, 0x8B, 0xB3, 0xB8, 0x88,
|
||||
0x82, 0x82, 0x6E, 0x3A, 0xCB, 0xD1, 0x9C, 0x6D, 0x20, 0xBD,
|
||||
0x94, 0xF4, 0x52, 0x29, 0xE2, 0x7F, 0xB7, 0xB6, 0x75, 0x10,
|
||||
0xC4, 0xED, 0x86, 0xEF, 0xF1, 0xDE, 0x75, 0x18, 0xA0, 0x75,
|
||||
0xD6, 0x50, 0x80, 0x35, 0x18, 0x5F, 0xC4, 0x9A, 0x58, 0xB2,
|
||||
0x92, 0x64, 0xE7, 0xE8, 0x7D, 0x6E, 0xFA, 0x83, 0x49, 0x16,
|
||||
0x01, 0xB9, 0xA4, 0xE5, 0x22, 0x5D, 0x69, 0xD5, 0x0D, 0x01,
|
||||
0x1F, 0xA5, 0x89, 0xF2, 0x2F, 0xE0, 0xAE, 0xCD, 0xBD, 0x1E,
|
||||
0xFD, 0x64, 0x33, 0xCB, 0x4C, 0x61, 0x7F, 0x3E, 0x1D, 0x87,
|
||||
0xD4, 0xD4, 0x97, 0x75, 0xE8, 0x22, 0xAD, 0x20, 0xCF, 0x61,
|
||||
0x6B, 0xDB, 0xC6, 0x61, 0x0F, 0x52, 0x11, 0x18, 0xBA, 0x61,
|
||||
0x74, 0xF2, 0x19, 0x35, 0x22, 0xAD, 0xB4, 0x1A, 0xD8, 0xA5,
|
||||
0x31, 0x28, 0x34, 0xAA, 0x22, 0x86, 0x30, 0x94, 0x7D, 0x29,
|
||||
0x48, 0x08, 0x8B, 0x0A, 0xC4, 0xD6, 0x04, 0xBD, 0x8F, 0x60,
|
||||
0x02, 0x96, 0x23, 0x9E, 0x51, 0x85, 0x6C, 0x1C, 0xA5, 0x5A,
|
||||
0xCD, 0xFD, 0x9E, 0x2D, 0x4F, 0x6F, 0xDC, 0x22, 0x17, 0x62,
|
||||
0x3D, 0x27, 0x29, 0x3C, 0xB4, 0x02, 0xF8, 0xB1, 0x59, 0x2A,
|
||||
0xDB, 0xCE, 0x8B, 0xB5, 0x7A, 0xBE, 0x00, 0x11, 0xEE, 0x3B,
|
||||
0x97, 0x36, 0x01, 0x00, 0x00};
|
||||
@ -1,98 +0,0 @@
|
||||
// filename: style.css.gz.h
|
||||
#define style_css_gz_len 948
|
||||
const char style_css_gz[] = {
|
||||
0x1F, 0x8B, 0x08, 0x00, 0xB2, 0x41, 0xD3, 0x60, 0x02, 0xFF,
|
||||
0xBD, 0x55, 0x4B, 0x6F, 0xDB, 0x38, 0x10, 0xBE, 0x1B, 0xF0,
|
||||
0x7F, 0x18, 0xB4, 0x58, 0x20, 0xEE, 0x5A, 0xAE, 0xF2, 0xD8,
|
||||
0x2C, 0xA0, 0x9C, 0x82, 0xB4, 0xDD, 0x1C, 0xB6, 0x28, 0xB0,
|
||||
0xC9, 0x61, 0xAF, 0x14, 0x35, 0xB2, 0x88, 0x50, 0xA2, 0x40,
|
||||
0x52, 0xB1, 0xDD, 0x22, 0xFF, 0x7D, 0x87, 0xA4, 0x24, 0xEB,
|
||||
0xE1, 0x4D, 0x17, 0x0B, 0xB4, 0xF0, 0x45, 0x24, 0xE7, 0xF5,
|
||||
0x7D, 0xF3, 0xCD, 0xB8, 0xB0, 0xA5, 0x84, 0x6F, 0xCB, 0x05,
|
||||
0x40, 0xAE, 0x2A, 0x1B, 0x19, 0xF1, 0x15, 0x13, 0x38, 0x8F,
|
||||
0xEB, 0xFD, 0x4D, 0x7F, 0x97, 0xB3, 0x52, 0xC8, 0x43, 0x02,
|
||||
0x86, 0x55, 0x26, 0x32, 0xA8, 0x45, 0xBE, 0x86, 0x5B, 0x2D,
|
||||
0x98, 0x5C, 0xC3, 0x3D, 0xCA, 0x67, 0xB4, 0x82, 0x33, 0x6F,
|
||||
0x9D, 0x32, 0xFE, 0xB4, 0xD5, 0xAA, 0xA9, 0xB2, 0x88, 0x2B,
|
||||
0xA9, 0x74, 0x02, 0x6F, 0xD3, 0x4B, 0xF7, 0xA3, 0xD7, 0x97,
|
||||
0xE5, 0x62, 0xB9, 0xD8, 0x58, 0x55, 0xA7, 0x4C, 0x87, 0x7C,
|
||||
0x35, 0xCB, 0x32, 0x51, 0x6D, 0x29, 0x1B, 0x96, 0xFF, 0xE6,
|
||||
0x7E, 0x9E, 0xBB, 0xDF, 0x8D, 0xF3, 0x05, 0x68, 0x2F, 0x77,
|
||||
0x85, 0xB0, 0x78, 0x33, 0xA9, 0x78, 0x1F, 0x49, 0xA6, 0xB7,
|
||||
0xE1, 0xDA, 0xE2, 0xDE, 0x46, 0x4C, 0x8A, 0x6D, 0x95, 0x00,
|
||||
0xC7, 0xCA, 0xA2, 0xEE, 0xF3, 0x73, 0xF2, 0xD0, 0x4A, 0x9E,
|
||||
0x2C, 0xC0, 0x5B, 0xD4, 0x6B, 0x90, 0x62, 0xCE, 0xC7, 0x75,
|
||||
0xCB, 0x87, 0x14, 0x15, 0x46, 0x05, 0x8A, 0x6D, 0x61, 0x13,
|
||||
0xB8, 0x08, 0x57, 0x68, 0x29, 0x43, 0x64, 0x6A, 0xC6, 0x43,
|
||||
0x30, 0x6F, 0xEA, 0x83, 0x2D, 0x17, 0xA9, 0xCA, 0x0E, 0x21,
|
||||
0x5A, 0x49, 0xE5, 0x09, 0x2A, 0x28, 0x06, 0xD6, 0x58, 0x15,
|
||||
0xF0, 0x2A, 0x9D, 0xA1, 0xF6, 0x1E, 0x60, 0x94, 0x14, 0x19,
|
||||
0xA4, 0x92, 0x28, 0x18, 0xBC, 0x45, 0x9A, 0x65, 0xA2, 0x31,
|
||||
0x09, 0x5C, 0x1E, 0x43, 0x2E, 0x17, 0xEF, 0xDF, 0xC1, 0x63,
|
||||
0x81, 0x60, 0x76, 0xC2, 0xF2, 0x02, 0x22, 0xB0, 0x74, 0x48,
|
||||
0xD5, 0x1E, 0x98, 0xE7, 0xCE, 0x1F, 0x0D, 0x45, 0x43, 0x0D,
|
||||
0xEF, 0xDE, 0x13, 0xE6, 0xD6, 0x2E, 0x40, 0x56, 0x46, 0x58,
|
||||
0xA1, 0xA8, 0x0E, 0x8D, 0x92, 0x59, 0xF1, 0x1C, 0x18, 0xCB,
|
||||
0x84, 0xA9, 0x25, 0xA3, 0x16, 0x8B, 0xCA, 0x23, 0x4C, 0xA5,
|
||||
0x6A, 0xEB, 0xD8, 0x89, 0xCC, 0x16, 0x09, 0x5C, 0x77, 0x82,
|
||||
0xE8, 0xB0, 0x5F, 0x5E, 0x1D, 0x61, 0x52, 0x3D, 0xF7, 0x94,
|
||||
0x0E, 0x32, 0xCC, 0x59, 0x23, 0x2D, 0xDC, 0x3F, 0x7E, 0xFE,
|
||||
0x13, 0x78, 0x81, 0xFC, 0xC9, 0x55, 0x35, 0xAC, 0x41, 0x54,
|
||||
0x75, 0x63, 0x43, 0x25, 0xCA, 0xF1, 0x65, 0x29, 0x65, 0x3C,
|
||||
0xCC, 0x13, 0x8F, 0x92, 0xC4, 0x83, 0x0C, 0x8F, 0x53, 0x54,
|
||||
0xE1, 0x7B, 0x82, 0x8A, 0xA5, 0x44, 0x64, 0xD3, 0xCA, 0x83,
|
||||
0x37, 0xDA, 0x38, 0xC1, 0xD4, 0x4A, 0xB4, 0x22, 0x20, 0x6D,
|
||||
0xA8, 0xBA, 0xCB, 0x22, 0x31, 0xB7, 0xDD, 0xB7, 0x3E, 0x26,
|
||||
0x74, 0xDC, 0x5B, 0xAB, 0xCA, 0xFE, 0x34, 0x57, 0x25, 0xE7,
|
||||
0xDC, 0x3F, 0x45, 0x3B, 0x4C, 0x9F, 0x84, 0x8D, 0xAC, 0xA6,
|
||||
0xC9, 0x68, 0x2B, 0xD8, 0x5C, 0x99, 0x90, 0x68, 0x76, 0x17,
|
||||
0x14, 0x18, 0xEA, 0x4E, 0x52, 0xCC, 0x95, 0xC6, 0xD7, 0xCB,
|
||||
0x27, 0xFD, 0x91, 0x7A, 0x13, 0x78, 0xF3, 0x66, 0xC4, 0xCA,
|
||||
0x45, 0x27, 0xC6, 0x96, 0xB3, 0xFE, 0x1C, 0x00, 0x5D, 0xB5,
|
||||
0xA7, 0x0E, 0x45, 0x7F, 0x9E, 0xE1, 0x38, 0x0E, 0xD2, 0xFF,
|
||||
0x00, 0xE2, 0x5B, 0x99, 0xF8, 0x2E, 0x63, 0x06, 0xBF, 0xC2,
|
||||
0xA8, 0x21, 0x27, 0x38, 0x8B, 0xAF, 0x6E, 0x6F, 0xAF, 0x3F,
|
||||
0x8C, 0xBD, 0x73, 0xC5, 0x1B, 0x33, 0xF3, 0x55, 0xFB, 0xC8,
|
||||
0x14, 0x2C, 0x53, 0x3B, 0x37, 0x2C, 0xB1, 0x9F, 0x8E, 0x93,
|
||||
0xDE, 0xB3, 0xDC, 0x23, 0x52, 0x47, 0x90, 0xE8, 0x9A, 0x98,
|
||||
0xF0, 0x9F, 0xA4, 0x7A, 0xFC, 0xFB, 0xCC, 0x71, 0xB6, 0x0A,
|
||||
0xD0, 0x4B, 0xF3, 0x5D, 0x9B, 0xD7, 0xDF, 0x5F, 0xBC, 0x3E,
|
||||
0xFF, 0x72, 0x68, 0xA9, 0x9A, 0x50, 0x8A, 0x19, 0x8A, 0x74,
|
||||
0x13, 0xE6, 0xF2, 0xDB, 0xA9, 0xB9, 0xEE, 0xC7, 0x68, 0x64,
|
||||
0x3B, 0x42, 0x32, 0x71, 0xF9, 0x2D, 0xFE, 0x65, 0xB8, 0x0C,
|
||||
0xA6, 0xC3, 0x21, 0xAC, 0x41, 0x99, 0x87, 0xF4, 0x54, 0xEB,
|
||||
0x16, 0x87, 0xDC, 0x76, 0xA4, 0xB0, 0xBA, 0x46, 0x46, 0xAF,
|
||||
0x9C, 0x76, 0x5B, 0xA5, 0x2A, 0xBC, 0x01, 0xA0, 0x28, 0x5F,
|
||||
0x9E, 0x51, 0xEB, 0xE1, 0x20, 0xDF, 0x3D, 0x3C, 0x80, 0xB1,
|
||||
0x07, 0x89, 0x01, 0x0E, 0xC0, 0xCC, 0x6F, 0x20, 0x43, 0x57,
|
||||
0x97, 0x8B, 0xF2, 0xA9, 0x91, 0x32, 0xF2, 0x77, 0xAD, 0xD3,
|
||||
0x68, 0x65, 0x38, 0x8B, 0x87, 0x1A, 0xB9, 0xC8, 0x05, 0x91,
|
||||
0x15, 0x9E, 0x5A, 0xBB, 0x53, 0xD4, 0x38, 0x73, 0x8F, 0x02,
|
||||
0x02, 0x87, 0x5C, 0xE9, 0xAA, 0x63, 0x77, 0x28, 0x33, 0x12,
|
||||
0x58, 0x76, 0xE9, 0x7E, 0xDE, 0xE3, 0x0F, 0x8D, 0x87, 0xC1,
|
||||
0x63, 0x6B, 0xAD, 0x1A, 0xEB, 0x96, 0x5B, 0x87, 0xD8, 0xF5,
|
||||
0x0C, 0x4B, 0xF5, 0x8C, 0xDD, 0x43, 0x67, 0xD6, 0x2F, 0xA6,
|
||||
0xCD, 0xEF, 0xA1, 0x5C, 0xB4, 0xA1, 0xED, 0x35, 0xD3, 0x58,
|
||||
0xF1, 0x03, 0x9C, 0x51, 0x6F, 0xA0, 0x54, 0x8D, 0xC1, 0x88,
|
||||
0xDC, 0x35, 0x60, 0x9E, 0x23, 0xB7, 0x06, 0x54, 0x05, 0x85,
|
||||
0xBB, 0x58, 0xB5, 0x91, 0x4E, 0x4E, 0xD5, 0x85, 0xF1, 0x41,
|
||||
0xE3, 0xCD, 0x05, 0x18, 0xA4, 0x11, 0xCF, 0xCC, 0x60, 0xC2,
|
||||
0xFA, 0x10, 0x6D, 0x84, 0xA1, 0x67, 0x5B, 0x97, 0x8F, 0xE0,
|
||||
0xDA, 0x1E, 0x64, 0xF7, 0x79, 0x5E, 0xC6, 0xB4, 0xF5, 0x49,
|
||||
0x88, 0x38, 0xDE, 0xBA, 0xE7, 0x7D, 0xAF, 0x0E, 0x60, 0x0A,
|
||||
0xB5, 0xF3, 0xA9, 0x07, 0x98, 0x5C, 0x90, 0x97, 0xA9, 0xB6,
|
||||
0x0A, 0x56, 0x65, 0x12, 0xE1, 0x8C, 0xAC, 0x7A, 0x70, 0x70,
|
||||
0x76, 0x57, 0x68, 0x55, 0xE2, 0x1A, 0xBE, 0xD4, 0xA8, 0xD9,
|
||||
0x1A, 0x1E, 0x58, 0xCE, 0xB4, 0x58, 0xC3, 0xC7, 0x6C, 0x8B,
|
||||
0x2B, 0x20, 0x0F, 0x1A, 0x31, 0xF5, 0x95, 0xEC, 0x3E, 0x09,
|
||||
0x4D, 0xAA, 0xDE, 0xAF, 0x68, 0x07, 0x83, 0x9A, 0x4A, 0x4D,
|
||||
0x2A, 0xF5, 0xB4, 0x9A, 0x97, 0x9E, 0x74, 0x69, 0xC2, 0x39,
|
||||
0xB2, 0x45, 0x53, 0xA6, 0xDF, 0xD3, 0xF2, 0x29, 0x29, 0xBB,
|
||||
0xF8, 0xFF, 0x41, 0xC4, 0x7E, 0x97, 0x76, 0x4D, 0x67, 0x60,
|
||||
0x82, 0x52, 0xF9, 0x84, 0x80, 0x53, 0xEA, 0x3E, 0x7A, 0x8E,
|
||||
0x4C, 0x5F, 0x53, 0x78, 0x37, 0x31, 0x7E, 0x75, 0xC0, 0x47,
|
||||
0x89, 0x25, 0xAD, 0xFB, 0x53, 0xD2, 0x6E, 0xB7, 0x5F, 0x2B,
|
||||
0x6D, 0xAC, 0xE6, 0xDA, 0x9E, 0xFE, 0xD5, 0x39, 0xD3, 0x3B,
|
||||
0x7F, 0x37, 0x96, 0xD4, 0xCB, 0x8C, 0x5F, 0xD7, 0x1B, 0x7F,
|
||||
0x33, 0xE4, 0xF6, 0xE7, 0xB0, 0xF1, 0xC3, 0x20, 0xFE, 0x03,
|
||||
0xF9, 0xD5, 0xDB, 0xFC, 0xD4, 0x0A, 0x00, 0x00};
|
||||
38
create_gz_c_arr.py
Normal file
38
create_gz_c_arr.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os, gzip
|
||||
# https://www.mischianti.org/2020/10/26/web-server-with-esp8266-and-esp32-byte-array-gzipped-pages-and-spiffs-2/
|
||||
|
||||
def convert_to_gzip(src, out, f):
|
||||
input_file = f'{src}{f}'
|
||||
output_file = f'{out}{f}.gz.h'
|
||||
output_charp = f'{f.replace(".", "_")}_gz'
|
||||
|
||||
top = ''
|
||||
with open(input_file, 'rb') as f_in:
|
||||
gz = gzip.compress(f_in.read())
|
||||
gzlen = len(gz)
|
||||
|
||||
top += f'// filename: {f}.gz.h\n'
|
||||
top += f'#define {output_charp}_len {gzlen}\n'
|
||||
top += f'const char {output_charp}[] = '
|
||||
top += '{'
|
||||
|
||||
with open(output_file, 'wb') as f_out:
|
||||
for i, b in enumerate(gz):
|
||||
if not i%10:
|
||||
top += '\n '
|
||||
top += f'0x{b:02X}, '
|
||||
top = top[:-2]
|
||||
top += '};'
|
||||
f_out.write(top.encode(encoding='utf-8'))
|
||||
|
||||
|
||||
src='data/'
|
||||
out='compress/'
|
||||
|
||||
if not 'compress' in os.listdir():
|
||||
os.mkdir('compress')
|
||||
|
||||
for f in os.listdir(src):
|
||||
convert_to_gzip(src, out, f)
|
||||
@ -1,35 +1,15 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os, gzip
|
||||
# https://www.mischianti.org/2020/10/26/web-server-with-esp8266-and-esp32-byte-array-gzipped-pages-and-spiffs-2/
|
||||
# https://stackoverflow.com/questions/8156707/gzip-a-file-in-python
|
||||
|
||||
def convert_to_gzip(src, out, f):
|
||||
input_file = f'{src}{f}'
|
||||
output_file = f'{out}{f}.gz.h'
|
||||
output_charp = f'{f.replace(".", "_")}_gz'
|
||||
src_dir='data'
|
||||
out_dir='data_gz'
|
||||
|
||||
top = ''
|
||||
with open(input_file, 'rb') as f_in:
|
||||
gz = gzip.compress(f_in.read())
|
||||
gzlen = len(gz)
|
||||
if not 'data_gz' in os.listdir():
|
||||
os.mkdir('data_gz')
|
||||
|
||||
top += f'// filename: {f}.gz.h\n'
|
||||
top += f'#define {output_charp}_len {gzlen}\n'
|
||||
top += f'const char {output_charp}[] = '
|
||||
top += '{'
|
||||
|
||||
with open(output_file, 'wb') as f_out:
|
||||
for i, b in enumerate(gz):
|
||||
if not i%10:
|
||||
top += '\n '
|
||||
top += f'0x{b:02X}, '
|
||||
top = top[:-2]
|
||||
top += '};'
|
||||
f_out.write(top.encode(encoding='utf-8'))
|
||||
|
||||
|
||||
src='data/'
|
||||
out='compress/'
|
||||
|
||||
for f in os.listdir(src):
|
||||
convert_to_gzip(src, out, f)
|
||||
for f in os.listdir(src_dir):
|
||||
with open(f'{src_dir}/{f}', 'rb') as f_in:
|
||||
with gzip.open(f'{out_dir}/{f}.gz', 'wb') as f_out:
|
||||
f_out.writelines(f_in)
|
||||
@ -1,38 +1,70 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>ESP8266 Treppenlicht</title>
|
||||
<!-- main style sheet -->
|
||||
<link href="/favicon.png" rel="icon" type="image/png" sizes="10x10">
|
||||
<link href="/style.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="kopfzeile"
|
||||
style="text-align: center;">
|
||||
<b>Treppenlicht</b>
|
||||
</div>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<div class="ueberschrift">
|
||||
<center>Helligkeit</center>
|
||||
<div class="slider">
|
||||
<label id="label_pwm">
|
||||
</label>
|
||||
<input type="range" class="testregler" min="0" max="100">
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="ueberschrift">
|
||||
<center>Laufgeschwindigkeit</center>
|
||||
<div class="slider">
|
||||
<label id="label_geschwindigkeit">
|
||||
</label>
|
||||
<input type="range" class="testregler" min="0" max="100">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<head>
|
||||
<title>ESP8266 Treppenlicht</title>
|
||||
<link href="/favicon.png" rel="icon" type="image/png" sizes="10x10">
|
||||
<link href="/style.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<script src="/input.js"></script>
|
||||
<body>
|
||||
<div class="topbar">Treppenlicht</div>
|
||||
|
||||
</html>
|
||||
<div class="param_block">
|
||||
<input type="button" class="control" data-action="s_oben" value="sensor_oben">
|
||||
<input type="button" class="control" data-action="s_unten" value="sensor_unten">
|
||||
<!-- <input type="button" class="control" data-action="on_off" value="on_off"> -->
|
||||
</div>
|
||||
|
||||
<div class="param_block">
|
||||
Active Brightness: <output id="out_act_pwm" class="val_range">50</output> %
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="range_act_pwm" data-output="out_act_pwm" min="0" max="100" value="50">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="param_block">
|
||||
Idle Brightness Maximum: <output id="out_idl_pwm" class="val_range">50</output> %
|
||||
<label id="note">[100% == Active Brightness]</label>
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="range_idl_pwm" data-output="out_idl_pwm" min="0" max="100" value="50">
|
||||
</div>
|
||||
<label id="note">idle brightness gets controlled via LDR measurments</label>
|
||||
</div>
|
||||
|
||||
<div class="param_block">
|
||||
Time per stair [ms]: <output id="out_tim_sta" class="val_range">300</output> ms
|
||||
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="range_tim_sta" data-output="out_tim_sta" min="0" max="5000" value="300">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="param_block">
|
||||
Time LDR [ms]: <output id="out_tim_ldr" class="val_range">500</output> ms
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="range_tim_ldr" data-output="out_tim_ldr" min="0" max="5000" value="500">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="param_block">
|
||||
LDR Schwelle [lx]: <output id="out_ldr_shw" class="val_range">50</output> lx
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="range_ldr_shw" data-output="out_ldr_shw" min="0" max="1000" value="50">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="terminal">
|
||||
<input type="button" id="clear_term" value="clear">
|
||||
<input type="checkbox" id="scroll" name="scroll" value="scroll" checked>
|
||||
<label for="scroll"> autoscroll </label>
|
||||
<textarea id="term">waiting for log messages ... </textarea>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
<script src="/input.js"></script>
|
||||
|
||||
</html>
|
||||
126
data/input.js
126
data/input.js
@ -1,8 +1,120 @@
|
||||
var slider = document.getElementById("range1");
|
||||
var output = document.getElementById("l_pwm");
|
||||
output.innerHTML = slider.value; // Display the default slider value
|
||||
let rangeValues = {};
|
||||
let xhrUpd = new XMLHttpRequest();
|
||||
|
||||
xhrUpd.onreadystatechange = function () {
|
||||
if (xhrUpd.readyState == 4) {
|
||||
if (xhrUpd.status == 200) {
|
||||
console.log("xhrUpd: ", xhrUpd.responseText);
|
||||
}
|
||||
else {
|
||||
console.log("xhrUpd: status=", xhrUpd.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reloadRangeValues() {
|
||||
let url = "/update";
|
||||
// if there are scheduled updates, send them
|
||||
if (Object.keys(rangeValues).length > 0) {
|
||||
let params = [];
|
||||
for (let p in rangeValues)
|
||||
params.push(encodeURIComponent(p) + "=" + encodeURIComponent(rangeValues[p]));
|
||||
params = params.join("&");
|
||||
|
||||
xhrUpd.open("POST", url, true);
|
||||
xhrUpd.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
xhrUpd.send(params);
|
||||
|
||||
rangeValues = {};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function reloadTerminal() {
|
||||
const terminal = document.querySelector("#term");
|
||||
const autoscroll = document.querySelector("#scroll");
|
||||
|
||||
fetch('/terminal', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: ''
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
if(data.length > 0) {
|
||||
terminal.innerHTML += data;
|
||||
if (autoscroll.checked)
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
}
|
||||
})
|
||||
.catch(error => console.log('Error:', error));
|
||||
};
|
||||
|
||||
function updateParameters() {
|
||||
fetch('/parameters', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: ''
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(json_str => {
|
||||
const active_pwm = Math.round(json_str.active_pwm / 4095 * 100);
|
||||
document.querySelector('#range_act_pwm').value = active_pwm;
|
||||
document.querySelector('#out_act_pwm').value = active_pwm;
|
||||
|
||||
const idle_pwm_max = Math.round(json_str.idle_pwm_max / json_str.active_pwm * 100);
|
||||
document.querySelector('#range_idl_pwm').value = idle_pwm_max;
|
||||
document.querySelector('#out_idl_pwm').value = idle_pwm_max;
|
||||
|
||||
document.querySelector('#range_tim_sta').value = json_str.time_per_stair;
|
||||
document.querySelector('#out_tim_sta').value = json_str.time_per_stair;
|
||||
|
||||
document.querySelector('#range_tim_ldr').value = json_str.time_ldr;
|
||||
document.querySelector('#out_tim_ldr').value = json_str.time_ldr;
|
||||
|
||||
document.querySelector('#range_ldr_shw').value = json_str.ldr_schwelle;
|
||||
document.querySelector('#out_ldr_shw').value = json_str.ldr_schwelle;
|
||||
|
||||
})
|
||||
.catch(error => console.log('Error:', error));
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setInterval(reloadTerminal, 1000);
|
||||
setInterval(reloadRangeValues, 1000);
|
||||
|
||||
updateParameters();
|
||||
|
||||
// use data- attributes for action
|
||||
document.querySelectorAll('.control').forEach((button) => {
|
||||
button.onclick = () => {
|
||||
fetch('/action', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `control=${button.dataset.action}`
|
||||
})
|
||||
.then(response => console.log(response))
|
||||
.catch(error => console.log('Error:', error));
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('.regler').forEach((regler) => {
|
||||
regler.oninput = () => {
|
||||
document.querySelector(`#${regler.dataset.output}`).innerHTML = regler.value;
|
||||
rangeValues[regler.id] = regler.value;
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelector('#clear_term').onclick = () => {
|
||||
document.querySelector("#term").innerHTML = '';
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Update the current slider value (each time you drag the slider handle)
|
||||
slider.oninput = function() {
|
||||
output.innerHTML = this.value;
|
||||
}
|
||||
BIN
data/light.png
BIN
data/light.png
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
170
data/style.css
170
data/style.css
@ -1,38 +1,50 @@
|
||||
html {
|
||||
font-size: 16px;
|
||||
font-family: sans-serif, Arial, Helvetica;
|
||||
background-color: #d4d4d4;
|
||||
background-color: #ffffff;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
border-radius: 3;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
padding: 1em;
|
||||
background-color: #1f1f1f;
|
||||
|
||||
padding: 10px;
|
||||
background-color: #585858;
|
||||
color: white;
|
||||
font-size: x-large;
|
||||
font-size: xx-large;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.control {
|
||||
.param_block{
|
||||
padding: 1em;
|
||||
color: #000000;
|
||||
border: 1px solid darkred;
|
||||
font-size: x-large;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.ueberschrift{
|
||||
color: #ffffff;
|
||||
font-size: 50px;
|
||||
width: 40%;
|
||||
background-color: #5f5f5f;
|
||||
.val_range {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.testregler{
|
||||
-webkit-appearance: none;
|
||||
height: 20px;
|
||||
width: 98%;
|
||||
.regler {
|
||||
/* -webkit-appearance: none; */
|
||||
height: 50px;
|
||||
width: 100%;
|
||||
border-radius: 20px;
|
||||
outline: black;
|
||||
background-color: rgb(176, 188, 228);
|
||||
}
|
||||
.testregler::-webkit-slider-thumb{
|
||||
|
||||
#note {
|
||||
font-size: medium;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* .regler::-webkit-slider-thumb{
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 5%;
|
||||
@ -40,41 +52,22 @@ html {
|
||||
border-radius: 10px;
|
||||
background-color: rgb(107, 122, 192);
|
||||
cursor:pointer;
|
||||
}
|
||||
input[type=range]::-webkit-slider-thumb{
|
||||
} */
|
||||
/* input[type=range]::-webkit-slider-thumb{
|
||||
-webkit-appearance: none;
|
||||
border:none;
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
background:goldenrod;
|
||||
margin-top: -15px;
|
||||
border-radius: o!important;
|
||||
height: 30px;
|
||||
width: 4%;
|
||||
border-radius: 30px;
|
||||
} */
|
||||
|
||||
}
|
||||
|
||||
.kopfzeile{
|
||||
color: #1f1f1f;
|
||||
font-size: 50px;
|
||||
width: 100%;
|
||||
background-color: #8d8a8a;
|
||||
|
||||
}
|
||||
p, li {
|
||||
font-size: 16px;
|
||||
line-height: 2;
|
||||
letter-spacing: 1px;
|
||||
.slider {
|
||||
margin: 1%;
|
||||
}
|
||||
|
||||
|
||||
body {
|
||||
margin: 0 auto;
|
||||
border: none;
|
||||
border-radius: 3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* The switch - the box around the slider */
|
||||
/*-------------------------------------------------------*/
|
||||
/*Switch:
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
@ -82,83 +75,60 @@ body {
|
||||
height: 34px;
|
||||
}
|
||||
|
||||
/* Hide default HTML checkbox */
|
||||
Hide default HTML checkbox
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
*/
|
||||
/* The slider */
|
||||
.slider {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/*.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 26px;
|
||||
width: 26px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}*/
|
||||
|
||||
input:checked + .slider {
|
||||
/*input:checked + .slider {
|
||||
background-color: #04AA6D;
|
||||
}
|
||||
|
||||
input:focus + .slider {
|
||||
box-shadow: 0 0 1px #04AA6D;
|
||||
}
|
||||
|
||||
}*/
|
||||
/*
|
||||
input:checked + .slider:before {
|
||||
-webkit-transform: translateX(26px);
|
||||
-ms-transform: translateX(26px);
|
||||
transform: translateX(26px);
|
||||
}
|
||||
/* Rounded sliders */
|
||||
.slider.round {
|
||||
border-radius: 34px;
|
||||
}
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
*/
|
||||
|
||||
.terminal {
|
||||
margin:5%;
|
||||
padding: 1%;
|
||||
width: 80%;
|
||||
border: 1px solid black;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
#term {
|
||||
font-size: large;
|
||||
width: 100%;
|
||||
height: 20em;
|
||||
}
|
||||
|
||||
/* The slider itself */
|
||||
.rangeslider {
|
||||
-webkit-appearance: none; /* Override default CSS styles */
|
||||
appearance: none;
|
||||
width: 50%; /* Full-width */
|
||||
height: 34px; /* Specified height */
|
||||
border-radius: 34px; /* range round corners */
|
||||
background: #d3d3d3; /* Grey background */
|
||||
outline: none; /* Remove outline */
|
||||
opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */
|
||||
-webkit-transition: .2s; /* 0.2 seconds transition on hover */
|
||||
transition: opacity .2s;
|
||||
#clear_term {
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
width: 100px;
|
||||
}
|
||||
/* Mouse-over effects */
|
||||
.rangeslider:hover {
|
||||
opacity: 1; /* Fully shown on mouse-over */
|
||||
|
||||
input:invalid+span:after {
|
||||
content: '✖';
|
||||
padding-left: 5px;
|
||||
}
|
||||
/* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */
|
||||
.rangeslider::-webkit-slider-thumb {
|
||||
-webkit-appearance: none; /* Override default look */
|
||||
appearance: none;
|
||||
width: 26px; /* Set a specific slider handle width */
|
||||
height: 26px; /* Slider handle height */
|
||||
border-radius: 50%; /* Round Element */
|
||||
background: #04AA6D; /* Green background */
|
||||
cursor: pointer; /* Cursor on hover */
|
||||
}
|
||||
.rangeslider::-moz-range-thumb {
|
||||
width: 26px; /* Set a specific slider handle width */
|
||||
height: 26px; /* Slider handle height */
|
||||
background: #04AA6D; /* Green background */
|
||||
cursor: pointer; /* Cursor on hover */
|
||||
|
||||
input:valid+span:after {
|
||||
content: '✓';
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
|
||||
88
doku.md
88
doku.md
@ -52,4 +52,90 @@ if(p.endsWith(".gzip")) {
|
||||
}
|
||||
else
|
||||
server.streamFile(f, mime::getContentType(SRH::_path), requestMethod);
|
||||
```
|
||||
```
|
||||
|
||||
### HW issues
|
||||
- GPIO2 used as input -> must be high during startup
|
||||
- PCB Solution: cut trace to GPIO2, solder bridge to GPIO16
|
||||
- -> disadvantage: GPIO16 is not interrupt capable
|
||||
|
||||
|
||||
### FSM 2 - to do
|
||||
- stairway light switches off after timeout
|
||||
- switches concurrently on again if sensor is still high
|
||||
- desired behavior? Defective Sensor would cause continuos animation
|
||||
- edge detection / interrupts as solution ?
|
||||
|
||||
|
||||
### 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
|
||||
TODO:
|
||||
- check dir for files automatic
|
||||
- move handleNotFound to httpserver.h
|
||||
- maybe compress files ?
|
||||
|
||||
|
||||
### LED Flickering issue
|
||||
https://github.com/NachtRaveVL/PCA9685-Arduino/issues/15
|
||||
PlatformIO Library veraltet !!
|
||||
|
||||
|
||||
### TIMER in OTA unterbrechen !!!!!
|
||||
|
||||
|
||||
|
||||
### further improvments
|
||||
with streamFile gzip encoded Files can be sent
|
||||
this reduces space on fs !
|
||||
new easier script needed to just convert to .gz
|
||||
maybe measure timings on ESP
|
||||
|
||||
__=> use serveStatic because way simpler !__
|
||||
__=> serverStatic("/") works wonders__
|
||||
|
||||
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARHRRHRGH
|
||||
Two implementations of FSM are not that good,
|
||||
linker puts them together ?!?
|
||||
:):):):):):):)
|
||||
=> maybe investigate for doc
|
||||
|
||||
### TODO Treppe
|
||||
- dynamic lighting with ldr
|
||||
- http control over active pwm ... => set_active_pwm()
|
||||
-> is implemntiert, kann mit % oder abs eingestellt werden
|
||||
- testing if dimming crashes when two animations
|
||||
-> ldr does not interrupt animation, animation get's finished and stairs fade out -> FSM works without collisions
|
||||
- interrupt to pending from sensors
|
||||
-> rising edge trigger implemented, via pending input
|
||||
- settings struct
|
||||
-> implemented with EEPROM
|
||||
-> adapted to only change on ruhezustand
|
||||
- script for gdb on windows
|
||||
-> [implemented](start_xtensa_gdb_stub.cmd)
|
||||
- welcome animation ?
|
||||
-> wird hochgedimmt beim einschalten von 0
|
||||
- on/off switch http
|
||||
- use logging to serial http monitor with httpserver.logt()
|
||||
-> is used for some status updates
|
||||
|
||||
- behavior when someone enters stairway from opposite direction while animation is running?
|
||||
-> currently ignored, second persons walks in darkness
|
||||
-> animation from both sides?
|
||||
-> problem: person 1 leaving stairway might pass the sensor right after person 2 -> person 1 leaving not detected
|
||||
|
||||
- behavior when someone enters stairway from opposite direction after animation finished but person 1 is still on stairway?
|
||||
-> currently stairs fade off from direction 1
|
||||
-> additional wait-state between "warten hoch/runter" and "abdimmen hoch/runter" after sensor detected person?
|
||||
|
||||
|
||||
- active brightness can be lower than idle in the moment
|
||||
- change idle to precentage of active !!
|
||||
|
||||
- Webpage needs to load settings from eeprom !!
|
||||
@ -1,48 +0,0 @@
|
||||
#ifndef __HTTPSERVER_H
|
||||
#define __HTTPSERVER_H
|
||||
|
||||
#include "filesys.h"
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
|
||||
class HTTPServer : public ESP8266WebServer {
|
||||
private:
|
||||
const char* rootDir;
|
||||
|
||||
bool addRootFileHandler();
|
||||
bool formatFS() {
|
||||
return format_fs();
|
||||
}
|
||||
void listRoot() {
|
||||
ls(rootDir);
|
||||
}
|
||||
|
||||
public:
|
||||
HTTPServer(const int _port, const char* _rootDir) :
|
||||
ESP8266WebServer(_port), rootDir(_rootDir)
|
||||
{ }
|
||||
~HTTPServer()
|
||||
{
|
||||
Serial.printf("[HTTPServer] shut down ...\n\r");
|
||||
}
|
||||
|
||||
bool start() {
|
||||
if(!mount_fs())
|
||||
return false;
|
||||
Serial.printf("[HTTPServer] LittleFS mounted !\n\r");
|
||||
|
||||
Serial.printf("[HTTPServer] root:\n\r");
|
||||
this->listRoot();
|
||||
Serial.printf("\n\r");
|
||||
|
||||
if( this->addRootFileHandler() ){
|
||||
this->begin();
|
||||
Serial.printf("[HTTPServer] Server active on Port 80 !\n\r");
|
||||
return true;
|
||||
}
|
||||
Serial.printf("[HTTPServer] Not starting Server, something went wrong !\n\r");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __HTTPSERVER_H
|
||||
51
include/ota.h
Normal file
51
include/ota.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef __OTA_H
|
||||
#define __OTA_H
|
||||
|
||||
#include <ArduinoOTA.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiUdp.h>
|
||||
|
||||
void ota_setup() {
|
||||
ArduinoOTA.setPort(8266);
|
||||
ArduinoOTA.setHostname("ESP_Treppenlicht");
|
||||
ArduinoOTA.setPassword("admin");
|
||||
// Password can be set with it's md5 value as well
|
||||
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
|
||||
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
|
||||
|
||||
ArduinoOTA.onStart([]() {
|
||||
String type;
|
||||
if (ArduinoOTA.getCommand() == U_FLASH) {
|
||||
type = "sketch";
|
||||
} else { // U_FS
|
||||
type = "filesystem";
|
||||
}
|
||||
|
||||
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
|
||||
Serial.println("Start updating " + type);
|
||||
});
|
||||
ArduinoOTA.onEnd([]() {
|
||||
Serial.println("\nEnd");
|
||||
});
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
|
||||
});
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
Serial.printf("Error[%u]: ", error);
|
||||
if (error == OTA_AUTH_ERROR) {
|
||||
Serial.println("Auth Failed");
|
||||
} else if (error == OTA_BEGIN_ERROR) {
|
||||
Serial.println("Begin Failed");
|
||||
} else if (error == OTA_CONNECT_ERROR) {
|
||||
Serial.println("Connect Failed");
|
||||
} else if (error == OTA_RECEIVE_ERROR) {
|
||||
Serial.println("Receive Failed");
|
||||
} else if (error == OTA_END_ERROR) {
|
||||
Serial.println("End Failed");
|
||||
}
|
||||
});
|
||||
ArduinoOTA.begin();
|
||||
|
||||
}
|
||||
|
||||
#endif // __OTA_H
|
||||
9
include/templ_wifi_credentials.h
Normal file
9
include/templ_wifi_credentials.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef __WIFI_CREDENTIALS_H
|
||||
#define __WIFI_CREDENTIALS_H
|
||||
|
||||
#ifndef STASSID
|
||||
#define STASSID "ssid"
|
||||
#define STAPSK "key"
|
||||
#endif
|
||||
|
||||
#endif // __WIFI_CREDENTIALS_H
|
||||
@ -1,14 +0,0 @@
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
Icon?
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# Generic:
|
||||
###############
|
||||
*.bak
|
||||
@ -1 +0,0 @@
|
||||
{"type": "library", "name": "PCA9685 16-Channel PWM Driver Module Library", "version": "1.2.9", "spec": {"owner": "ottowinter", "id": 2100, "name": "PCA9685 16-Channel PWM Driver Module Library", "requirements": null, "url": null}}
|
||||
@ -1,836 +0,0 @@
|
||||
/* Arduino Library for the PCA9685 16-Channel PWM Driver Module.
|
||||
Copyright (c) 2016 NachtRaveVL <nachtravevl@gmail.com>
|
||||
Copyright (C) 2012 Kasper Skårhøj <kasperskaarhoj@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Created by Kasper Skårhøj, August 3rd, 2012.
|
||||
Forked by Vitska, June 18th, 2016.
|
||||
Forked by NachtRaveVL, July 29th, 2016.
|
||||
|
||||
PCA9685-Arduino - Version 1.2.9
|
||||
*/
|
||||
|
||||
#include "PCA9685.h"
|
||||
|
||||
#define PCA9685_I2C_BASE_ADDRESS (byte)0x40
|
||||
|
||||
// Register addresses from data sheet
|
||||
#define PCA9685_MODE1_REG (byte)0x00
|
||||
#define PCA9685_MODE2_REG (byte)0x01
|
||||
#define PCA9685_SUBADR1_REG (byte)0x02
|
||||
#define PCA9685_SUBADR2_REG (byte)0x03
|
||||
#define PCA9685_SUBADR3_REG (byte)0x04
|
||||
#define PCA9685_ALLCALL_REG (byte)0x05
|
||||
#define PCA9685_LED0_REG (byte)0x06 // Start of LEDx regs, 4B per reg, 2B on phase, 2B off phase, little-endian
|
||||
#define PCA9685_PRESCALE_REG (byte)0xFE
|
||||
#define PCA9685_ALLLED_REG (byte)0xFA
|
||||
|
||||
// Mode1 register pin layout
|
||||
#define PCA9685_MODE_RESTART (byte)0x80
|
||||
#define PCA9685_MODE_EXTCLK (byte)0x40
|
||||
#define PCA9685_MODE_AUTOINC (byte)0x20
|
||||
#define PCA9685_MODE_SLEEP (byte)0x10
|
||||
#define PCA9685_MODE_SUBADR1 (byte)0x08
|
||||
#define PCA9685_MODE_SUBADR2 (byte)0x04
|
||||
#define PCA9685_MODE_SUBADR3 (byte)0x02
|
||||
#define PCA9685_MODE_ALLCALL (byte)0x01
|
||||
|
||||
#define PCA9685_SW_RESET (byte)0x06 // Sent to address 0x00 to reset all devices on Wire line
|
||||
#define PCA9685_PWM_FULL (uint16_t)0x01000 // Special value for full on/full off LEDx modes
|
||||
|
||||
// To balance the load out in a weaved fashion, we use this offset table to distribute
|
||||
// the load on the outputs in a more interleaving fashion than just a simple 16 offset
|
||||
// per channel. We can set the off cycle value to be lower than the on cycle, which will
|
||||
// put the high edge across the 0-4095 phase cycle range, which is supported by device.
|
||||
static uint16_t phaseDistTable[16] = { 0, 2048, 1024, 3072, 512, 3584, 1536, 2560, 256, 3840, 1280, 2304, 3328, 768, 2816, 1792 };
|
||||
|
||||
#ifndef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
PCA9685::PCA9685(TwoWire& i2cWire, PCA9685_PhaseBalancer phaseBalancer) {
|
||||
_i2cWire = &i2cWire;
|
||||
#else
|
||||
PCA9685::PCA9685(PCA9685_PhaseBalancer phaseBalancer) {
|
||||
#endif
|
||||
_i2cAddress = 0;
|
||||
_phaseBalancer = phaseBalancer;
|
||||
_isProxyAddresser = false;
|
||||
_lastI2CError = 0;
|
||||
}
|
||||
|
||||
void PCA9685::resetDevices() {
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::resetDevices");
|
||||
#endif
|
||||
|
||||
i2cWire_beginTransmission(0x00);
|
||||
i2cWire_write(PCA9685_SW_RESET);
|
||||
i2cWire_endTransmission();
|
||||
|
||||
delayMicroseconds(10);
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
checkForErrors();
|
||||
#endif
|
||||
}
|
||||
|
||||
void PCA9685::init(byte i2cAddress, byte mode) {
|
||||
if (_isProxyAddresser) return;
|
||||
|
||||
// I2C 7-bit address is B 1 A5 A4 A3 A2 A1 A0
|
||||
// RW bit added by Arduino core TWI library
|
||||
_i2cAddress = PCA9685_I2C_BASE_ADDRESS | (i2cAddress & 0x3F);
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("PCA9685::init i2cAddress: 0x");
|
||||
Serial.println(_i2cAddress, HEX);
|
||||
#endif
|
||||
|
||||
writeRegister(PCA9685_MODE1_REG, PCA9685_MODE_RESTART | PCA9685_MODE_AUTOINC);
|
||||
writeRegister(PCA9685_MODE2_REG, mode);
|
||||
}
|
||||
|
||||
#ifndef PCA9685_EXCLUDE_EXT_FUNC
|
||||
|
||||
void PCA9685::initAsProxyAddresser(byte i2cAddress) {
|
||||
_i2cAddress = i2cAddress & 0xFE;
|
||||
_isProxyAddresser = true;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("PCA9685::initAsProxyAddresser i2cAddress: 0x");
|
||||
Serial.println(_i2cAddress, HEX);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
byte PCA9685::getI2CAddress() {
|
||||
return _i2cAddress;
|
||||
}
|
||||
|
||||
PCA9685_PhaseBalancer PCA9685::getPhaseBalancer() {
|
||||
return _phaseBalancer;
|
||||
}
|
||||
|
||||
void PCA9685::setPWMFrequency(float pwmFrequency) {
|
||||
if (pwmFrequency < 0 || _isProxyAddresser) return;
|
||||
|
||||
// This equation comes from section 7.3.5 of the datasheet, but the rounding has been
|
||||
// removed because it isn't needed. Lowest freq is 23.84, highest is 1525.88.
|
||||
int preScalerVal = (25000000 / (4096 * pwmFrequency)) - 1;
|
||||
if (preScalerVal > 255) preScalerVal = 255;
|
||||
if (preScalerVal < 3) preScalerVal = 3;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("PCA9685::setPWMFrequency pwmFrequency: ");
|
||||
Serial.print(pwmFrequency);
|
||||
Serial.print(", preScalerVal: 0x");
|
||||
Serial.println(preScalerVal, HEX);
|
||||
#endif
|
||||
|
||||
// The PRE_SCALE register can only be set when the SLEEP bit of MODE1 register is set to logic 1.
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg = (mode1Reg & ~PCA9685_MODE_RESTART) | PCA9685_MODE_SLEEP));
|
||||
writeRegister(PCA9685_PRESCALE_REG, (byte)preScalerVal);
|
||||
|
||||
// It takes 500us max for the oscillator to be up and running once SLEEP bit has been set to logic 0.
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg = (mode1Reg & ~PCA9685_MODE_SLEEP) | PCA9685_MODE_RESTART));
|
||||
delayMicroseconds(500);
|
||||
}
|
||||
|
||||
void PCA9685::setChannelOn(int channel) {
|
||||
if (channel < 0 || channel > 15) return;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::setChannelOn");
|
||||
#endif
|
||||
|
||||
writeChannelBegin(channel);
|
||||
writeChannelPWM(PCA9685_PWM_FULL, 0); // time_on = FULL; time_off = 0;
|
||||
writeChannelEnd();
|
||||
}
|
||||
|
||||
void PCA9685::setChannelOff(int channel) {
|
||||
if (channel < 0 || channel > 15) return;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::setChannelOff");
|
||||
#endif
|
||||
|
||||
writeChannelBegin(channel);
|
||||
writeChannelPWM(0, PCA9685_PWM_FULL); // time_on = 0; time_off = FULL;
|
||||
writeChannelEnd();
|
||||
}
|
||||
|
||||
void PCA9685::setChannelPWM(int channel, uint16_t pwmAmount) {
|
||||
if (channel < 0 || channel > 15) return;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::setChannelPWM");
|
||||
#endif
|
||||
|
||||
writeChannelBegin(channel);
|
||||
|
||||
uint16_t phaseBegin, phaseEnd;
|
||||
getPhaseCycle(channel, pwmAmount, &phaseBegin, &phaseEnd);
|
||||
|
||||
writeChannelPWM(phaseBegin, phaseEnd);
|
||||
|
||||
writeChannelEnd();
|
||||
}
|
||||
|
||||
void PCA9685::setChannelsPWM(int begChannel, int numChannels, const uint16_t *pwmAmounts) {
|
||||
if (begChannel < 0 || begChannel > 15 || numChannels < 0) return;
|
||||
if (begChannel + numChannels > 16) numChannels -= (begChannel + numChannels) - 16;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("PCA9685::setChannelsPWM numChannels: ");
|
||||
Serial.println(numChannels);
|
||||
#endif
|
||||
|
||||
// In avr/libraries/Wire.h and avr/libraries/utility/twi.h, _BUFFER_LENGTH controls
|
||||
// how many channels can be written at once. Therefore, we loop around until all
|
||||
// channels have been written out into their registers.
|
||||
|
||||
while (numChannels > 0) {
|
||||
writeChannelBegin(begChannel);
|
||||
|
||||
int maxChannels = min(numChannels, (_BUFFER_LENGTH - 1) / 4);
|
||||
while (maxChannels-- > 0) {
|
||||
uint16_t phaseBegin, phaseEnd;
|
||||
getPhaseCycle(begChannel++, *pwmAmounts++, &phaseBegin, &phaseEnd);
|
||||
|
||||
writeChannelPWM(phaseBegin, phaseEnd);
|
||||
--numChannels;
|
||||
}
|
||||
|
||||
writeChannelEnd();
|
||||
if (_lastI2CError) return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PCA9685_EXCLUDE_EXT_FUNC
|
||||
|
||||
void PCA9685::setAllChannelsPWM(uint16_t pwmAmount) {
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::setAllChannelsPWM");
|
||||
#endif
|
||||
|
||||
writeChannelBegin(-1); // Special value for ALLLED registers
|
||||
|
||||
uint16_t phaseBegin, phaseEnd;
|
||||
getPhaseCycle(-1, pwmAmount, &phaseBegin, &phaseEnd);
|
||||
|
||||
writeChannelPWM(phaseBegin, phaseEnd);
|
||||
|
||||
writeChannelEnd();
|
||||
}
|
||||
|
||||
uint16_t PCA9685::getChannelPWM(int channel) {
|
||||
if (channel < 0 || channel > 15 || _isProxyAddresser) return 0;
|
||||
|
||||
byte regAddress = PCA9685_LED0_REG + (channel << 2);
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("PCA9685::getChannelPWM channel: ");
|
||||
Serial.print(channel);
|
||||
Serial.print(", regAddress: 0x");
|
||||
Serial.println(regAddress, HEX);
|
||||
#endif
|
||||
|
||||
i2cWire_beginTransmission(_i2cAddress);
|
||||
i2cWire_write(regAddress);
|
||||
if (i2cWire_endTransmission()) {
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
checkForErrors();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bytesRead = i2cWire_requestFrom((uint8_t)_i2cAddress, (uint8_t)4);
|
||||
if (bytesRead != 4) {
|
||||
while (bytesRead-- > 0)
|
||||
i2cWire_read();
|
||||
_lastI2CError = 4;
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
checkForErrors();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t phaseBegin = (uint16_t)i2cWire_read();
|
||||
phaseBegin |= (uint16_t)i2cWire_read() << 8;
|
||||
uint16_t phaseEnd = (uint16_t)i2cWire_read();
|
||||
phaseEnd |= (uint16_t)i2cWire_read() << 8;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(" PCA9685::getChannelPWM phaseBegin: ");
|
||||
Serial.print(phaseBegin);
|
||||
Serial.print(", phaseEnd: ");
|
||||
Serial.println(phaseEnd);
|
||||
#endif
|
||||
|
||||
// See datasheet section 7.3.3
|
||||
uint16_t retVal;
|
||||
if (phaseEnd >= PCA9685_PWM_FULL)
|
||||
// Full OFF
|
||||
// Figure 11 Example 4: full OFF takes precedence over full ON
|
||||
// See also remark after Table 7
|
||||
retVal = 0;
|
||||
else if (phaseBegin >= PCA9685_PWM_FULL)
|
||||
// Full ON
|
||||
// Figure 9 Example 3
|
||||
retVal = PCA9685_PWM_FULL;
|
||||
else if (phaseBegin <= phaseEnd)
|
||||
// start and finish in same cycle
|
||||
// Section 7.3.3 example 1
|
||||
retVal = phaseEnd - phaseBegin;
|
||||
else
|
||||
// span cycles
|
||||
// Section 7.3.3 example 2
|
||||
retVal = (phaseEnd + PCA9685_PWM_FULL) - phaseBegin;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(" PCA9685::getChannelPWM retVal: ");
|
||||
Serial.println(retVal);
|
||||
#endif
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void PCA9685::enableAllCallAddress(byte i2cAddress) {
|
||||
if (_isProxyAddresser) return;
|
||||
|
||||
i2cAddress &= 0xFE;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("PCA9685::enableAllCallAddress i2cAddress: 0x");
|
||||
Serial.println(i2cAddress, HEX);
|
||||
#endif
|
||||
|
||||
writeRegister(PCA9685_ALLCALL_REG, i2cAddress);
|
||||
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg |= PCA9685_MODE_ALLCALL));
|
||||
}
|
||||
|
||||
void PCA9685::enableSub1Address(byte i2cAddress) {
|
||||
if (_isProxyAddresser) return;
|
||||
|
||||
i2cAddress &= 0xFE;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("PCA9685::enableSub1Address i2cAddress: 0x");
|
||||
Serial.println(i2cAddress, HEX);
|
||||
#endif
|
||||
|
||||
writeRegister(PCA9685_SUBADR1_REG, i2cAddress);
|
||||
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg |= PCA9685_MODE_SUBADR1));
|
||||
}
|
||||
|
||||
void PCA9685::enableSub2Address(byte i2cAddress) {
|
||||
if (_isProxyAddresser) return;
|
||||
|
||||
i2cAddress &= 0xFE;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("PCA9685::enableSub2Address i2cAddress: 0x");
|
||||
Serial.println(i2cAddress, HEX);
|
||||
#endif
|
||||
|
||||
writeRegister(PCA9685_SUBADR2_REG, i2cAddress);
|
||||
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg |= PCA9685_MODE_SUBADR2));
|
||||
}
|
||||
|
||||
void PCA9685::enableSub3Address(byte i2cAddress) {
|
||||
if (_isProxyAddresser) return;
|
||||
|
||||
i2cAddress &= 0xFE;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("PCA9685::enableSub3Address i2cAddress: 0x");
|
||||
Serial.println(i2cAddress, HEX);
|
||||
#endif
|
||||
|
||||
writeRegister(PCA9685_SUBADR3_REG, i2cAddress);
|
||||
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg |= PCA9685_MODE_SUBADR3));
|
||||
}
|
||||
|
||||
void PCA9685::disableAllCallAddress() {
|
||||
if (_isProxyAddresser) return;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::disableAllCallAddress");
|
||||
#endif
|
||||
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg &= ~PCA9685_MODE_ALLCALL));
|
||||
}
|
||||
|
||||
void PCA9685::disableSub1Address() {
|
||||
if (_isProxyAddresser) return;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::disableSub1Address");
|
||||
#endif
|
||||
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg &= ~PCA9685_MODE_SUBADR1));
|
||||
}
|
||||
|
||||
void PCA9685::disableSub2Address() {
|
||||
if (_isProxyAddresser) return;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::disableSub2Address");
|
||||
#endif
|
||||
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg &= ~PCA9685_MODE_SUBADR2));
|
||||
}
|
||||
|
||||
void PCA9685::disableSub3Address() {
|
||||
if (_isProxyAddresser) return;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::disableSub3Address");
|
||||
#endif
|
||||
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg &= ~PCA9685_MODE_SUBADR3));
|
||||
}
|
||||
|
||||
void PCA9685::enableExtClockLine() {
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.println("PCA9685::enableExtClockLine");
|
||||
#endif
|
||||
|
||||
// The PRE_SCALE register can only be set when the SLEEP bit of MODE1 register is set to logic 1.
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg = (mode1Reg & ~PCA9685_MODE_RESTART) | PCA9685_MODE_SLEEP));
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg |= PCA9685_MODE_EXTCLK));
|
||||
|
||||
// It takes 500us max for the oscillator to be up and running once SLEEP bit has been set to logic 0.
|
||||
writeRegister(PCA9685_MODE1_REG, (mode1Reg = (mode1Reg & ~PCA9685_MODE_SLEEP) | PCA9685_MODE_RESTART));
|
||||
delayMicroseconds(500);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
byte PCA9685::getLastI2CError() {
|
||||
return _lastI2CError;
|
||||
}
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
|
||||
static const char *textForI2CError(byte errorCode) {
|
||||
switch (errorCode) {
|
||||
case 0:
|
||||
return "Success";
|
||||
case 1:
|
||||
return "Data too long to fit in transmit buffer";
|
||||
case 2:
|
||||
return "Received NACK on transmit of address";
|
||||
case 3:
|
||||
return "Received NACK on transmit of data";
|
||||
default:
|
||||
return "Other error";
|
||||
}
|
||||
}
|
||||
|
||||
void PCA9685::checkForErrors() {
|
||||
if (_lastI2CError) {
|
||||
Serial.print(" PCA9685::checkErrors lastI2CError: ");
|
||||
Serial.print(_lastI2CError);
|
||||
Serial.print(": ");
|
||||
Serial.println(textForI2CError(getLastI2CError()));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void PCA9685::getPhaseCycle(int channel, uint16_t pwmAmount, uint16_t *phaseBegin, uint16_t *phaseEnd) {
|
||||
// Set delay
|
||||
if (channel < 0) {
|
||||
// All channels
|
||||
*phaseBegin = 0;
|
||||
}
|
||||
else if (_phaseBalancer == PCA9685_PhaseBalancer_Linear) {
|
||||
// Distribute high phase area over entire phase range to balance load.
|
||||
*phaseBegin = channel * (4096 / 16);
|
||||
}
|
||||
else if (_phaseBalancer == PCA9685_PhaseBalancer_Weaved) {
|
||||
// Distribute high phase area over entire phase range to balance load.
|
||||
*phaseBegin = phaseDistTable[channel];
|
||||
}
|
||||
else {
|
||||
*phaseBegin = 0;
|
||||
}
|
||||
|
||||
// See datasheet section 7.3.3
|
||||
if (pwmAmount == 0) {
|
||||
// Full OFF => time_off[12] = 1;
|
||||
*phaseEnd = PCA9685_PWM_FULL;
|
||||
}
|
||||
else if (pwmAmount >= PCA9685_PWM_FULL) {
|
||||
// Full ON => time_on[12] = 1; time_off = ignored;
|
||||
*phaseBegin |= PCA9685_PWM_FULL;
|
||||
*phaseEnd = 0;
|
||||
}
|
||||
else {
|
||||
*phaseEnd = *phaseBegin + pwmAmount;
|
||||
if (*phaseEnd >= PCA9685_PWM_FULL)
|
||||
*phaseEnd -= PCA9685_PWM_FULL;
|
||||
}
|
||||
}
|
||||
|
||||
void PCA9685::writeChannelBegin(int channel) {
|
||||
byte regAddress;
|
||||
|
||||
if (channel != -1)
|
||||
regAddress = PCA9685_LED0_REG + (channel * 0x04);
|
||||
else
|
||||
regAddress = PCA9685_ALLLED_REG;
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(" PCA9685::writeChannelBegin channel: ");
|
||||
Serial.print(channel);
|
||||
Serial.print(", regAddress: 0x");
|
||||
Serial.println(regAddress, HEX);
|
||||
#endif
|
||||
|
||||
i2cWire_beginTransmission(_i2cAddress);
|
||||
i2cWire_write(regAddress);
|
||||
}
|
||||
|
||||
void PCA9685::writeChannelPWM(uint16_t phaseBegin, uint16_t phaseEnd) {
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(" PCA9685::writeChannelPWM phaseBegin: ");
|
||||
Serial.print(phaseBegin);
|
||||
Serial.print(", phaseEnd: ");
|
||||
Serial.println(phaseEnd);
|
||||
#endif
|
||||
|
||||
i2cWire_write(lowByte(phaseBegin));
|
||||
i2cWire_write(highByte(phaseBegin));
|
||||
i2cWire_write(lowByte(phaseEnd));
|
||||
i2cWire_write(highByte(phaseEnd));
|
||||
}
|
||||
|
||||
void PCA9685::writeChannelEnd() {
|
||||
i2cWire_endTransmission();
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
checkForErrors();
|
||||
#endif
|
||||
}
|
||||
|
||||
void PCA9685::writeRegister(byte regAddress, byte value) {
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(" PCA9685::writeRegister regAddress: 0x");
|
||||
Serial.print(regAddress, HEX);
|
||||
Serial.print(", value: 0x");
|
||||
Serial.println(value, HEX);
|
||||
#endif
|
||||
|
||||
i2cWire_beginTransmission(_i2cAddress);
|
||||
i2cWire_write(regAddress);
|
||||
i2cWire_write(value);
|
||||
i2cWire_endTransmission();
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
checkForErrors();
|
||||
#endif
|
||||
}
|
||||
|
||||
byte PCA9685::readRegister(byte regAddress) {
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(" PCA9685::readRegister regAddress: 0x");
|
||||
Serial.println(regAddress, HEX);
|
||||
#endif
|
||||
|
||||
i2cWire_beginTransmission(_i2cAddress);
|
||||
i2cWire_write(regAddress);
|
||||
if (i2cWire_endTransmission()) {
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
checkForErrors();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bytesRead = i2cWire_requestFrom((uint8_t)_i2cAddress, (uint8_t)1);
|
||||
if (bytesRead != 1) {
|
||||
while (bytesRead-- > 0)
|
||||
i2cWire_read();
|
||||
_lastI2CError = 4;
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
checkForErrors();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
byte retVal = i2cWire_read();
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(" PCA9685::readRegister retVal: 0x");
|
||||
Serial.println(retVal, HEX);
|
||||
#endif
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
#ifdef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
bool __attribute__((noinline)) i2c_start(uint8_t addr);
|
||||
void __attribute__((noinline)) i2c_stop(void) asm("ass_i2c_stop");
|
||||
bool __attribute__((noinline)) i2c_write(uint8_t value) asm("ass_i2c_write");
|
||||
uint8_t __attribute__((noinline)) i2c_read(bool last);
|
||||
#endif
|
||||
|
||||
void PCA9685::i2cWire_beginTransmission(uint8_t addr) {
|
||||
_lastI2CError = 0;
|
||||
#ifndef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
_i2cWire->beginTransmission(addr);
|
||||
#else
|
||||
i2c_start(addr);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t PCA9685::i2cWire_endTransmission(void) {
|
||||
#ifndef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
return (_lastI2CError = _i2cWire->endTransmission());
|
||||
#else
|
||||
i2c_stop();
|
||||
return (_lastI2CError = 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t PCA9685::i2cWire_requestFrom(uint8_t addr, uint8_t len) {
|
||||
#ifndef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
return _i2cWire->requestFrom(addr, len);
|
||||
#else
|
||||
i2c_start(addr | 0x01);
|
||||
return (_readBytes = len);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t PCA9685::i2cWire_write(uint8_t data) {
|
||||
#ifndef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
return _i2cWire->write(data);
|
||||
#else
|
||||
return (size_t)i2c_write(data);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t PCA9685::i2cWire_read(void) {
|
||||
#ifndef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
return (uint8_t)(_i2cWire->read() & 0xFF);
|
||||
#else
|
||||
if (_readBytes > 1) {
|
||||
_readByes -= 1;
|
||||
return (uint8_t)(i2c_read(false) & 0xFF);
|
||||
}
|
||||
else {
|
||||
_readBytes = 0;
|
||||
return (uint8_t)(i2c_read(true) & 0xFF);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
|
||||
void PCA9685::printModuleInfo() {
|
||||
Serial.println(""); Serial.println(" ~~~ PCA9685 Module Info ~~~");
|
||||
|
||||
Serial.println(""); Serial.println("i2c Address:");
|
||||
Serial.print("0x");
|
||||
Serial.println(_i2cAddress, HEX);
|
||||
|
||||
Serial.println(""); Serial.println("Phase Balancer:");
|
||||
switch (_phaseBalancer) {
|
||||
case PCA9685_PhaseBalancer_None:
|
||||
Serial.println("PCA9685_PhaseBalancer_None"); break;
|
||||
case PCA9685_PhaseBalancer_Linear:
|
||||
Serial.println("PCA9685_PhaseBalancer_Linear"); break;
|
||||
case PCA9685_PhaseBalancer_Weaved:
|
||||
Serial.println("PCA9685_PhaseBalancer_Weaved"); break;
|
||||
default:
|
||||
Serial.println(""); break;
|
||||
}
|
||||
|
||||
if (!_isProxyAddresser) {
|
||||
Serial.println(""); Serial.println("Proxy Addresser:");
|
||||
Serial.println("false");
|
||||
|
||||
Serial.println(""); Serial.println("Mode1 Register:");
|
||||
byte mode1Reg = readRegister(PCA9685_MODE1_REG);
|
||||
Serial.print("0x");
|
||||
Serial.print(mode1Reg, HEX);
|
||||
Serial.print(", Bitset:");
|
||||
if (mode1Reg & PCA9685_MODE_RESTART)
|
||||
Serial.print(" PCA9685_MODE_RESTART");
|
||||
if (mode1Reg & PCA9685_MODE_EXTCLK)
|
||||
Serial.print(" PCA9685_MODE_EXTCLK");
|
||||
if (mode1Reg & PCA9685_MODE_AUTOINC)
|
||||
Serial.print(" PCA9685_MODE_AUTOINC");
|
||||
if (mode1Reg & PCA9685_MODE_SLEEP)
|
||||
Serial.print(" PCA9685_MODE_SLEEP");
|
||||
if (mode1Reg & PCA9685_MODE_SUBADR1)
|
||||
Serial.print(" PCA9685_MODE_SUBADR1");
|
||||
if (mode1Reg & PCA9685_MODE_SUBADR2)
|
||||
Serial.print(" PCA9685_MODE_SUBADR2");
|
||||
if (mode1Reg & PCA9685_MODE_SUBADR3)
|
||||
Serial.print(" PCA9685_MODE_SUBADR3");
|
||||
if (mode1Reg & PCA9685_MODE_ALLCALL)
|
||||
Serial.print(" PCA9685_MODE_ALLCALL");
|
||||
Serial.println("");
|
||||
|
||||
Serial.println(""); Serial.println("Mode2 Register:");
|
||||
byte mode2Reg = readRegister(PCA9685_MODE2_REG);
|
||||
Serial.print("0x");
|
||||
Serial.print(mode2Reg, HEX);
|
||||
Serial.print(", Bitset:");
|
||||
if (mode2Reg & PCA9685_MODE_INVRT)
|
||||
Serial.print(" PCA9685_MODE_INVRT");
|
||||
if (mode2Reg & PCA9685_MODE_OUTPUT_ONACK)
|
||||
Serial.print(" PCA9685_MODE_OUTPUT_ONACK");
|
||||
if (mode2Reg & PCA9685_MODE_OUTPUT_TPOLE)
|
||||
Serial.print(" PCA9685_MODE_OUTPUT_TPOLE");
|
||||
if (mode2Reg & PCA9685_MODE_OUTNE_HIGHZ)
|
||||
Serial.print(" PCA9685_MODE_OUTNE_HIGHZ");
|
||||
if (mode2Reg & PCA9685_MODE_OUTNE_LOW)
|
||||
Serial.print(" PCA9685_MODE_OUTNE_LOW");
|
||||
Serial.println("");
|
||||
|
||||
Serial.println(""); Serial.println("SubAddress1 Register:");
|
||||
byte subAdr1Reg = readRegister(PCA9685_SUBADR1_REG);
|
||||
Serial.print("0x");
|
||||
Serial.println(subAdr1Reg, HEX);
|
||||
|
||||
Serial.println(""); Serial.println("SubAddress2 Register:");
|
||||
byte subAdr2Reg = readRegister(PCA9685_SUBADR2_REG);
|
||||
Serial.print("0x");
|
||||
Serial.println(subAdr2Reg, HEX);
|
||||
|
||||
Serial.println(""); Serial.println("SubAddress3 Register:");
|
||||
byte subAdr3Reg = readRegister(PCA9685_SUBADR3_REG);
|
||||
Serial.print("0x");
|
||||
Serial.println(subAdr3Reg, HEX);
|
||||
|
||||
Serial.println(""); Serial.println("AllCall Register:");
|
||||
byte allCallReg = readRegister(PCA9685_ALLCALL_REG);
|
||||
Serial.print("0x");
|
||||
Serial.println(allCallReg, HEX);
|
||||
}
|
||||
else {
|
||||
Serial.println(""); Serial.println("Proxy Addresser:");
|
||||
Serial.println("true");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef PCA9685_EXCLUDE_SERVO_EVAL
|
||||
|
||||
PCA9685_ServoEvaluator::PCA9685_ServoEvaluator(uint16_t n90PWMAmount, uint16_t p90PWMAmount) {
|
||||
n90PWMAmount = constrain(n90PWMAmount, 0, PCA9685_PWM_FULL);
|
||||
p90PWMAmount = constrain(p90PWMAmount, n90PWMAmount, PCA9685_PWM_FULL);
|
||||
|
||||
_coeff = new float[2];
|
||||
_isCSpline = false;
|
||||
|
||||
_coeff[0] = n90PWMAmount;
|
||||
_coeff[1] = (p90PWMAmount - n90PWMAmount) / 180.0f;
|
||||
}
|
||||
|
||||
PCA9685_ServoEvaluator::PCA9685_ServoEvaluator(uint16_t n90PWMAmount, uint16_t zeroPWMAmount, uint16_t p90PWMAmount) {
|
||||
n90PWMAmount = constrain(n90PWMAmount, 0, PCA9685_PWM_FULL);
|
||||
zeroPWMAmount = constrain(zeroPWMAmount, n90PWMAmount, PCA9685_PWM_FULL);
|
||||
p90PWMAmount = constrain(p90PWMAmount, zeroPWMAmount, PCA9685_PWM_FULL);
|
||||
|
||||
if (p90PWMAmount - zeroPWMAmount != zeroPWMAmount - n90PWMAmount) {
|
||||
_coeff = new float[8];
|
||||
_isCSpline = true;
|
||||
|
||||
// Cubic spline code adapted from: https://shiftedbits.org/2011/01/30/cubic-spline-interpolation/
|
||||
/* "THE BEER-WARE LICENSE" (Revision 42): Devin Lane wrote this [part]. As long as you retain
|
||||
* this notice you can do whatever you want with this stuff. If we meet some day, and you
|
||||
* think this stuff is worth it, you can buy me a beer in return. */
|
||||
|
||||
float x[3] = { 0, 90, 180 };
|
||||
float y[3] = { (float)n90PWMAmount, (float)zeroPWMAmount, (float)p90PWMAmount };
|
||||
float c[3], b[2], d[2], h[2], l[1], u[2], a[1], z[2]; // n = 3
|
||||
|
||||
h[0] = x[1] - x[0];
|
||||
u[0] = z[0] = 0;
|
||||
c[2] = 0;
|
||||
|
||||
for (int i = 1; i < 2; ++i) {
|
||||
h[i] = x[i + 1] - x[i];
|
||||
l[i - 1] = (2 * (x[i + 1] - x[i - 1])) - h[i - 1] * u[i - 1];
|
||||
u[i] = h[i] / l[i - 1];
|
||||
a[i - 1] = (3 / h[i]) * (y[i + 1] - y[i]) - (3 / h[i - 1]) * (y[i] - y[i - 1]);
|
||||
z[i] = (a[i - 1] - h[i - 1] * z[i - 1]) / l[i - 1];
|
||||
}
|
||||
|
||||
for (int i = 1; i >= 0; --i) {
|
||||
c[i] = z[i] - u[i] * c[i + 1];
|
||||
b[i] = (y[i + 1] - y[i]) / h[i] - (h[i] * (c[i + 1] + 2 * c[i])) / 3;
|
||||
d[i] = (c[i + 1] - c[i]) / (3 * h[i]);
|
||||
|
||||
_coeff[4 * i + 0] = y[i]; // a
|
||||
_coeff[4 * i + 1] = b[i]; // b
|
||||
_coeff[4 * i + 2] = c[i]; // c
|
||||
_coeff[4 * i + 3] = d[i]; // d
|
||||
}
|
||||
}
|
||||
else {
|
||||
_coeff = new float[2];
|
||||
_isCSpline = false;
|
||||
|
||||
_coeff[0] = n90PWMAmount;
|
||||
_coeff[1] = (p90PWMAmount - n90PWMAmount) / 180.0f;
|
||||
}
|
||||
}
|
||||
|
||||
PCA9685_ServoEvaluator::~PCA9685_ServoEvaluator() {
|
||||
if (_coeff) delete[] _coeff;
|
||||
}
|
||||
|
||||
uint16_t PCA9685_ServoEvaluator::pwmForAngle(float angle) {
|
||||
float retVal;
|
||||
angle = constrain(angle + 90, 0, 180);
|
||||
|
||||
if (!_isCSpline) {
|
||||
retVal = _coeff[0] + (_coeff[1] * angle);
|
||||
}
|
||||
else {
|
||||
if (angle <= 90) {
|
||||
retVal = _coeff[0] + (_coeff[1] * angle) + (_coeff[2] * angle * angle) + (_coeff[3] * angle * angle * angle);
|
||||
}
|
||||
else {
|
||||
angle -= 90;
|
||||
retVal = _coeff[4] + (_coeff[5] * angle) + (_coeff[6] * angle * angle) + (_coeff[7] * angle * angle * angle);
|
||||
}
|
||||
}
|
||||
|
||||
return (uint16_t)constrain((int)roundf(retVal), 0, PCA9685_PWM_FULL);
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,213 +0,0 @@
|
||||
/* Arduino Library for the PCA9685 16-Channel PWM Driver Module.
|
||||
Copyright (c) 2016 NachtRaveVL <nachtravevl@gmail.com>
|
||||
Copyright (C) 2012 Kasper Skårhøj <kasperskaarhoj@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Created by Kasper Skårhøj, August 3rd, 2012.
|
||||
Forked by Vitska, June 18th, 2016.
|
||||
Forked by NachtRaveVL, July 29th, 2016.
|
||||
|
||||
PCA9685-Arduino - Version 1.2.9
|
||||
*/
|
||||
|
||||
#ifndef PCA9685_H
|
||||
#define PCA9685_H
|
||||
|
||||
// Library Setup
|
||||
|
||||
// Uncomment this define to enable use of the software i2c library (min 4MHz+ processor required).
|
||||
//#define PCA9685_ENABLE_SOFTWARE_I2C 1 // http://playground.arduino.cc/Main/SoftwareI2CLibrary
|
||||
|
||||
// Uncomment this define if wanting to exclude extended functionality from compilation.
|
||||
//#define PCA9685_EXCLUDE_EXT_FUNC 1
|
||||
|
||||
// Uncomment this define if wanting to exclude ServoEvaluator assistant from compilation.
|
||||
//#define PCA9685_EXCLUDE_SERVO_EVAL 1
|
||||
|
||||
// Uncomment this define to enable debug output.
|
||||
//#define PCA9685_ENABLE_DEBUG_OUTPUT 1
|
||||
|
||||
// Servo Control Note
|
||||
// Many 180 degree controlled digital servos run on a 20ms pulse width (50Hz update
|
||||
// frequency) based duty cycle, and do not utilize the entire pulse width for their
|
||||
// -90/+90 degree control. Typically, 2.5% of the 20ms pulse width (0.5ms) is considered
|
||||
// -90 degrees, and 12.5% of the 20ms pulse width (2.5ms) is considered +90 degrees. This
|
||||
// roughly translates to raw PCA9685 PWM values of 102 and 512 (out of the 4096 value
|
||||
// range) for -90 to +90 degree control, but may need to be adjusted to fit your specific
|
||||
// servo (e.g. some I've tested run ~130 to ~525 for their -90/+90 degree control). Also
|
||||
// be aware that driving some servos past their -90/+90 degrees of movement can cause a
|
||||
// little plastic limiter pin to break off and get stuck inside of the gearing, which
|
||||
// could potentially cause the servo to become jammed. See the PCA9685_ServoEvaluator
|
||||
// class to assist with calculating PWM values from Servo angle values.
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >= 100
|
||||
#include <Arduino.h>
|
||||
#else
|
||||
#include <WProgram.h>
|
||||
#endif
|
||||
#ifndef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
#define _BUFFER_LENGTH 32
|
||||
|
||||
#define PCA9685_MODE_INVRT (byte)0x10 // Inverts polarity of channel output signal
|
||||
#define PCA9685_MODE_OUTPUT_ONACK (byte)0x08 // Channel update happens upon ACK (post-set) rather than on STOP (endTransmission)
|
||||
#define PCA9685_MODE_OUTPUT_TPOLE (byte)0x04 // Use a totem-pole (push-pull) style output, typical for boards using this chipset
|
||||
#define PCA9685_MODE_OUTNE_HIGHZ (byte)0x02 // For active low output enable, sets channel output to high-impedance state
|
||||
#define PCA9685_MODE_OUTNE_LOW (byte)0x01 // Similarly, sets channel output to high if in totem-pole mode, otherwise high-impedance state
|
||||
|
||||
#define PCA9685_MIN_CHANNEL 0
|
||||
#define PCA9685_MAX_CHANNEL 15
|
||||
#define PCA9685_CHANNEL_COUNT 16
|
||||
|
||||
typedef enum {
|
||||
PCA9685_PhaseBalancer_None = -1, // Disables phase balancing, all high phase areas start at begining of cycle
|
||||
PCA9685_PhaseBalancer_Linear = 0, // Balances all outputs linearly, 256 steps away from previous output
|
||||
PCA9685_PhaseBalancer_Weaved, // Balances first few outputs better, steps away from previous shorten towards last output
|
||||
|
||||
PCA9685_PhaseBalancer_Count
|
||||
} PCA9685_PhaseBalancer;
|
||||
|
||||
class PCA9685 {
|
||||
public:
|
||||
#ifndef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
// May use a different Wire instance than Wire. Some chipsets, such as Due/Zero/etc.,
|
||||
// have a Wire1 class instance that uses the SDA1/SCL1 lines instead.
|
||||
// Supported i2c baud rates are 100kHz, 400kHz, and 1000kHz.
|
||||
PCA9685(TwoWire& i2cWire = Wire, PCA9685_PhaseBalancer phaseBalancer = PCA9685_PhaseBalancer_Linear);
|
||||
#else
|
||||
// Minimum supported i2c baud rate is 100kHz, which means minimum supported processor
|
||||
// speed is 4MHz+ while running i2c standard mode. For 400kHz i2c baud rate, minimum
|
||||
// supported processor speed is 16MHz+ while running i2c fast mode.
|
||||
PCA9685(PCA9685_PhaseBalancer phaseBalancer = PCA9685_PhaseBalancer_Linear);
|
||||
#endif
|
||||
|
||||
// Should be called only once in setup(), before any init()'s, but after Wire.begin().
|
||||
// Only should be called once on any Wire instance to do a software reset, which
|
||||
// will affect all devices on that line. This helps when you're constantly rebuilding
|
||||
// and reuploading to ensure all the devices on that line are reset properly.
|
||||
void resetDevices();
|
||||
|
||||
// Called in setup(). The i2c address here is the value of the A0, A1, A2, A3, A4 and
|
||||
// A5 pins ONLY, as the class takes care of its internal base address. i2cAddress
|
||||
// should be a value between 0 and 61, since only 62 boards can be addressed.
|
||||
void init(byte i2cAddress = 0, byte mode = PCA9685_MODE_OUTPUT_ONACK | PCA9685_MODE_OUTPUT_TPOLE);
|
||||
|
||||
#ifndef PCA9685_EXCLUDE_EXT_FUNC
|
||||
// Called in setup(). Used when instance talks through to AllCall/Sub1-Sub3 instances
|
||||
// as a proxy object. Using this method will disable any method that performs a read
|
||||
// or conflicts certain states.
|
||||
void initAsProxyAddresser(byte i2cAddress = 0xE0);
|
||||
#endif
|
||||
|
||||
byte getI2CAddress();
|
||||
PCA9685_PhaseBalancer getPhaseBalancer();
|
||||
|
||||
// Min: 24Hz, Max: 1526Hz, Default: 200Hz (resolution widens as Hz goes higher)
|
||||
void setPWMFrequency(float pwmFrequency);
|
||||
|
||||
// Turns channel either full on or full off
|
||||
void setChannelOn(int channel);
|
||||
void setChannelOff(int channel);
|
||||
|
||||
// PWM amounts 0 - 4096, 0 full off, 4096 full on
|
||||
void setChannelPWM(int channel, uint16_t pwmAmount);
|
||||
void setChannelsPWM(int begChannel, int numChannels, const uint16_t *pwmAmounts);
|
||||
|
||||
#ifndef PCA9685_EXCLUDE_EXT_FUNC
|
||||
// Sets all channels, but won't distribute phases
|
||||
void setAllChannelsPWM(uint16_t pwmAmount);
|
||||
|
||||
// Returns PWM amounts 0 - 4096, 0 full off, 4096 full on
|
||||
uint16_t getChannelPWM(int channel);
|
||||
|
||||
// Enables multiple talk-through paths via i2c bus (lsb/bit0 must stay 0)
|
||||
// To use, create a new class instance using initAsSubAddressed() with said address
|
||||
void enableAllCallAddress(byte i2cAddress = 0xE0);
|
||||
void enableSub1Address(byte i2cAddress = 0xE2);
|
||||
void enableSub2Address(byte i2cAddress = 0xE4);
|
||||
void enableSub3Address(byte i2cAddress = 0xE8);
|
||||
void disableAllCallAddress();
|
||||
void disableSub1Address();
|
||||
void disableSub2Address();
|
||||
void disableSub3Address();
|
||||
|
||||
// Allows external clock line to be utilized (once enabled cannot be disabled)
|
||||
void enableExtClockLine();
|
||||
#endif
|
||||
|
||||
byte getLastI2CError();
|
||||
|
||||
#ifdef PCA9685_ENABLE_DEBUG_OUTPUT
|
||||
void printModuleInfo();
|
||||
void checkForErrors();
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifndef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
TwoWire *_i2cWire; // Wire class instance to use
|
||||
#endif
|
||||
byte _i2cAddress; // Module's i2c address
|
||||
PCA9685_PhaseBalancer _phaseBalancer; // Phase balancer scheme to distribute load
|
||||
bool _isProxyAddresser; // Instance is a proxy for sub addressing (disables certain functionality)
|
||||
byte _lastI2CError; // Last i2c error
|
||||
|
||||
void getPhaseCycle(int channel, uint16_t pwmAmount, uint16_t *phaseBegin, uint16_t *phaseEnd);
|
||||
|
||||
void writeChannelBegin(int channel);
|
||||
void writeChannelPWM(uint16_t phaseBegin, uint16_t phaseEnd);
|
||||
void writeChannelEnd();
|
||||
|
||||
void writeRegister(byte regAddress, byte value);
|
||||
byte readRegister(byte regAddress);
|
||||
|
||||
#ifdef PCA9685_ENABLE_SOFTWARE_I2C
|
||||
uint8_t _readBytes;
|
||||
#endif
|
||||
void i2cWire_beginTransmission(uint8_t);
|
||||
uint8_t i2cWire_endTransmission(void);
|
||||
uint8_t i2cWire_requestFrom(uint8_t, uint8_t);
|
||||
size_t i2cWire_write(uint8_t);
|
||||
uint8_t i2cWire_read(void);
|
||||
};
|
||||
|
||||
#ifndef PCA9685_EXCLUDE_SERVO_EVAL
|
||||
|
||||
// Class to assist with calculating Servo PWM values from angle values
|
||||
class PCA9685_ServoEvaluator {
|
||||
public:
|
||||
// Uses a linear interpolation method to quickly compute PWM output value. Uses
|
||||
// default values of 2.5% and 12.5% of phase length for -90/+90.
|
||||
PCA9685_ServoEvaluator(uint16_t n90PWMAmount = 102, uint16_t p90PWMAmount = 512);
|
||||
|
||||
// Uses a cubic spline to interpolate due to an offsetted zero angle that isn't
|
||||
// exactly between -90/+90. This takes more time to compute, but gives a more
|
||||
// accurate PWM output value along the entire range.
|
||||
PCA9685_ServoEvaluator(uint16_t n90PWMAmount, uint16_t zeroPWMAmount, uint16_t p90PWMAmount);
|
||||
|
||||
~PCA9685_ServoEvaluator();
|
||||
|
||||
// Returns the PWM value to use given the angle (-90 to +90)
|
||||
uint16_t pwmForAngle(float angle);
|
||||
|
||||
private:
|
||||
float *_coeff; // a,b,c,d coefficient values
|
||||
bool _isCSpline; // Cubic spline tracking, for _coeff length
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,328 +0,0 @@
|
||||
# PCA9685-Arduino
|
||||
Arduino Library for the PCA9685 16-Channel PWM Driver Module.
|
||||
|
||||
**PCA9685-Arduino - Version 1.2.9**
|
||||
|
||||
Library to control a PCA9685 16-channel PWM driver module from an Arduino board.
|
||||
Licensed under the copy-left GNU GPL v3 license.
|
||||
|
||||
Created by Kasper Skårhøj, August 3rd, 2012.
|
||||
Forked by Vitska, June 18th, 2016.
|
||||
Forked by NachtRaveVL, July 29th, 2016.
|
||||
|
||||
This library allows communication with boards running a PCA6985 16-channel PWM driver module. It supports a wide range of available functionality, from setting the output PWM frequecy, allowing multi-device proxy addressing, and provides an assistant class for working with Servos.
|
||||
|
||||
The datasheet for the IC is available from <http://www.nxp.com/documents/data_sheet/PCA9685.pdf>.
|
||||
|
||||
## Library Setup
|
||||
|
||||
There are several defines inside of the library's header file that allows for more fine-tuned control.
|
||||
|
||||
```Arduino
|
||||
// Uncomment this define to enable use of the software i2c library (min 4MHz+ processor required).
|
||||
//#define PCA9685_ENABLE_SOFTWARE_I2C 1 // http://playground.arduino.cc/Main/SoftwareI2CLibrary
|
||||
|
||||
// Uncomment this define if wanting to exclude extended functionality from compilation.
|
||||
//#define PCA9685_EXCLUDE_EXT_FUNC 1
|
||||
|
||||
// Uncomment this define if wanting to exclude ServoEvaluator assistant from compilation.
|
||||
//#define PCA9685_EXCLUDE_SERVO_EVAL 1
|
||||
|
||||
// Uncomment this define to enable debug output.
|
||||
//#define PCA9685_ENABLE_DEBUG_OUTPUT 1
|
||||
```
|
||||
|
||||
## Servo Control Note
|
||||
|
||||
Many 180 degree controlled digital servos run on a 20ms pulse width (50Hz update frequency) based duty cycle, and do not utilize the entire pulse width for their -90/+90 degree control. Typically, 2.5% of the 20ms pulse width (0.5ms) is considered -90 degrees, and 12.5% of the 20ms pulse width (2.5ms) is considered +90 degrees. This roughly translates to raw PCA9685 PWM values of 102 and 512 (out of the 4096 value range) for -90 to +90 degree control, but may need to be adjusted to fit your specific servo (e.g. some I've tested run ~130 to ~525 for their -90/+90 degree control). Also be aware that driving some servos past their -90/+90 degrees of movement can cause a little plastic limiter pin to break off and get stuck inside of the gearing, which could potentially cause the servo to become jammed. See the PCA9685_ServoEvaluator class to assist with calculating PWM values from Servo angle values.
|
||||
|
||||
## Example Usage
|
||||
|
||||
Below are several examples of library usage.
|
||||
|
||||
### Simple Example
|
||||
```Arduino
|
||||
#include <Wire.h>
|
||||
#include "PCA9685.h"
|
||||
|
||||
PCA9685 pwmController; // Library using default Wire and default linear phase balancing scheme
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
Wire.begin(); // Wire must be started first
|
||||
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
|
||||
pwmController.resetDevices(); // Software resets all PCA9685 devices on Wire line
|
||||
|
||||
pwmController.init(B000000); // Address pins A5-A0 set to B000000
|
||||
pwmController.setPWMFrequency(100); // Default is 200Hz, supports 24Hz to 1526Hz
|
||||
|
||||
pwmController.setChannelPWM(0, 128 << 4); // Set PWM to 128/255, but in 4096 land
|
||||
|
||||
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Batching Example
|
||||
|
||||
In this example, we randomly select PWM frequencies on all 12 outputs and allow them to drive for 5 seconds before changing them.
|
||||
|
||||
```Arduino
|
||||
#include <Wire.h>
|
||||
#include "PCA9685.h"
|
||||
|
||||
PCA9685 pwmController; // Library using default Wire and default linear phase balancing scheme
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
Wire.begin(); // Wire must be started first
|
||||
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
|
||||
pwmController.resetDevices(); // Software resets all PCA9685 devices on Wire line
|
||||
|
||||
pwmController.init(B010101); // Address pins A5-A0 set to B010101
|
||||
pwmController.setPWMFrequency(500); // Default is 200Hz, supports 24Hz to 1526Hz
|
||||
|
||||
randomSeed(analogRead(0)); // Use white noise for our randomness
|
||||
}
|
||||
|
||||
void loop() {
|
||||
word pwms[12];
|
||||
pwms[0] = random(0, 4096);
|
||||
pwms[1] = random(0, 4096);
|
||||
pwms[2] = random(0, 4096);
|
||||
pwms[3] = random(0, 4096);
|
||||
pwms[4] = random(0, 4096);
|
||||
pwms[5] = random(0, 4096);
|
||||
pwms[6] = random(0, 4096);
|
||||
pwms[7] = random(0, 4096);
|
||||
pwms[8] = random(0, 4096);
|
||||
pwms[9] = random(0, 4096);
|
||||
pwms[10] = random(0, 4096);
|
||||
pwms[11] = random(0, 4096);
|
||||
pwmController.setChannelsPWM(0, 12, pwms);
|
||||
delay(5000);
|
||||
|
||||
// Note: Only 7 channels can be written in one i2c transaction due to a
|
||||
// BUFFER_LENGTH limit of 32, so 12 channels will take two i2c transactions.
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Multi-Device Proxy Example
|
||||
|
||||
In this example, we use a special instance to control other modules attached to it via the ALL_CALL register.
|
||||
|
||||
```Arduino
|
||||
#include <Wire.h>
|
||||
#include "PCA9685.h"
|
||||
|
||||
PCA9685 pwmController1; // Library using default Wire and default linear phase balancing scheme
|
||||
PCA9685 pwmController2; // Library using default Wire and default linear phase balancing scheme
|
||||
|
||||
PCA9685 pwmControllerAll; // Not a real device, will act as a proxy to pwmController1 and pwmController2
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
Wire.begin(); // Wire must be started first
|
||||
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
|
||||
pwmController1.resetDevices(); // Software resets all PCA9685 devices on Wire line (including pwmController2 in this case)
|
||||
|
||||
pwmController1.init(B000000); // Address pins A5-A0 set to B000000
|
||||
pwmController2.init(B000001); // Address pins A5-A0 set to B000001
|
||||
|
||||
pwmController1.setChannelOff(0); // Turn channel 0 off
|
||||
pwmController2.setChannelOff(0); // On both
|
||||
|
||||
pwmController1.enableAllCallAddress(); // Default address of 0xE0
|
||||
pwmController2.enableAllCallAddress(); // Same default address
|
||||
|
||||
pwmControllerAll.initAsProxyAddresser(); // Same default address of 0x0E as used in enable above
|
||||
|
||||
pwmControllerAll.setChannelPWM(0, 4096); // Enables full on on both pwmController1 and pwmController2
|
||||
|
||||
Serial.println(pwmController1.getChannelPWM(0)); // Should output 4096
|
||||
Serial.println(pwmController2.getChannelPWM(0)); // Should also output 4096
|
||||
|
||||
// Note: Various parts of functionality of the proxy class instance are actually
|
||||
// disabled - typically anything that involves a read command being issued.
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Servo Evaluator Example
|
||||
|
||||
In this example, we utilize the ServoEvaluator class to assist with setting PWM frequencies when working with servos. We will be using Wire1, which is only available on boards with SDA1/SCL1 (Due, Zero, etc.) - change to Wire if Wire1 is unavailable.
|
||||
|
||||
```Arduino
|
||||
#include <Wire.h>
|
||||
#include "PCA9685.h"
|
||||
|
||||
PCA9685 pwmController(Wire1, PCA9685_PhaseBalancer_Weaved); // Library using Wire1 and weaved phase balancing scheme
|
||||
|
||||
// Linearly interpolates between standard 2.5%/12.5% phase length (102/512) for -90°/+90°
|
||||
PCA9685_ServoEvaluator pwmServo1;
|
||||
|
||||
// Testing our second servo has found that -90° sits at 128, 0° at 324, and +90° at 526.
|
||||
// Since 324 isn't precisely in the middle, a cubic spline will be used to smoothly
|
||||
// interpolate PWM values, which will account for said discrepancy. Additionally, since
|
||||
// 324 is closer to 128 than 526, there is less resolution in the -90° to 0° range, and
|
||||
// more in the 0° to +90° range.
|
||||
PCA9685_ServoEvaluator pwmServo2(128,324,526);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
Wire1.begin(); // Wire must be started first
|
||||
Wire1.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
|
||||
pwmController.resetDevices(); // Software resets all PCA9685 devices on Wire line
|
||||
|
||||
pwmController.init(B000000); // Address pins A5-A0 set to B000000
|
||||
pwmController.setPWMFrequency(50); // 50Hz provides 20ms standard servo phase length
|
||||
|
||||
pwmController.setChannelPWM(0, pwmServo1.pwmForAngle(-90));
|
||||
Serial.println(pwmController.getChannelPWM(0)); // Should output 102 for -90°
|
||||
|
||||
// Showing linearity for midpoint, 205 away from both -90° and 90°
|
||||
Serial.println(pwmServo1.pwmForAngle(0)); // Should output 307 for 0°
|
||||
|
||||
pwmController.setChannelPWM(0, pwmServo1.pwmForAngle(90));
|
||||
Serial.println(pwmController.getChannelPWM(0)); // Should output 512 for +90°
|
||||
|
||||
pwmController.setChannelPWM(1, pwmServo2.pwmForAngle(-90));
|
||||
Serial.println(pwmController.getChannelPWM(1)); // Should output 128 for -90°
|
||||
|
||||
// Showing less resolution in the -90° to 0° range
|
||||
Serial.println(pwmServo2.pwmForAngle(-45)); // Should output 225 for -45°, 97 away from -90°
|
||||
|
||||
pwmController.setChannelPWM(1, pwmServo2.pwmForAngle(0));
|
||||
Serial.println(pwmController.getChannelPWM(1)); // Should output 324 for 0°
|
||||
|
||||
// Showing more resolution in the 0° to +90° range
|
||||
Serial.println(pwmServo2.pwmForAngle(45)); // Should output 424 for +45°, 102 away from +90°
|
||||
|
||||
pwmController.setChannelPWM(1, pwmServo2.pwmForAngle(90));
|
||||
Serial.println(pwmController.getChannelPWM(1)); // Should output 526 for +90°
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Software I2C Example
|
||||
|
||||
In this example, we utilize the software I2C functionality for chips that do not have a hardware I2C bus. We must uncomment the PCA9685_ENABLE_SOFTWARE_I2C define in the libraries main header file for software I2C mode to be enabled.
|
||||
|
||||
In PCA9685.h:
|
||||
```Arduino
|
||||
// Uncomment this define to enable use of the software i2c library (min 4MHz+ processor required).
|
||||
#define PCA9685_ENABLE_SOFTWARE_I2C 1 // http://playground.arduino.cc/Main/SoftwareI2CLibrary
|
||||
```
|
||||
|
||||
In main sketch:
|
||||
```Arduino
|
||||
#include "PCA9685.h"
|
||||
|
||||
#define SCL_PIN 2 // Setup defines are written before library include
|
||||
#define SCL_PORT PORTD
|
||||
#define SDA_PIN 0
|
||||
#define SDA_PORT PORTC
|
||||
|
||||
#if F_CPU >= 16000000
|
||||
#define I2C_FASTMODE 1 // Running a 16MHz processor allows us to use I2C fast mode
|
||||
#endif
|
||||
|
||||
#include "SoftI2CMaster.h" // Include must come after setup defines
|
||||
|
||||
PCA9685 pwmController; // Library using default linear phase balancing scheme
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
i2c_init(); // Software I2C must be started first
|
||||
|
||||
pwmController.resetDevices(); // Software resets all PCA9685 devices on software I2C line
|
||||
|
||||
pwmController.init(B000000); // Address pins A5-A0 set to B000000
|
||||
|
||||
pwmController.setChannelPWM(0, 2048); // Should see a 50% duty cycle along the 5ms phase width
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Module Info
|
||||
|
||||
If one uncomments the PCA9685_ENABLE_DEBUG_OUTPUT define in the libraries main header file (thus enabling debug output) the printModuleInfo() method becomes available, which will display information about the module itself, including initalized states, register values, current settings, etc. All calls being made will display internal debug information about the structure of the call itself. An example of this output is shown here:
|
||||
|
||||
In PCA9685.h:
|
||||
```Arduino
|
||||
// Uncomment this define to enable debug output.
|
||||
#define PCA9685_ENABLE_DEBUG_OUTPUT 1
|
||||
```
|
||||
|
||||
In main sketch:
|
||||
```Arduino
|
||||
#include <Wire.h>
|
||||
#include "PCA9685.h"
|
||||
|
||||
PCA9685 pwmController;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
Wire.begin(); // Wire must be started first
|
||||
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
|
||||
pwmController.printModuleInfo();
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
In serial monitor:
|
||||
```
|
||||
~~~ PCA9685 Module Info ~~~
|
||||
|
||||
i2c Address:
|
||||
0x40
|
||||
|
||||
Phase Balancer:
|
||||
PCA9685_PhaseBalancer_Weaved
|
||||
|
||||
Proxy Addresser:
|
||||
false
|
||||
|
||||
Mode1 Register:
|
||||
PCA9685::readRegister regAddress: 0x0
|
||||
PCA9685::readRegister retVal: 0x20
|
||||
0x20, Bitset: PCA9685_MODE_AUTOINC
|
||||
|
||||
Mode2 Register:
|
||||
PCA9685::readRegister regAddress: 0x1
|
||||
PCA9685::readRegister retVal: 0xC
|
||||
0xC, Bitset: PCA9685_MODE_OUTPUT_ONACK PCA9685_MODE_OUTPUT_TPOLE
|
||||
|
||||
SubAddress1 Register:
|
||||
PCA9685::readRegister regAddress: 0x2
|
||||
PCA9685::readRegister retVal: 0xE2
|
||||
0xE2
|
||||
|
||||
SubAddress2 Register:
|
||||
PCA9685::readRegister regAddress: 0x3
|
||||
PCA9685::readRegister retVal: 0xE4
|
||||
0xE4
|
||||
|
||||
SubAddress3 Register:
|
||||
PCA9685::readRegister regAddress: 0x4
|
||||
PCA9685::readRegister retVal: 0xE8
|
||||
0xE8
|
||||
|
||||
AllCall Register:
|
||||
PCA9685::readRegister regAddress: 0x5
|
||||
PCA9685::readRegister retVal: 0xE0
|
||||
0xE0
|
||||
|
||||
```
|
||||
@ -1,10 +0,0 @@
|
||||
name=PCA9685 16-Channel PWM Driver Module Library
|
||||
version=1.2.9
|
||||
author=NachtRaveVL <nachtravevl@gmail.com>, Vitska, Kasper Skårhøj <kasperskaarhoj@gmail.com>
|
||||
maintainer=NachtRaveVL <nachtravevl@gmail.com>
|
||||
sentence=Library to control a PCA9685 16-channel PWM driver module from an Arduino board.
|
||||
paragraph=This library allows communication with boards running a PCA6985 16-channel PWM driver module. It supports a wide range of available functionality, from setting the output PWM frequecy, allowing multi-device proxy addressing, and provides an assistant class for working with Servos.
|
||||
category=Device Control
|
||||
url=https://github.com/NachtRaveVL/PCA9685-Arduino
|
||||
architectures=*
|
||||
|
||||
@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
1
lib/PCA9685-Arduino
Submodule
1
lib/PCA9685-Arduino
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit a70be39257e317d35e9118b385006a1e030e6452
|
||||
46
lib/README
46
lib/README
@ -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,15 +1,8 @@
|
||||
#include "filesys.h"
|
||||
|
||||
// listDir("/");
|
||||
// deleteFile("/hello.txt");
|
||||
// writeFile("/hello.txt", "Hello ");
|
||||
// appendFile("/hello.txt", "World!\n\r");
|
||||
// readFile("/hello.txt");
|
||||
// listDir("/");
|
||||
|
||||
FSInfo fsinfo;
|
||||
|
||||
bool mount_fs() {
|
||||
auto mount_fs() -> bool {
|
||||
if(!LittleFS.begin()) {
|
||||
Serial.println("[ERROR] LittleFS.info(), reset ...");
|
||||
return false;
|
||||
@ -32,7 +25,7 @@ bool mount_fs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool format_fs() {
|
||||
auto format_fs() -> bool {
|
||||
printf("Formatting FS ! \n\r");
|
||||
return LittleFS.format();
|
||||
}
|
||||
@ -58,7 +51,12 @@ void ls(const char * dirname) {
|
||||
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);
|
||||
|
||||
File file = LittleFS.open(path, "r");
|
||||
@ -123,8 +121,4 @@ void deleteFile(const char * path) {
|
||||
} else {
|
||||
Serial.println("Delete failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,16 +1,16 @@
|
||||
#ifndef __FILESYS_H
|
||||
#define __FILESYS_H
|
||||
#pragma once
|
||||
|
||||
#include <LittleFS.h>
|
||||
|
||||
// some usefull wrappers for Filesystem
|
||||
bool mount_fs();
|
||||
bool format_fs();
|
||||
|
||||
File open(const char * path);
|
||||
|
||||
void ls(const char * dirname);
|
||||
void readFile(const char * path);
|
||||
void printFile(const char * path);
|
||||
void writeFile(const char * path, const char * message);
|
||||
void appendFile(const char * path, const char * message);
|
||||
void renameFile(const char * path1, const char * path2);
|
||||
void deleteFile(const char * path);
|
||||
|
||||
#endif // __FILESYS_H
|
||||
122
lib/httpserver/httpserver.cpp
Normal file
122
lib/httpserver/httpserver.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
#include "httpserver.h"
|
||||
|
||||
auto HTTPServer::start() -> bool {
|
||||
if (!mount_fs()) {
|
||||
logf("cant mount filesystem, EXIT !\n\r");
|
||||
return false;
|
||||
}
|
||||
|
||||
logf("LittleFS mounted !\n\r");
|
||||
logf("root:\n\r");
|
||||
this->listRoot();
|
||||
logf("\n\r");
|
||||
|
||||
// default handler
|
||||
this->onNotFound([this]() {
|
||||
String message = "File Not Found\n\n";
|
||||
message += "URI: ";
|
||||
message += uri();
|
||||
message += "\nMethod: ";
|
||||
message += (method() == HTTP_GET) ? "GET" : "POST";
|
||||
message += "\nArguments: ";
|
||||
message += args();
|
||||
message += "\n";
|
||||
|
||||
for (uint8_t i = 0; i < args(); i++) {
|
||||
message += " " + argName(i) + ": " + arg(i) + "\n";
|
||||
}
|
||||
send(404, "text/plain", message);
|
||||
});
|
||||
|
||||
// add static root file handler for http
|
||||
this->serveStatic("/", LittleFS, "/");
|
||||
this->begin();
|
||||
logf("Server active on Port 80 !\n\r");
|
||||
return true;
|
||||
}
|
||||
|
||||
void HTTPServer::start_apps() {
|
||||
this->on("/action", HTTP_POST, [this]() {
|
||||
if (args()) {
|
||||
logf("%s=%s\n", argName(0).c_str(), arg(0).c_str());
|
||||
|
||||
if (argName(0).equals("control")) {
|
||||
if (arg(0).equals("s_oben")) {
|
||||
treppe->overwrite_sensors(true, false);
|
||||
logt("control => s_oben !\n");
|
||||
}
|
||||
else if (arg(0).equals("s_unten")) {
|
||||
treppe->overwrite_sensors(false, true);
|
||||
logt("control => s_unten !\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
send(200, "text/plain", "accepted");
|
||||
});
|
||||
|
||||
this->on("/update", HTTP_POST, [this]() {
|
||||
if (args()) {
|
||||
for (int i = 0; i < args() - 1; i++) {
|
||||
logf("%s=%s\n", argName(i).c_str(), arg(i).c_str());
|
||||
|
||||
if (argName(i).equals("range_act_pwm")) {
|
||||
treppe->set_active_pwm(arg(i).toInt(), VORGABE_PROZENT);
|
||||
logt("set_active_pwm = %d %\n", arg(i).toInt());
|
||||
}
|
||||
else if (argName(i).equals("range_idl_pwm")) {
|
||||
treppe->set_idle_pwm_max(arg(i).toInt(), VORGABE_PROZENT);
|
||||
logt("set_idle_pwm_max = %d %\n", arg(i).toInt());
|
||||
}
|
||||
else if (argName(i).equals("range_tim_sta")) {
|
||||
treppe->set_time_per_stair(arg(i).toInt());
|
||||
logt("set_time_per_stair = %d\n", arg(i).toInt());
|
||||
}
|
||||
else if (argName(i).equals("range_tim_ldr")) {
|
||||
treppe->set_time_ldr(arg(i).toInt());
|
||||
logt("set_time_ldr = %d\n", arg(i).toInt());
|
||||
}
|
||||
else if (argName(i).equals("range_ldr_shw")) {
|
||||
treppe->set_ldr_schwelle(arg(i).toInt(), VORGABE_12BIT);
|
||||
logt("set_ldr_schwelle = %d %\n", arg(i).toInt());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
send(200, "text/plain", "accepted");
|
||||
});
|
||||
|
||||
this->on("/terminal", HTTP_POST, [this]() {
|
||||
// logf("got /terminal\n");
|
||||
if (tbuf_head) {
|
||||
send(200, "text/plain", tbuf);
|
||||
tbuf_head = 0;
|
||||
} else {
|
||||
send(202, "text/plain", "");
|
||||
}
|
||||
});
|
||||
|
||||
this->on("/parameters", HTTP_POST, [this]() {
|
||||
logt("got /parameters\n");
|
||||
char json_str[255];
|
||||
treppe->param_to_json(json_str, 255);
|
||||
logt("%s\n", json_str);
|
||||
send(200, "application/json", json_str);
|
||||
});
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
void HTTPServer::logf(const char *format, Args... args) const {
|
||||
Serial.print(log_prefix);
|
||||
Serial.printf(format, 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) {
|
||||
tbuf_head +=
|
||||
vsnprintf(tbuf + tbuf_head, TBUF_LEN - tbuf_head, format, args);
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
40
lib/httpserver/httpserver.h
Normal file
40
lib/httpserver/httpserver.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef __HTTPSERVER_H
|
||||
#define __HTTPSERVER_H
|
||||
// Wrapper for ESP8266WebServer with Filesystem as HTTP source
|
||||
|
||||
#include "filesys.h"
|
||||
#include "treppe.h"
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// debug log <ESP8266WebServer.h>
|
||||
// #define DEBUGV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
|
||||
|
||||
#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); }
|
||||
Treppe *treppe;
|
||||
|
||||
public:
|
||||
HTTPServer(const int _port, const char *_rootDir, Treppe *_treppe)
|
||||
: ESP8266WebServer(_port), rootDir(_rootDir), treppe(_treppe) {}
|
||||
~HTTPServer() { Serial.printf("[HTTPServer] shut down ...\n\r"); }
|
||||
|
||||
bool start();
|
||||
void start_apps();
|
||||
|
||||
template <class... Args>
|
||||
void logf(const char *format, Args... args) const;
|
||||
void logt(const char *format, ...);
|
||||
};
|
||||
|
||||
#endif // __HTTPSERVER_H
|
||||
296
lib/treppe/FSMTreppe4/FSMTreppe4.cpp
Normal file
296
lib/treppe/FSMTreppe4/FSMTreppe4.cpp
Normal file
@ -0,0 +1,296 @@
|
||||
//
|
||||
// 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.65
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Tue Sep 7 08:47:00 2021
|
||||
//
|
||||
// Target selection: ert.tlc
|
||||
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
|
||||
// Code generation objectives: Unspecified
|
||||
// Validation result: Not run
|
||||
//
|
||||
#include "FSMTreppe4.h"
|
||||
|
||||
// Named constants for Chart: '<Root>/FSMTreppe'
|
||||
const uint8_t FSMTreppe_IN_abdimmen_hoch = 1U;
|
||||
const uint8_t FSMTreppe_IN_abdimmen_ldr = 2U;
|
||||
const uint8_t FSMTreppe_IN_abdimmen_runter = 3U;
|
||||
const uint8_t FSMTreppe_IN_aufdimmen_hoch = 4U;
|
||||
const uint8_t FSMTreppe_IN_aufdimmen_ldr = 5U;
|
||||
const uint8_t FSMTreppe_IN_aufdimmen_runter = 6U;
|
||||
const uint8_t FSMTreppe_IN_dimm_regelung = 7U;
|
||||
const uint8_t FSMTreppe_IN_inaktiv = 8U;
|
||||
const uint8_t FSMTreppe_IN_ruhezustand = 9U;
|
||||
const uint8_t FSMTreppe_IN_warten_hoch = 10U;
|
||||
const uint8_t FSMTreppe_IN_warten_runter = 11U;
|
||||
|
||||
// Model step function
|
||||
void FSMTreppeModelClass::step()
|
||||
{
|
||||
// Chart: '<Root>/FSMTreppe' incorporates:
|
||||
// Inport: '<Root>/anim_beendet'
|
||||
// Inport: '<Root>/ldr_changed'
|
||||
// Inport: '<Root>/ldr_schwelle'
|
||||
// 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_inaktiv;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 0U;
|
||||
} else {
|
||||
switch (FSMTreppe_DW.is_c3_FSMTreppe) {
|
||||
case FSMTreppe_IN_abdimmen_hoch:
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 6U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_abdimmen_ldr:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 2U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_inaktiv;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 0U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_abdimmen_runter:
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 9U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_aufdimmen_hoch:
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 4U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_hoch;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 5U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_aufdimmen_ldr:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_aufdimmen_runter:
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 7U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_runter;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 8U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_dimm_regelung:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 10U;
|
||||
if ((FSMTreppe_DW.temporalCounter_i1 >= 500U) || (FSMTreppe_U.anim_beendet
|
||||
== 1U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_inaktiv:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 0U;
|
||||
if (FSMTreppe_U.ldr_schwelle == 1U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_ldr;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_ruhezustand:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
if (FSMTreppe_U.sensor_unten == 1U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_hoch;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 4U;
|
||||
} else if (FSMTreppe_U.sensor_oben == 1U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_runter;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 7U;
|
||||
} else if (FSMTreppe_U.ldr_schwelle == 0U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_ldr;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 2U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
} else if (FSMTreppe_U.ldr_changed == 1U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_dimm_regelung;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 10U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_warten_hoch:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 5U;
|
||||
if ((FSMTreppe_U.sensor_oben == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_hoch;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 6U;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Outport: '<Root>/status'
|
||||
// case IN_warten_runter:
|
||||
FSMTreppe_Y.status = 8U;
|
||||
if ((FSMTreppe_U.sensor_unten == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_runter;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 9U;
|
||||
}
|
||||
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]
|
||||
//
|
||||
120
lib/treppe/FSMTreppe4/FSMTreppe4.h
Normal file
120
lib/treppe/FSMTreppe4/FSMTreppe4.h
Normal file
@ -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.65
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Tue Sep 7 08:47:00 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'
|
||||
};
|
||||
|
||||
// External inputs (root inport signals with default storage)
|
||||
struct ExtU_FSMTreppe_T {
|
||||
uint32_t sensor_unten; // '<Root>/sensor_unten'
|
||||
uint32_t sensor_oben; // '<Root>/sensor_oben'
|
||||
uint32_t anim_beendet; // '<Root>/anim_beendet'
|
||||
uint32_t ldr_schwelle; // '<Root>/ldr_schwelle'
|
||||
uint32_t ldr_changed; // '<Root>/ldr_changed'
|
||||
};
|
||||
|
||||
// External outputs (root outports fed by signals with default storage)
|
||||
struct ExtY_FSMTreppe_T {
|
||||
uint32_t laufrichtung; // '<Root>/laufrichtung'
|
||||
uint32_t status; // '<Root>/status'
|
||||
uint32_t dimmrichtung; // '<Root>/dimmrichtung'
|
||||
};
|
||||
|
||||
// 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]
|
||||
//
|
||||
304
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/FSMTreppe.cpp
Normal file
304
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/FSMTreppe.cpp
Normal file
@ -0,0 +1,304 @@
|
||||
//
|
||||
// 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.65
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Tue Sep 7 08:47:00 2021
|
||||
//
|
||||
// Target selection: ert.tlc
|
||||
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
|
||||
// Code generation objectives: Unspecified
|
||||
// Validation result: Not run
|
||||
//
|
||||
#include "FSMTreppe.h"
|
||||
#include "FSMTreppe_private.h"
|
||||
|
||||
// Named constants for Chart: '<Root>/FSMTreppe'
|
||||
const uint8_T FSMTreppe_IN_abdimmen_hoch = 1U;
|
||||
const uint8_T FSMTreppe_IN_abdimmen_ldr = 2U;
|
||||
const uint8_T FSMTreppe_IN_abdimmen_runter = 3U;
|
||||
const uint8_T FSMTreppe_IN_aufdimmen_hoch = 4U;
|
||||
const uint8_T FSMTreppe_IN_aufdimmen_ldr = 5U;
|
||||
const uint8_T FSMTreppe_IN_aufdimmen_runter = 6U;
|
||||
const uint8_T FSMTreppe_IN_dimm_regelung = 7U;
|
||||
const uint8_T FSMTreppe_IN_inaktiv = 8U;
|
||||
const uint8_T FSMTreppe_IN_ruhezustand = 9U;
|
||||
const uint8_T FSMTreppe_IN_warten_hoch = 10U;
|
||||
const uint8_T FSMTreppe_IN_warten_runter = 11U;
|
||||
|
||||
// Model step function
|
||||
void FSMTreppeModelClass::step()
|
||||
{
|
||||
// Chart: '<Root>/FSMTreppe' incorporates:
|
||||
// Inport: '<Root>/anim_beendet'
|
||||
// Inport: '<Root>/ldr_changed'
|
||||
// Inport: '<Root>/ldr_schwelle'
|
||||
// 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_inaktiv;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 0U;
|
||||
} else {
|
||||
switch (FSMTreppe_DW.is_c3_FSMTreppe) {
|
||||
case FSMTreppe_IN_abdimmen_hoch:
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 6U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_abdimmen_ldr:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 2U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_inaktiv;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 0U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_abdimmen_runter:
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 9U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_aufdimmen_hoch:
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 4U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_hoch;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 5U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_aufdimmen_ldr:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_aufdimmen_runter:
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 7U;
|
||||
if ((FSMTreppe_U.anim_beendet == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_warten_runter;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 8U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_dimm_regelung:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 10U;
|
||||
if ((FSMTreppe_DW.temporalCounter_i1 >= 500U) || (FSMTreppe_U.anim_beendet
|
||||
== 1U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_ruhezustand;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_inaktiv:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 0U;
|
||||
if (FSMTreppe_U.ldr_schwelle == 1U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_ldr;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_ruhezustand:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 3U;
|
||||
if (FSMTreppe_U.sensor_unten == 1U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_hoch;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 4U;
|
||||
} else if (FSMTreppe_U.sensor_oben == 1U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_aufdimmen_runter;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/laufrichtung'
|
||||
FSMTreppe_Y.laufrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 1U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 7U;
|
||||
} else if (FSMTreppe_U.ldr_schwelle == 0U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_ldr;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 2U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
} else if (FSMTreppe_U.ldr_changed == 1U) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_dimm_regelung;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 10U;
|
||||
}
|
||||
break;
|
||||
|
||||
case FSMTreppe_IN_warten_hoch:
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 5U;
|
||||
if ((FSMTreppe_U.sensor_oben == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_hoch;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 6U;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Outport: '<Root>/status'
|
||||
// case IN_warten_runter:
|
||||
FSMTreppe_Y.status = 8U;
|
||||
if ((FSMTreppe_U.sensor_unten == 1U) || (FSMTreppe_DW.temporalCounter_i1 >=
|
||||
500U)) {
|
||||
FSMTreppe_DW.is_c3_FSMTreppe = FSMTreppe_IN_abdimmen_runter;
|
||||
FSMTreppe_DW.temporalCounter_i1 = 0U;
|
||||
|
||||
// Outport: '<Root>/dimmrichtung'
|
||||
FSMTreppe_Y.dimmrichtung = 0U;
|
||||
|
||||
// Outport: '<Root>/status'
|
||||
FSMTreppe_Y.status = 9U;
|
||||
}
|
||||
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(),
|
||||
FSMTreppe_M()
|
||||
{
|
||||
// Currently there is no constructor body generated.
|
||||
}
|
||||
|
||||
// Destructor
|
||||
FSMTreppeModelClass::~FSMTreppeModelClass()
|
||||
{
|
||||
// Currently there is no destructor body generated.
|
||||
}
|
||||
|
||||
// Real-Time Model get method
|
||||
FSMTreppeModelClass::RT_MODEL_FSMTreppe_T * FSMTreppeModelClass::getRTM()
|
||||
{
|
||||
return (&FSMTreppe_M);
|
||||
}
|
||||
|
||||
//
|
||||
// File trailer for generated code.
|
||||
//
|
||||
// [EOF]
|
||||
//
|
||||
140
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/FSMTreppe.h
Normal file
140
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/FSMTreppe.h
Normal file
@ -0,0 +1,140 @@
|
||||
//
|
||||
// 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.65
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Tue Sep 7 08:47:00 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 "rtwtypes.h"
|
||||
#include "FSMTreppe_types.h"
|
||||
|
||||
// Macros for accessing real-time model data structure
|
||||
#ifndef rtmGetErrorStatus
|
||||
#define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)
|
||||
#endif
|
||||
|
||||
#ifndef rtmSetErrorStatus
|
||||
#define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))
|
||||
#endif
|
||||
|
||||
// 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'
|
||||
};
|
||||
|
||||
// External inputs (root inport signals with default storage)
|
||||
struct ExtU_FSMTreppe_T {
|
||||
uint32_T sensor_unten; // '<Root>/sensor_unten'
|
||||
uint32_T sensor_oben; // '<Root>/sensor_oben'
|
||||
uint32_T anim_beendet; // '<Root>/anim_beendet'
|
||||
uint32_T ldr_schwelle; // '<Root>/ldr_schwelle'
|
||||
uint32_T ldr_changed; // '<Root>/ldr_changed'
|
||||
};
|
||||
|
||||
// External outputs (root outports fed by signals with default storage)
|
||||
struct ExtY_FSMTreppe_T {
|
||||
uint32_T laufrichtung; // '<Root>/laufrichtung'
|
||||
uint32_T status; // '<Root>/status'
|
||||
uint32_T dimmrichtung; // '<Root>/dimmrichtung'
|
||||
};
|
||||
|
||||
// Real-time Model Data Structure
|
||||
struct RT_MODEL_FSMTreppe_T {
|
||||
const char_T * volatile errorStatus;
|
||||
};
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Real-Time Model get method
|
||||
FSMTreppeModelClass::RT_MODEL_FSMTreppe_T * getRTM();
|
||||
|
||||
// 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;
|
||||
|
||||
// Real-Time Model
|
||||
RT_MODEL_FSMTreppe_T FSMTreppe_M;
|
||||
};
|
||||
|
||||
//-
|
||||
// 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]
|
||||
//
|
||||
28
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/FSMTreppe_private.h
Normal file
28
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/FSMTreppe_private.h
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// 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_private.h
|
||||
//
|
||||
// Code generated for Simulink model 'FSMTreppe'.
|
||||
//
|
||||
// Model version : 1.65
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Tue Sep 7 08:47:00 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_private_h_
|
||||
#define RTW_HEADER_FSMTreppe_private_h_
|
||||
#include "rtwtypes.h"
|
||||
#endif // RTW_HEADER_FSMTreppe_private_h_
|
||||
|
||||
//
|
||||
// File trailer for generated code.
|
||||
//
|
||||
// [EOF]
|
||||
//
|
||||
29
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/FSMTreppe_types.h
Normal file
29
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/FSMTreppe_types.h
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// 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_types.h
|
||||
//
|
||||
// Code generated for Simulink model 'FSMTreppe'.
|
||||
//
|
||||
// Model version : 1.65
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Tue Sep 7 08:47:00 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_types_h_
|
||||
#define RTW_HEADER_FSMTreppe_types_h_
|
||||
|
||||
// Model Code Variants
|
||||
#endif // RTW_HEADER_FSMTreppe_types_h_
|
||||
|
||||
//
|
||||
// File trailer for generated code.
|
||||
//
|
||||
// [EOF]
|
||||
//
|
||||
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/buildInfo.mat
Normal file
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/buildInfo.mat
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/codeInfo.mat
Normal file
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/codeInfo.mat
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/codedescriptor.dmr
Normal file
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/codedescriptor.dmr
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/compileInfo.mat
Normal file
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/compileInfo.mat
Normal file
Binary file not shown.
14
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/defines.txt
Normal file
14
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/defines.txt
Normal file
@ -0,0 +1,14 @@
|
||||
MODEL=FSMTreppe
|
||||
NUMST=1
|
||||
NCSTATES=0
|
||||
HAVESTDIO
|
||||
MODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0
|
||||
CLASSIC_INTERFACE=0
|
||||
ALLOCATIONFCN=0
|
||||
TID01EQ=0
|
||||
TERMFCN=1
|
||||
ONESTEPFCN=1
|
||||
MAT_FILE=0
|
||||
MULTI_INSTANCE_CODE=1
|
||||
INTEGER_CODE=0
|
||||
MT=0
|
||||
109
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/ert_main.cpp
Normal file
109
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/ert_main.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
//
|
||||
// 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: ert_main.cpp
|
||||
//
|
||||
// Code generated for Simulink model 'FSMTreppe'.
|
||||
//
|
||||
// Model version : 1.65
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Tue Sep 7 08:47:00 2021
|
||||
//
|
||||
// Target selection: ert.tlc
|
||||
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
|
||||
// Code generation objectives: Unspecified
|
||||
// Validation result: Not run
|
||||
//
|
||||
#include <stddef.h>
|
||||
#include <stdio.h> // This ert_main.c example uses printf/fflush
|
||||
#include "FSMTreppe.h" // Model's header file
|
||||
#include "rtwtypes.h"
|
||||
|
||||
static FSMTreppeModelClass FSMTreppe_Obj;// Instance of model class
|
||||
|
||||
//
|
||||
// Associating rt_OneStep with a real-time clock or interrupt service routine
|
||||
// is what makes the generated code "real-time". The function rt_OneStep is
|
||||
// always associated with the base rate of the model. Subrates are managed
|
||||
// by the base rate from inside the generated code. Enabling/disabling
|
||||
// interrupts and floating point context switches are target specific. This
|
||||
// example code indicates where these should take place relative to executing
|
||||
// the generated code step function. Overrun behavior should be tailored to
|
||||
// your application needs. This example simply sets an error status in the
|
||||
// real-time model and returns from rt_OneStep.
|
||||
//
|
||||
void rt_OneStep(void);
|
||||
void rt_OneStep(void)
|
||||
{
|
||||
static boolean_T OverrunFlag = false;
|
||||
|
||||
// Disable interrupts here
|
||||
|
||||
// Check for overrun
|
||||
if (OverrunFlag) {
|
||||
rtmSetErrorStatus(FSMTreppe_Obj.getRTM(), "Overrun");
|
||||
return;
|
||||
}
|
||||
|
||||
OverrunFlag = true;
|
||||
|
||||
// Save FPU context here (if necessary)
|
||||
// Re-enable timer or interrupt here
|
||||
// Set model inputs here
|
||||
|
||||
// Step the model
|
||||
FSMTreppe_Obj.step();
|
||||
|
||||
// Get model outputs here
|
||||
|
||||
// Indicate task complete
|
||||
OverrunFlag = false;
|
||||
|
||||
// Disable interrupts here
|
||||
// Restore FPU context here (if necessary)
|
||||
// Enable interrupts here
|
||||
}
|
||||
|
||||
//
|
||||
// The example "main" function illustrates what is required by your
|
||||
// application code to initialize, execute, and terminate the generated code.
|
||||
// Attaching rt_OneStep to a real-time clock is target specific. This example
|
||||
// illustrates how you do this relative to initializing the model.
|
||||
//
|
||||
int_T main(int_T argc, const char *argv[])
|
||||
{
|
||||
// Unused arguments
|
||||
(void)(argc);
|
||||
(void)(argv);
|
||||
|
||||
// Initialize model
|
||||
FSMTreppe_Obj.initialize();
|
||||
|
||||
// Attach rt_OneStep to a timer or interrupt service routine with
|
||||
// period 0.01 seconds (the model's base sample time) here. The
|
||||
// call syntax for rt_OneStep is
|
||||
//
|
||||
// rt_OneStep();
|
||||
|
||||
printf("Warning: The simulation will run forever. "
|
||||
"Generated ERT main won't simulate model step behavior. "
|
||||
"To change this behavior select the 'MAT-file logging' option.\n");
|
||||
fflush((NULL));
|
||||
while (rtmGetErrorStatus(FSMTreppe_Obj.getRTM()) == (NULL)) {
|
||||
// Perform other application tasks here
|
||||
}
|
||||
|
||||
// Disable rt_OneStep() here
|
||||
|
||||
// Terminate model
|
||||
FSMTreppe_Obj.terminate();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// File trailer for generated code.
|
||||
//
|
||||
// [EOF]
|
||||
//
|
||||
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/make_exception.mat
Normal file
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/make_exception.mat
Normal file
Binary file not shown.
2
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/modelsources.txt
Normal file
2
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/modelsources.txt
Normal file
@ -0,0 +1,2 @@
|
||||
FSMTreppe.cpp
|
||||
|
||||
4
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/rtw_proj.tmw
Normal file
4
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/rtw_proj.tmw
Normal file
@ -0,0 +1,4 @@
|
||||
Simulink Coder project for FSMTreppe using . MATLAB root = C:\Program Files\MATLAB\R2021a. SimStruct date: 15-Nov-2020 02:10:14
|
||||
This file is generated by Simulink Coder for use by the make utility
|
||||
to determine when to rebuild objects when the name of the current Simulink Coder project changes.
|
||||
The rtwinfomat located at: ..\slprj\ert\FSMTreppe\tmwinternal\binfo.mat
|
||||
160
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/rtwtypes.h
Normal file
160
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/rtwtypes.h
Normal file
@ -0,0 +1,160 @@
|
||||
//
|
||||
// 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: rtwtypes.h
|
||||
//
|
||||
// Code generated for Simulink model 'FSMTreppe'.
|
||||
//
|
||||
// Model version : 1.65
|
||||
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||
// C/C++ source code generated on : Tue Sep 7 08:47:00 2021
|
||||
//
|
||||
// Target selection: ert.tlc
|
||||
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
|
||||
// Code generation objectives: Unspecified
|
||||
// Validation result: Not run
|
||||
//
|
||||
|
||||
#ifndef RTWTYPES_H
|
||||
#define RTWTYPES_H
|
||||
|
||||
// Logical type definitions
|
||||
#if (!defined(__cplusplus))
|
||||
#ifndef false
|
||||
#define false (0U)
|
||||
#endif
|
||||
|
||||
#ifndef true
|
||||
#define true (1U)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//=======================================================================*
|
||||
// Target hardware information
|
||||
// Device type: ARM Compatible->ARM Cortex-M
|
||||
// Number of bits: char: 8 short: 16 int: 32
|
||||
// long: 32
|
||||
// native word size: 32
|
||||
// Byte ordering: LittleEndian
|
||||
// Signed integer division rounds to: Zero
|
||||
// Shift right on a signed integer as arithmetic shift: on
|
||||
// =======================================================================
|
||||
|
||||
//=======================================================================*
|
||||
// Fixed width word size data types: *
|
||||
// int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
|
||||
// uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
|
||||
// real32_T, real64_T - 32 and 64 bit floating point numbers *
|
||||
// =======================================================================
|
||||
typedef signed char int8_T;
|
||||
typedef unsigned char uint8_T;
|
||||
typedef short int16_T;
|
||||
typedef unsigned short uint16_T;
|
||||
typedef int int32_T;
|
||||
typedef unsigned int uint32_T;
|
||||
typedef float real32_T;
|
||||
typedef double real64_T;
|
||||
|
||||
//===========================================================================*
|
||||
// Generic type definitions: boolean_T, char_T, byte_T, int_T, uint_T, *
|
||||
// real_T, time_T, ulong_T. *
|
||||
// ===========================================================================
|
||||
typedef double real_T;
|
||||
typedef double time_T;
|
||||
typedef unsigned char boolean_T;
|
||||
typedef int int_T;
|
||||
typedef unsigned int uint_T;
|
||||
typedef unsigned long ulong_T;
|
||||
typedef char char_T;
|
||||
typedef unsigned char uchar_T;
|
||||
typedef char_T byte_T;
|
||||
|
||||
//===========================================================================*
|
||||
// Complex number type definitions *
|
||||
// ===========================================================================
|
||||
#define CREAL_T
|
||||
|
||||
typedef struct {
|
||||
real32_T re;
|
||||
real32_T im;
|
||||
} creal32_T;
|
||||
|
||||
typedef struct {
|
||||
real64_T re;
|
||||
real64_T im;
|
||||
} creal64_T;
|
||||
|
||||
typedef struct {
|
||||
real_T re;
|
||||
real_T im;
|
||||
} creal_T;
|
||||
|
||||
#define CINT8_T
|
||||
|
||||
typedef struct {
|
||||
int8_T re;
|
||||
int8_T im;
|
||||
} cint8_T;
|
||||
|
||||
#define CUINT8_T
|
||||
|
||||
typedef struct {
|
||||
uint8_T re;
|
||||
uint8_T im;
|
||||
} cuint8_T;
|
||||
|
||||
#define CINT16_T
|
||||
|
||||
typedef struct {
|
||||
int16_T re;
|
||||
int16_T im;
|
||||
} cint16_T;
|
||||
|
||||
#define CUINT16_T
|
||||
|
||||
typedef struct {
|
||||
uint16_T re;
|
||||
uint16_T im;
|
||||
} cuint16_T;
|
||||
|
||||
#define CINT32_T
|
||||
|
||||
typedef struct {
|
||||
int32_T re;
|
||||
int32_T im;
|
||||
} cint32_T;
|
||||
|
||||
#define CUINT32_T
|
||||
|
||||
typedef struct {
|
||||
uint32_T re;
|
||||
uint32_T im;
|
||||
} cuint32_T;
|
||||
|
||||
//=======================================================================*
|
||||
// Min and Max: *
|
||||
// int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
|
||||
// uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
|
||||
// =======================================================================
|
||||
#define MAX_int8_T ((int8_T)(127))
|
||||
#define MIN_int8_T ((int8_T)(-128))
|
||||
#define MAX_uint8_T ((uint8_T)(255U))
|
||||
#define MAX_int16_T ((int16_T)(32767))
|
||||
#define MIN_int16_T ((int16_T)(-32768))
|
||||
#define MAX_uint16_T ((uint16_T)(65535U))
|
||||
#define MAX_int32_T ((int32_T)(2147483647))
|
||||
#define MIN_int32_T ((int32_T)(-2147483647-1))
|
||||
#define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU))
|
||||
|
||||
// Block D-Work pointer type
|
||||
typedef void * pointer_T;
|
||||
|
||||
#endif // RTWTYPES_H
|
||||
|
||||
//
|
||||
// File trailer for generated code.
|
||||
//
|
||||
// [EOF]
|
||||
//
|
||||
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/rtwtypeschksum.mat
Normal file
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/rtwtypeschksum.mat
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/tmwinternal/tr
Normal file
BIN
lib/treppe/MatLabSrc/FSMTreppe_ert_rtw/tmwinternal/tr
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/FSM_Treppenlicht.slx
Normal file
BIN
lib/treppe/MatLabSrc/FSM_Treppenlicht.slx
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/jitEngineAccessInfo.mat
Normal file
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/jitEngineAccessInfo.mat
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/s62r8ORs8TiuwKiY4lPlaeC.l
Normal file
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/s62r8ORs8TiuwKiY4lPlaeC.l
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/s62r8ORs8TiuwKiY4lPlaeC.mat
Normal file
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/s62r8ORs8TiuwKiY4lPlaeC.mat
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/sTGUi98rQlfFIIKcc1lBYo.l
Normal file
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/sTGUi98rQlfFIIKcc1lBYo.l
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/sTGUi98rQlfFIIKcc1lBYo.mat
Normal file
BIN
lib/treppe/MatLabSrc/slprj/_jitprj/sTGUi98rQlfFIIKcc1lBYo.mat
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,49 @@
|
||||
%implements "machineSource" "C"
|
||||
%function CacheMachineDefinitions(block,system) void
|
||||
%openfile tmpFcnBuf
|
||||
%closefile tmpFcnBuf
|
||||
%<SLibCacheCodeToFile("sf_machine_data_defn",tmpFcnBuf)>\
|
||||
|
||||
%endfunction
|
||||
%function DumpMachineInitializer(block) Output
|
||||
|
||||
%openfile tmpFcnBuf
|
||||
|
||||
%closefile tmpFcnBuf
|
||||
%if !WHITE_SPACE(tmpFcnBuf)
|
||||
|
||||
/* Machine initializer */
|
||||
%<tmpFcnBuf>\
|
||||
%endif
|
||||
%endfunction
|
||||
%function GlobalMachineInitializer(block) void
|
||||
%openfile tmpFcnBuf
|
||||
%<DumpMachineInitializer(block)>\
|
||||
%closefile tmpFcnBuf
|
||||
%return tmpFcnBuf
|
||||
%endfunction %% GlobalMachineInitializer
|
||||
|
||||
%function DumpMachineTerminator(block) Output
|
||||
%openfile tmpFcnBuf
|
||||
|
||||
%closefile tmpFcnBuf
|
||||
%if !WHITE_SPACE(tmpFcnBuf)
|
||||
|
||||
/* Machine initializer */
|
||||
%<tmpFcnBuf>\
|
||||
%endif
|
||||
%endfunction
|
||||
%function GlobalMachineTerminator(block) void
|
||||
%openfile tmpFcnBuf
|
||||
%<DumpMachineTerminator(block)>\
|
||||
%closefile tmpFcnBuf
|
||||
%return tmpFcnBuf
|
||||
%endfunction %% GlobalMachineTerminator
|
||||
|
||||
%function CacheMachineFunctions(block,system) void
|
||||
%openfile tmpFcnBuf
|
||||
|
||||
|
||||
%closefile tmpFcnBuf
|
||||
%<SLibCacheCodeToFile("sf_machine_fcn_defn",tmpFcnBuf)>
|
||||
%endfunction
|
||||
@ -0,0 +1,40 @@
|
||||
%implements "machineHeader" "C"
|
||||
%function CacheOutputs(block,system) void
|
||||
%assign srcFileName = SLibGetFullFileNameForSystemCode("sys_src_incl", system.SystemIdx)
|
||||
%openfile typedefsBuf
|
||||
|
||||
%closefile typedefsBuf
|
||||
%<SLibCacheCodeToFile("sf_machine_typedef",typedefsBuf)>
|
||||
%if !WHITE_SPACE(typedefsBuf)
|
||||
%<SLibUpdateHeadersNeededByFile(srcFileName, SLibGetFullFileNameForCode("sf_machine_typedef"))>
|
||||
%endif
|
||||
%openfile definesBuf
|
||||
%closefile definesBuf
|
||||
%<SLibCacheCodeToFile("sf_machine_data_define",definesBuf)>
|
||||
%if !WHITE_SPACE(definesBuf)
|
||||
%<SLibUpdateHeadersNeededByFile(srcFileName, SLibGetFullFileNameForCode("sf_machine_data_define"))>
|
||||
%endif
|
||||
%openfile externDataBuf
|
||||
%closefile externDataBuf
|
||||
%<SLibCacheCodeToFile("sf_machine_extern_data_decl",externDataBuf)>
|
||||
%if !WHITE_SPACE(externDataBuf)
|
||||
%<SLibUpdateHeadersNeededByFile(srcFileName, SLibGetFullFileNameForCode("sf_machine_extern_data_decl"))>
|
||||
%endif
|
||||
%openfile externDataBuf
|
||||
%closefile externDataBuf
|
||||
%<SLibCacheCodeToFile("sf_machine_public_extern_data_decl",externDataBuf)>
|
||||
%if !WHITE_SPACE(externDataBuf)
|
||||
%<SLibUpdateHeadersNeededByFile(srcFileName, SLibGetFullFileNameForCode("sf_machine_public_extern_data_decl"))>
|
||||
%endif
|
||||
%openfile externDataBuf
|
||||
|
||||
|
||||
|
||||
%closefile externDataBuf
|
||||
%<SLibCacheCodeToFile("sf_machine_extern_fcn_decl",externDataBuf)>
|
||||
%if !WHITE_SPACE(externDataBuf)
|
||||
%<SLibUpdateHeadersNeededByFile(srcFileName, SLibGetFullFileNameForCode("sf_machine_extern_fcn_decl"))>
|
||||
%endif
|
||||
%endfunction %% CacheOutputs
|
||||
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
%implements "chartSource" "C"
|
||||
%function ChartConfig(block, system) void
|
||||
%createrecord chartConfiguration { ...
|
||||
executeAtInitialization 0 ...
|
||||
}
|
||||
%return chartConfiguration
|
||||
%endfunction
|
||||
%function ChartDataMap(block, system) void
|
||||
%createrecord ChartDataElements {\
|
||||
NumChartData 3 \
|
||||
ChartDataDefaults {\
|
||||
RecordType "ChartData"\
|
||||
Dimensions []\
|
||||
IsTestPoint 0\
|
||||
}\
|
||||
ChartData {\
|
||||
Name "is_active_c3_FSMTreppe"\
|
||||
Description "StateIsActive"\
|
||||
SFName ""\
|
||||
Path ""\
|
||||
SrcLocation ""\
|
||||
}\
|
||||
ChartData {\
|
||||
Name "is_c3_FSMTreppe"\
|
||||
Description "StateActiveChild"\
|
||||
SFName ""\
|
||||
Path ""\
|
||||
SrcLocation ""\
|
||||
}\
|
||||
ChartData {\
|
||||
Name "temporalCounter_i1"\
|
||||
Description "TemporalCounter"\
|
||||
SFName ""\
|
||||
Path ""\
|
||||
SrcLocation ""\
|
||||
}\
|
||||
}
|
||||
%return ChartDataElements
|
||||
%endfunction
|
||||
@ -0,0 +1 @@
|
||||
|
||||
BIN
lib/treppe/MatLabSrc/slprj/_sfprj/FSMTreppe/amsi_serial.mat
Normal file
BIN
lib/treppe/MatLabSrc/slprj/_sfprj/FSMTreppe/amsi_serial.mat
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,369 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MF0 version="1.1" packageUris="http://schema.mathworks.com/mf0/ci/19700101 http://schema.mathworks.com/mf0/sl_modelref_info/R2021a http://schema.mathworks.com/mf0/slexec_mm_sto/R2021a_202007071525">
|
||||
<ModelRefInfoRepo.ModelRefInfoRoot type="ModelRefInfoRepo.ModelRefInfoRoot" uuid="8c91d049-4f97-4bab-9878-75249f9e4ce5">
|
||||
<autoSolverStatusFlags>327</autoSolverStatusFlags>
|
||||
<childModelRefInfo type="ModelRefInfoRepo.ChildModelRefInfo" uuid="a6d6d289-18e5-4e3a-a084-25aa29dfde4c">
|
||||
<modelName>FSMTreppe</modelName>
|
||||
<modelPath>FSMTreppe</modelPath>
|
||||
</childModelRefInfo>
|
||||
<dataTransferInfos>AAFJTQAAAAAOAAAAOAAAAAYAAAAIAAAAAgAAAAAAAAAFAAAACAAAAAAAAAABAAAAAQAAAAAAAAAFAAQAAQAAAAEAAAAAAAAA</dataTransferInfos>
|
||||
<fundamentalSampleTimePeriod>.01</fundamentalSampleTimePeriod>
|
||||
<hasBlockWithPeriodicDiscreteSampleTime>true</hasBlockWithPeriodicDiscreteSampleTime>
|
||||
<hasBwsAccessed>true</hasBwsAccessed>
|
||||
<hasBwsAccessedByAnyModel>true</hasBwsAccessedByAnyModel>
|
||||
<hasStatesModifiedInOutputUpdate>true</hasStatesModifiedInOutputUpdate>
|
||||
<inports type="ModelRefInfoRepo.InportInformation" uuid="3dc97546-0910-427f-9bc7-9e91fec18867">
|
||||
<isNotDerivPort>true</isNotDerivPort>
|
||||
<designMax>Inf</designMax>
|
||||
<designMin>-Inf</designMin>
|
||||
<indexType>2</indexType>
|
||||
<rateInfo type="ModelRefInfoRepo.RateInfo">
|
||||
<compiled>true</compiled>
|
||||
<nonFcnCallPartitionName>D1</nonFcnCallPartitionName>
|
||||
<period>.01</period>
|
||||
<priority>40</priority>
|
||||
<rateIdx>0</rateIdx>
|
||||
</rateInfo>
|
||||
<resolvedSignalObject></resolvedSignalObject>
|
||||
<sigNameToEMVCEMap type="ModelRefInfoRepo.SigNameEMVCEInfo" uuid="9cd81293-70da-4c16-8844-138377fd2ffa"/>
|
||||
</inports>
|
||||
<inports type="ModelRefInfoRepo.InportInformation" uuid="f73563dc-9c8d-4480-99e9-2c0b052edfc9">
|
||||
<isNotDerivPort>true</isNotDerivPort>
|
||||
<designMax>Inf</designMax>
|
||||
<designMin>-Inf</designMin>
|
||||
<indexType>2</indexType>
|
||||
<originalPortNumber>1</originalPortNumber>
|
||||
<rateInfo type="ModelRefInfoRepo.RateInfo">
|
||||
<compiled>true</compiled>
|
||||
<nonFcnCallPartitionName>D1</nonFcnCallPartitionName>
|
||||
<period>.01</period>
|
||||
<priority>40</priority>
|
||||
<rateIdx>0</rateIdx>
|
||||
</rateInfo>
|
||||
<resolvedSignalObject></resolvedSignalObject>
|
||||
<sigNameToEMVCEMap type="ModelRefInfoRepo.SigNameEMVCEInfo" uuid="98c95bd5-dcdd-41dd-87c0-d47532b36c10"/>
|
||||
</inports>
|
||||
<inports type="ModelRefInfoRepo.InportInformation" uuid="2034510f-ecff-4ad3-b7a1-bd08f645356b">
|
||||
<isNotDerivPort>true</isNotDerivPort>
|
||||
<designMax>Inf</designMax>
|
||||
<designMin>-Inf</designMin>
|
||||
<indexType>2</indexType>
|
||||
<originalPortNumber>2</originalPortNumber>
|
||||
<rateInfo type="ModelRefInfoRepo.RateInfo">
|
||||
<compiled>true</compiled>
|
||||
<nonFcnCallPartitionName>D1</nonFcnCallPartitionName>
|
||||
<period>.01</period>
|
||||
<priority>40</priority>
|
||||
<rateIdx>0</rateIdx>
|
||||
</rateInfo>
|
||||
<resolvedSignalObject></resolvedSignalObject>
|
||||
<sigNameToEMVCEMap type="ModelRefInfoRepo.SigNameEMVCEInfo" uuid="cd2922c2-d42f-4799-aeec-e36598671a09"/>
|
||||
</inports>
|
||||
<inports type="ModelRefInfoRepo.InportInformation" uuid="cc6453dd-0d6b-44c7-ae81-7ae9ea6fee69">
|
||||
<isNotDerivPort>true</isNotDerivPort>
|
||||
<designMax>Inf</designMax>
|
||||
<designMin>-Inf</designMin>
|
||||
<indexType>2</indexType>
|
||||
<originalPortNumber>3</originalPortNumber>
|
||||
<rateInfo type="ModelRefInfoRepo.RateInfo">
|
||||
<compiled>true</compiled>
|
||||
<nonFcnCallPartitionName>D1</nonFcnCallPartitionName>
|
||||
<period>.01</period>
|
||||
<priority>40</priority>
|
||||
<rateIdx>0</rateIdx>
|
||||
</rateInfo>
|
||||
<resolvedSignalObject></resolvedSignalObject>
|
||||
<sigNameToEMVCEMap type="ModelRefInfoRepo.SigNameEMVCEInfo" uuid="b541c213-306d-4f84-a877-ad3423724d21"/>
|
||||
</inports>
|
||||
<inports type="ModelRefInfoRepo.InportInformation" uuid="bd911fe8-045d-4191-ba64-990a9b0baba8">
|
||||
<isNotDerivPort>true</isNotDerivPort>
|
||||
<designMax>Inf</designMax>
|
||||
<designMin>-Inf</designMin>
|
||||
<indexType>2</indexType>
|
||||
<originalPortNumber>4</originalPortNumber>
|
||||
<rateInfo type="ModelRefInfoRepo.RateInfo">
|
||||
<compiled>true</compiled>
|
||||
<nonFcnCallPartitionName>D1</nonFcnCallPartitionName>
|
||||
<period>.01</period>
|
||||
<priority>40</priority>
|
||||
<rateIdx>0</rateIdx>
|
||||
</rateInfo>
|
||||
<resolvedSignalObject></resolvedSignalObject>
|
||||
<sigNameToEMVCEMap type="ModelRefInfoRepo.SigNameEMVCEInfo" uuid="9282f124-0226-4425-9c6a-8fbc484d8f62"/>
|
||||
</inports>
|
||||
<isBdInSimModeForSimCodegenVariants>false</isBdInSimModeForSimCodegenVariants>
|
||||
<isInlineParamsOn>true</isInlineParamsOn>
|
||||
<isOrigInportVirtualBus>false</isOrigInportVirtualBus>
|
||||
<isOrigInportVirtualBus>false</isOrigInportVirtualBus>
|
||||
<isOrigInportVirtualBus>false</isOrigInportVirtualBus>
|
||||
<isOrigInportVirtualBus>false</isOrigInportVirtualBus>
|
||||
<isOrigInportVirtualBus>false</isOrigInportVirtualBus>
|
||||
<isOrigOutportVirtualBus>false</isOrigOutportVirtualBus>
|
||||
<isOrigOutportVirtualBus>false</isOrigOutportVirtualBus>
|
||||
<isOrigOutportVirtualBus>false</isOrigOutportVirtualBus>
|
||||
<loggingSaveFormat>2</loggingSaveFormat>
|
||||
<maxFreqHz>-1.0</maxFreqHz>
|
||||
<numDataInputPorts>5</numDataInputPorts>
|
||||
<numLoggableJacobianDStates>0</numLoggableJacobianDStates>
|
||||
<origInportBusType></origInportBusType>
|
||||
<origInportBusType></origInportBusType>
|
||||
<origInportBusType></origInportBusType>
|
||||
<origInportBusType></origInportBusType>
|
||||
<origInportBusType></origInportBusType>
|
||||
<origOutportBusOutputAsStruct>false</origOutportBusOutputAsStruct>
|
||||
<origOutportBusOutputAsStruct>false</origOutportBusOutputAsStruct>
|
||||
<origOutportBusOutputAsStruct>false</origOutportBusOutputAsStruct>
|
||||
<origOutportBusType></origOutportBusType>
|
||||
<origOutportBusType></origOutportBusType>
|
||||
<origOutportBusType></origOutportBusType>
|
||||
<outports type="ModelRefInfoRepo.OutportInformation" uuid="730188ea-a135-4ebe-90bf-6d86de487f40">
|
||||
<hasSystemInitMethod>true</hasSystemInitMethod>
|
||||
<designMax>Inf</designMax>
|
||||
<designMin>-Inf</designMin>
|
||||
<rateInfo type="ModelRefInfoRepo.RateInfo">
|
||||
<compiled>true</compiled>
|
||||
<nonFcnCallPartitionName>D1</nonFcnCallPartitionName>
|
||||
<period>.01</period>
|
||||
<priority>40</priority>
|
||||
<rateIdx>0</rateIdx>
|
||||
</rateInfo>
|
||||
<resolvedSignalObject></resolvedSignalObject>
|
||||
<sigNameToEMVCEMap type="ModelRefInfoRepo.SigNameEMVCEInfo" uuid="022f3f70-d650-4c09-b92e-a82eae70cca0"/>
|
||||
</outports>
|
||||
<outports type="ModelRefInfoRepo.OutportInformation" uuid="a4bd5e44-5daa-439d-9fcd-074b1f23791b">
|
||||
<hasSystemInitMethod>true</hasSystemInitMethod>
|
||||
<designMax>Inf</designMax>
|
||||
<designMin>-Inf</designMin>
|
||||
<originalPortNumber>1</originalPortNumber>
|
||||
<rateInfo type="ModelRefInfoRepo.RateInfo">
|
||||
<compiled>true</compiled>
|
||||
<nonFcnCallPartitionName>D1</nonFcnCallPartitionName>
|
||||
<period>.01</period>
|
||||
<priority>40</priority>
|
||||
<rateIdx>0</rateIdx>
|
||||
</rateInfo>
|
||||
<resolvedSignalObject></resolvedSignalObject>
|
||||
<sigNameToEMVCEMap type="ModelRefInfoRepo.SigNameEMVCEInfo" uuid="9a85f83a-af2f-4a8b-8b39-f87903bab9e3"/>
|
||||
</outports>
|
||||
<outports type="ModelRefInfoRepo.OutportInformation" uuid="b045b60e-3dae-4adc-990e-4bb63a007aa3">
|
||||
<hasSystemInitMethod>true</hasSystemInitMethod>
|
||||
<designMax>Inf</designMax>
|
||||
<designMin>-Inf</designMin>
|
||||
<originalPortNumber>2</originalPortNumber>
|
||||
<rateInfo type="ModelRefInfoRepo.RateInfo">
|
||||
<compiled>true</compiled>
|
||||
<nonFcnCallPartitionName>D1</nonFcnCallPartitionName>
|
||||
<period>.01</period>
|
||||
<priority>40</priority>
|
||||
<rateIdx>0</rateIdx>
|
||||
</rateInfo>
|
||||
<resolvedSignalObject></resolvedSignalObject>
|
||||
<sigNameToEMVCEMap type="ModelRefInfoRepo.SigNameEMVCEInfo" uuid="c528ad7d-8ccf-4847-9b02-7492d282a463"/>
|
||||
</outports>
|
||||
<removeResetFunc>true</removeResetFunc>
|
||||
<runtimeNonFcnCallRateInfos type="ModelRefInfoRepo.RateInfo">
|
||||
<compiled>true</compiled>
|
||||
<nonFcnCallPartitionName>D1</nonFcnCallPartitionName>
|
||||
<period>.01</period>
|
||||
<priority>40</priority>
|
||||
<rateIdx>0</rateIdx>
|
||||
</runtimeNonFcnCallRateInfos>
|
||||
<sampleTimeInheritanceRule>2</sampleTimeInheritanceRule>
|
||||
<timingAndTaskingRegistry><?xml version="1.0"?>
|
||||
<slexec_sto version="1.1" packageUris="http://schema.mathworks.com/mf0/slexec_mm_sto/R2021a_202007071525">
|
||||
<sto.Registry type="sto.Registry" uuid="9b7d34e5-9d96-44f0-b2a3-9f989daf3c92">
|
||||
<clocks type="sto.Timer" uuid="626dfc1a-2af1-4bf4-b453-3f3a1fda66c1">
|
||||
<computedFundamentalDiscretePeriod>.01</computedFundamentalDiscretePeriod>
|
||||
<resolution>.01</resolution>
|
||||
<clockTickConstraint>PeriodicWithFixedResolution</clockTickConstraint>
|
||||
<specifiedTaskingMode>ClassicMultiTasking</specifiedTaskingMode>
|
||||
<timeAdvanceMode>FixedStep</timeAdvanceMode>
|
||||
<clockDomain type="sto.ClockDomain" uuid="e7bc3f67-5218-4c0d-9dea-3c07a32eafc4">
|
||||
<baseTaskID>_task0</baseTaskID>
|
||||
<rates type="sto.Rate" uuid="d4495b93-a61c-4a6a-81c8-0f9b18a67d05"/>
|
||||
<rootTaskHierarchyElements type="sto.Task" uuid="5a391a5c-a43d-4aa9-bc41-2a93663da7b2">
|
||||
<isExecutable>true</isExecutable>
|
||||
<orderIndex>1</orderIndex>
|
||||
<rates type="sto.Rate" uuid="d4495b93-a61c-4a6a-81c8-0f9b18a67d05">
|
||||
<annotation>D1</annotation>
|
||||
<colorIndex>2</colorIndex>
|
||||
<description>Discrete 1</description>
|
||||
<eventSourceType>UNSPECIFIED_EVENT_SOURCE</eventSourceType>
|
||||
<registry type="sto.Registry" uuid="9b7d34e5-9d96-44f0-b2a3-9f989daf3c92"/>
|
||||
<taskId>_task0</taskId>
|
||||
<rateSpec type="sto.RateSpec" uuid="ae5af4bd-9e1d-4b56-893c-68e4b2480f8d">
|
||||
<period>.01</period>
|
||||
<rateType>ClassicPeriodicDiscrete</rateType>
|
||||
</rateSpec>
|
||||
</rates>
|
||||
<elementType>Task</elementType>
|
||||
<identifier>_task0</identifier>
|
||||
<priority>40</priority>
|
||||
</rootTaskHierarchyElements>
|
||||
</clockDomain>
|
||||
</clocks>
|
||||
<executionSpec>Undetermined</executionSpec>
|
||||
<taskDependencyGraph type="sto.SerializedTaskConnectionList" uuid="f3e9c73b-bb20-4ef6-a737-eff2b3a03780">
|
||||
<taskIdentifier>_task0</taskIdentifier>
|
||||
</taskDependencyGraph>
|
||||
<taskPriorityDirection>HighNumberLast</taskPriorityDirection>
|
||||
<taskingMode>ClassicMultiTasking</taskingMode>
|
||||
<tasks type="sto.Task" uuid="5a391a5c-a43d-4aa9-bc41-2a93663da7b2"/>
|
||||
<timeAdvanceMode>FixedStep</timeAdvanceMode>
|
||||
</sto.Registry>
|
||||
</slexec_sto></timingAndTaskingRegistry>
|
||||
<zeroInternalMemoryAtStartupUnchecked>true</zeroInternalMemoryAtStartupUnchecked>
|
||||
<FMUBlockMap type="ModelRefInfoRepo.FMUBlockInfo" uuid="b93b26b0-22f0-4764-a798-053907f178f4"/>
|
||||
<codeGenInfo type="ModelRefInfoRepo.CodeGenInformation" uuid="d598be23-3911-4922-9ca1-b6dca592cdf8"/>
|
||||
<configSettingsForConsistencyChecks type="ModelRefInfoRepo.ConfigSettingsForConsistencyChecks" uuid="79532f7e-333b-46dc-830a-de1e37104a81">
|
||||
<consistentOutportInitialization>true</consistentOutportInitialization>
|
||||
<fixedStepSize>.01</fixedStepSize>
|
||||
<hasHybridSampleTime>true</hasHybridSampleTime>
|
||||
<optimizedInitCode>true</optimizedInitCode>
|
||||
<signalLoggingSaveFormat>2</signalLoggingSaveFormat>
|
||||
<simSIMDOptimization>1</simSIMDOptimization>
|
||||
<solverName>FixedStepDiscrete</solverName>
|
||||
<solverType>SOLVER_TYPE_FIXEDSTEP</solverType>
|
||||
<hardwareSettings type="ModelRefInfoRepo.HardwareSettings" uuid="69f559cc-e983-4421-8260-4b0ab3d57945">
|
||||
<prodBitPerChar>8</prodBitPerChar>
|
||||
<prodBitPerDouble>64</prodBitPerDouble>
|
||||
<prodBitPerFloat>32</prodBitPerFloat>
|
||||
<prodBitPerInt>32</prodBitPerInt>
|
||||
<prodBitPerLong>32</prodBitPerLong>
|
||||
<prodBitPerLongLong>64</prodBitPerLongLong>
|
||||
<prodBitPerPointer>32</prodBitPerPointer>
|
||||
<prodBitPerPtrDiffT>32</prodBitPerPtrDiffT>
|
||||
<prodBitPerShort>16</prodBitPerShort>
|
||||
<prodBitPerSizeT>32</prodBitPerSizeT>
|
||||
<prodEndianess>1</prodEndianess>
|
||||
<prodLargestAtomicFloat>1</prodLargestAtomicFloat>
|
||||
<prodLargestAtomicInteger>3</prodLargestAtomicInteger>
|
||||
<prodShiftRight>true</prodShiftRight>
|
||||
<prodWordSize>32</prodWordSize>
|
||||
</hardwareSettings>
|
||||
</configSettingsForConsistencyChecks>
|
||||
<controllableInputRatesMap type="ModelRefInfoRepo.VarTsUIDMap" uuid="188fca95-6ffa-4497-91c4-097c5c5aee33"/>
|
||||
<controllableOutputRatesMap type="ModelRefInfoRepo.VarTsUIDMap" uuid="34d898ee-0488-42bb-be25-40cbd6819eaf"/>
|
||||
<dataPortGroup type="ModelRefInfoRepo.DataPortGroup" uuid="99ea55ca-19b6-439c-b494-ab33265aa22b">
|
||||
<compDataInputPorts>0</compDataInputPorts>
|
||||
<compDataInputPorts>1</compDataInputPorts>
|
||||
<compDataInputPorts>2</compDataInputPorts>
|
||||
<compDataInputPorts>3</compDataInputPorts>
|
||||
<compDataInputPorts>4</compDataInputPorts>
|
||||
<compDataOutputPorts>0</compDataOutputPorts>
|
||||
<compDataOutputPorts>1</compDataOutputPorts>
|
||||
<compDataOutputPorts>2</compDataOutputPorts>
|
||||
<dataInputPorts>0</dataInputPorts>
|
||||
<dataInputPorts>1</dataInputPorts>
|
||||
<dataInputPorts>2</dataInputPorts>
|
||||
<dataInputPorts>3</dataInputPorts>
|
||||
<dataInputPorts>4</dataInputPorts>
|
||||
<dataOutputPorts>0</dataOutputPorts>
|
||||
<dataOutputPorts>1</dataOutputPorts>
|
||||
<dataOutputPorts>2</dataOutputPorts>
|
||||
</dataPortGroup>
|
||||
<expFcnUnconnectedDataPortGroup type="ModelRefInfoRepo.DataPortGroup" uuid="9857c752-3ac8-4e50-8860-b306bd783dd4"/>
|
||||
<interfaceParameterInfo type="ModelRefInfoRepo.InterfaceParameterInfo" uuid="e1381a12-d132-4b2a-8837-635f4863a9c2"/>
|
||||
<messageInfo type="ModelRefInfoRepo.MessageInformation" uuid="d14ba5d4-7085-4560-87a6-b9de7a83fb36"/>
|
||||
<methodInfo type="ModelRefInfoRepo.MethodExistenceInfo" uuid="d88c6655-e78d-4745-93e1-9f8837d13b0b">
|
||||
<hasEnableMethod>true</hasEnableMethod>
|
||||
<hasSystemInitializeMethod>true</hasSystemInitializeMethod>
|
||||
<hasSystemResetMethod>true</hasSystemResetMethod>
|
||||
<hasTerminateMethod>true</hasTerminateMethod>
|
||||
</methodInfo>
|
||||
<periodicEventPortUnsupportedBlockInfo type="ModelRefInfoRepo.PeriodicEventPortUnsupportedBlockInfo" uuid="f61487e4-ebaf-4b99-9d2b-c4b1ea41af92"/>
|
||||
<portGroupsRequireSameRate type="ModelRefInfoRepo.PortGroupsRequireSameRate" uuid="79702c85-5b35-40f3-ae57-7023f221a663">
|
||||
<DSMPortGroups type="ModelRefInfoRepo.NameToPortGroupIdxVectMap" uuid="6de7bfcb-0451-406e-8e38-16e7fe1c75a6"/>
|
||||
<GlobalDSMPortGroups type="ModelRefInfoRepo.NameToPortGroupIdxVectMap" uuid="6f27c871-22fc-4c10-8f4d-1d41d46055ee"/>
|
||||
<mergedPortGroups type="ModelRefInfoRepo.NameToPortGroupIdxVectMap" uuid="5d9254a5-a2a4-4a98-9aef-3308701c81f0"/>
|
||||
</portGroupsRequireSameRate>
|
||||
<rateBasedMdlGlobalDSMRateSpec type="ModelRefInfoRepo.GlobalDSMRateSpecMap" uuid="a29995d7-52f1-4edd-aaef-698a2a68529b"/>
|
||||
<rateSpecOfGlobalDSMAccessedByDescExpFcnMdlMap type="ModelRefInfoRepo.GlobalDSMRateSpecMap" uuid="45b11e5f-09ce-4444-be7c-9384c8ed3d75"/>
|
||||
<rootBlockDiagramInterface type="ci.Model" uuid="25370f49-f80f-4984-a40b-a7f84df8f739">
|
||||
<p_RootComponentInterface type="ci.ComponentInterface" uuid="70af63cd-69ac-460e-af61-b81475e3805e">
|
||||
<p_InputPorts type="ci.SignalInterface" uuid="05356a46-76c9-496b-b870-a6606a2681b4">
|
||||
<p_ComputedNumericDimensions>1.0</p_ComputedNumericDimensions>
|
||||
<p_ComputedSampleTime>.01</p_ComputedSampleTime>
|
||||
<p_ComputedSampleTime>0.0</p_ComputedSampleTime>
|
||||
<p_ComputedSymbolicDimensions>inherit</p_ComputedSymbolicDimensions>
|
||||
<p_ComputedType>uint32</p_ComputedType>
|
||||
</p_InputPorts>
|
||||
<p_InputPorts type="ci.SignalInterface" uuid="65b4f285-1e30-435e-93ab-dd78ef98157e">
|
||||
<p_ComputedNumericDimensions>1.0</p_ComputedNumericDimensions>
|
||||
<p_ComputedSampleTime>.01</p_ComputedSampleTime>
|
||||
<p_ComputedSampleTime>0.0</p_ComputedSampleTime>
|
||||
<p_ComputedSymbolicDimensions>inherit</p_ComputedSymbolicDimensions>
|
||||
<p_ComputedType>uint32</p_ComputedType>
|
||||
</p_InputPorts>
|
||||
<p_InputPorts type="ci.SignalInterface" uuid="7af0a6c1-c38b-47c3-b02a-8930848add94">
|
||||
<p_ComputedNumericDimensions>1.0</p_ComputedNumericDimensions>
|
||||
<p_ComputedSampleTime>.01</p_ComputedSampleTime>
|
||||
<p_ComputedSampleTime>0.0</p_ComputedSampleTime>
|
||||
<p_ComputedSymbolicDimensions>inherit</p_ComputedSymbolicDimensions>
|
||||
<p_ComputedType>uint32</p_ComputedType>
|
||||
</p_InputPorts>
|
||||
<p_InputPorts type="ci.SignalInterface" uuid="6840ec21-0ff0-4091-9e69-78eafc35d6f5">
|
||||
<p_ComputedNumericDimensions>1.0</p_ComputedNumericDimensions>
|
||||
<p_ComputedSampleTime>.01</p_ComputedSampleTime>
|
||||
<p_ComputedSampleTime>0.0</p_ComputedSampleTime>
|
||||
<p_ComputedSymbolicDimensions>inherit</p_ComputedSymbolicDimensions>
|
||||
<p_ComputedType>uint32</p_ComputedType>
|
||||
</p_InputPorts>
|
||||
<p_InputPorts type="ci.SignalInterface" uuid="11187d0c-88fb-4a76-b6c1-8ae6af93ec59">
|
||||
<p_ComputedNumericDimensions>1.0</p_ComputedNumericDimensions>
|
||||
<p_ComputedSampleTime>.01</p_ComputedSampleTime>
|
||||
<p_ComputedSampleTime>0.0</p_ComputedSampleTime>
|
||||
<p_ComputedSymbolicDimensions>inherit</p_ComputedSymbolicDimensions>
|
||||
<p_ComputedType>uint32</p_ComputedType>
|
||||
</p_InputPorts>
|
||||
<p_Name>FSMTreppe</p_Name>
|
||||
<p_OutputPorts type="ci.SignalInterface" uuid="a983c36b-3a44-48e2-95a5-3cf9884f8810">
|
||||
<p_ComputedNumericDimensions>1.0</p_ComputedNumericDimensions>
|
||||
<p_ComputedSampleTime>.01</p_ComputedSampleTime>
|
||||
<p_ComputedSampleTime>0.0</p_ComputedSampleTime>
|
||||
<p_ComputedSymbolicDimensions>inherit</p_ComputedSymbolicDimensions>
|
||||
<p_ComputedType>uint32</p_ComputedType>
|
||||
</p_OutputPorts>
|
||||
<p_OutputPorts type="ci.SignalInterface" uuid="f099e52b-3f98-4f3d-9a53-e5f41ee8bd93">
|
||||
<p_ComputedNumericDimensions>1.0</p_ComputedNumericDimensions>
|
||||
<p_ComputedSampleTime>.01</p_ComputedSampleTime>
|
||||
<p_ComputedSampleTime>0.0</p_ComputedSampleTime>
|
||||
<p_ComputedSymbolicDimensions>inherit</p_ComputedSymbolicDimensions>
|
||||
<p_ComputedType>uint32</p_ComputedType>
|
||||
</p_OutputPorts>
|
||||
<p_OutputPorts type="ci.SignalInterface" uuid="21fb1cab-f5bf-4b33-8280-97ca7bd77920">
|
||||
<p_ComputedNumericDimensions>1.0</p_ComputedNumericDimensions>
|
||||
<p_ComputedSampleTime>.01</p_ComputedSampleTime>
|
||||
<p_ComputedSampleTime>0.0</p_ComputedSampleTime>
|
||||
<p_ComputedSymbolicDimensions>inherit</p_ComputedSymbolicDimensions>
|
||||
<p_ComputedType>uint32</p_ComputedType>
|
||||
</p_OutputPorts>
|
||||
<p_Type>ROOT</p_Type>
|
||||
</p_RootComponentInterface>
|
||||
</rootBlockDiagramInterface>
|
||||
<simulinkFunctions type="ModelRefInfoRepo.SimulinkFunctions" uuid="d5f398f3-db0d-4011-8e70-b49ab7ad1d2e">
|
||||
<compSimulinkFunctionCatalog></compSimulinkFunctionCatalog>
|
||||
</simulinkFunctions>
|
||||
<stateWriterToOwnerMap type="ModelRefInfoRepo.StateWriterInfo" uuid="bd389837-c442-4b09-904b-968bdf13ec78"/>
|
||||
<stoClientDataRegistry type="sto.ClientDataRegistry" uuid="b745f9d4-b391-4ce6-8b3b-ddfa4c1c3048">
|
||||
<dataSets type="sto.ClientClockNamedDataSet" uuid="295512be-0378-4fde-8696-c3318b490c08">
|
||||
<tag>sltpEvents</tag>
|
||||
</dataSets>
|
||||
<dataSets type="sto.ClientTaskHierarchyElementNamedDataSet" uuid="aee088fb-049d-4150-9f5f-88ba57760916">
|
||||
<tag>sltpTaskGroups</tag>
|
||||
</dataSets>
|
||||
<dataSets type="sto.ClientTaskHierarchyElementNamedDataSet" uuid="26bbddc2-d033-4b56-bd42-4ebc47367e3f">
|
||||
<dSet type="ModelRefInfoRepo.SltpTaskData" uuid="e04174da-4467-4c63-a2fe-3974591c9c06"/>
|
||||
<tSet type="ModelRefInfoRepo.SltpTaskData" uuid="e04174da-4467-4c63-a2fe-3974591c9c06">
|
||||
<dataName>D1</dataName>
|
||||
<linkedSet type="sto.ClientTaskHierarchyElementNamedDataSet" uuid="26bbddc2-d033-4b56-bd42-4ebc47367e3f"/>
|
||||
<id type="sto.TaskHierarchyElementId">
|
||||
<id>_task0</id>
|
||||
</id>
|
||||
</tSet>
|
||||
<tag>sltpTasks</tag>
|
||||
</dataSets>
|
||||
</stoClientDataRegistry>
|
||||
<varTsUIDMap type="ModelRefInfoRepo.VarTsUIDMap" uuid="5509c4d8-513d-44e6-94d3-3b9fa42f55f1"/>
|
||||
</ModelRefInfoRepo.ModelRefInfoRoot>
|
||||
</MF0>
|
||||
BIN
lib/treppe/MatLabSrc/slprj/ert/FSMTreppe/tmwinternal/binfo.mat
Normal file
BIN
lib/treppe/MatLabSrc/slprj/ert/FSMTreppe/tmwinternal/binfo.mat
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/slprj/ert/FSMTreppe/tmwinternal/minfo.mat
Normal file
BIN
lib/treppe/MatLabSrc/slprj/ert/FSMTreppe/tmwinternal/minfo.mat
Normal file
Binary file not shown.
BIN
lib/treppe/MatLabSrc/slprj/ert/FSMTreppe/tmwinternal/scv
Normal file
BIN
lib/treppe/MatLabSrc/slprj/ert/FSMTreppe/tmwinternal/scv
Normal file
Binary file not shown.
Binary file not shown.
BIN
lib/treppe/MatLabSrc/slprj/ert/_sharedutils/shared_file.dmr
Normal file
BIN
lib/treppe/MatLabSrc/slprj/ert/_sharedutils/shared_file.dmr
Normal file
Binary file not shown.
2
lib/treppe/MatLabSrc/slprj/sl_proj.tmw
Normal file
2
lib/treppe/MatLabSrc/slprj/sl_proj.tmw
Normal file
@ -0,0 +1,2 @@
|
||||
Simulink Coder project marker file. Please don't change it.
|
||||
slprjVersion: 10.3_086
|
||||
463
lib/treppe/treppe.cpp
Normal file
463
lib/treppe/treppe.cpp
Normal file
@ -0,0 +1,463 @@
|
||||
#include "treppe.h"
|
||||
// #define DEBUG_TIMING
|
||||
|
||||
/*
|
||||
- dimmer_tick: increment pwm jeden tick, bis anim beendet
|
||||
- return: fsm_pend.anim_beendet
|
||||
*/
|
||||
bool Treppe::dimmer_tick(dimmer_t *dimmer, bool dim_type) {
|
||||
dimmer->pwm += dimmer->delta_pwm;
|
||||
|
||||
#ifdef DIMMDEBUG
|
||||
Serial.printf("%.0f", dimmer->pwm);
|
||||
#endif
|
||||
|
||||
if (dim_type == DIM_STUFEN) {
|
||||
pwmController.setChannelPWM(dimmer->stufe,
|
||||
static_cast<uint16_t>(dimmer->pwm));
|
||||
} else { // DIM_LDR
|
||||
pwmController.setAllChannelsPWM(static_cast<uint16_t>(dimmer->pwm));
|
||||
}
|
||||
|
||||
dimmer->tick++;
|
||||
if (dimmer->tick < dimmer->ticks) {
|
||||
#ifdef DIMMDEBUG
|
||||
Serial.print("-");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#ifdef DIMMDEBUG
|
||||
Serial.println("");
|
||||
#endif
|
||||
|
||||
if (dim_type == DIM_LDR) {
|
||||
Serial.printf("DIM_LDR: start: %d, ziel: %d\n", dimmer->start_pwm,
|
||||
dimmer->ziel_pwm);
|
||||
return true;
|
||||
} else { // DIM_STUFEN
|
||||
Serial.printf("DIM_STUFEN: stufe: %d, start: %d, ziel: %d\n",
|
||||
dimmer->stufe, dimmer->start_pwm, dimmer->ziel_pwm);
|
||||
|
||||
if (fsm_outputs.laufrichtung == LR_HOCH) {
|
||||
if (dimmer->stufe >= stufen - 1)
|
||||
return true;
|
||||
dimmer->stufe++;
|
||||
} else { // LR_RUNTER
|
||||
if (dimmer->stufe <= 0)
|
||||
return true;
|
||||
dimmer->stufe--;
|
||||
}
|
||||
dimmer->tick = 0;
|
||||
dimmer->pwm = dimmer->start_pwm;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// startbedingunen für animation
|
||||
void Treppe::start_animation(dimmer_t *dimmer, bool dim_type, uint16_t on_pwm,
|
||||
uint16_t off_pwm) {
|
||||
fsm_pend.anim_beendet = false;
|
||||
|
||||
if (dim_type == DIM_STUFEN) {
|
||||
if (fsm_outputs.laufrichtung == LR_HOCH)
|
||||
dimmer->stufe = 0;
|
||||
else
|
||||
dimmer->stufe = stufen - 1;
|
||||
|
||||
dimmer->ticks = param.time_per_stair / INT_TIME; // [ms]
|
||||
} else { // DIM_LDR
|
||||
dimmer->ticks = param.time_ldr / INT_TIME; // [ms]
|
||||
}
|
||||
|
||||
if (fsm_outputs.dimmrichtung == DR_AUFDIMMEN) {
|
||||
dimmer->start_pwm = off_pwm;
|
||||
dimmer->ziel_pwm = on_pwm;
|
||||
dimmer->delta_pwm = (float)(on_pwm - off_pwm) / (float)dimmer->ticks;
|
||||
} else {
|
||||
dimmer->start_pwm = on_pwm;
|
||||
dimmer->ziel_pwm = off_pwm;
|
||||
dimmer->delta_pwm = (float)(off_pwm - on_pwm) / (float)dimmer->ticks;
|
||||
}
|
||||
|
||||
dimmer->tick = 0;
|
||||
dimmer->pwm = dimmer->start_pwm;
|
||||
|
||||
#ifndef LDR_REGELUNG
|
||||
idle_pwm_ist = param.idle_pwm_max;
|
||||
#endif
|
||||
|
||||
Serial.printf("stufe %d, ticks %d, delta %f, start %d, ziel %d\n",
|
||||
dimmer->stufe, dimmer->ticks, dimmer->delta_pwm,
|
||||
dimmer->start_pwm, dimmer->ziel_pwm);
|
||||
}
|
||||
|
||||
void Treppe::print_state_on_change() {
|
||||
static FSMTreppeModelClass::ExtU_FSMTreppe_T last_in;
|
||||
static FSMTreppeModelClass::ExtY_FSMTreppe_T last_out;
|
||||
if (fsm_inputs.anim_beendet != last_in.anim_beendet ||
|
||||
fsm_inputs.sensor_oben != last_in.sensor_oben ||
|
||||
fsm_inputs.sensor_unten != last_in.sensor_unten ||
|
||||
fsm_inputs.ldr_schwelle != last_in.ldr_schwelle ||
|
||||
fsm_outputs.dimmrichtung != last_out.dimmrichtung ||
|
||||
fsm_outputs.laufrichtung != last_out.laufrichtung ||
|
||||
fsm_outputs.status != last_out.status) {
|
||||
last_in.anim_beendet = fsm_inputs.anim_beendet;
|
||||
last_in.sensor_oben = fsm_inputs.sensor_oben;
|
||||
last_in.sensor_unten = fsm_inputs.sensor_unten;
|
||||
last_in.ldr_schwelle = fsm_inputs.ldr_schwelle;
|
||||
last_out.dimmrichtung = fsm_outputs.dimmrichtung;
|
||||
last_out.laufrichtung = fsm_outputs.laufrichtung;
|
||||
last_out.status = fsm_outputs.status;
|
||||
|
||||
Serial.printf("FSM IN: s_u: %d, s_o: %d, a_b: %d, l_s: %d => ",
|
||||
fsm_inputs.sensor_oben, fsm_inputs.sensor_unten,
|
||||
fsm_inputs.anim_beendet, fsm_inputs.ldr_schwelle);
|
||||
Serial.printf("OUT: LR: %d DR: %d ST: %d\n", fsm_outputs.laufrichtung,
|
||||
fsm_outputs.dimmrichtung, fsm_outputs.status);
|
||||
}
|
||||
}
|
||||
|
||||
void Treppe::overwrite_sensors(bool s_oben, bool s_unten) {
|
||||
fsm_pend.web_ctrl_s_oben = s_oben;
|
||||
fsm_pend.web_ctrl_s_unten = s_unten;
|
||||
}
|
||||
|
||||
void Treppe::read_sensors() {
|
||||
const bool s_oben = digitalRead(SENSOR_OBEN);
|
||||
const bool s_unten = digitalRead(SENSOR_UNTEN);
|
||||
|
||||
fsm_pend.sensor_oben = false;
|
||||
fsm_pend.sensor_unten = false;
|
||||
|
||||
// rising trigger => 1 cycle true !
|
||||
if (s_oben && !fsm_pend.last_s_oben) {
|
||||
fsm_pend.sensor_oben = true;
|
||||
}
|
||||
if (s_unten && !fsm_pend.last_s_unten) {
|
||||
fsm_pend.sensor_unten = true;
|
||||
}
|
||||
|
||||
fsm_pend.last_s_oben = s_oben;
|
||||
fsm_pend.last_s_unten = s_unten;
|
||||
|
||||
// check for manipulation over webserver
|
||||
if (fsm_pend.web_ctrl_s_oben) {
|
||||
fsm_pend.sensor_oben = true;
|
||||
fsm_pend.web_ctrl_s_oben = false;
|
||||
}
|
||||
if (fsm_pend.web_ctrl_s_unten) {
|
||||
fsm_pend.sensor_unten = true;
|
||||
fsm_pend.web_ctrl_s_unten = false;
|
||||
}
|
||||
}
|
||||
|
||||
float Treppe::read_ldr() {
|
||||
/*
|
||||
Reads Illuminance in Lux
|
||||
|
||||
FUTURE USE : show current Illuminance on Webserver in order to calibrate
|
||||
|
||||
Voltage Divider 1 (R13, R14):
|
||||
R13 = 220k, R14 = 82k
|
||||
V(ADC) = V(in1) * R14/(R13+R14)
|
||||
-> V(in1) = V(ADC) * (R13+R14)/R14
|
||||
V(ADC) = analogRead(A0)/1023.00
|
||||
-> V(in1) = analogRead(A0)/1023.00 * (R13+R14)/R14
|
||||
= analogRead(A0) * (R13+R14)/(R14*1023.00)
|
||||
= analogRead(A0) * (220k+82k)/(82k*1023.00)
|
||||
= analogRead(A0) * 0.0036
|
||||
|
||||
Voltage Divider 2 (LDR, R1 || (R13+R14))
|
||||
R1 = 47k, R13+R14 = 302k -> R1||(R13+R14) = 40,67k
|
||||
Vcc/V(in1) = R(LDR) / (R1||(R13+R14))
|
||||
-> R(LDR) = Vcc/V(in1) * (R1||(R13+R14))
|
||||
R(LDR) = 3.3V * 40.67k / V(in1)
|
||||
|
||||
Join formulas:
|
||||
|
||||
R(LDR) = 3.3V * 40.67k / (0.0036 * analogRead(A0))
|
||||
= 37280.00/analogRead(A0)
|
||||
ldr_ohm = R(LDR)
|
||||
|
||||
E(LDR) = 6526.5 * R(LDR)^-2 (see Excel Regression)
|
||||
E(LDR) = 6526.5 / (R(LDR)^2)
|
||||
ldr_value = E(LDR)
|
||||
*/
|
||||
// float ldr_ohm = 37280.00 / analogRead(A0);
|
||||
float vol_adc = analogRead(A0) * 0.0036;
|
||||
if(vol_adc > 3.29) // prevent negative values !
|
||||
vol_adc = 3.29;
|
||||
float ldr_ohm = 40.67 * (3.3 - vol_adc) / vol_adc;
|
||||
float ldr_value = 6526.6 / (ldr_ohm * ldr_ohm);
|
||||
#ifdef LDRDEBUG
|
||||
Serial.printf("vol_adc: %f Ohm: %f lux: %f Comp: %d\n", vol_adc, ldr_ohm, ldr_value,
|
||||
param.ldr_schwelle);
|
||||
#endif
|
||||
return ldr_value;
|
||||
}
|
||||
|
||||
void Treppe::sample_ldr() {
|
||||
ldr_average += read_ldr();
|
||||
ldr_average_cnt++;
|
||||
if(ldr_average_cnt > LDR_AVERAGE_SAMPLES) {
|
||||
float ldr_avg = static_cast<float>(ldr_average / LDR_AVERAGE_SAMPLES);
|
||||
Serial.printf("ldr_avg: %f schwelle: %d\n", ldr_avg, param.ldr_schwelle);
|
||||
if(check_ldr(ldr_avg)) {
|
||||
update_soll_pwm_with_ldr(ldr_avg);
|
||||
}
|
||||
ldr_average = 0.0;
|
||||
ldr_average_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Treppe::update_soll_pwm_with_ldr(float ldr_avg) {
|
||||
// LDR quasi linear :)
|
||||
/*
|
||||
soll ldr_average
|
||||
---- = ------------
|
||||
ist ldr_schwelle
|
||||
*/
|
||||
|
||||
#ifdef LDR_REGELUNG
|
||||
if(ldr_avg >= param.ldr_schwelle) {
|
||||
return;
|
||||
}
|
||||
idle_pwm_soll = (1 - (ldr_avg / param.ldr_schwelle)) * param.idle_pwm_max;
|
||||
Serial.printf("Update idle_pwm_soll_with_ldr: %d\n", idle_pwm_soll);
|
||||
|
||||
if(idle_pwm_ist != idle_pwm_soll)
|
||||
fsm_inputs.ldr_changed = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Treppe::check_ldr(float ldr_avg) {
|
||||
static uint8_t active = 0;
|
||||
|
||||
if (ldr_avg < param.ldr_schwelle) {
|
||||
active = 1;
|
||||
}
|
||||
if (ldr_avg > param.ldr_schwelle + LDR_HYS) {
|
||||
active = 0;
|
||||
}
|
||||
fsm_inputs.ldr_schwelle = active;
|
||||
return active;
|
||||
}
|
||||
|
||||
void Treppe::task() {
|
||||
#ifdef DEBUG_TIMING
|
||||
uint32_t m = micros();
|
||||
#endif
|
||||
sample_ldr();
|
||||
|
||||
|
||||
#ifdef DEBUG_TIMING
|
||||
Serial.print("1:");
|
||||
Serial.println(micros() - m);
|
||||
m = micros();
|
||||
#endif
|
||||
|
||||
read_sensors();
|
||||
fsm_inputs.sensor_oben = fsm_pend.sensor_oben;
|
||||
fsm_inputs.sensor_unten = fsm_pend.sensor_unten;
|
||||
|
||||
fsm_inputs.anim_beendet = fsm_pend.anim_beendet;
|
||||
|
||||
#ifdef DEBUG_TIMING
|
||||
Serial.print("2:");
|
||||
Serial.println(micros() - m);
|
||||
m = micros();
|
||||
#endif
|
||||
|
||||
FSMTreppe_Obj.setExternalInputs(&fsm_inputs);
|
||||
FSMTreppe_Obj.step();
|
||||
fsm_outputs = FSMTreppe_Obj.getExternalOutputs();
|
||||
|
||||
#ifdef DEBUG_TIMING
|
||||
Serial.print("3:");
|
||||
Serial.println(micros() - m);
|
||||
m = micros();
|
||||
#endif
|
||||
|
||||
print_state_on_change();
|
||||
|
||||
#ifdef DEBUG_TIMING
|
||||
Serial.print("4:");
|
||||
Serial.println(micros() - m);
|
||||
m = micros();
|
||||
#endif
|
||||
|
||||
if (fsm_outputs.status == ST_AUFDIMMEN_HOCH ||
|
||||
fsm_outputs.status == ST_ABDIMMEN_HOCH ||
|
||||
fsm_outputs.status == ST_AUFDIMMEN_RUNTER ||
|
||||
fsm_outputs.status == ST_ABDIMMEN_RUNTER) {
|
||||
if (fsm_pend.anim_beendet) {
|
||||
start_animation(&dimmer_stufen, DIM_STUFEN, param.active_pwm,
|
||||
idle_pwm_ist);
|
||||
}
|
||||
else {
|
||||
fsm_pend.anim_beendet = dimmer_tick(&dimmer_stufen, DIM_STUFEN);
|
||||
}
|
||||
}
|
||||
else if (fsm_outputs.status == ST_AUFDIMMEN_LDR ||
|
||||
fsm_outputs.status == ST_ABDIMMEN_LDR) {
|
||||
if (fsm_pend.anim_beendet) {
|
||||
#ifdef LDR_REGELUNG
|
||||
start_animation(&dimmer_ldr, DIM_LDR, idle_pwm_soll, 0);
|
||||
idle_pwm_ist = idle_pwm_soll;
|
||||
#else
|
||||
start_animation(&dimmer_ldr, DIM_LDR, idle_pwm_ist, 0);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
fsm_pend.anim_beendet = dimmer_tick(&dimmer_ldr, DIM_LDR);
|
||||
}
|
||||
else if(fsm_outputs.status == ST_LDR_CHANGED) {
|
||||
fsm_inputs.ldr_changed = false;
|
||||
|
||||
#ifdef LDR_REGELUNG
|
||||
if (fsm_pend.anim_beendet) {
|
||||
if(idle_pwm_soll < idle_pwm_ist) {
|
||||
fsm_outputs.dimmrichtung = DR_ABDIMMEN;
|
||||
start_animation(&dimmer_ldr, DIM_LDR, idle_pwm_ist, idle_pwm_soll);
|
||||
}
|
||||
else {
|
||||
fsm_outputs.dimmrichtung = DR_AUFDIMMEN;
|
||||
start_animation(&dimmer_ldr, DIM_LDR, idle_pwm_soll, idle_pwm_ist);
|
||||
}
|
||||
idle_pwm_ist = idle_pwm_soll;
|
||||
}
|
||||
else {
|
||||
fsm_pend.anim_beendet = dimmer_tick(&dimmer_ldr, DIM_LDR);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (fsm_outputs.status == ST_RUHEZUSTAND ||
|
||||
fsm_outputs.status == ST_INAKTIV_LDR) {
|
||||
if (param_changed) {
|
||||
param_changed = false;
|
||||
param = param_pend;
|
||||
save_param_to_eeprom();
|
||||
Serial.printf("Parameter Change applied!\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_TIMING
|
||||
Serial.print("5:");
|
||||
Serial.println(micros() - m);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Treppe::setup() {
|
||||
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.init(PCA9685_PhaseBalancer_Linear);
|
||||
pwmController.setPWMFrequency(200);
|
||||
// pwmController.setAllChannelsPWM(idle_pwm);
|
||||
|
||||
// WARNING: before getting Parameters of Flash, make sure plausible parameters
|
||||
// are written in flash!
|
||||
EEPROM.get(EEP_START_ADDR, param); // get Parameters of flash
|
||||
param_pend = param;
|
||||
#ifndef LDR_REGELUNG
|
||||
idle_pwm_ist = param.idle_pwm_max;
|
||||
#endif
|
||||
|
||||
pinMode(13, OUTPUT);
|
||||
pinMode(0, OUTPUT);
|
||||
digitalWrite(13, HIGH);
|
||||
digitalWrite(0, HIGH);
|
||||
|
||||
pinMode(A0, INPUT);
|
||||
pinMode(SENSOR_OBEN, INPUT);
|
||||
pinMode(SENSOR_UNTEN, INPUT);
|
||||
pinMode(OE, OUTPUT);
|
||||
digitalWrite(OE, 0);
|
||||
|
||||
Serial.printf("Treppe: stufen=%d\n", stufen);
|
||||
}
|
||||
|
||||
void Treppe::save_param_to_eeprom() {
|
||||
EEPROM.put(EEP_START_ADDR,
|
||||
param); // copy Parameters so "EEPROM"-section in RAM
|
||||
EEPROM.commit(); // write "EEPROM"-section to flash
|
||||
}
|
||||
|
||||
void Treppe::set_idle_pwm_max(const uint16_t value,
|
||||
const vorgabe_typ_t vorgabe_typ) {
|
||||
if (vorgabe_typ == VORGABE_PROZENT) {
|
||||
param_pend.idle_pwm_max = param_pend.active_pwm * value / 100;
|
||||
} else if (vorgabe_typ == VORGABE_12BIT) {
|
||||
param_pend.idle_pwm_max = value;
|
||||
}
|
||||
|
||||
if (param_pend.idle_pwm_max > param_pend.active_pwm) {
|
||||
param_pend.idle_pwm_max = param_pend.active_pwm;
|
||||
}
|
||||
param_changed = true;
|
||||
|
||||
Serial.printf("Treppe: param_pend.idle_pwm_max=%d\n",
|
||||
param_pend.idle_pwm_max);
|
||||
}
|
||||
|
||||
void Treppe::set_active_pwm(const uint16_t value,
|
||||
const vorgabe_typ_t vorgabe_typ) {
|
||||
|
||||
if (vorgabe_typ == VORGABE_PROZENT) {
|
||||
param_pend.active_pwm = 4095 * value / 100;
|
||||
} else if (vorgabe_typ == VORGABE_12BIT) {
|
||||
param_pend.active_pwm = value;
|
||||
}
|
||||
|
||||
if (param_pend.active_pwm > 4095) {
|
||||
param_pend.idle_pwm_max = 4095;
|
||||
}
|
||||
param_changed = true;
|
||||
|
||||
Serial.printf("Treppe: param_pend.active_pwm=%d\n", param_pend.active_pwm);
|
||||
}
|
||||
|
||||
void Treppe::set_time_ldr(const uint16_t value) {
|
||||
param_pend.time_ldr = value;
|
||||
if (param_pend.time_ldr > TIME_MS_MAX)
|
||||
param_pend.time_ldr = TIME_MS_MAX;
|
||||
param_changed = true;
|
||||
|
||||
Serial.printf("Treppe: time_ldr=%d\n", param_pend.time_ldr);
|
||||
}
|
||||
|
||||
void Treppe::set_time_per_stair(const uint16_t value) {
|
||||
param_pend.time_per_stair = value;
|
||||
if (param_pend.time_per_stair > TIME_MS_MAX)
|
||||
param_pend.time_per_stair = TIME_MS_MAX;
|
||||
param_changed = true;
|
||||
|
||||
Serial.printf("Treppe: time_per_stair=%d\n", param_pend.time_per_stair);
|
||||
}
|
||||
|
||||
void Treppe::set_ldr_schwelle(const uint16_t value,
|
||||
const vorgabe_typ_t vorgabe_typ) {
|
||||
if (vorgabe_typ == VORGABE_PROZENT) {
|
||||
// ?!
|
||||
param_pend.ldr_schwelle = 10 * value / 100;
|
||||
} else if (vorgabe_typ == VORGABE_12BIT) {
|
||||
param_pend.ldr_schwelle = value;
|
||||
}
|
||||
param_changed = true;
|
||||
|
||||
Serial.printf("Treppe: ldr_schwelle=%d\n", param_pend.ldr_schwelle);
|
||||
}
|
||||
|
||||
void Treppe::param_to_json(char *json_str, size_t sz) {
|
||||
snprintf(json_str, sz, "{\n\
|
||||
\"time_ldr\": %d,\n\
|
||||
\"time_per_stair\": %d,\n\
|
||||
\"idle_pwm_max\": %d,\n\
|
||||
\"active_pwm\": %d,\n\
|
||||
\"ldr_schwelle\": %d\n}\n",
|
||||
param.time_ldr, param.time_per_stair, param.idle_pwm_max,
|
||||
param.active_pwm, param.ldr_schwelle);
|
||||
}
|
||||
128
lib/treppe/treppe.h
Normal file
128
lib/treppe/treppe.h
Normal file
@ -0,0 +1,128 @@
|
||||
#ifndef __TREPPE_H
|
||||
#define __TREPPE_H
|
||||
|
||||
#include "FSMTreppe4/FSMTreppe4.h"
|
||||
#include "PCA9685.h"
|
||||
#include <EEPROM.h>
|
||||
|
||||
// #define LDR_REGELUNG // comment in to activate LDR control
|
||||
// #define LDRDEBUG // comment in to show LDR measurement
|
||||
#define LDR_HYS 5 // Hysteresis for switching off FSM [lux]
|
||||
#define LDR_AVERAGE_SAMPLES 50
|
||||
|
||||
#define SENSOR_OBEN 16
|
||||
#define SENSOR_UNTEN 12
|
||||
#define OE 14
|
||||
|
||||
#define INT_TIME 20 // interrupt intervall [ms]
|
||||
#define TIME_MS_MAX 5000 // maximum time for animation [ms]
|
||||
|
||||
enum vorgabe_typ_t { VORGABE_PROZENT = 0, VORGABE_12BIT = 1 };
|
||||
|
||||
#define EEP_START_ADDR 100 // define Start Address for "EEPROM" storage -> depends on size of "wifi_data"!
|
||||
|
||||
class Treppe {
|
||||
private:
|
||||
const uint8_t stufen;
|
||||
|
||||
struct stairway_param_t {
|
||||
uint16_t time_ldr = 500;
|
||||
uint16_t time_per_stair = 300; // dimmtime per stair [ms]
|
||||
uint16_t idle_pwm_max = 100;
|
||||
uint16_t active_pwm = 2000;
|
||||
uint16_t ldr_schwelle = 30; // activation value for FSM [lx]
|
||||
};
|
||||
stairway_param_t param;
|
||||
stairway_param_t param_pend; // zwischenspeicher änderungen
|
||||
bool param_changed = false;
|
||||
|
||||
float ldr_average = 0.0;
|
||||
uint16_t ldr_average_cnt = 0;
|
||||
uint16_t idle_pwm_ist = 0;
|
||||
uint16_t idle_pwm_soll = 0;
|
||||
|
||||
struct fsm_pending_inputs_t {
|
||||
bool anim_beendet = true;
|
||||
bool sensor_unten = false;
|
||||
bool last_s_unten = false;
|
||||
bool web_ctrl_s_unten = false;
|
||||
bool sensor_oben = false;
|
||||
bool last_s_oben = false;
|
||||
bool web_ctrl_s_oben = false;
|
||||
bool ldr_changed = false;
|
||||
};
|
||||
fsm_pending_inputs_t fsm_pend;
|
||||
|
||||
struct dimmer_t {
|
||||
uint8_t stufe = 0;
|
||||
uint16_t ticks = 0;
|
||||
uint16_t tick = 0;
|
||||
|
||||
float delta_pwm = 0.0;
|
||||
float pwm = 0.0;
|
||||
uint16_t start_pwm = 0;
|
||||
uint16_t ziel_pwm = 0;
|
||||
};
|
||||
enum dimmer_type_t { DIM_STUFEN = 0, DIM_LDR = 1 };
|
||||
dimmer_t dimmer_stufen;
|
||||
dimmer_t dimmer_ldr;
|
||||
|
||||
// initialize with i2c-Address 0, use Wire Library
|
||||
PCA9685 pwmController;
|
||||
FSMTreppeModelClass FSMTreppe_Obj;
|
||||
FSMTreppeModelClass::ExtU_FSMTreppe_T fsm_inputs;
|
||||
FSMTreppeModelClass::ExtY_FSMTreppe_T fsm_outputs;
|
||||
enum fsm_status_t {
|
||||
ST_INAKTIV_LDR = 0,
|
||||
ST_AUFDIMMEN_LDR = 1,
|
||||
ST_ABDIMMEN_LDR = 2,
|
||||
ST_RUHEZUSTAND = 3,
|
||||
ST_AUFDIMMEN_HOCH = 4,
|
||||
ST_WARTEN_HOCH = 5,
|
||||
ST_ABDIMMEN_HOCH = 6,
|
||||
ST_AUFDIMMEN_RUNTER = 7,
|
||||
ST_WARTEN_RUNTER = 8,
|
||||
ST_ABDIMMEN_RUNTER = 9,
|
||||
ST_LDR_CHANGED = 10
|
||||
};
|
||||
enum fsm_laufrichtung_t { LR_RUNTER = 0, LR_HOCH = 1 };
|
||||
enum fsm_dimmrichtung_t { DR_ABDIMMEN = 0, DR_AUFDIMMEN = 1 };
|
||||
|
||||
void read_sensors();
|
||||
void print_state_on_change();
|
||||
|
||||
/* DIMM */
|
||||
bool dimmer_tick(dimmer_t *dimmer, bool dim_type);
|
||||
void start_animation(dimmer_t *dimmer, bool dim_type, uint16_t on_pwm,
|
||||
uint16_t off_pwm);
|
||||
|
||||
/* LDR */
|
||||
bool read_sensor(int sensor);
|
||||
float read_ldr();
|
||||
void sample_ldr();
|
||||
|
||||
bool check_ldr(float ldr_avg);
|
||||
void update_soll_pwm_with_ldr(float ldr_avg);
|
||||
|
||||
public:
|
||||
Treppe(uint8_t _stufen) : stufen(_stufen) { FSMTreppe_Obj.initialize(); }
|
||||
~Treppe() { FSMTreppe_Obj.terminate(); }
|
||||
|
||||
void setup();
|
||||
void task(); // call periodically
|
||||
|
||||
// Parameter section
|
||||
void save_param_to_eeprom();
|
||||
void param_to_json(char* json_str, size_t sz);
|
||||
|
||||
void set_idle_pwm_max(const uint16_t value, const vorgabe_typ_t vorgabe_typ);
|
||||
void set_active_pwm(const uint16_t value, const vorgabe_typ_t vorgabe_typ);
|
||||
|
||||
void set_time_ldr(const uint16_t value);
|
||||
void set_time_per_stair(const uint16_t value);
|
||||
void set_ldr_schwelle(const uint16_t value, const vorgabe_typ_t vorgabe_typ);
|
||||
|
||||
void overwrite_sensors(bool s_oben, bool s_unten);
|
||||
};
|
||||
|
||||
#endif // __TREPPE_H
|
||||
BIN
misc/LDR-Regression.xlsx
Normal file
BIN
misc/LDR-Regression.xlsx
Normal file
Binary file not shown.
17
scripts/gdboptions_win
Normal file
17
scripts/gdboptions_win
Normal file
@ -0,0 +1,17 @@
|
||||
set remote hardware-breakpoint-limit 1
|
||||
set remote hardware-watchpoint-limit 1
|
||||
set remote interrupt-on-connect on
|
||||
set remote kill-packet off
|
||||
set remote symbol-lookup-packet off
|
||||
set remote verbose-resume-packet off
|
||||
mem 0x20000000 0x3fefffff ro cache
|
||||
mem 0x3ff00000 0x3fffffff rw
|
||||
mem 0x40000000 0x400fffff ro cache
|
||||
mem 0x40100000 0x4013ffff rw cache
|
||||
mem 0x40140000 0x5fffffff ro cache
|
||||
mem 0x60000000 0x60001fff rw
|
||||
set serial baud 460800
|
||||
|
||||
file .pio/build/debug/firmware.elf
|
||||
target remote \\.\COM23
|
||||
thb loop
|
||||
@ -1,17 +0,0 @@
|
||||
#include "httpserver.h"
|
||||
|
||||
|
||||
bool HTTPServer::addRootFileHandler() {
|
||||
|
||||
// //experimental, see doku.md
|
||||
// server.serveStatic("/compressed", LittleFS, "/compressed.html.gzip");
|
||||
|
||||
this->serveStatic("", LittleFS, "/index.html");
|
||||
this->serveStatic("/", LittleFS, "/index.html");
|
||||
this->serveStatic("/#", LittleFS, "/index.html");
|
||||
this->serveStatic("/style.css", LittleFS, "/style.css");
|
||||
this->serveStatic("/input.js", LittleFS, "/input.js");
|
||||
this->serveStatic("/favicon.png", LittleFS, "/favicon.png");
|
||||
|
||||
return true;
|
||||
}
|
||||
300
src/main.cpp
300
src/main.cpp
@ -1,146 +1,90 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
// debugging support via GDBStub over UART
|
||||
#ifdef WITH_DEBUGGING_ON
|
||||
#include <GDBStub.h>
|
||||
#include <GDBStub.h> // debugging support via GDBStub over UART
|
||||
#endif
|
||||
|
||||
#include "PCA9685.h"
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
|
||||
#define ESP12_LED 2
|
||||
#define NODEMCU_LED 16
|
||||
|
||||
// OTA & WEB
|
||||
#include "wifi_credentials.h"
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include <ArduinoOTA.h>
|
||||
|
||||
#include <ESP8266mDNS.h>
|
||||
#include "httpserver.h"
|
||||
#include "ota.h"
|
||||
#include "wifi_credentials.h"
|
||||
#include <EEPROM.h>
|
||||
|
||||
const char* ssid = STASSID;
|
||||
const char* password = STAPSK;
|
||||
// BOARD
|
||||
#define ESP12_LED 2
|
||||
// #define NODEMCU_LED 16
|
||||
|
||||
// PWM
|
||||
#include "treppe.h"
|
||||
os_timer_t timer1;
|
||||
int timer_arg;
|
||||
uint8_t timer_flag = 0;
|
||||
Treppe stairs(12);
|
||||
|
||||
void setup_ota();
|
||||
void setup_pwm_pca9685();
|
||||
void handleNotFound();
|
||||
// WIFI
|
||||
const char *ssid = STASSID;
|
||||
const char *password = STAPSK;
|
||||
|
||||
const int led = 13;
|
||||
// port 80, root directory of server '/'
|
||||
HTTPServer httpServer(80, "/", &stairs);
|
||||
|
||||
HTTPServer httpServer(80, "/");
|
||||
|
||||
void handleNotFound() {
|
||||
String message = "File Not Found\n\n";
|
||||
message += "URI: ";
|
||||
message += httpServer.uri();
|
||||
message += "\nMethod: ";
|
||||
message += (httpServer.method() == HTTP_GET) ? "GET" : "POST";
|
||||
message += "\nArguments: ";
|
||||
message += httpServer.args();
|
||||
message += "\n";
|
||||
|
||||
for (uint8_t i = 0; i < httpServer.args(); i++) {
|
||||
message += " " + httpServer.argName(i) + ": " + httpServer.arg(i) + "\n";
|
||||
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); \
|
||||
}
|
||||
|
||||
httpServer.send(404, "text/plain", message);
|
||||
}
|
||||
|
||||
PCA9685 pwmController;
|
||||
|
||||
|
||||
|
||||
|
||||
void setup_ota() {
|
||||
ArduinoOTA.setPort(8266);
|
||||
ArduinoOTA.setHostname("ESP_Treppenlicht");
|
||||
ArduinoOTA.setPassword("admin");
|
||||
// Password can be set with it's md5 value as well
|
||||
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
|
||||
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
|
||||
|
||||
ArduinoOTA.onStart([]() {
|
||||
String type;
|
||||
if (ArduinoOTA.getCommand() == U_FLASH) {
|
||||
type = "sketch";
|
||||
} else { // U_FS
|
||||
type = "filesystem";
|
||||
}
|
||||
|
||||
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
|
||||
Serial.println("Start updating " + type);
|
||||
});
|
||||
ArduinoOTA.onEnd([]() {
|
||||
Serial.println("\nEnd");
|
||||
});
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
|
||||
});
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
Serial.printf("Error[%u]: ", error);
|
||||
if (error == OTA_AUTH_ERROR) {
|
||||
Serial.println("Auth Failed");
|
||||
} else if (error == OTA_BEGIN_ERROR) {
|
||||
Serial.println("Begin Failed");
|
||||
} else if (error == OTA_CONNECT_ERROR) {
|
||||
Serial.println("Connect Failed");
|
||||
} else if (error == OTA_RECEIVE_ERROR) {
|
||||
Serial.println("Receive Failed");
|
||||
} else if (error == OTA_END_ERROR) {
|
||||
Serial.println("End Failed");
|
||||
}
|
||||
});
|
||||
ArduinoOTA.begin();
|
||||
}
|
||||
|
||||
void setup_pwm_pca9685() {
|
||||
pwmController.resetDevices(); // Software resets all PCA9685 devices on Wire line
|
||||
|
||||
pwmController.init(B000000); // Address pins A5-A0 set to B000000
|
||||
pwmController.setPWMFrequency(200); // Default is 200Hz, supports 24Hz to 1526Hz
|
||||
|
||||
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4
|
||||
}
|
||||
|
||||
|
||||
uint32_t dimmtimer = 0;
|
||||
uint8_t direction = 1;
|
||||
uint8_t onoff = 1;
|
||||
|
||||
void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor);
|
||||
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor);
|
||||
|
||||
uint8_t flag = 0;
|
||||
void timer_callback(void *pArg)
|
||||
{
|
||||
*((int *) pArg) += 1;
|
||||
|
||||
flag = 1;
|
||||
struct { // Struct for wifi-data, 40 Bytes each SSID and PW
|
||||
char SSID[40] = "";
|
||||
char PW[40] = "";
|
||||
} wifi_data;
|
||||
|
||||
void timerCallback(void *pArg) {
|
||||
*(static_cast<int *>(pArg)) += 1;
|
||||
stairs.task();
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
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);
|
||||
Serial.println("Booting ....");
|
||||
pinMode(ESP12_LED, OUTPUT);
|
||||
|
||||
Wire.begin(); // Wire must be started first
|
||||
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
EEPROM.begin(512); // init virtual "EEPROM" with size 512 Bytes
|
||||
|
||||
// strncpy(wifi_data.SSID, "donotconnect", 40);
|
||||
// strncpy(wifi_data.PW, "unsafe lol", 40);
|
||||
|
||||
EEPROM.get(0, wifi_data);
|
||||
// EEPROM.commit();
|
||||
|
||||
Wire.begin(); // Wire must be started first
|
||||
Wire.setClock(
|
||||
1000000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
|
||||
stairs.setup();
|
||||
Serial.println("PCA9685 connected !");
|
||||
// attachInterrupt(digitalPinToInterrupt(2), int_test, RISING);
|
||||
// attachInterrupt(digitalPinToInterrupt(12), int_test, RISING);
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
@ -151,133 +95,35 @@ void setup() {
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
pinMode(led, OUTPUT);
|
||||
digitalWrite(led, 0);
|
||||
Serial.println("");
|
||||
Serial.print("Connected to ");
|
||||
Serial.println(ssid);
|
||||
Serial.print("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
os_timer_setfn(&timer1, timer_callback, &timer_arg);
|
||||
os_timer_arm(&timer1, 1, true);
|
||||
|
||||
Serial.println("Ready");
|
||||
Serial.print("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
setup_ota();
|
||||
ota_setup();
|
||||
|
||||
httpServer.start();
|
||||
httpServer.onNotFound(handleNotFound);
|
||||
httpServer.start_apps();
|
||||
Serial.println("HTTP server started !");
|
||||
|
||||
setup_pwm_pca9685();
|
||||
Serial.println("PCA9685 connected !");
|
||||
}
|
||||
|
||||
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor){
|
||||
static uint8_t lastled = 255;
|
||||
static uint8_t current_pwm = 0;
|
||||
|
||||
if(led != lastled){
|
||||
pwmController.setChannelPWM(led, startval);
|
||||
lastled = led;
|
||||
current_pwm = startval;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(current_pwm == stopval){
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if(startval > stopval){
|
||||
current_pwm -= 1;
|
||||
}
|
||||
else {
|
||||
current_pwm += 1;
|
||||
}
|
||||
pwmController.setChannelPWM(led, current_pwm*factor);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define LEDCOUNT 16
|
||||
|
||||
void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){
|
||||
static int8_t led = 0;
|
||||
static uint8_t brightness = 0;
|
||||
static uint8_t lastbrightness = 0;
|
||||
static uint8_t finish = 1;
|
||||
static uint32_t status = 0;
|
||||
uint32_t status_build = 0;
|
||||
status_build |= direction << 16;
|
||||
status_build |= onoff << 8;
|
||||
status_build |= factor;
|
||||
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 = LEDCOUNT-1;
|
||||
if(onoff){
|
||||
brightness = 127; // set brightness value depending of on/off
|
||||
lastbrightness = 0;
|
||||
}
|
||||
else{
|
||||
brightness = 0;
|
||||
lastbrightness = 127;
|
||||
}
|
||||
status = status_build; // set parameter memory
|
||||
Serial.print("----Status Changed! onoff: ");
|
||||
Serial.print(onoff);
|
||||
Serial.print(" dir: ");
|
||||
Serial.println(direction);
|
||||
|
||||
|
||||
if (MDNS.begin("treppenlicht")) {
|
||||
Serial.println("MDNS for treppenlicht started");
|
||||
}
|
||||
if(!finish){ // finish == 0 -> action pending
|
||||
if(!softstart_led(led,lastbrightness, brightness, factor)){
|
||||
Serial.print("one LED finished, new set led: ");
|
||||
Serial.print(led);
|
||||
Serial.print(" last: ");
|
||||
Serial.print(lastbrightness);
|
||||
Serial.print(" curr: ");
|
||||
Serial.println(brightness);
|
||||
if(direction){
|
||||
led++;
|
||||
if(led >= LEDCOUNT) {
|
||||
finish = 1;
|
||||
//lastbrightness = brightness;
|
||||
}
|
||||
}
|
||||
else{
|
||||
led--;
|
||||
if(led < 0){
|
||||
//lastbrightness = brightness;
|
||||
finish = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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); }
|
||||
os_timer_setfn(&timer1, timerCallback, &timer_flag);
|
||||
os_timer_arm(&timer1, 20, true);
|
||||
|
||||
Serial.println("SSID: " + String(wifi_data.SSID) +
|
||||
" PW: " + String(wifi_data.PW));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(millis() - dimmtimer > 2){
|
||||
//ledsequence(direction, onoff, 4);
|
||||
dimmtimer = millis();
|
||||
if (inter != 0u) {
|
||||
Serial.printf("interrupt\n");
|
||||
inter = 0;
|
||||
}
|
||||
if(millis() > 25000 && onoff == 1 && direction == 1) onoff = 0;
|
||||
if(millis() > 35000 && direction == 1){
|
||||
onoff = 1;
|
||||
direction = 0;
|
||||
}
|
||||
TIMEIF_US(ArduinoOTA.handle(), 1000, "OTA");
|
||||
TIMEIF_US(httpServer.handleClient(), 1000, "HTTP");
|
||||
|
||||
if(flag) {
|
||||
flag = 0;
|
||||
ledsequence(direction, onoff, 4);
|
||||
//Serial.printf("[%lu] interrupt\n\r", millis());
|
||||
}
|
||||
TIMEIF_US(ArduinoOTA.handle(), 10000, "OTA");
|
||||
TIMEIF_US(httpServer.handleClient(), 10000, "HTTP");
|
||||
}
|
||||
5
start_xtensa_gdb_stub.cmd
Normal file
5
start_xtensa_gdb_stub.cmd
Normal file
@ -0,0 +1,5 @@
|
||||
SET GDB_PATH=C:\Users\simon\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.0-newlib4.0.0-gnu23-48f7b08\bin\xtensa-lx106-elf-gdb.exe
|
||||
|
||||
echo "Starting gdb"
|
||||
echo %GDB_PATH%
|
||||
%GDB_PATH% -x ".\scripts\gdboptions_win"
|
||||
@ -1,6 +1,5 @@
|
||||
#!/bin/bash
|
||||
GDB_PATH=~/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.0-newlib4.0.0-gnu23-48f7b08/bin/xtensa-lx106-elf-gdb
|
||||
|
||||
cd ..
|
||||
echo "Starting gdb"
|
||||
$GDB_PATH -x scripts/gdboptions
|
||||
$GDB_PATH -x scripts/gdboptions
|
||||
@ -8,38 +8,90 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env]
|
||||
platform = espressif8266
|
||||
board = nodemcuv2
|
||||
framework = arduino
|
||||
[platformio]
|
||||
description = ESP8266 Treppenlicht Steuerung
|
||||
default_envs = ota
|
||||
; test_dir = test
|
||||
data_dir = data_gz
|
||||
|
||||
[env:hardware]
|
||||
platform = espressif8266
|
||||
; board = nodemcuv2
|
||||
board = huzzah
|
||||
framework = arduino
|
||||
; build_unflags = -Os
|
||||
; build_flags = -O2
|
||||
|
||||
; for http files
|
||||
board_build.filesystem = littlefs
|
||||
board_build.ldscript = eagle.flash.4m1m.ld
|
||||
extra_scripts = pre:create_gz_files.py
|
||||
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:serial]
|
||||
extends = env:hardware
|
||||
upload_protocol = esptool
|
||||
upload_speed = 921600
|
||||
upload_port = COM23
|
||||
monitor_port = COM23
|
||||
monitor_speed = 76800
|
||||
|
||||
[env:ota]
|
||||
extends = env:hardware
|
||||
; OTA => https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
|
||||
upload_protocol = espota
|
||||
upload_port = <!! IP ADDRESS !!>
|
||||
upload_flags =
|
||||
--port=8266
|
||||
--port=8266
|
||||
--host_port=<!! PORT !!>
|
||||
--auth=admin
|
||||
|
||||
|
||||
[env:debug]
|
||||
extends = env:hardware
|
||||
; look at doku.md
|
||||
build_flags = -DWITH_DEBUGGING_ON -Os -g3 -ggdb3
|
||||
upload_protocol = esptool
|
||||
upload_speed = 921600
|
||||
upload_port = COM23
|
||||
|
||||
; for pio check
|
||||
; check_tool = cppcheck
|
||||
check_tool = clangtidy
|
||||
check_flags =
|
||||
clangtidy: --fix-errors lib/httpserver/*
|
||||
; clangtidy: lib/httpserver/* lib/treppe/* lib/treppe/FSMTreppe3/* lib/PCA9685-Arduino/*
|
||||
check_skip_packages = yes
|
||||
|
||||
# This file is used compile and run tests located in the `unit` directory.
|
||||
# For more info, see:
|
||||
# https://docs.platformio.org/en/latest/plus/unit-testing.html
|
||||
# https://github.com/ThrowTheSwitch/Unity
|
||||
# https://github.com/ThrowTheSwitch/Unity/blob/master/docs/UnityAssertionsReference.md
|
||||
|
||||
|
||||
|
||||
# To prepare coverage data for lcov, add ${coverage.build_flags} to env:test build flags
|
||||
# To actually generate coverage report:
|
||||
# $ `pio test` / run the test `program` manually
|
||||
# $ lcov --include (readlink -f ../espurna)'/*' --capture --directory .pio/build/test/ --output-file test.info
|
||||
# $ genhtml --ignore-errors source test.info --output-directory out
|
||||
|
||||
[coverage]
|
||||
build_flags = -lgcov -fprofile-arcs -ftest-coverage
|
||||
|
||||
[env:test]
|
||||
extends = env:hardware
|
||||
|
||||
|
||||
[env:native]
|
||||
platform = native
|
||||
test_build_project_src = true
|
||||
build_flags =
|
||||
-DMANUFACTURER="PLATFORMIO"
|
||||
-DDEVICE="TEST"
|
||||
-std=gnu++11
|
||||
-g
|
||||
-Os
|
||||
-I lib/treppe
|
||||
-I lib/PCA9685-Arduino
|
||||
|
||||
|
||||
|
||||
@ -1,40 +1,40 @@
|
||||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
// #include <Arduino.h>
|
||||
// #include <unity.h>
|
||||
|
||||
String STR_TO_TEST;
|
||||
// String STR_TO_TEST;
|
||||
|
||||
void setUp(void) {
|
||||
// set stuff up here
|
||||
STR_TO_TEST = "Hello, world!";
|
||||
}
|
||||
// // void setUp(void) {
|
||||
// // // set stuff up here
|
||||
// // STR_TO_TEST = "Hello, world!";
|
||||
// // }
|
||||
|
||||
void tearDown(void) {
|
||||
// clean stuff up here
|
||||
STR_TO_TEST = "";
|
||||
}
|
||||
// // void tearDown(void) {
|
||||
// // // clean stuff up here
|
||||
// // STR_TO_TEST = "";
|
||||
// // }
|
||||
|
||||
void test_led_builtin_pin_number(void) {
|
||||
TEST_ASSERT_EQUAL(2, LED_BUILTIN);
|
||||
}
|
||||
// void test_led_builtin_pin_number(void) {
|
||||
// TEST_ASSERT_EQUAL(2, LED_BUILTIN);
|
||||
// }
|
||||
|
||||
void test_string_concat(void) {
|
||||
String hello = "Hello, ";
|
||||
String world = "world!";
|
||||
TEST_ASSERT_EQUAL_STRING(STR_TO_TEST.c_str(), (hello + world).c_str());
|
||||
}
|
||||
// void test_string_concat(void) {
|
||||
// String hello = "Hello, ";
|
||||
// String world = "world!";
|
||||
// TEST_ASSERT_EQUAL_STRING(STR_TO_TEST.c_str(), (hello + world).c_str());
|
||||
// }
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
delay(2000); // service delay
|
||||
UNITY_BEGIN();
|
||||
// void setup()
|
||||
// {
|
||||
// delay(2000); // service delay
|
||||
// UNITY_BEGIN();
|
||||
|
||||
RUN_TEST(test_led_builtin_pin_number);
|
||||
RUN_TEST(test_string_concat);
|
||||
// RUN_TEST(test_led_builtin_pin_number);
|
||||
// RUN_TEST(test_string_concat);
|
||||
|
||||
UNITY_END(); // stop unit testing
|
||||
}
|
||||
// UNITY_END(); // stop unit testing
|
||||
// }
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
// void loop()
|
||||
// {
|
||||
// }
|
||||
47
test/test_pwm.cpp
Normal file
47
test/test_pwm.cpp
Normal 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()
|
||||
{
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user