Normalize line endings (CRLF to LF)

This commit is contained in:
2026-05-07 09:00:36 +02:00
parent 604c8a3eaf
commit 47631f4de4
64 changed files with 11061 additions and 11053 deletions
+10 -10
View File
@@ -1,10 +1,10 @@
{ {
// See http://go.microsoft.com/fwlink/?LinkId=827846 // See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format // for the documentation about the extensions.json format
"recommendations": [ "recommendations": [
"platformio.platformio-ide" "platformio.platformio-ide"
], ],
"unwantedRecommendations": [ "unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack" "ms-vscode.cpptools-extension-pack"
] ]
} }
+37 -37
View File
@@ -1,37 +1,37 @@
This directory is intended for project header files. This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'. by including it, with the C preprocessing directive `#include'.
```src/main.c ```src/main.c
#include "header.h" #include "header.h"
int main (void) int main (void)
{ {
... ...
} }
``` ```
Including a header file produces the same results as copying the header file Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program. find one copy will result in inconsistencies within a program.
In C, the convention is to give header files names that end with `.h'. In C, the convention is to give header files names that end with `.h'.
Read more about using header files in official GCC documentation: Read more about using header files in official GCC documentation:
* Include Syntax * Include Syntax
* Include Operation * Include Operation
* Once-Only Headers * Once-Only Headers
* Computed Includes * Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
+46 -46
View File
@@ -1,46 +1,46 @@
This directory is intended for project specific (private) libraries. This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into the executable file. PlatformIO will compile them to static libraries and link into the executable file.
The source code of each library should be placed in a separate directory The source code of each library should be placed in a separate directory
("lib/your_library_name/[Code]"). ("lib/your_library_name/[Code]").
For example, see the structure of the following example libraries `Foo` and `Bar`: For example, see the structure of the following example libraries `Foo` and `Bar`:
|--lib |--lib
| | | |
| |--Bar | |--Bar
| | |--docs | | |--docs
| | |--examples | | |--examples
| | |--src | | |--src
| | |- Bar.c | | |- Bar.c
| | |- Bar.h | | |- Bar.h
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html | | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| | | |
| |--Foo | |--Foo
| | |- Foo.c | | |- Foo.c
| | |- Foo.h | | |- Foo.h
| | | |
| |- README --> THIS FILE | |- README --> THIS FILE
| |
|- platformio.ini |- platformio.ini
|--src |--src
|- main.c |- main.c
Example contents of `src/main.c` using Foo and Bar: Example contents of `src/main.c` using Foo and Bar:
``` ```
#include <Foo.h> #include <Foo.h>
#include <Bar.h> #include <Bar.h>
int main (void) int main (void)
{ {
... ...
} }
``` ```
The PlatformIO Library Dependency Finder will find automatically dependent The PlatformIO Library Dependency Finder will find automatically dependent
libraries by scanning project source files. libraries by scanning project source files.
More information about PlatformIO Library Dependency Finder More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html - https://docs.platformio.org/page/librarymanager/ldf.html
+38 -38
View File
@@ -1,38 +1,38 @@
; PlatformIO Project Configuration File ; PlatformIO Project Configuration File
; ;
; Build options: build flags, source filter ; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags ; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages ; Library options: dependencies, extra library storages
; Advanced options: extra scripting ; Advanced options: extra scripting
; ;
; Please visit documentation for the other options and examples ; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[common] [common]
platform = espressif32 platform = espressif32
board = nodemcu-32s board = nodemcu-32s
framework = arduino framework = arduino
upload_speed = 921600 upload_speed = 921600
monitor_speed = 115200 monitor_speed = 115200
build_flags = build_flags =
-I ./src/xcp -I ./src/xcp
-I ./src/Receivers433 -I ./src/Receivers433
-I ./src/Receivers433/Receivers3ByteKeys -I ./src/Receivers433/Receivers3ByteKeys
lib_deps = lib_deps =
adafruit/Adafruit GFX Library@^1.12.4 adafruit/Adafruit GFX Library@^1.12.4
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.6.1 thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.6.1
knolleary/PubSubClient @ ^2.8 knolleary/PubSubClient @ ^2.8
[env:EG] [env:EG]
extends = common extends = common
upload_port = COM3 upload_port = COM3
build_flags = build_flags =
${common.build_flags} ${common.build_flags}
-D VERSION_DG_ONLY=0 -D VERSION_DG_ONLY=0
[env:DG] [env:DG]
extends = common extends = common
upload_port = COM3 upload_port = COM3
build_flags = build_flags =
${common.build_flags} ${common.build_flags}
-D VERSION_DG_ONLY=1 -D VERSION_DG_ONLY=1
+126 -126
View File
@@ -1,126 +1,126 @@
/* /*
Base32.cpp - Library for encoding to/decoding from Base32. Base32.cpp - Library for encoding to/decoding from Base32.
Compatible with RFC 4648 ( http://tools.ietf.org/html/rfc4648 ) Compatible with RFC 4648 ( http://tools.ietf.org/html/rfc4648 )
Created by Vladimir Tarasow, December 18, 2012. Created by Vladimir Tarasow, December 18, 2012.
Released into the public domain. Released into the public domain.
*/ */
#include "Arduino.h" #include "Arduino.h"
#include "Base32.h" #include "Base32.h"
#include "stdint.h" #include "stdint.h"
Base32::Base32() Base32::Base32()
{ {
} }
/* appends 0 to the base32 string */ /* appends 0 to the base32 string */
int Base32::toBase32(byte* in, long length, char * out, boolean usePadding) int Base32::toBase32(byte* in, long length, char * out, boolean usePadding)
{ {
char base32StandardAlphabet[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"}; char base32StandardAlphabet[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"};
char standardPaddingChar = '='; char standardPaddingChar = '=';
int result = 0; int result = 0;
int count = 0; int count = 0;
int bufSize = 8; int bufSize = 8;
int index = 0; int index = 0;
if (length < 0 || length > 268435456LL) if (length < 0 || length > 268435456LL)
{ {
return 0; return 0;
} }
if (length > 0) if (length > 0)
{ {
int buffer = in[0]; int buffer = in[0];
int next = 1; int next = 1;
int bitsLeft = 8; int bitsLeft = 8;
while (count < bufSize && (bitsLeft > 0 || next < length)) while (count < bufSize && (bitsLeft > 0 || next < length))
{ {
if (bitsLeft < 5) if (bitsLeft < 5)
{ {
if (next < length) if (next < length)
{ {
buffer <<= 8; buffer <<= 8;
buffer |= in[next] & 0xFF; buffer |= in[next] & 0xFF;
next++; next++;
bitsLeft += 8; bitsLeft += 8;
} }
else else
{ {
int pad = 5 - bitsLeft; int pad = 5 - bitsLeft;
buffer <<= pad; buffer <<= pad;
bitsLeft += pad; bitsLeft += pad;
} }
} }
index = 0x1F & (buffer >> (bitsLeft -5)); index = 0x1F & (buffer >> (bitsLeft -5));
bitsLeft -= 5; bitsLeft -= 5;
out[result] = (byte)base32StandardAlphabet[index]; out[result] = (byte)base32StandardAlphabet[index];
result++; result++;
} }
} }
if (usePadding) if (usePadding)
{ {
int pads = (result % 8); int pads = (result % 8);
if (pads > 0) if (pads > 0)
{ {
pads = (8 - pads); pads = (8 - pads);
for (int i = 0; i < pads; i++) for (int i = 0; i < pads; i++)
{ {
out[result] = standardPaddingChar; out[result] = standardPaddingChar;
result++; result++;
} }
} }
} }
out[result] = '\0'; out[result] = '\0';
return result; return result;
} }
int Base32::fromBase32(byte* in, long length, byte*& out) int Base32::fromBase32(byte* in, long length, byte*& out)
{ {
int result = 0; // Length of the array of decoded values. int result = 0; // Length of the array of decoded values.
int buffer = 0; int buffer = 0;
int bitsLeft = 0; int bitsLeft = 0;
byte* temp = NULL; byte* temp = NULL;
temp = (byte*)malloc(length); // Allocating temporary array. temp = (byte*)malloc(length); // Allocating temporary array.
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
byte ch = in[i]; byte ch = in[i];
// ignoring some characters: ' ', '\t', '\r', '\n', '=' // ignoring some characters: ' ', '\t', '\r', '\n', '='
if (ch == 0xA0 || ch == 0x09 || ch == 0x0A || ch == 0x0D || ch == 0x3D) continue; if (ch == 0xA0 || ch == 0x09 || ch == 0x0A || ch == 0x0D || ch == 0x3D) continue;
// recovering mistyped: '0' -> 'O', '1' -> 'L', '8' -> 'B' // recovering mistyped: '0' -> 'O', '1' -> 'L', '8' -> 'B'
if (ch == 0x30) { ch = 0x4F; } else if (ch == 0x31) { ch = 0x4C; } else if (ch == 0x38) { ch = 0x42; } if (ch == 0x30) { ch = 0x4F; } else if (ch == 0x31) { ch = 0x4C; } else if (ch == 0x38) { ch = 0x42; }
// look up one base32 symbols: from 'A' to 'Z' or from 'a' to 'z' or from '2' to '7' // look up one base32 symbols: from 'A' to 'Z' or from 'a' to 'z' or from '2' to '7'
if ((ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A)) { ch = ((ch & 0x1F) - 1); } if ((ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A)) { ch = ((ch & 0x1F) - 1); }
else if (ch >= 0x32 && ch <= 0x37) { ch -= (0x32 - 26); } else if (ch >= 0x32 && ch <= 0x37) { ch -= (0x32 - 26); }
else { free(temp); return 0; } else { free(temp); return 0; }
buffer <<= 5; buffer <<= 5;
buffer |= ch; buffer |= ch;
bitsLeft += 5; bitsLeft += 5;
if (bitsLeft >= 8) if (bitsLeft >= 8)
{ {
temp[result] = (unsigned char)((unsigned int)(buffer >> (bitsLeft - 8)) & 0xFF); temp[result] = (unsigned char)((unsigned int)(buffer >> (bitsLeft - 8)) & 0xFF);
result++; result++;
bitsLeft -= 8; bitsLeft -= 8;
} }
} }
out = (byte*)malloc(result); out = (byte*)malloc(result);
memcpy(out, temp, result); memcpy(out, temp, result);
free(temp); free(temp);
return result; return result;
} }
+22 -22
View File
@@ -1,22 +1,22 @@
/* /*
Base32.h - Library for encoding to/decoding from Base32. Base32.h - Library for encoding to/decoding from Base32.
Compatible with RFC 4648 ( http://tools.ietf.org/html/rfc4648 ) Compatible with RFC 4648 ( http://tools.ietf.org/html/rfc4648 )
Created by Vladimir Tarasow, December 18, 2012. Created by Vladimir Tarasow, December 18, 2012.
Released into the public domain. Released into the public domain.
*/ */
#ifndef Base32_h #ifndef Base32_h
#define Base32_h #define Base32_h
#include "Arduino.h" #include "Arduino.h"
#include "stdint.h" #include "stdint.h"
class Base32 class Base32
{ {
public: public:
Base32(); Base32();
int toBase32(byte*, long, char*, boolean); int toBase32(byte*, long, char*, boolean);
int fromBase32(byte*, long, byte*&); int fromBase32(byte*, long, byte*&);
}; };
#endif #endif
+178 -178
View File
@@ -1,178 +1,178 @@
#include "main.h" #include "main.h"
#if VERSION_BIG_DISPLAY #if VERSION_BIG_DISPLAY
/* /*
* Display.cpp * Display.cpp
* *
* Created on: 15.05.2020 * Created on: 15.05.2020
* Author: flori * Author: flori
*/ */
#include "Arduino.h" #include "Arduino.h"
#include <SPI.h> #include <SPI.h>
#include <Adafruit_GFX.h> // needs Adafruit_GFX_Library + Adafruit_BusIO #include <Adafruit_GFX.h> // needs Adafruit_GFX_Library + Adafruit_BusIO
#include <Adafruit_ST7735.h> // needs Adafruit_ST7735_and_ST7789_Library #include <Adafruit_ST7735.h> // needs Adafruit_ST7735_and_ST7789_Library
#include <Fonts/FreeSans9pt7b.h> #include <Fonts/FreeSans9pt7b.h>
#include "Display.h" #include "Display.h"
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_PIN_CS, TFT_PIN_DC, TFT_PIN_MOSI, TFT_PIN_CLK, TFT_PIN_RST); // ST7735-Bibliothek Setup Adafruit_ST7735 tft = Adafruit_ST7735(TFT_PIN_CS, TFT_PIN_DC, TFT_PIN_MOSI, TFT_PIN_CLK, TFT_PIN_RST); // ST7735-Bibliothek Setup
Display display; Display display;
static int wWindow = 38; static int wWindow = 38;
static int hWindow = 18; static int hWindow = 18;
/** /**
* *
*/ */
void Display::Init(void) void Display::Init(void)
{ {
tft.initR(INITR_BLACKTAB); tft.initR(INITR_BLACKTAB);
tft.setRotation(1); tft.setRotation(1);
tft.fillScreen(ST7735_BLACK); tft.fillScreen(ST7735_BLACK);
} }
void drawWindow(int x, int y, Fenster *fenster) void drawWindow(int x, int y, Fenster *fenster)
{ {
uint16_t col = fenster->ShallPiep() ? ST7735_ORANGE : fenster->IsOpen() ? ST77XX_WHITE : 0x0010; uint16_t col = fenster->ShallPiep() ? ST7735_ORANGE : fenster->IsOpen() ? ST77XX_WHITE : 0x0010;
if (col != fenster->color) if (col != fenster->color)
{ {
tft.fillRect(x,y,wWindow, hWindow, ST7735_BLACK); tft.fillRect(x,y,wWindow, hWindow, ST7735_BLACK);
tft.drawRect(x,y,wWindow, hWindow, col); tft.drawRect(x,y,wWindow, hWindow, col);
tft.setCursor( x+2, y + hWindow/2 - 3); tft.setCursor( x+2, y + hWindow/2 - 3);
tft.setTextSize(1); tft.setTextSize(1);
tft.setTextColor(col); tft.setTextColor(col);
tft.print(fenster->name); tft.print(fenster->name);
fenster->color = col; fenster->color = col;
} }
} }
DeciSeconds_t calcRemainingTime() DeciSeconds_t calcRemainingTime()
{ {
DeciSeconds_t remainingTime = 99999; DeciSeconds_t remainingTime = 99999;
for (uint8_t i = 0; i < NUM_FENSTER; i++) for (uint8_t i = 0; i < NUM_FENSTER; i++)
{ {
if (alleFenster[i]->IsOpen()) remainingTime = min(remainingTime, alleFenster[i]->GetRemainingTime()); if (alleFenster[i]->IsOpen()) remainingTime = min(remainingTime, alleFenster[i]->GetRemainingTime());
} }
return remainingTime; return remainingTime;
} }
/** /**
* *
*/ */
void Display::Update(void) void Display::Update(void)
{ {
// drawRect(pos_links,pos_oben,breite,hoehe,farbe); // drawRect(pos_links,pos_oben,breite,hoehe,farbe);
// setTextSize(groesse); // setTextSize(groesse);
//tft.fillScreen(ST7735_BLACK); //tft.fillScreen(ST7735_BLACK);
tft.drawRect(0, 0, 160, 128, ST7735_BLUE); tft.drawRect(0, 0, 160, 128, ST7735_BLUE);
tft.setFont(NULL); tft.setFont(NULL);
int x = 0; int x = 0;
int xs = 1; int xs = 1;
int y = 1; int y = 1;
#if 0 #if 0
drawWindow(xs + 0 * (wWindow + 2), y, &fensterBadOben); drawWindow(xs + 0 * (wWindow + 2), y, &fensterBadOben);
drawWindow(xs + 1 * (wWindow + 2), y, &fensterFlo); drawWindow(xs + 1 * (wWindow + 2), y, &fensterFlo);
drawWindow(xs + 2 * (wWindow + 2), y, &fensterHanna); drawWindow(xs + 2 * (wWindow + 2), y, &fensterHanna);
drawWindow(xs + 3 * (wWindow + 2), y, &fensterFloBuero); drawWindow(xs + 3 * (wWindow + 2), y, &fensterFloBuero);
y += hWindow + 2; y += hWindow + 2;
#endif #endif
drawWindow(xs , y, &fensterBadUnten); drawWindow(xs , y, &fensterBadUnten);
drawWindow(xs + 1 * (wWindow + 2), y, &fensterKueche); drawWindow(xs + 1 * (wWindow + 2), y, &fensterKueche);
drawWindow(xs + 2 * (wWindow + 2), y, &fensterWz); drawWindow(xs + 2 * (wWindow + 2), y, &fensterWz);
drawWindow(xs + 3 * (wWindow + 2), y, &fensterWz2); drawWindow(xs + 3 * (wWindow + 2), y, &fensterWz2);
//drawWindow(xs+3*(wWindow+2), y, "Bad", true); //drawWindow(xs+3*(wWindow+2), y, "Bad", true);
y += hWindow + 2; y += hWindow + 2;
drawWindow(xs + 0 * (wWindow + 2), y, &fensterToniNeu); drawWindow(xs + 0 * (wWindow + 2), y, &fensterToniNeu);
drawWindow(xs + 1 * (wWindow + 2), y, &fensterGefrier); drawWindow(xs + 1 * (wWindow + 2), y, &fensterGefrier);
y += hWindow + 2; y += hWindow + 2;
drawWindow(xs + 0 * (wWindow + 2), y, &fensterKeller); drawWindow(xs + 0 * (wWindow + 2), y, &fensterKeller);
drawWindow(xs + 1 * (wWindow + 2), y, &fensterGaeste); drawWindow(xs + 1 * (wWindow + 2), y, &fensterGaeste);
// drawWindow(xs+1*(wWindow+2), y, "Vorrat", getRandBool(), getRandBool()); // drawWindow(xs+1*(wWindow+2), y, "Vorrat", getRandBool(), getRandBool());
//drawWindow(xs+2*(wWindow+2), y, "Wohnz", true); //drawWindow(xs+2*(wWindow+2), y, "Wohnz", true);
//drawWindow(xs+3*(wWindow+2), y, "Bad", true); //drawWindow(xs+3*(wWindow+2), y, "Bad", true);
//tft.setFont(&FreeSans9pt7b); //tft.setFont(&FreeSans9pt7b);
tft.setTextSize(2); tft.setTextSize(2);
tft.setTextColor( ST77XX_CYAN); tft.setTextColor( ST77XX_CYAN);
x = 90; x = 90;
y = 70; y = 70;
tft.setCursor(x, y); tft.setCursor(x, y);
tft.fillRect(x, y-1, 159-90, 20, ST7735_BLACK ); tft.fillRect(x, y-1, 159-90, 20, ST7735_BLACK );
//thermoData.rh = 50; thermoData.temp =7.3; //thermoData.rh = 50; thermoData.temp =7.3;
if (thermoData.rhPercent > 0) if (thermoData.rhPercent > 0)
{ {
sprintf(strBuf, "% 3d C", (int) thermoData.tempC ); sprintf(strBuf, "% 3d C", (int) thermoData.tempC );
} }
else else
{ {
sprintf(strBuf, " --"); sprintf(strBuf, " --");
} }
tft.print(strBuf); tft.print(strBuf);
x = 10; x = 10;
y = 97; y = 97;
tft.setTextSize(3); tft.setTextSize(3);
int yrect = 90; int yrect = 90;
int xrect = 1; int xrect = 1;
uint16_t wrect = 158; uint16_t wrect = 158;
uint16_t hrect = 127-yrect; uint16_t hrect = 127-yrect;
strcpy(strBuf, ""); strcpy(strBuf, "");
for (uint8_t i = 0; i < NUM_FENSTER; i++) for (uint8_t i = 0; i < NUM_FENSTER; i++)
{ {
if (alleFenster[i]->ShallPiep()) if (alleFenster[i]->ShallPiep())
{ {
strcpy(strBuf, alleFenster[i]->name); strcpy(strBuf, alleFenster[i]->name);
break; break;
} }
} }
if (strlen(strBuf)==0) if (strlen(strBuf)==0)
{ {
DeciSeconds_t remainingTime = calcRemainingTime(); DeciSeconds_t remainingTime = calcRemainingTime();
uint8_t mins = (remainingTime / 10) / 60; uint8_t mins = (remainingTime / 10) / 60;
uint8_t secs = (remainingTime / 10) % 60; uint8_t secs = (remainingTime / 10) % 60;
if (mins < 60) if (mins < 60)
{ {
sprintf(strBuf, "%d:%02d", (int) (mins), (int) (secs)); sprintf(strBuf, "%d:%02d", (int) (mins), (int) (secs));
} }
} }
if (strlen(strBuf)==0) if (strlen(strBuf)==0)
{ {
tft.fillRect(xrect, yrect, wrect, hrect, ST7735_BLACK); tft.fillRect(xrect, yrect, wrect, hrect, ST7735_BLACK);
} }
else else
{ {
tft.fillRect(xrect, yrect, wrect, hrect, ST7735_WHITE); tft.fillRect(xrect, yrect, wrect, hrect, ST7735_WHITE);
tft.setTextColor( ST77XX_BLACK); tft.setTextColor( ST77XX_BLACK);
uint16_t w, h; uint16_t w, h;
int16_t x1, y1; int16_t x1, y1;
tft.getTextBounds(strBuf, x, y, &x1, &y1, &w, &h); tft.getTextBounds(strBuf, x, y, &x1, &y1, &w, &h);
tft.setCursor(xrect + (wrect - w) / 2, yrect + (hrect - h) / 2); tft.setCursor(xrect + (wrect - w) / 2, yrect + (hrect - h) / 2);
tft.print(strBuf); tft.print(strBuf);
} }
} }
#endif #endif
+29 -29
View File
@@ -1,29 +1,29 @@
/* /*
* Display.h * Display.h
* *
* Created on: 15.05.2020 * Created on: 15.05.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#if VERSION_BIG_DISPLAY #if VERSION_BIG_DISPLAY
#ifndef DISPLAY_H_ #ifndef DISPLAY_H_
#define DISPLAY_H_ #define DISPLAY_H_
class Display class Display
{ {
public: public:
void Init(void); void Init(void);
void Update(void); void Update(void);
private: private:
char strBuf[50]; char strBuf[50];
}; };
extern Display display; extern Display display;
#endif /* DISPLAY_H_ */ #endif /* DISPLAY_H_ */
#endif /* #if VERSION_EG_ONLY */ #endif /* #if VERSION_EG_ONLY */
+153 -153
View File
@@ -1,153 +1,153 @@
#include "main.h" #include "main.h"
#if VERSION_SMALL_DISPLAY #if VERSION_SMALL_DISPLAY
/* /*
* Display.cpp * Display.cpp
* *
* Created on: 15.05.2020 * Created on: 15.05.2020
* Author: flori * Author: flori
*/ */
#include "Arduino.h" #include "Arduino.h"
#include "Display_SSD1306.h" #include "Display_SSD1306.h"
#include "SSD1306Wire.h" /* LIBRARY : ESP8266_and_ESP32_OLED_driver_for_SSD1306_displays */ #include "SSD1306Wire.h" /* LIBRARY : ESP8266_and_ESP32_OLED_driver_for_SSD1306_displays */
// for 128x64 displays: // for 128x64 displays:
SSD1306Wire ssd1306(0x3c, SDA, SCL); // ADDRESS, SDA, SCL SSD1306Wire ssd1306(0x3c, SDA, SCL); // ADDRESS, SDA, SCL
Display display; Display display;
/** /**
* *
*/ */
void Display::Init(void) void Display::Init(void)
{ {
ssd1306.init(); ssd1306.init();
} }
DeciSeconds_t calcRemainingTime() DeciSeconds_t calcRemainingTime()
{ {
DeciSeconds_t remainingTime = 99999; DeciSeconds_t remainingTime = 99999;
for (uint8_t i = 0; i < NUM_FENSTER; i++) for (uint8_t i = 0; i < NUM_FENSTER; i++)
{ {
if (alleFenster[i]->IsOpen()) remainingTime = min(remainingTime, alleFenster[i]->GetRemainingTime()); if (alleFenster[i]->IsOpen()) remainingTime = min(remainingTime, alleFenster[i]->GetRemainingTime());
} }
return remainingTime; return remainingTime;
} }
/** /**
* *
*/ */
void Display::Update(void) void Display::Update(void)
{ {
ssd1306.clear(); ssd1306.clear();
ssd1306.setFont(ArialMT_Plain_16); /* https://github.com/ThingPulse/esp8266-oled-ssd1306/blob/master/README.md */ ssd1306.setFont(ArialMT_Plain_16); /* https://github.com/ThingPulse/esp8266-oled-ssd1306/blob/master/README.md */
ssd1306.setBrightness(100u); ssd1306.setBrightness(100u);
int x = 2; int x = 2;
int y = 0; int y = 0;
int yrect = 0; int yrect = 0;
int xrect = 0; int xrect = 0;
uint16_t wrect = 64; uint16_t wrect = 64;
uint16_t hrect = 18; uint16_t hrect = 18;
/* print Windows */ /* print Windows */
uint8_t i; uint8_t i;
for (i=0; i<NUM_FENSTER; i++) for (i=0; i<NUM_FENSTER; i++)
{ {
if (alleFenster[i]->IsOpen()) if (alleFenster[i]->IsOpen())
{ {
ssd1306.setColor(WHITE); ssd1306.setColor(WHITE);
ssd1306.fillRect(xrect, yrect, wrect, hrect); ssd1306.fillRect(xrect, yrect, wrect, hrect);
ssd1306.setColor(BLACK); ssd1306.setColor(BLACK);
ssd1306.drawString(x, y, alleFenster[i]->name); ssd1306.drawString(x, y, alleFenster[i]->name);
ssd1306.drawString(x+1, y, alleFenster[i]->name); ssd1306.drawString(x+1, y, alleFenster[i]->name);
ssd1306.drawString(x+1, y+1, alleFenster[i]->name); ssd1306.drawString(x+1, y+1, alleFenster[i]->name);
ssd1306.drawString(x, y+1, alleFenster[i]->name); ssd1306.drawString(x, y+1, alleFenster[i]->name);
} }
else else
{ {
ssd1306.setColor(WHITE); ssd1306.setColor(WHITE);
ssd1306.drawString(x, y, alleFenster[i]->name); ssd1306.drawString(x, y, alleFenster[i]->name);
} }
if (i&1) if (i&1)
{ {
xrect = 0u; xrect = 0u;
x = 2u; x = 2u;
yrect += 20; yrect += 20;
y+= 20; y+= 20;
} }
else else
{ {
xrect = 64; xrect = 64;
x = 66; x = 66;
} }
} }
/* print Temperature */ /* print Temperature */
x=0; x=0;
y=64-16; y=64-16;
if (thermoData.rhPercent > 0) if (thermoData.rhPercent > 0)
{ {
sprintf(strBuf, "% 3d C", (int) thermoData.tempC); sprintf(strBuf, "% 3d C", (int) thermoData.tempC);
} }
else else
{ {
sprintf(strBuf, " --"); sprintf(strBuf, " --");
} }
//tft.print(strBuf); //tft.print(strBuf);
ssd1306.setColor(WHITE); ssd1306.setColor(WHITE);
ssd1306.drawString(x, y, strBuf); ssd1306.drawString(x, y, strBuf);
/* print Remaining time */ /* print Remaining time */
yrect = 64-16; yrect = 64-16;
xrect = 64; xrect = 64;
wrect = 32; wrect = 32;
hrect = 16; hrect = 16;
strcpy(strBuf, ""); strcpy(strBuf, "");
for (uint8_t i = 0; i < NUM_FENSTER; i++) for (uint8_t i = 0; i < NUM_FENSTER; i++)
{ {
if (alleFenster[i]->ShallPiep()) if (alleFenster[i]->ShallPiep())
{ {
strcpy(strBuf, alleFenster[i]->name); strcpy(strBuf, alleFenster[i]->name);
break; break;
} }
} }
if (strlen(strBuf)==0) if (strlen(strBuf)==0)
{ {
DeciSeconds_t remainingTime = calcRemainingTime(); DeciSeconds_t remainingTime = calcRemainingTime();
uint8_t mins = (remainingTime / 10) / 60; uint8_t mins = (remainingTime / 10) / 60;
uint8_t secs = (remainingTime / 10) % 60; uint8_t secs = (remainingTime / 10) % 60;
if (mins < 60) if (mins < 60)
{ {
sprintf(strBuf, "%d:%02d", (int) (mins), (int) (secs)); sprintf(strBuf, "%d:%02d", (int) (mins), (int) (secs));
} }
} }
if (strlen(strBuf)==0) if (strlen(strBuf)==0)
{ {
//ssd1306.setColor(BLACK); //ssd1306.setColor(BLACK);
//ssd1306.fillRect(xrect, yrect, wrect, hrect); //ssd1306.fillRect(xrect, yrect, wrect, hrect);
} }
else else
{ {
ssd1306.setColor(WHITE); ssd1306.setColor(WHITE);
//ssd1306.fillRect(xrect, yrect, wrect, hrect); //ssd1306.fillRect(xrect, yrect, wrect, hrect);
//ssd1306.setColor(BLACK); //ssd1306.setColor(BLACK);
ssd1306.drawString(xrect,yrect, strBuf); ssd1306.drawString(xrect,yrect, strBuf);
ssd1306.drawString(xrect+1,yrect, strBuf); ssd1306.drawString(xrect+1,yrect, strBuf);
} }
ssd1306.display(); ssd1306.display();
} }
#endif // #if VERSION_DG_ONLY #endif // #if VERSION_DG_ONLY
+30 -30
View File
@@ -1,30 +1,30 @@
/* /*
* Display.h * Display.h
* *
* Created on: 15.05.2020 * Created on: 15.05.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#if VERSION_SMALL_DISPLAY #if VERSION_SMALL_DISPLAY
#ifndef DISPLAY_SSD1306_H_ #ifndef DISPLAY_SSD1306_H_
#define DISPLAY_SSD1306_H_ #define DISPLAY_SSD1306_H_
class Display class Display
{ {
public: public:
void Init(void); void Init(void);
void Update(void); void Update(void);
private: private:
char strBuf[50]; char strBuf[50];
}; };
extern Display display; extern Display display;
#endif /* DISPLAY_SSD1306_H_ */ #endif /* DISPLAY_SSD1306_H_ */
#endif #endif
+107 -107
View File
@@ -1,107 +1,107 @@
/* /*
* Fenster.cpp * Fenster.cpp
* *
* Created on: 29.02.2020 * Created on: 29.02.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "Fenster.h" #include "Fenster.h"
#include "ReceiverFunkThermometer.h" #include "ReceiverFunkThermometer.h"
#define SERIAL_PRINT(x) //Serial.print(" "); Serial.print(x) #define SERIAL_PRINT(x) //Serial.print(" "); Serial.print(x)
/** /**
* *
*/ */
Fenster::Fenster(const char *_name, uint8_t myKeyNumber) Fenster::Fenster(const char *_name, uint8_t myKeyNumber)
{ {
strcpy(this->name , _name); strcpy(this->name , _name);
this->myKeyNumber = myKeyNumber; this->myKeyNumber = myKeyNumber;
openingTime = 0; openingTime = 0;
shallPiep = false; shallPiep = false;
color = 0; color = 0;
} }
/** /**
* keyNum : key number with offset * keyNum : key number with offset
*/ */
bool Fenster::HandleKey(int8_t keyNum, bool direction) bool Fenster::HandleKey(int8_t keyNum, bool direction)
{ {
bool bThisWindowChanged = false; bool bThisWindowChanged = false;
if (keyNum == myKeyNumber) if (keyNum == myKeyNumber)
{ {
if (direction == DIRECTION_OPEN) if (direction == DIRECTION_OPEN)
{ {
if (openingTime == 0u) if (openingTime == 0u)
{ {
bThisWindowChanged = true; bThisWindowChanged = true;
openingTime = tDecis; openingTime = tDecis;
SERIAL_PRINT("open "); SERIAL_PRINT("open ");
SERIAL_PRINT(myKeyNumber); SERIAL_PRINT(myKeyNumber);
SERIAL_PRINT(waitTimeDs); SERIAL_PRINT(waitTimeDs);
} }
} }
else else
{ {
if (openingTime != 0u) if (openingTime != 0u)
{ {
bThisWindowChanged = true; bThisWindowChanged = true;
shallPiep = false; shallPiep = false;
openingTime = 0; openingTime = 0;
SERIAL_PRINT("close "); SERIAL_PRINT("close ");
SERIAL_PRINT(myKeyNumber); SERIAL_PRINT(myKeyNumber);
} }
} }
} }
return bThisWindowChanged; return bThisWindowChanged;
} }
/** /**
* *
*/ */
bool Fenster::ShallPiep() bool Fenster::ShallPiep()
{ {
DeciSeconds_t tWaitDs = waitTimeDs; DeciSeconds_t tWaitDs = waitTimeDs;
if (this == &fensterGefrier) if (this == &fensterGefrier)
{ {
tWaitDs = 300u; tWaitDs = 300u;
} }
if ((tDecis > openingTime + tWaitDs) && (openingTime > 0)) if ((tDecis > openingTime + tWaitDs) && (openingTime > 0))
{ {
shallPiep = true; shallPiep = true;
} }
return shallPiep; return shallPiep;
} }
/** /**
* *
*/ */
DeciSeconds_t Fenster::GetRemainingTime() DeciSeconds_t Fenster::GetRemainingTime()
{ {
DeciSeconds_t tWaitDs = waitTimeDs; DeciSeconds_t tWaitDs = waitTimeDs;
if (this == &fensterGefrier) if (this == &fensterGefrier)
{ {
tWaitDs = 300u; tWaitDs = 300u;
} }
if (openingTime > 0) if (openingTime > 0)
{ {
DeciSeconds_t remainingTime = openingTime + tWaitDs - tDecis; DeciSeconds_t remainingTime = openingTime + tWaitDs - tDecis;
return remainingTime; return remainingTime;
} }
else else
{ {
return 0; return 0;
} }
} }
bool Fenster::IsOpen() bool Fenster::IsOpen()
{ {
return (openingTime > 0); return (openingTime > 0);
} }
+32 -32
View File
@@ -1,32 +1,32 @@
/* /*
* Fenster.h * Fenster.h
* *
* Created on: 29.02.2020 * Created on: 29.02.2020
* Author: flori * Author: flori
*/ */
#ifndef FENSTER_H_ #ifndef FENSTER_H_
#define FENSTER_H_ #define FENSTER_H_
#include "typedefs.h" #include "typedefs.h"
class Fenster class Fenster
{ {
public: public:
char name[8]; char name[8];
uint16_t color; uint16_t color;
Fenster(const char *_name, uint8_t myKeyNumber); Fenster(const char *_name, uint8_t myKeyNumber);
bool HandleKey(int8_t keyNum, bool direction); bool HandleKey(int8_t keyNum, bool direction);
bool ShallPiep(); bool ShallPiep();
DeciSeconds_t GetRemainingTime(); DeciSeconds_t GetRemainingTime();
bool IsOpen(); bool IsOpen();
private: private:
uint8_t myKeyNumber; uint8_t myKeyNumber;
DeciSeconds_t openingTime; DeciSeconds_t openingTime;
bool shallPiep; bool shallPiep;
}; };
#endif /* FENSTER_H_ */ #endif /* FENSTER_H_ */
+20 -20
View File
@@ -1,20 +1,20 @@
/* /*
* Hamming.cpp * Hamming.cpp
* *
* Created on: 10.10.2022 * Created on: 10.10.2022
* Author: flori * Author: flori
*/ */
#include "Hamming.h" #include "Hamming.h"
Hamming::Hamming() Hamming::Hamming()
{ {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
Hamming::~Hamming() Hamming::~Hamming()
{ {
// TODO Auto-generated destructor stub // TODO Auto-generated destructor stub
} }
+18 -18
View File
@@ -1,18 +1,18 @@
/* /*
* Hamming.h * Hamming.h
* *
* Created on: 10.10.2022 * Created on: 10.10.2022
* Author: flori * Author: flori
*/ */
#ifndef HAMMING_H_ #ifndef HAMMING_H_
#define HAMMING_H_ #define HAMMING_H_
class Hamming class Hamming
{ {
public: public:
Hamming(); Hamming();
virtual ~Hamming(); virtual ~Hamming();
}; };
#endif /* HAMMING_H_ */ #endif /* HAMMING_H_ */
+156 -156
View File
@@ -1,156 +1,156 @@
#include "main.h" #include "main.h"
#include "PiepPattern.h" #include "PiepPattern.h"
#include "ReceiverSmartWares.h" #include "ReceiverSmartWares.h"
#include "ReceiverAiggend.h" #include "ReceiverAiggend.h"
#include "ReceiverOval.h" #include "ReceiverOval.h"
#include "ReceiverKerui.h" #include "ReceiverKerui.h"
#include "ReceiverFunkThermometer.h" #include "ReceiverFunkThermometer.h"
#include "InterruptHandler.h" #include "InterruptHandler.h"
#define LOOP_COUNTS_FOR_PAUSE (2u) #define LOOP_COUNTS_FOR_PAUSE (2u)
/*****************************************************/ /*****************************************************/
IRAM_ATTR void timerIsr(); IRAM_ATTR void timerIsr();
IRAM_ATTR void pinLevelChangeIsr(void); IRAM_ATTR void pinLevelChangeIsr(void);
/*****************************************************/ /*****************************************************/
hw_timer_t * timer; hw_timer_t * timer;
/** /**
* *
*/ */
void InterruptHandler_Init(void) void InterruptHandler_Init(void)
{ {
/* setup interrupt */ /* setup interrupt */
attachInterrupt(digitalPinToInterrupt(DIN_FUNK), pinLevelChangeIsr, CHANGE); attachInterrupt(digitalPinToInterrupt(DIN_FUNK), pinLevelChangeIsr, CHANGE);
#if 1 #if 1
timer = timerBegin(0, 80, true); /* 80 -> 1 Mhz */ timer = timerBegin(0, 80, true); /* 80 -> 1 Mhz */
timerAttachInterrupt(timer, &timerIsr, true); timerAttachInterrupt(timer, &timerIsr, true);
timerAlarmWrite(timer, ISR_TIME_US, true); timerAlarmWrite(timer, ISR_TIME_US, true);
timerAlarmEnable(timer); timerAlarmEnable(timer);
#endif #endif
} }
/** /**
* called every 10 ms * called every 10 ms
* *
* used to update tDecis, and for beeping * used to update tDecis, and for beeping
*/ */
IRAM_ATTR void timerIsr() IRAM_ATTR void timerIsr()
{ {
static uint32_t tshortPiepStartedMs = 0; static uint32_t tshortPiepStartedMs = 0;
static uint8_t count = 0; static uint8_t count = 0;
static boolean toneOn = false; static boolean toneOn = false;
uint32_t tMillis = millis(); uint32_t tMillis = millis();
#if 0 #if 0
static bool on = true; static bool on = true;
if (on) digitalWrite(DOUT_TEST_TIMER, HIGH); if (on) digitalWrite(DOUT_TEST_TIMER, HIGH);
else digitalWrite(DOUT_TEST_TIMER, LOW); else digitalWrite(DOUT_TEST_TIMER, LOW);
on = !on; on = !on;
#endif #endif
if (++count == MS_TO_ISR_COUNT(100uL) ) if (++count == MS_TO_ISR_COUNT(100uL) )
{ {
/* increment tDecis every 100ms */ /* increment tDecis every 100ms */
count = 0; count = 0;
tDecis++; tDecis++;
} }
if (bRequestShortBeep) if (bRequestShortBeep)
{ {
bRequestShortBeep = false; bRequestShortBeep = false;
tshortPiepStartedMs = tMillis; tshortPiepStartedMs = tMillis;
} }
if (tshortPiepStartedMs > 0u) if (tshortPiepStartedMs > 0u)
{ {
if (tMillis < (tshortPiepStartedMs + 30uL)) if (tMillis < (tshortPiepStartedMs + 30uL))
{ {
if (false == toneOn) if (false == toneOn)
{ {
TONE_REQUEST_ON(TONE_REQUEST_SOURCE_SHORTPIEP); TONE_REQUEST_ON(TONE_REQUEST_SOURCE_SHORTPIEP);
toneOn = true; toneOn = true;
} }
} }
else else
{ {
TONE_REQUEST_OFF(TONE_REQUEST_SOURCE_SHORTPIEP); TONE_REQUEST_OFF(TONE_REQUEST_SOURCE_SHORTPIEP);
tshortPiepStartedMs = 0; tshortPiepStartedMs = 0;
toneOn = false; toneOn = false;
} }
} }
else else
{ {
piepPattern->TaskCyclic(); piepPattern->TaskCyclic();
} }
if (toneRequest != 0u) if (toneRequest != 0u)
{ {
digitalWrite(DOUT_PIEP_VCC, HIGH); digitalWrite(DOUT_PIEP_VCC, HIGH);
} }
else else
{ {
digitalWrite(DOUT_PIEP_VCC, LOW); digitalWrite(DOUT_PIEP_VCC, LOW);
} }
} }
IRAM_ATTR void InterruptHandler_Stop(void) IRAM_ATTR void InterruptHandler_Stop(void)
{ {
timerAlarmDisable(timer); timerAlarmDisable(timer);
detachInterrupt(digitalPinToInterrupt(DIN_FUNK)); detachInterrupt(digitalPinToInterrupt(DIN_FUNK));
} }
IRAM_ATTR void InterruptHandler_PauseReceive() IRAM_ATTR void InterruptHandler_PauseReceive()
{ {
loopCountSincePause = 0u; loopCountSincePause = 0u;
} }
/** /**
* *
*/ */
IRAM_ATTR void pinLevelChangeIsr(void) IRAM_ATTR void pinLevelChangeIsr(void)
{ {
static bool lastVal = LOW; static bool lastVal = LOW;
static uint32_t lastMics = 0; static uint32_t lastMics = 0;
static uint32_t MINIMAL_DT_MICROS_FOR_RECEIVERS = 100u; static uint32_t MINIMAL_DT_MICROS_FOR_RECEIVERS = 100u;
uint32_t dtMicros = micros() - lastMics; uint32_t dtMicros = micros() - lastMics;
bool pinFunkVal = digitalRead(DIN_FUNK); bool pinFunkVal = digitalRead(DIN_FUNK);
if (lastVal == pinFunkVal) if (lastVal == pinFunkVal)
{ {
return; return;
} }
else else
{ {
lastMics = micros(); lastMics = micros();
lastVal = pinFunkVal; lastVal = pinFunkVal;
if (loopCountSincePause < LOOP_COUNTS_FOR_PAUSE) if (loopCountSincePause < LOOP_COUNTS_FOR_PAUSE)
{ {
/* after receiving a key, wait for the main loop to run x times before activating receiving again */ /* after receiving a key, wait for the main loop to run x times before activating receiving again */
return; return;
} }
else if (dtMicros > MINIMAL_DT_MICROS_FOR_RECEIVERS) else if (dtMicros > MINIMAL_DT_MICROS_FOR_RECEIVERS)
{ {
receiverSw.Isr(dtMicros, pinFunkVal); receiverSw.Isr(dtMicros, pinFunkVal);
receiverAiggend.Isr(dtMicros, pinFunkVal); receiverAiggend.Isr(dtMicros, pinFunkVal);
receiverOval.Isr(dtMicros, pinFunkVal); receiverOval.Isr(dtMicros, pinFunkVal);
receiverKerui.Isr(dtMicros, pinFunkVal); receiverKerui.Isr(dtMicros, pinFunkVal);
receiverThermo.Isr(dtMicros, pinFunkVal); receiverThermo.Isr(dtMicros, pinFunkVal);
//digitalWrite(LED_BUILTIN, pinFunkVal); //digitalWrite(LED_BUILTIN, pinFunkVal);
} }
} }
} }
+33 -25
View File
@@ -1,25 +1,33 @@
/* /*
* interruptHandler.h * interruptHandler.h
* *
* Created on: 11.10.2022 * Created on: 11.10.2022
* Author: flori * Author: flori
*/ */
#ifndef INTERRUPTHANDLER_H_ #ifndef INTERRUPTHANDLER_H_
#define INTERRUPTHANDLER_H_ #define INTERRUPTHANDLER_H_
#include "Arduino.h" #include "Arduino.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#define ISR_TIME_US (10000uL) #include "freertos/queue.h"
#define MS_TO_ISR_COUNT(ms) ( ((ms)*1000uL) / ISR_TIME_US ) #define ISR_TIME_US (10000uL)
#define MS_TO_ISR_COUNT(ms) ( ((ms)*1000uL) / ISR_TIME_US )
void InterruptHandler_Init(void);
void InterruptHandler_PauseReceive(); /* RF pulse event pushed from pinLevelChangeIsr to rfDecodeTask via queue */
void InterruptHandler_Stop(void); typedef struct {
uint32_t dtMicros;
bool pinValue;
} RfEvent_t;
#endif /* INTERRUPTHANDLER_H_ */
extern SemaphoreHandle_t beepSemaphore; /* given every ISR_TIME_US to wake beepTask */
extern QueueHandle_t rfEventQueue; /* RF pulse events for rfDecodeTask */
void InterruptHandler_Init(void);
void InterruptHandler_PauseReceive();
void InterruptHandler_Stop(void);
#endif /* INTERRUPTHANDLER_H_ */
+54 -54
View File
@@ -1,54 +1,54 @@
/* /*
* LedBlinker.cpp * LedBlinker.cpp
* *
* Created on: 29.02.2020 * Created on: 29.02.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "LedBlinker.h" #include "LedBlinker.h"
#include "ReceiverFunkThermometer.h" #include "ReceiverFunkThermometer.h"
#define BLINK_TIME ((DeciSeconds_t)2) #define BLINK_TIME ((DeciSeconds_t)2)
LedBlinker ledBlinker; LedBlinker ledBlinker;
/** /**
* *
*/ */
void LedBlinker::OnLoop() void LedBlinker::OnLoop()
{ {
static DeciSeconds_t tOn; static DeciSeconds_t tOn;
static DeciSeconds_t tOff; static DeciSeconds_t tOff;
static uint32_t numBlinkFast = 0; static uint32_t numBlinkFast = 0;
if (numberWindowsOpen > 0) if (numberWindowsOpen > 0)
{ {
if (tDecis > tOn) if (tDecis > tOn)
{ {
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(LED_BUILTIN, HIGH);
tOff = tDecis + BLINK_TIME; tOff = tDecis + BLINK_TIME;
tOn = tOff + BLINK_TIME; tOn = tOff + BLINK_TIME;
} }
if (tDecis > tOff) if (tDecis > tOff)
{ {
digitalWrite(LED_BUILTIN, LOW); digitalWrite(LED_BUILTIN, LOW);
tOn = tDecis + BLINK_TIME; tOn = tDecis + BLINK_TIME;
tOff = tOn + BLINK_TIME; tOff = tOn + BLINK_TIME;
if (numBlinkFast>0) if (numBlinkFast>0)
{ {
numBlinkFast--; numBlinkFast--;
} }
else else
{ {
numBlinkFast = numberWindowsOpen-1; numBlinkFast = numberWindowsOpen-1;
tOn += BLINK_TIME*3; tOn += BLINK_TIME*3;
tOff += BLINK_TIME*3; tOff += BLINK_TIME*3;
} }
} }
} }
} }
+19 -19
View File
@@ -1,19 +1,19 @@
/* /*
* LedBlinker.h * LedBlinker.h
* *
* Created on: 29.02.2020 * Created on: 29.02.2020
* Author: flori * Author: flori
*/ */
#ifndef LEDBLINKER_H_ #ifndef LEDBLINKER_H_
#define LEDBLINKER_H_ #define LEDBLINKER_H_
class LedBlinker class LedBlinker
{ {
public: public:
void OnLoop(); void OnLoop();
}; };
extern LedBlinker ledBlinker; extern LedBlinker ledBlinker;
#endif /* LEDBLINKER_H_ */ #endif /* LEDBLINKER_H_ */
+194 -194
View File
@@ -1,194 +1,194 @@
/* /*
* MyWifiClient.cpp * MyWifiClient.cpp
* *
* Created on: 24.09.2020 * Created on: 24.09.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "Base32.h" #include "Base32.h"
#include "Seconds.h" #include "Seconds.h"
#include "Version.h" #include "Version.h"
#include "MyWifiClient.h" #include "MyWifiClient.h"
Base32 base32; Base32 base32;
#if 1 #if 1
#define MonitorPrint(...) Serial.print(__VA_ARGS__) #define MonitorPrint(...) Serial.print(__VA_ARGS__)
#define MonitorPrintln(...) Serial.println(__VA_ARGS__) #define MonitorPrintln(...) Serial.println(__VA_ARGS__)
#else #else
#define MonitorPrint(...) #define MonitorPrint(...)
#define MonitorPrintln(...) #define MonitorPrintln(...)
#endif #endif
MyWifiClient myWifiClient; MyWifiClient myWifiClient;
/** /**
* *
*/ */
MyWifiClient::MyWifiClient() MyWifiClient::MyWifiClient()
{ {
state = IDLE; state = IDLE;
bSend = false; bSend = false;
} }
/** /**
* *
*/ */
MyWifiClient::~MyWifiClient() MyWifiClient::~MyWifiClient()
{ {
} }
/** /**
* *
*/ */
bool MyWifiClient::canSend(void) bool MyWifiClient::canSend(void)
{ {
return state == IDLE && bSend == false; return state == IDLE && bSend == false;
} }
/* converts dat to base32 and triggers GET request */ /* converts dat to base32 and triggers GET request */
void MyWifiClient::send(uint8_t *dat, uint16_t len) void MyWifiClient::send(uint8_t *dat, uint16_t len)
{ {
strcpy( wifibufMsg , "GET /genericData.php?project=fensterpiepser&dataname=fenster&data="); strcpy( wifibufMsg , "GET /genericData.php?project=fensterpiepser&dataname=fenster&data=");
size_t pos = strlen(wifibufMsg); size_t pos = strlen(wifibufMsg);
(void) base32.toBase32(dat, len, &wifibufMsg[pos], true); (void) base32.toBase32(dat, len, &wifibufMsg[pos], true);
strcat( wifibufMsg, " HTTP/1.1\r\nHost: fly-with-cats.com\r\nAccept: */*\r\n\r\n"); strcat( wifibufMsg, " HTTP/1.1\r\nHost: fly-with-cats.com\r\nAccept: */*\r\n\r\n");
bSend = true; bSend = true;
} }
/** /**
* *
*/ */
void MyWifiClient::onSetup(void) void MyWifiClient::onSetup(void)
{ {
} }
/** /**
* *
*/ */
void MyWifiClient::onLoop(void) void MyWifiClient::onLoop(void)
{ {
static substate_t substate = ENTRY; static substate_t substate = ENTRY;
static state_t prevState = IDLE; static state_t prevState = IDLE;
if (prevState != state) if (prevState != state)
{ {
substate = ENTRY; substate = ENTRY;
prevState = state; prevState = state;
switch(state) switch(state)
{ {
case IDLE: case IDLE:
MonitorPrintln("IDLE"); MonitorPrintln("IDLE");
break; break;
case WAIT_CONNECT: case WAIT_CONNECT:
MonitorPrintln("WAIT_CONNECT"); MonitorPrintln("WAIT_CONNECT");
break; break;
case WAIT_RECEIVE: case WAIT_RECEIVE:
MonitorPrintln("WAIT_RECEIVE"); MonitorPrintln("WAIT_RECEIVE");
break; break;
} }
} }
switch (state) switch (state)
{ {
case IDLE: case IDLE:
switch (substate) switch (substate)
{ {
static uint32_t tConnectWifiEndSeconds; static uint32_t tConnectWifiEndSeconds;
case ENTRY: case ENTRY:
tConnectWifiEndSeconds = Seconds::Get() + 60; tConnectWifiEndSeconds = Seconds::Get() + 60;
substate = CYCLIC; substate = CYCLIC;
break; break;
case CYCLIC: case CYCLIC:
if (WiFi.isConnected()) if (WiFi.isConnected())
{ {
tConnectWifiEndSeconds = Seconds::Get() + 60; tConnectWifiEndSeconds = Seconds::Get() + 60;
if (bSend) if (bSend)
{ {
bSend = false; bSend = false;
state = WAIT_CONNECT; state = WAIT_CONNECT;
} }
} }
else else
{ {
if (Seconds::Get() > tConnectWifiEndSeconds) if (Seconds::Get() > tConnectWifiEndSeconds)
{ {
Serial.println("RESET (Wifi)"); Serial.println("RESET (Wifi)");
ESP.restart(); ESP.restart();
} }
} }
break; break;
} }
break; break;
case WAIT_CONNECT: case WAIT_CONNECT:
switch (substate) switch (substate)
{ {
static uint32_t tConnectEndSeconds; static uint32_t tConnectEndSeconds;
case ENTRY: case ENTRY:
/* Connect to Server */ /* Connect to Server */
this->connect("fly-with-cats.com", 8887, 100); this->connect("fly-with-cats.com", 8887, 100);
tConnectEndSeconds = Seconds::Get() + 5; tConnectEndSeconds = Seconds::Get() + 5;
substate = CYCLIC; substate = CYCLIC;
break; break;
case CYCLIC: case CYCLIC:
if (this->connected()) if (this->connected())
{ {
/* send HTTP request */ /* send HTTP request */
this->print(wifibufMsg); this->print(wifibufMsg);
MonitorPrint(wifibufMsg); MonitorPrint(wifibufMsg);
state = WAIT_RECEIVE; state = WAIT_RECEIVE;
} }
else if (Seconds::Get() > tConnectEndSeconds) else if (Seconds::Get() > tConnectEndSeconds)
{ {
state = IDLE; state = IDLE;
} }
break; break;
} }
break; break;
case WAIT_RECEIVE: case WAIT_RECEIVE:
switch (substate) switch (substate)
{ {
static uint32_t tReceiveEndSeconds; static uint32_t tReceiveEndSeconds;
case ENTRY: case ENTRY:
tReceiveEndSeconds = Seconds::Get() + 5; tReceiveEndSeconds = Seconds::Get() + 5;
substate = CYCLIC; substate = CYCLIC;
break; break;
case CYCLIC: case CYCLIC:
if (this->available()) if (this->available())
{ {
int sizeRec = this->read(wifibufRx, WIFI_BUF_SIZE_RX); int sizeRec = this->read(wifibufRx, WIFI_BUF_SIZE_RX);
wifibufRx[sizeRec] = 0; wifibufRx[sizeRec] = 0;
//MonitorPrintln((char*)wifibufRx); //MonitorPrintln((char*)wifibufRx);
state = IDLE; state = IDLE;
} }
else if (Seconds::Get() >= tReceiveEndSeconds) else if (Seconds::Get() >= tReceiveEndSeconds)
{ {
this->stop(); this->stop();
state = IDLE; state = IDLE;
} }
break; break;
} }
} }
} }
+41 -41
View File
@@ -1,41 +1,41 @@
/* /*
* MyWifiClient.h * MyWifiClient.h
* *
* Created on: 24.09.2020 * Created on: 24.09.2020
* Author: flori * Author: flori
*/ */
#ifndef MYWIFICLIENT_H_ #ifndef MYWIFICLIENT_H_
#define MYWIFICLIENT_H_ #define MYWIFICLIENT_H_
#include <WiFi.h> #include <WiFi.h>
#include "Base32.h" #include "Base32.h"
#include <WiFiClient.h> #include <WiFiClient.h>
#define WIFI_BUF_SIZE_RX 1024 #define WIFI_BUF_SIZE_RX 1024
typedef enum { IDLE, WAIT_CONNECT, WAIT_RECEIVE } state_t; typedef enum { IDLE, WAIT_CONNECT, WAIT_RECEIVE } state_t;
typedef enum { ENTRY, CYCLIC } substate_t; typedef enum { ENTRY, CYCLIC } substate_t;
class MyWifiClient: public WiFiClient class MyWifiClient: public WiFiClient
{ {
public: public:
MyWifiClient(); MyWifiClient();
virtual ~MyWifiClient(); virtual ~MyWifiClient();
void send(uint8_t *dat, uint16_t len); void send(uint8_t *dat, uint16_t len);
void onSetup(void); void onSetup(void);
void onLoop(void); void onLoop(void);
bool canSend(void); bool canSend(void);
private: private:
bool bSend; bool bSend;
state_t state; state_t state;
char wifibufMsg[WIFI_BUF_SIZE_RX]; char wifibufMsg[WIFI_BUF_SIZE_RX];
uint8_t wifibufRx[WIFI_BUF_SIZE_RX]; uint8_t wifibufRx[WIFI_BUF_SIZE_RX];
}; };
extern MyWifiClient myWifiClient; extern MyWifiClient myWifiClient;
extern Base32 base32; extern Base32 base32;
#endif /* MYWIFICLIENT_H_ */ #endif /* MYWIFICLIENT_H_ */
+146 -146
View File
@@ -1,146 +1,146 @@
/* /*
* PiepMode.cpp * PiepMode.cpp
* *
* Created on: 25.02.2020 * Created on: 25.02.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "PiepMode.h" #include "PiepMode.h"
#define SERIAL_PRINT(x) //Serial.print(" "); Serial.print(x) #define SERIAL_PRINT(x) //Serial.print(" "); Serial.print(x)
#define STANDBY 0 #define STANDBY 0
#define ON 1 #define ON 1
#define OFF 2 #define OFF 2
/** /**
* *
*/ */
PiepMode::PiepMode() PiepMode::PiepMode()
{ {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
state = STANDBY; state = STANDBY;
startRequest = false; startRequest = false;
stopRequest = false; stopRequest = false;
requestCount = 255; requestCount = 255;
timer = 0; timer = 0;
onTime = 100; onTime = 100;
offTime = 100; offTime = 100;
counter = 0; counter = 0;
outPin = 13; outPin = 13;
} }
/** /**
* *
*/ */
IRAM_ATTR void PiepMode::Start(uint8_t outPin) IRAM_ATTR void PiepMode::Start(uint8_t outPin)
{ {
startRequest = true; startRequest = true;
this->outPin = outPin; this->outPin = outPin;
//pinMode(outPin, OUTPUT); //pinMode(outPin, OUTPUT);
state = STANDBY; state = STANDBY;
} }
/** /**
* *
*/ */
IRAM_ATTR void PiepMode::Stop() IRAM_ATTR void PiepMode::Stop()
{ {
stopRequest = true; stopRequest = true;
TONE_REQUEST_OFF(TONE_REQUEST_SOURCE_MODE); TONE_REQUEST_OFF(TONE_REQUEST_SOURCE_MODE);
} }
/** /**
* *
*/ */
IRAM_ATTR bool PiepMode::HasCompleted(void) IRAM_ATTR bool PiepMode::HasCompleted(void)
{ {
return (state == STANDBY); return (state == STANDBY);
} }
/** /**
* *
*/ */
IRAM_ATTR void PiepMode::TaskCyclic() IRAM_ATTR void PiepMode::TaskCyclic()
{ {
switch (state) switch (state)
{ {
case STANDBY: case STANDBY:
SERIAL_PRINT("S"); SERIAL_PRINT("S");
stopRequest = false; stopRequest = false;
if (startRequest) if (startRequest)
{ {
startRequest = false; startRequest = false;
state = ON; state = ON;
counter = 0; counter = 0;
timer = onTime; timer = onTime;
} }
break; break;
case ON: case ON:
SERIAL_PRINT(timer); SERIAL_PRINT(timer);
SERIAL_PRINT(onTime); SERIAL_PRINT(onTime);
/* switch on */ /* switch on */
startRequest = false; startRequest = false;
if (stopRequest) if (stopRequest)
{ {
state = STANDBY; state = STANDBY;
} }
else if (timer > 0) else if (timer > 0)
{ {
TONE_REQUEST_ON(TONE_REQUEST_SOURCE_MODE); TONE_REQUEST_ON(TONE_REQUEST_SOURCE_MODE);
timer--; timer--;
} }
else else
{ {
timer = offTime; timer = offTime;
state = OFF; state = OFF;
} }
break; break;
case OFF: case OFF:
SERIAL_PRINT("F"); SERIAL_PRINT("F");
/* switch off */ /* switch off */
startRequest = false; startRequest = false;
if (stopRequest) if (stopRequest)
{ {
state = STANDBY; state = STANDBY;
} }
else if (timer > 0) else if (timer > 0)
{ {
TONE_REQUEST_OFF(TONE_REQUEST_SOURCE_MODE); TONE_REQUEST_OFF(TONE_REQUEST_SOURCE_MODE);
timer--; timer--;
} }
else if (requestCount == 0) else if (requestCount == 0)
{ {
timer = onTime; timer = onTime;
state = ON; state = ON;
} }
else if (++counter < requestCount) else if (++counter < requestCount)
{ {
timer = onTime; timer = onTime;
state = ON; state = ON;
} }
else else
{ {
state = STANDBY; state = STANDBY;
} }
break; break;
default: default:
Serial.print(state); Serial.print(state);
break; break;
} }
} }
+30 -30
View File
@@ -1,30 +1,30 @@
/* /*
* PiepMode.h * PiepMode.h
* *
* Created on: 25.02.2020 * Created on: 25.02.2020
* Author: flori * Author: flori
*/ */
#ifndef PIEPMODE_H_ #ifndef PIEPMODE_H_
#define PIEPMODE_H_ #define PIEPMODE_H_
class PiepMode class PiepMode
{ {
public: public:
PiepMode(); PiepMode();
void TaskCyclic(); void TaskCyclic();
void Start(uint8_t outPin); void Start(uint8_t outPin);
void Stop(); void Stop();
bool HasCompleted(void); bool HasCompleted(void);
uint32_t onTime, offTime; uint32_t onTime, offTime;
uint32_t requestCount; uint32_t requestCount;
private : private :
uint32_t counter, timer, outPin; uint32_t counter, timer, outPin;
uint8_t state; uint8_t state;
uint8_t startRequest, stopRequest; uint8_t startRequest, stopRequest;
}; };
#endif /* PIEPMODE_H_ */ #endif /* PIEPMODE_H_ */
+115 -115
View File
@@ -1,115 +1,115 @@
/* /*
* PiepPattern.cpp * PiepPattern.cpp
* *
* Created on: 25.02.2020 * Created on: 25.02.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "PiepPattern.h" #include "PiepPattern.h"
#include "PiepMode.h" #include "PiepMode.h"
#define SERIAL_PRINT(x) // Serial.print(" "); Serial.print(x) #define SERIAL_PRINT(x) // Serial.print(" "); Serial.print(x)
#define STANDBY 0 #define STANDBY 0
#define ON 1 #define ON 1
/** /**
* *
*/ */
PiepPattern::PiepPattern() PiepPattern::PiepPattern()
{ {
requestCount = 0; requestCount = 0;
numberModes = 0; numberModes = 0;
counter = 0; counter = 0;
modeIndex = 0; modeIndex = 0;
startRequest = false; startRequest = false;
stopRequest = false; stopRequest = false;
state = STANDBY; state = STANDBY;
outPin = 13; outPin = 13;
piepModes = NULL; piepModes = NULL;
} }
/** /**
* *
*/ */
IRAM_ATTR void PiepPattern::Start(uint8_t outPin) IRAM_ATTR void PiepPattern::Start(uint8_t outPin)
{ {
startRequest = true; startRequest = true;
this->outPin = outPin; this->outPin = outPin;
state = STANDBY; state = STANDBY;
} }
/** /**
* *
*/ */
IRAM_ATTR void PiepPattern::Stop() IRAM_ATTR void PiepPattern::Stop()
{ {
stopRequest = true; stopRequest = true;
} }
/** /**
* *
*/ */
IRAM_ATTR void PiepPattern::TaskCyclic() IRAM_ATTR void PiepPattern::TaskCyclic()
{ {
switch (state) switch (state)
{ {
case STANDBY: case STANDBY:
SERIAL_PRINT("STDBY"); SERIAL_PRINT("STDBY");
stopRequest = false; stopRequest = false;
if (startRequest) if (startRequest)
{ {
startRequest = false; startRequest = false;
counter = 0; counter = 0;
modeIndex = 0; modeIndex = 0;
if (numberModes > 0) if (numberModes > 0)
{ {
state = ON; state = ON;
piepModes[modeIndex]->Start(outPin); piepModes[modeIndex]->Start(outPin);
piepModes[modeIndex]->TaskCyclic(); piepModes[modeIndex]->TaskCyclic();
} }
} }
break; break;
case ON: case ON:
SERIAL_PRINT(modeIndex); SERIAL_PRINT(modeIndex);
SERIAL_PRINT(piepModes[modeIndex]->onTime); SERIAL_PRINT(piepModes[modeIndex]->onTime);
startRequest = false; startRequest = false;
piepModes[modeIndex]->TaskCyclic(); piepModes[modeIndex]->TaskCyclic();
if (stopRequest) if (stopRequest)
{ {
piepModes[modeIndex]->Stop(); piepModes[modeIndex]->Stop();
state = STANDBY; state = STANDBY;
} }
else else
{ {
if (piepModes[modeIndex]->HasCompleted()) if (piepModes[modeIndex]->HasCompleted())
{ {
if (++modeIndex < numberModes) if (++modeIndex < numberModes)
{ {
piepModes[modeIndex]->Start(outPin); piepModes[modeIndex]->Start(outPin);
} }
else if ( requestCount == 0) else if ( requestCount == 0)
{ {
modeIndex = 0; modeIndex = 0;
piepModes[modeIndex]->Start(outPin); piepModes[modeIndex]->Start(outPin);
} }
else if ( ++counter < requestCount ) else if ( ++counter < requestCount )
{ {
modeIndex = 0; modeIndex = 0;
piepModes[modeIndex]->Start(outPin); piepModes[modeIndex]->Start(outPin);
} }
} }
} }
break; break;
default: default:
Serial.print(state); Serial.print(state);
break; break;
} }
} }
+36 -36
View File
@@ -1,36 +1,36 @@
/* /*
* PiepPattern.h * PiepPattern.h
* *
* Created on: 25.02.2020 * Created on: 25.02.2020
* Author: flori * Author: flori
*/ */
#ifndef PIEPPATTERN_H_ #ifndef PIEPPATTERN_H_
#define PIEPPATTERN_H_ #define PIEPPATTERN_H_
#include "PiepMode.h" #include "PiepMode.h"
class PiepPattern class PiepPattern
{ {
public: public:
PiepPattern(); PiepPattern();
void TaskCyclic(); void TaskCyclic();
void Start(uint8_t outPin); void Start(uint8_t outPin);
void Stop(void); void Stop(void);
uint8_t requestCount; uint8_t requestCount;
uint8_t numberModes; uint8_t numberModes;
class PiepMode **piepModes; class PiepMode **piepModes;
private : private :
uint8_t counter; uint8_t counter;
uint8_t modeIndex; uint8_t modeIndex;
uint8_t outPin; uint8_t outPin;
uint8_t startRequest, stopRequest; uint8_t startRequest, stopRequest;
uint8_t state; uint8_t state;
}; };
#endif /* PIEPPATTERN_H_ */ #endif /* PIEPPATTERN_H_ */
+344 -344
View File
@@ -1,344 +1,344 @@
/* /*
* ReceiverFunkThermometer.cpp * ReceiverFunkThermometer.cpp
* *
* Created on: 10.05.2020 * Created on: 10.05.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "ReceiverFunkThermometer.h" #include "ReceiverFunkThermometer.h"
#include <MyMqttClient.h> #include <MyMqttClient.h>
#define DEBUG_LEVEL 2 #define DEBUG_LEVEL 2
#define MonitorPrint(x) Serial.print(x) #define MonitorPrint(x) Serial.print(x)
ReceiverFunkThermometer receiverThermo; ReceiverFunkThermometer receiverThermo;
/* ca. alle 50s wird temp + rh gesendet */ /* ca. alle 50s wird temp + rh gesendet */
/** /**
* *
*/ */
ReceiverFunkThermometer::ReceiverFunkThermometer() ReceiverFunkThermometer::ReceiverFunkThermometer()
{ {
ResetBuffer(); ResetBuffer();
data.tempC = 10; data.tempC = 10;
data.rhPercent = 50; data.rhPercent = 50;
bNewData = false; bNewData = false;
dataLast.tempC = 99; dataLast.tempC = 99;
dataLast.rhPercent = 0u; dataLast.rhPercent = 0u;
rBitNumber = 0u; rBitNumber = 0u;
} }
/** /**
* *
*/ */
bool ReceiverFunkThermometer::HasNewData(void) bool ReceiverFunkThermometer::HasNewData(void)
{ {
return bNewData; return bNewData;
} }
/** /**
* *
*/ */
ReceiverFunkThermometerData_t ReceiverFunkThermometer::GetData(void) ReceiverFunkThermometerData_t ReceiverFunkThermometer::GetData(void)
{ {
ReceiverFunkThermometerData_t datTemp = data; ReceiverFunkThermometerData_t datTemp = data;
return datTemp; return datTemp;
} }
/** /**
* *
*/ */
IRAM_ATTR void ReceiverFunkThermometer::Isr(uint32_t dtMicros, bool pinValue) IRAM_ATTR void ReceiverFunkThermometer::Isr(uint32_t dtMicros, bool pinValue)
{ {
static SignalDurationThermometer_t lastDuration = FUNK_THERMO_INVALID; static SignalDurationThermometer_t lastDuration = FUNK_THERMO_INVALID;
SignalDurationThermometer_t thisDuration = FUNK_THERMO_INVALID; SignalDurationThermometer_t thisDuration = FUNK_THERMO_INVALID;
if (dtMicros > 400 && dtMicros < 600) if (dtMicros > 400 && dtMicros < 600)
{ {
thisDuration = MS_0_5; thisDuration = MS_0_5;
} }
else if (dtMicros > 900 && dtMicros < 1100) else if (dtMicros > 900 && dtMicros < 1100)
{ {
thisDuration = MS_1_0; thisDuration = MS_1_0;
} }
else if (dtMicros > 1800 && dtMicros < 2200) else if (dtMicros > 1800 && dtMicros < 2200)
{ {
thisDuration = MS_2_0; thisDuration = MS_2_0;
} }
else else
{ {
thisDuration = FUNK_THERMO_INVALID; thisDuration = FUNK_THERMO_INVALID;
} }
if (thisDuration == FUNK_THERMO_INVALID ) if (thisDuration == FUNK_THERMO_INVALID )
{ {
ResetBuffer(); ResetBuffer();
} }
else else
{ {
if (lastDuration == FUNK_THERMO_INVALID) if (lastDuration == FUNK_THERMO_INVALID)
{ {
} }
else if (pinValue == HIGH ) else if (pinValue == HIGH )
{ {
if (thisDuration==MS_2_0 && lastDuration == MS_0_5) if (thisDuration==MS_2_0 && lastDuration == MS_0_5)
{ {
/* bit 1 received */ /* bit 1 received */
rBytes[rByteIndex] |= (1 << rBitIndex); rBytes[rByteIndex] |= (1 << rBitIndex);
if (rBitIndex == 0) if (rBitIndex == 0)
{ {
NextByte(); NextByte();
} }
else else
{ {
rBitIndex--; rBitIndex--;
} }
rBitNumber++; rBitNumber++;
if (THERMO_NUM_BITS_IGNORED == rBitNumber) if (THERMO_NUM_BITS_IGNORED == rBitNumber)
{ {
rByteIndex = 0; rByteIndex = 0;
rBitIndex = 7; rBitIndex = 7;
rBytes[0] = 0; rBytes[0] = 0;
} }
} }
else if (thisDuration==MS_1_0 &&lastDuration == MS_0_5) else if (thisDuration==MS_1_0 &&lastDuration == MS_0_5)
{ {
/* bit 0 received */ /* bit 0 received */
if (rBitIndex == 0) if (rBitIndex == 0)
{ {
NextByte(); NextByte();
} }
else else
{ {
rBitIndex--; rBitIndex--;
} }
rBitNumber++; rBitNumber++;
if (THERMO_NUM_BITS_IGNORED == rBitNumber) if (THERMO_NUM_BITS_IGNORED == rBitNumber)
{ {
rByteIndex = 0; rByteIndex = 0;
rBitIndex = 7; rBitIndex = 7;
rBytes[0] = 0; rBytes[0] = 0;
} }
} }
} }
} }
lastDuration = thisDuration; lastDuration = thisDuration;
} }
/** /**
* *
*/ */
IRAM_ATTR void ReceiverFunkThermometer::ResetBuffer(void) IRAM_ATTR void ReceiverFunkThermometer::ResetBuffer(void)
{ {
rByteIndex = 0; rByteIndex = 0;
rBitIndex = 7; rBitIndex = 7;
rBytes[0] = 0; rBytes[0] = 0;
rBitNumber = 0u; rBitNumber = 0u;
} }
/** /**
* *
*/ */
IRAM_ATTR void ReceiverFunkThermometer::NextByte(void) IRAM_ATTR void ReceiverFunkThermometer::NextByte(void)
{ {
rByteIndex++; rByteIndex++;
rBitIndex = 7; rBitIndex = 7;
if (rByteIndex == THERMO_KEY_NUMBYTES_PER_KEY) if (rByteIndex == THERMO_KEY_NUMBYTES_PER_KEY)
{ {
OnTempReceived(); OnTempReceived();
ResetBuffer(); ResetBuffer();
} }
else else
{ {
/* init the next byte */ /* init the next byte */
rBytes[rByteIndex] = 0; rBytes[rByteIndex] = 0;
} }
} }
/* /*
* *
bytes received from woolworth temp bytes received from woolworth temp
-0,9C 89% -0,9C 89%
112 112
255 255
127 127
89 89
------------ ------------
-0,8 89 -0,8 89
112 112
255 255
143 143
89 89
------------ ------------
-0,7 89 -0,7 89
112 112
255 255
159 159
89 89
------------ ------------
-0,6 89 -0,6 89
112 112
255 255
175 175
89 89
------------ ------------
-0,5 89 -0,5 89
112 112
255 255
191 191
89 89
------------ ------------
0,0 90 0,0 90
112 112
0 0
15 15
90 rh 90 rh
------------ ------------
0.1 90 0.1 90
112 112
0 0
31 31
90 90
112 112
0 0
95 95
90 90
6.4 6.4
112 112
4 4
15 15
69 69
6 6
111 111
93 93
102 102
10 10
96 96
6 6
111 111
93 93
102 102
10 10
* *
*/ */
IRAM_ATTR void ReceiverFunkThermometer::printBits(void) IRAM_ATTR void ReceiverFunkThermometer::printBits(void)
{ {
Serial.println(""); Serial.println("");
Serial.println("T_RH"); Serial.println("T_RH");
for (int i = 0; i < THERMO_KEY_NUMBYTES_PER_KEY; i++) for (int i = 0; i < THERMO_KEY_NUMBYTES_PER_KEY; i++)
{ {
for (int j = 7; j >= 0; j--) for (int j = 7; j >= 0; j--)
{ {
Serial.print((rBytes[i] >> j) & 0x01); Serial.print((rBytes[i] >> j) & 0x01);
} }
Serial.print(" "); Serial.print(" ");
} }
} }
/* /*
Fehler: (anderer Sensor?) Fehler: (anderer Sensor?)
01100000 00000110 10011111 01011101 T_RH 01100000 00000110 10011111 01011101 T_RH
01100000 00000110 10011111 01011101 105 / 93 01100000 00000110 10011111 01011101 105 / 93
Korrekt: Korrekt:
01011000 00000111 10001111 00110110 T_RH 01011000 00000111 10001111 00110110 T_RH
01011000 00000111 10001111 00110110 120 / 54 01011000 00000111 10001111 00110110 120 / 54
iiiiiiii tttttttt ttttffff hhhhhhhh iiiiiiii tttttttt ttttffff hhhhhhhh
*/ */
IRAM_ATTR void ReceiverFunkThermometer::OnTempReceived(void) IRAM_ATTR void ReceiverFunkThermometer::OnTempReceived(void)
{ {
/* first 4 bits of 36 bits are thrown away.. Rest : /* first 4 bits of 36 bits are thrown away.. Rest :
bytes 0 1 2 3 bytes 0 1 2 3
nibbles : 0 1 2 3 4 5 6 7 nibbles : 0 1 2 3 4 5 6 7
value : id id t t t 0xf h h value : id id t t t 0xf h h
*/ */
#define PRINT_ON_TEMP_RECEIVED 0 #define PRINT_ON_TEMP_RECEIVED 0
#if PRINT_ON_TEMP_RECEIVED #if PRINT_ON_TEMP_RECEIVED
printBits(); printBits();
#endif #endif
if ( ((rBytes[0]&0xF0)==0x50) /* id bits are 0101 */ if ( ((rBytes[0]&0xF0)==0x50) /* id bits are 0101 */
&& (rBytes[2]&0xF) == 0xF) && (rBytes[2]&0xF) == 0xF)
{ {
int16_t tempInt = 0; int16_t tempInt = 0;
int16_t tempNow = 0; int16_t tempNow = 0;
uint8_t rhNow = rBytes[3]; uint8_t rhNow = rBytes[3];
bool isNegative; bool isNegative;
tempInt = rBytes[1] << 4; tempInt = rBytes[1] << 4;
tempInt |= (int16_t)(rBytes[2] >> 4); tempInt |= (int16_t)(rBytes[2] >> 4);
isNegative = (rBytes[1]&0x80) != 0u; isNegative = (rBytes[1]&0x80) != 0u;
if ( isNegative) // the first bit of nibble 1 shows if the value is negative if ( isNegative) // the first bit of nibble 1 shows if the value is negative
{ {
/* 2's complement */ /* 2's complement */
tempInt = (~tempInt) & 0xFFFu; tempInt = (~tempInt) & 0xFFFu;
tempInt += 1; tempInt += 1;
} }
/* do the rounding with positive number */ /* do the rounding with positive number */
tempNow = (tempInt + 5) / 10; tempNow = (tempInt + 5) / 10;
dataLast.tempDeciCelsius = tempInt; dataLast.tempDeciCelsius = tempInt;
if (isNegative) if (isNegative)
{ {
/* set to negative */ /* set to negative */
tempNow = -tempNow; tempNow = -tempNow;
dataLast.tempDeciCelsius = -dataLast.tempDeciCelsius; dataLast.tempDeciCelsius = -dataLast.tempDeciCelsius;
} }
int16_t dTempAbs = (tempNow >= dataLast.tempC) ? (tempNow - dataLast.tempC) : (dataLast.tempC - tempNow); int16_t dTempAbs = (tempNow >= dataLast.tempC) ? (tempNow - dataLast.tempC) : (dataLast.tempC - tempNow);
uint8_t dRHAbs = (rhNow >= dataLast.rhPercent) ? (rhNow - dataLast.rhPercent) : (dataLast.rhPercent - rhNow); uint8_t dRHAbs = (rhNow >= dataLast.rhPercent) ? (rhNow - dataLast.rhPercent) : (dataLast.rhPercent - rhNow);
dataLast.tempC = tempNow; dataLast.tempC = tempNow;
dataLast.rhPercent = rhNow; dataLast.rhPercent = rhNow;
#if 1 #if 1
/* plausibility check: Temp and RH cannot have changed more than 2 units , if a similar value was received two times, it should be ok*/ /* plausibility check: Temp and RH cannot have changed more than 2 units , if a similar value was received two times, it should be ok*/
if ( (dTempAbs <= 2) && if ( (dTempAbs <= 2) &&
(dRHAbs <= 2u) ) (dRHAbs <= 2u) )
#endif #endif
{ {
if (data.tempDeciCelsius != dataLast.tempDeciCelsius || data.rhPercent != dataLast.rhPercent) if (data.tempDeciCelsius != dataLast.tempDeciCelsius || data.rhPercent != dataLast.rhPercent)
{ {
bNewData = true; bNewData = true;
data = dataLast; data = dataLast;
data.rawData = ((uint32_t)rBytes[0] << 24) | ((uint32_t)rBytes[1] << 16) | ((uint32_t)rBytes[2] << 8) | rBytes[3]; data.rawData = ((uint32_t)rBytes[0] << 24) | ((uint32_t)rBytes[1] << 16) | ((uint32_t)rBytes[2] << 8) | rBytes[3];
#if PRINT_ON_TEMP_RECEIVED #if PRINT_ON_TEMP_RECEIVED
Serial.print(data.tempDeciCelsius); Serial.print(data.tempDeciCelsius);
Serial.print(" / "); Serial.print(" / ");
Serial.println(data.rhPercent); Serial.println(data.rhPercent);
#endif #endif
} }
} }
} }
} }
+65 -65
View File
@@ -1,65 +1,65 @@
/* /*
* ReceiverFunkThermometer.h * ReceiverFunkThermometer.h
* *
* Created on: 10.05.2020 * Created on: 10.05.2020
* Author: flori * Author: flori
*/ */
#ifndef RECEIVERFUNKTHERMOMETER_H_ #ifndef RECEIVERFUNKTHERMOMETER_H_
#define RECEIVERFUNKTHERMOMETER_H_ #define RECEIVERFUNKTHERMOMETER_H_
#define THERMO_NUM_BITS_IGNORED 4 #define THERMO_NUM_BITS_IGNORED 4
#define THERMO_NUM_BITS_PER_KEY 36 #define THERMO_NUM_BITS_PER_KEY 36
#define THERMO_KEY_NUMBYTES_PER_KEY 4/* 36 bits, but first 4 bits are ignored -> 32 bits */ #define THERMO_KEY_NUMBYTES_PER_KEY 4/* 36 bits, but first 4 bits are ignored -> 32 bits */
typedef enum typedef enum
{ {
FUNK_THERMO_INVALID, FUNK_THERMO_INVALID,
MS_0_5, MS_0_5,
MS_1_0, MS_1_0,
MS_2_0 MS_2_0
} SignalDurationThermometer_t; } SignalDurationThermometer_t;
typedef struct typedef struct
{ {
int16_t tempDeciCelsius; int16_t tempDeciCelsius;
int16_t tempC; int16_t tempC;
uint8_t rhPercent; uint8_t rhPercent;
uint32_t rawData; uint32_t rawData;
} ReceiverFunkThermometerData_t; } ReceiverFunkThermometerData_t;
class ReceiverFunkThermometer class ReceiverFunkThermometer
{ {
public: public:
ReceiverFunkThermometer(); ReceiverFunkThermometer();
void Isr(uint32_t dtMicros, bool pinValue); void Isr(uint32_t dtMicros, bool pinValue);
bool HasNewData(void); bool HasNewData(void);
ReceiverFunkThermometerData_t GetData(void); ReceiverFunkThermometerData_t GetData(void);
void ResetNewData(void){ bNewData = false; } void ResetNewData(void){ bNewData = false; }
private: private:
void OnTempReceived(void); void OnTempReceived(void);
void ResetBuffer(void); void ResetBuffer(void);
void NextByte(void); void NextByte(void);
void printBits(void); void printBits(void);
uint8_t rBytes[THERMO_KEY_NUMBYTES_PER_KEY]; uint8_t rBytes[THERMO_KEY_NUMBYTES_PER_KEY];
uint8_t rByteIndex = 0; uint8_t rByteIndex = 0;
uint8_t rBitIndex = 7; uint8_t rBitIndex = 7;
uint8_t rBitNumber = 0; uint8_t rBitNumber = 0;
ReceiverFunkThermometerData_t data; ReceiverFunkThermometerData_t data;
ReceiverFunkThermometerData_t dataLast; ReceiverFunkThermometerData_t dataLast;
bool bNewData = false; bool bNewData = false;
}; };
extern ReceiverFunkThermometer receiverThermo; extern ReceiverFunkThermometer receiverThermo;
#endif /* RECEIVERFUNKTHERMOMETER_H_ */ #endif /* RECEIVERFUNKTHERMOMETER_H_ */
+219 -219
View File
@@ -1,219 +1,219 @@
/* /*
* ReceiverSmartWares.cpp * ReceiverSmartWares.cpp
* *
* Created on: 22.02.2020 * Created on: 22.02.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "ReceiverSmartWares.h" #include "ReceiverSmartWares.h"
#define MonitorPrint(x) //Serial.print(x) #define MonitorPrint(x) //Serial.print(x)
#define MonitorPrintln(x) //Serial.println(x) #define MonitorPrintln(x) //Serial.println(x)
#define KEY_BYTE_OPEN 0x56 #define KEY_BYTE_OPEN 0x56
#define KEY_BYTE_CLOSE 0x55 #define KEY_BYTE_CLOSE 0x55
ReceiverSmartWares receiverSw; ReceiverSmartWares receiverSw;
#if 0 #if 0
static const char* keyNames[] = { static const char* keyNames[] = {
"DAEMM","FB1","FB2","FB3","FB4", "DAEMM","FB1","FB2","FB3","FB4",
"HAUSTUERE","KLO EG","BAD","WIN 4","KELLERTREPPE", "HAUSTUERE","KLO EG","BAD","WIN 4","KELLERTREPPE",
"GEFRIER","ABSTELL","WIN TONI","Doppel_L","DOPPEL_R", "GEFRIER","ABSTELL","WIN TONI","Doppel_L","DOPPEL_R",
"LICHT S","LICHT W","LICHT O","LICHT GARAGE","BEW GARAGE", "LICHT S","LICHT W","LICHT O","LICHT GARAGE","BEW GARAGE",
"STECK 1","STECK 2"}; "STECK 1","STECK 2"};
#endif #endif
/* bytes 4 + 5 sind immer 0x55, byte 6 sagt ON oder oFF, daher hier nur als 0 aufgefuehrt */ /* bytes 4 + 5 sind immer 0x55, byte 6 sagt ON oder oFF, daher hier nur als 0 aufgefuehrt */
const uint8_t ReceiverSmartWares::keys[SMW_KEY_NUMKEYS][SMW_KEY_NUMBYTES_PER_KEY] = const uint8_t ReceiverSmartWares::keys[SMW_KEY_NUMKEYS][SMW_KEY_NUMBYTES_PER_KEY] =
{ {
/* ausgelesene Keys */ /* ausgelesene Keys */
{ 0b01010101, 0b01100101, 0b10010110, 0b10011001, 0, 0, 0, 0b01010110 }, //0 DAEMMERUNG { 0b01010101, 0b01100101, 0b10010110, 0b10011001, 0, 0, 0, 0b01010110 }, //0 DAEMMERUNG
{ 0b01011010, 0b01100101, 0b10101001, 0b10010101, 0, 0, 0, 0b01010110 }, //1 FB1 { 0b01011010, 0b01100101, 0b10101001, 0b10010101, 0, 0, 0, 0b01010110 }, //1 FB1
{ 0b01011010, 0b01100101, 0b10101001, 0b10010101, 0, 0, 0, 0b01011001 }, //2 FB2 { 0b01011010, 0b01100101, 0b10101001, 0b10010101, 0, 0, 0, 0b01011001 }, //2 FB2
{ 0b01011010, 0b01100101, 0b10101001, 0b10010101, 0, 0, 0, 0b01011010 }, //3 FB3 { 0b01011010, 0b01100101, 0b10101001, 0b10010101, 0, 0, 0, 0b01011010 }, //3 FB3
{ 0b01011010, 0b01100101, 0b10101001, 0b10010101, 0, 0, 0, 0b01100101 }, //4 FB4 { 0b01011010, 0b01100101, 0b10101001, 0b10010101, 0, 0, 0, 0b01100101 }, //4 FB4
{ 0b01010110, 0b01010101, 0b10101001, 0b01100110, 0, 0, 0, 0b01010110 }, //5 BEW HAUSTUERE { 0b01010110, 0b01010101, 0b10101001, 0b01100110, 0, 0, 0, 0b01010110 }, //5 BEW HAUSTUERE
{ 0b01010101, 0b01101001, 0b10010110, 0b10010101, 0, 0, 0, 0b01010110 }, //6 WINDOW KLO unten { 0b01010101, 0b01101001, 0b10010110, 0b10010101, 0, 0, 0, 0b01010110 }, //6 WINDOW KLO unten
{ 0b01010101, 0b10011010, 0b10010110, 0b10100110, 0, 0, 0, 0b01010110 }, //7 WINDOW BAD oben { 0b01010101, 0b10011010, 0b10010110, 0b10100110, 0, 0, 0, 0b01010110 }, //7 WINDOW BAD oben
{ 0b01010101, 0b10100110, 0b01011010, 0b01011010, 0, 0, 0, 0b01010110 }, //8 WINDOW FLO { 0b01010101, 0b10100110, 0b01011010, 0b01011010, 0, 0, 0, 0b01010110 }, //8 WINDOW FLO
{ 0b01010101, 0b01011001, 0b01010101, 0b01100110, 0, 0, 0, 0b01010110 }, //9 BEW KELLERTREPPE { 0b01010101, 0b01011001, 0b01010101, 0b01100110, 0, 0, 0, 0b01010110 }, //9 BEW KELLERTREPPE
{ 0b01010101, 0b10011010, 0b01101001, 0b01100110, 0, 0, 0, 0b01010110 }, //10 GEFRIER { 0b01010101, 0b10011010, 0b01101001, 0b01100110, 0, 0, 0, 0b01010110 }, //10 GEFRIER
{ 0b01010101, 0b10100110, 0b01011010, 0b01011010, 0, 0, 0, 0b01010110 }, //11 ABSTELLRAUM { 0b01010101, 0b10100110, 0b01011010, 0b01011010, 0, 0, 0, 0b01010110 }, //11 ABSTELLRAUM
{ 0b01010101, 0b10101001, 0b01100110, 0b01011010, 0, 0, 0, 0b01010110 }, //12 WINDOW TONI { 0b01010101, 0b10101001, 0b01100110, 0b01011010, 0, 0, 0, 0b01010110 }, //12 WINDOW TONI
{ 0b01011001, 0b01101001, 0b01100101, 0b01011001, 0, 0, 0, 0b01010110 }, //13 DOPPELSCHALTER_L { 0b01011001, 0b01101001, 0b01100101, 0b01011001, 0, 0, 0, 0b01010110 }, //13 DOPPELSCHALTER_L
{ 0b01011001, 0b01101001, 0b01100101, 0b01011001, 0, 0, 0, 0b01011001 }, //14 DOPPELSCHALTER_R { 0b01011001, 0b01101001, 0b01100101, 0b01011001, 0, 0, 0, 0b01011001 }, //14 DOPPELSCHALTER_R
/* selbst erfundene Keys */ /* selbst erfundene Keys */
/* nur 5,6,9,a : immer genausoviele 1en wie 0en -> immer gleich lange sendedauer */ /* nur 5,6,9,a : immer genausoviele 1en wie 0en -> immer gleich lange sendedauer */
{ 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x55}, //15 LICHT TERASSE_SUED { 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x55}, //15 LICHT TERASSE_SUED
{ 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x56}, //16 LICHT TERASSE_WEST { 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x56}, //16 LICHT TERASSE_WEST
{ 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x59}, //17 LICHT HAUSTÜRE_OST { 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x59}, //17 LICHT HAUSTÜRE_OST
{ 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x5a}, //18 LICHT GARAGE { 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x5a}, //18 LICHT GARAGE
{ 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x65}, //19 BEW GARAGE (weitergeleitet von ReceiverBew) { 0x56, 0x55, 0x56, 0x55, 0, 0, 0, 0x65}, //19 BEW GARAGE (weitergeleitet von ReceiverBew)
{ 0x6A, 0x95, 0x55, 0x99, 0, 0, 0, 0x56} , // Smartwares Ferbedienung Steckdose Auen A { 0x6A, 0x95, 0x55, 0x99, 0, 0, 0, 0x56} , // Smartwares Ferbedienung Steckdose Auen A
{ 0x6A, 0x95, 0x55, 0x99, 0, 0, 0, 0x59} , // Smartwares Ferbedienung Steckdose Auen B { 0x6A, 0x95, 0x55, 0x99, 0, 0, 0, 0x59} , // Smartwares Ferbedienung Steckdose Auen B
}; };
#define NUM_SW_WINDOW_KEYS 5u #define NUM_SW_WINDOW_KEYS 5u
const uint8_t smWindowKeys[NUM_SW_WINDOW_KEYS] = {6u, 7u, 8u, 10u, 12u }; const uint8_t smWindowKeys[NUM_SW_WINDOW_KEYS] = {6u, 7u, 8u, 10u, 12u };
/* NUR FENSTER KEYS WERDEN WEITERGELEITET , SIEHE UNTEN*/ /* NUR FENSTER KEYS WERDEN WEITERGELEITET , SIEHE UNTEN*/
/** /**
* *
*/ */
ReceiverSmartWares::ReceiverSmartWares() ReceiverSmartWares::ReceiverSmartWares()
{ {
lastReceivedKeyNum = -1; lastReceivedKeyNum = -1;
lastKeyOpenDirection = 0; lastKeyOpenDirection = 0;
ResetBuffer(); ResetBuffer();
} }
/** /**
* *
*/ */
IRAM_ATTR void ReceiverSmartWares::Isr(uint32_t dtMicros, bool pinValue) IRAM_ATTR void ReceiverSmartWares::Isr(uint32_t dtMicros, bool pinValue)
{ {
static SignalDuration_t lastDuration = INVALID; static SignalDuration_t lastDuration = INVALID;
SignalDuration_t thisDuration = INVALID; SignalDuration_t thisDuration = INVALID;
if (dtMicros > 150 && dtMicros < 350) if (dtMicros > 150 && dtMicros < 350)
{ {
thisDuration = SHORT; thisDuration = SHORT;
} }
else if (dtMicros > 1000 && dtMicros < 1350) else if (dtMicros > 1000 && dtMicros < 1350)
{ {
thisDuration = LONG; thisDuration = LONG;
} }
else else
{ {
thisDuration = INVALID; thisDuration = INVALID;
} }
if (thisDuration == INVALID) if (thisDuration == INVALID)
{ {
if (numBits == 64) if (numBits == 64)
{ {
compareKeys(); compareKeys();
} }
ResetBuffer(); ResetBuffer();
} }
else else
{ {
if (lastDuration == INVALID) if (lastDuration == INVALID)
{ {
} }
else if (pinValue == HIGH) else if (pinValue == HIGH)
{ {
numBits++; numBits++;
if (thisDuration == LONG && lastDuration == SHORT) if (thisDuration == LONG && lastDuration == SHORT)
{ {
rBytes[rByteIndex] |= (1 << rBitIndex); /* set a 1 */ rBytes[rByteIndex] |= (1 << rBitIndex); /* set a 1 */
if (rBitIndex == 0) if (rBitIndex == 0)
{ {
NextByte(); NextByte();
} }
else else
{ {
rBitIndex--; rBitIndex--;
} }
} }
else if (thisDuration == SHORT && lastDuration == SHORT) else if (thisDuration == SHORT && lastDuration == SHORT)
{ {
/* leave the 0 that was the init value of every bit */ /* leave the 0 that was the init value of every bit */
if (rBitIndex == 0) if (rBitIndex == 0)
{ {
NextByte(); NextByte();
} }
else else
{ {
rBitIndex--; rBitIndex--;
} }
} }
} }
} }
lastDuration = thisDuration; lastDuration = thisDuration;
} }
/** /**
* *
*/ */
IRAM_ATTR void ReceiverSmartWares::ResetBuffer() IRAM_ATTR void ReceiverSmartWares::ResetBuffer()
{ {
rByteIndex = 0; rByteIndex = 0;
rBitIndex = 7; rBitIndex = 7;
numBits = 0; numBits = 0;
rBytes[0] = 0; rBytes[0] = 0;
} }
/** /**
* *
*/ */
IRAM_ATTR void ReceiverSmartWares::NextByte() IRAM_ATTR void ReceiverSmartWares::NextByte()
{ {
rByteIndex++; rByteIndex++;
rBitIndex = 7; rBitIndex = 7;
if (rByteIndex == SMW_KEY_NUMBYTES_PER_KEY) if (rByteIndex == SMW_KEY_NUMBYTES_PER_KEY)
{ {
compareKeys(); compareKeys();
ResetBuffer(); ResetBuffer();
} }
else else
{ {
rBytes[rByteIndex] = 0; rBytes[rByteIndex] = 0;
} }
} }
/** /**
* *
*/ */
IRAM_ATTR void ReceiverSmartWares::compareKeys() IRAM_ATTR void ReceiverSmartWares::compareKeys()
{ {
int8_t keyFound = -1; int8_t keyFound = -1;
uint8_t i,j; uint8_t i,j;
for (i=0; i<NUM_SW_WINDOW_KEYS; i++) for (i=0; i<NUM_SW_WINDOW_KEYS; i++)
{ {
keyFound = smWindowKeys[i]; keyFound = smWindowKeys[i];
if (rBytes[0] != keys[keyFound][0] ) { keyFound = -1; } if (rBytes[0] != keys[keyFound][0] ) { keyFound = -1; }
else if (rBytes[1] != keys[keyFound][1] ) { keyFound = -1; } else if (rBytes[1] != keys[keyFound][1] ) { keyFound = -1; }
else if (rBytes[2] != keys[keyFound][2] ) { keyFound = -1; } else if (rBytes[2] != keys[keyFound][2] ) { keyFound = -1; }
else if (rBytes[3] != keys[keyFound][3] ) { keyFound = -1; } else if (rBytes[3] != keys[keyFound][3] ) { keyFound = -1; }
else if (rBytes[4] != 0x55 ) { keyFound = -1; } else if (rBytes[4] != 0x55 ) { keyFound = -1; }
else if (rBytes[5] != 0x55 ) { keyFound = -1; } else if (rBytes[5] != 0x55 ) { keyFound = -1; }
else if ((rBytes[6] != KEY_BYTE_OPEN) && (rBytes[6] != KEY_BYTE_CLOSE)) { keyFound = -1; } else if ((rBytes[6] != KEY_BYTE_OPEN) && (rBytes[6] != KEY_BYTE_CLOSE)) { keyFound = -1; }
else if (rBytes[7] != keys[keyFound][7] ) { keyFound = -1; } else if (rBytes[7] != keys[keyFound][7] ) { keyFound = -1; }
else else
{ {
MonitorPrint("\nSM "); MonitorPrint("\nSM ");
MonitorPrint(keyFound); MonitorPrint(keyFound);
break; break;
} }
} }
bool direction = (rBytes[6] == KEY_BYTE_OPEN); bool direction = (rBytes[6] == KEY_BYTE_OPEN);
if ((keyFound>=6 && keyFound<=8) || keyFound==12 || keyFound==10) /* NUR FENSTER KEYS WERDEN WEITERGELEITET */ if ((keyFound>=6 && keyFound<=8) || keyFound==12 || keyFound==10) /* NUR FENSTER KEYS WERDEN WEITERGELEITET */
{ {
if ((keyFound != lastReceivedKeyNum) || (direction != lastKeyOpenDirection)) if ((keyFound != lastReceivedKeyNum) || (direction != lastKeyOpenDirection))
{ {
newKeyReceived = true; newKeyReceived = true;
lastReceivedKeyNum = keyFound; lastReceivedKeyNum = keyFound;
lastKeyOpenDirection = direction; lastKeyOpenDirection = direction;
} }
} }
else else
{ {
sprintf(textBuf, "SM %x %x %x %X %x %x %x %x", rBytes[0], rBytes[1], sprintf(textBuf, "SM %x %x %x %X %x %x %x %x", rBytes[0], rBytes[1],
rBytes[2], rBytes[3], rBytes[4], rBytes[5], rBytes[6], rBytes[2], rBytes[3], rBytes[4], rBytes[5], rBytes[6],
rBytes[7]); rBytes[7]);
MonitorPrintln(textBuf); MonitorPrintln(textBuf);
} }
} }
+46 -46
View File
@@ -1,46 +1,46 @@
/* /*
* ReceiverSmartWares.h * ReceiverSmartWares.h
* *
* Created on: 22.02.2020 * Created on: 22.02.2020
* Author: flori * Author: flori
*/ */
#ifndef RECEIVERSMARTWARES_H_ #ifndef RECEIVERSMARTWARES_H_
#define RECEIVERSMARTWARES_H_ #define RECEIVERSMARTWARES_H_
#include "ReceiverWinSensor433.h" #include "ReceiverWinSensor433.h"
#define SMW_KEY_NUMKEYS 22 #define SMW_KEY_NUMKEYS 22
#define SMW_KEY_NUMBYTES_PER_KEY 8 #define SMW_KEY_NUMBYTES_PER_KEY 8
class ReceiverSmartWares : public Receiver433 class ReceiverSmartWares : public Receiver433
{ {
public: public:
ReceiverSmartWares(); ReceiverSmartWares();
virtual void Isr(uint32_t dtMicros, bool pinValue); virtual void Isr(uint32_t dtMicros, bool pinValue);
private: private:
static const uint8_t keys[SMW_KEY_NUMKEYS][SMW_KEY_NUMBYTES_PER_KEY]; static const uint8_t keys[SMW_KEY_NUMKEYS][SMW_KEY_NUMBYTES_PER_KEY];
uint8_t rBytes[SMW_KEY_NUMBYTES_PER_KEY]; uint8_t rBytes[SMW_KEY_NUMBYTES_PER_KEY];
uint8_t rByteIndex = 0; uint8_t rByteIndex = 0;
uint8_t rBitIndex = 7; uint8_t rBitIndex = 7;
uint8_t numBits = 0; uint8_t numBits = 0;
char textBuf[32]; char textBuf[32];
//void printByteBits(byte by); //void printByteBits(byte by);
//void printBuffer(); //void printBuffer();
void compareKeys(); void compareKeys();
//uint8_t correlationFunction(uint8_t buf1[], uint8_t buf2[], uint8_t sizeBufs, int8_t shift); //uint8_t correlationFunction(uint8_t buf1[], uint8_t buf2[], uint8_t sizeBufs, int8_t shift);
void ResetBuffer(); void ResetBuffer();
void NextByte(); void NextByte();
}; };
extern ReceiverSmartWares receiverSw; extern ReceiverSmartWares receiverSw;
#endif /* RECEIVERSMARTWARES_H_ */ #endif /* RECEIVERSMARTWARES_H_ */
+37 -37
View File
@@ -1,37 +1,37 @@
/* /*
* Receiver433.cpp * Receiver433.cpp
* *
* Created on: 17.10.2021 * Created on: 17.10.2021
* Author: flori * Author: flori
*/ */
#include "ReceiverWinSensor433.h" #include "ReceiverWinSensor433.h"
Receiver433::Receiver433() Receiver433::Receiver433()
{ {
doBuffer = true; doBuffer = true;
newKeyReceived = false; newKeyReceived = false;
lastReceivedKeyNum = -1; lastReceivedKeyNum = -1;
lastKeyOpenDirection = false; lastKeyOpenDirection = false;
} }
Receiver433::~Receiver433() Receiver433::~Receiver433()
{ {
// TODO Auto-generated destructor stub // TODO Auto-generated destructor stub
} }
int8_t Receiver433::GetLastReceivedKeyNum() int8_t Receiver433::GetLastReceivedKeyNum()
{ {
if (newKeyReceived) return lastReceivedKeyNum; if (newKeyReceived) return lastReceivedKeyNum;
else return -1; else return -1;
} }
void Receiver433::ResetReceivedKeyNum() void Receiver433::ResetReceivedKeyNum()
{ {
newKeyReceived = false; newKeyReceived = false;
} }
bool Receiver433::GetLastReceivedDirection() bool Receiver433::GetLastReceivedDirection()
{ {
return lastKeyOpenDirection; return lastKeyOpenDirection;
} }
+47 -47
View File
@@ -1,47 +1,47 @@
/* /*
* Receiver433.h * Receiver433.h
* *
* Created on: 17.10.2021 * Created on: 17.10.2021
* Author: flori * Author: flori
*/ */
#ifndef RECEIVERWINSENSOR433_H_ #ifndef RECEIVERWINSENSOR433_H_
#define RECEIVERWINSENSOR433_H_ #define RECEIVERWINSENSOR433_H_
#include "Arduino.h" #include "Arduino.h"
typedef enum typedef enum
{ {
INVALID, INVALID,
SHORT, SHORT,
LONG LONG
} SignalDuration_t; } SignalDuration_t;
/* VIRTUAL BASE CLASS FOR RECEIVERS */ /* VIRTUAL BASE CLASS FOR RECEIVERS */
class Receiver433 class Receiver433
{ {
public: public:
Receiver433(); Receiver433();
virtual ~Receiver433(); virtual ~Receiver433();
virtual void Isr(uint32_t dtMicros, bool pinValue) = 0; virtual void Isr(uint32_t dtMicros, bool pinValue) = 0;
virtual int8_t GetLastReceivedKeyNum(); virtual int8_t GetLastReceivedKeyNum();
virtual void ResetReceivedKeyNum(); virtual void ResetReceivedKeyNum();
virtual bool GetLastReceivedDirection(); virtual bool GetLastReceivedDirection();
protected: protected:
bool lastKeyOpenDirection; // TRUE -> OPEN, FALSE -> CLOSE bool lastKeyOpenDirection; // TRUE -> OPEN, FALSE -> CLOSE
bool doBuffer; bool doBuffer;
bool newKeyReceived; bool newKeyReceived;
int8_t lastReceivedKeyNum; int8_t lastReceivedKeyNum;
}; };
#endif /* RECEIVERWINSENSOR433_H_ */ #endif /* RECEIVERWINSENSOR433_H_ */
@@ -1,194 +1,194 @@
/* /*
* Receiver3ByteKey.cpp * Receiver3ByteKey.cpp
* *
* Created on: 12.10.2022 * Created on: 12.10.2022
* Author: flori * Author: flori
*/ */
#include "Receiver3ByteKey.h" #include "Receiver3ByteKey.h"
#include "InterruptHandler.h" #include "InterruptHandler.h"
/*******************************************************************/ /*******************************************************************/
#define DEBUG_LEVEL_NO_PRINT 0 #define DEBUG_LEVEL_NO_PRINT 0
#define DEBUG_LEVEL_PRINT_NEW_KEYS_ONLY 1 #define DEBUG_LEVEL_PRINT_NEW_KEYS_ONLY 1
#define DEBUG_LEVEL_PRINT_ALL_RECEIVED_KEYS 2 #define DEBUG_LEVEL_PRINT_ALL_RECEIVED_KEYS 2
#define DEBUG_LEVEL DEBUG_LEVEL_NO_PRINT #define DEBUG_LEVEL DEBUG_LEVEL_NO_PRINT
#define SERIAL_PRINT(x) Serial.print(x) #define SERIAL_PRINT(x) Serial.print(x)
/*******************************************************************/ /*******************************************************************/
/** /**
* *
*/ */
Receiver3ByteKey::Receiver3ByteKey() Receiver3ByteKey::Receiver3ByteKey()
{ {
lastDuration = INVALID; lastDuration = INVALID;
lastReceivedKeyNum = -1; lastReceivedKeyNum = -1;
lastKeyOpenDirection = 0; lastKeyOpenDirection = 0;
ResetBuffer(); ResetBuffer();
} }
/** /**
* *
*/ */
IRAM_ATTR void Receiver3ByteKey::Isr(uint32_t dtMicros, bool pinValue) IRAM_ATTR void Receiver3ByteKey::Isr(uint32_t dtMicros, bool pinValue)
{ {
SignalDuration_t thisDuration = INVALID; SignalDuration_t thisDuration = INVALID;
if (dtMicros > config.tShortMin && dtMicros < config.tShortMax) if (dtMicros > config.tShortMin && dtMicros < config.tShortMax)
{ {
thisDuration = SHORT; thisDuration = SHORT;
//if (doBuffer) buft[ibuf++] = dtMicros; //if (doBuffer) buft[ibuf++] = dtMicros;
} }
else if (dtMicros > config.tLongMin && dtMicros < config.tLongMax) else if (dtMicros > config.tLongMin && dtMicros < config.tLongMax)
{ {
thisDuration = LONG; thisDuration = LONG;
//if (doBuffer) buft[ibuf++] = dtMicros; //if (doBuffer) buft[ibuf++] = dtMicros;
} }
else else
{ {
thisDuration = INVALID; thisDuration = INVALID;
} }
if (thisDuration == INVALID) if (thisDuration == INVALID)
{ {
ResetBuffer(); ResetBuffer();
} }
else else
{ {
if (lastDuration == INVALID) if (lastDuration == INVALID)
{ {
/* ResetBuffer was already called last time */ /* ResetBuffer was already called last time */
} }
else if (pinValue == HIGH) else if (pinValue == HIGH)
{ {
// a valid bit is always terminated with a rising edge (the last bit is always 0 so this is the termination for the last bit to read ) // a valid bit is always terminated with a rising edge (the last bit is always 0 so this is the termination for the last bit to read )
if (thisDuration == LONG && lastDuration == SHORT) // short high, long low -> bit 0 if (thisDuration == LONG && lastDuration == SHORT) // short high, long low -> bit 0
{ {
/* bytes are initialized as 0, so for bit 0, nothing to change */ /* bytes are initialized as 0, so for bit 0, nothing to change */
NextBit(); NextBit();
} }
else if (thisDuration == SHORT && lastDuration == LONG) // long high, short low -> bit 1 else if (thisDuration == SHORT && lastDuration == LONG) // long high, short low -> bit 1
{ {
rBytes[rByteIndex] |= (1 << rBitIndex); // bit 1 rBytes[rByteIndex] |= (1 << rBitIndex); // bit 1
NextBit(); NextBit();
} }
else else
{ {
// long -> long or short->short is invalid // long -> long or short->short is invalid
ResetBuffer(); ResetBuffer();
} }
} }
else else
{ {
/* falling edge -> wait for next rising edge */ /* falling edge -> wait for next rising edge */
} }
} }
lastDuration = thisDuration; lastDuration = thisDuration;
} }
/** /**
* *
*/ */
IRAM_ATTR void Receiver3ByteKey::ResetBuffer() IRAM_ATTR void Receiver3ByteKey::ResetBuffer()
{ {
rByteIndex = 0; rByteIndex = 0;
rBitIndex = 7; rBitIndex = 7;
rBytes[0] = 0; /* all other bytes are set to 0 in NextByte() */ rBytes[0] = 0; /* all other bytes are set to 0 in NextByte() */
ibuf = 0; ibuf = 0;
} }
/** /**
* *
*/ */
IRAM_ATTR void Receiver3ByteKey::NextBit() IRAM_ATTR void Receiver3ByteKey::NextBit()
{ {
if (rBitIndex == 0) if (rBitIndex == 0)
{ {
NextByte(); NextByte();
} }
else else
{ {
rBitIndex--; rBitIndex--;
} }
} }
/** /**
* *
*/ */
IRAM_ATTR void Receiver3ByteKey::NextByte() IRAM_ATTR void Receiver3ByteKey::NextByte()
{ {
rByteIndex++; rByteIndex++;
rBitIndex = 7; rBitIndex = 7;
if (rByteIndex == NUM_BYTES_PER_KEY) if (rByteIndex == NUM_BYTES_PER_KEY)
{ {
compareKeys(); compareKeys();
ResetBuffer(); ResetBuffer();
} }
else else
{ {
rBytes[rByteIndex] = 0; rBytes[rByteIndex] = 0;
} }
} }
/** /**
* *
*/ */
IRAM_ATTR void Receiver3ByteKey::compareKeys() IRAM_ATTR void Receiver3ByteKey::compareKeys()
{ {
int8_t keyFound = -1; int8_t keyFound = -1;
bool direction = false; bool direction = false;
uint8_t i; uint8_t i;
for (i=0; i<config.numberKeys; i++) for (i=0; i<config.numberKeys; i++)
{ {
keyFound = i; keyFound = i;
uint8_t iBase = i*(NUM_BYTES_PER_KEY+1u); /* there is always one more byte indicating closing */ uint8_t iBase = i*(NUM_BYTES_PER_KEY+1u); /* there is always one more byte indicating closing */
if (rBytes[0] != config.keys[iBase+0]) { keyFound = -1; } /* byte 0 does not match */ if (rBytes[0] != config.keys[iBase+0]) { keyFound = -1; } /* byte 0 does not match */
else if (rBytes[1] != config.keys[iBase+1]) { keyFound = -1; } /* byte 1 does not match */ else if (rBytes[1] != config.keys[iBase+1]) { keyFound = -1; } /* byte 1 does not match */
else if ((rBytes[2] != config.keys[iBase+2]) && else if ((rBytes[2] != config.keys[iBase+2]) &&
(rBytes[2] != config.keys[iBase+3]) ) { keyFound = -1; } /* neither open , nor close byte match */ (rBytes[2] != config.keys[iBase+3]) ) { keyFound = -1; } /* neither open , nor close byte match */
if (keyFound==i) if (keyFound==i)
{ {
break; break;
} }
} }
if (keyFound>=0) if (keyFound>=0)
{ {
uint8_t iBase = keyFound*(NUM_BYTES_PER_KEY+1u); uint8_t iBase = keyFound*(NUM_BYTES_PER_KEY+1u);
direction = rBytes[2] == config.keys[ iBase + 2 ]; direction = rBytes[2] == config.keys[ iBase + 2 ];
if ( (keyFound != lastReceivedKeyNum ) || (lastKeyOpenDirection != direction) ) if ( (keyFound != lastReceivedKeyNum ) || (lastKeyOpenDirection != direction) )
{ {
doBuffer = false; doBuffer = false;
newKeyReceived = true; newKeyReceived = true;
lastReceivedKeyNum = keyFound; lastReceivedKeyNum = keyFound;
lastKeyOpenDirection = direction; lastKeyOpenDirection = direction;
InterruptHandler_PauseReceive(); InterruptHandler_PauseReceive();
#if DEBUG_LEVEL>=DEBUG_LEVEL_PRINT_ALL_RECEIVED_KEYS #if DEBUG_LEVEL>=DEBUG_LEVEL_PRINT_ALL_RECEIVED_KEYS
sprintf(textBuf, "\n%s %d %d", config.name, keyFound, lastKeyOpenDirection); sprintf(textBuf, "\n%s %d %d", config.name, keyFound, lastKeyOpenDirection);
SERIAL_PRINT(textBuf); SERIAL_PRINT(textBuf);
#endif #endif
} }
} }
else else
{ {
#if DEBUG_LEVEL>=DEBUG_LEVEL_PRINT_NEW_KEYS_ONLY #if DEBUG_LEVEL>=DEBUG_LEVEL_PRINT_NEW_KEYS_ONLY
sprintf(textBuf, "\nnew %s %x %x %x", config.name, rBytes[0], rBytes[1], rBytes[2]); sprintf(textBuf, "\nnew %s %x %x %x", config.name, rBytes[0], rBytes[1], rBytes[2]);
SERIAL_PRINT(textBuf); SERIAL_PRINT(textBuf);
#endif #endif
} }
} }
@@ -1,60 +1,60 @@
/* /*
* Receiver3ByteKey.h * Receiver3ByteKey.h
* *
* Created on: 12.10.2022 * Created on: 12.10.2022
* Author: flori * Author: flori
*/ */
#ifndef RECEIVER3BYTEKEY_H_ #ifndef RECEIVER3BYTEKEY_H_
#define RECEIVER3BYTEKEY_H_ #define RECEIVER3BYTEKEY_H_
#include "ReceiverWinSensor433.h" #include "ReceiverWinSensor433.h"
#define NUM_BYTES_PER_KEY 3u #define NUM_BYTES_PER_KEY 3u
class Receiver3ByteKey : public Receiver433 class Receiver3ByteKey : public Receiver433
{ {
public: public:
Receiver3ByteKey(); Receiver3ByteKey();
void Isr(uint32_t dtMicros, bool pinValue); void Isr(uint32_t dtMicros, bool pinValue);
void startBuffering(){ doBuffer = true; } void startBuffering(){ doBuffer = true; }
uint32_t buft[10*8]; uint32_t buft[10*8];
protected: protected:
class Config class Config
{ {
public: public:
const char *name; const char *name;
uint16_t tShortMin; uint16_t tShortMin;
uint16_t tShortMax; uint16_t tShortMax;
uint16_t tLongMin; uint16_t tLongMin;
uint16_t tLongMax; uint16_t tLongMax;
uint8_t numberKeys; uint8_t numberKeys;
const uint8_t *keys; const uint8_t *keys;
}; };
class Config config; class Config config;
private: private:
SignalDuration_t lastDuration; SignalDuration_t lastDuration;
uint8_t rBytes[NUM_BYTES_PER_KEY]; uint8_t rBytes[NUM_BYTES_PER_KEY];
uint8_t rByteIndex = 0; uint8_t rByteIndex = 0;
uint8_t rBitIndex = 7; uint8_t rBitIndex = 7;
uint32_t ibuf; uint32_t ibuf;
//void printByteBits(byte by); //void printByteBits(byte by);
//void printBuffer(); //void printBuffer();
void compareKeys(); void compareKeys();
//uint8_t correlationFunction(uint8_t buf1[], uint8_t buf2[], uint8_t sizeBufs, int8_t shift); //uint8_t correlationFunction(uint8_t buf1[], uint8_t buf2[], uint8_t sizeBufs, int8_t shift);
void ResetBuffer(); void ResetBuffer();
void NextBit(); void NextBit();
void NextByte(); void NextByte();
char textBuf[32]; char textBuf[32];
}; };
#endif /* RECEIVER3BYTEKEY_H_ */ #endif /* RECEIVER3BYTEKEY_H_ */
@@ -1,49 +1,49 @@
/* /*
* ReceiverAiggend.cpp * ReceiverAiggend.cpp
* *
* Created on: 21.10.2020 * Created on: 21.10.2020
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "Receiver3ByteKey.h" #include "Receiver3ByteKey.h"
#include "ReceiverAiggend.h" #include "ReceiverAiggend.h"
/*******************************************************************/ /*******************************************************************/
#define KEY_NIBBLE_OPEN 0x0A #define KEY_NIBBLE_OPEN 0x0A
#define KEY_NIBBLE_CLOSE 0x0E #define KEY_NIBBLE_CLOSE 0x0E
#define NUM_KEYS_AIGGEND 4u #define NUM_KEYS_AIGGEND 4u
/*******************************************************************/ /*******************************************************************/
static const char* nameAiggend = "Aiggend"; static const char* nameAiggend = "Aiggend";
static const uint8_t keysAiggend[NUM_KEYS_AIGGEND * (NUM_BYTES_PER_KEY+1u) ] = static const uint8_t keysAiggend[NUM_KEYS_AIGGEND * (NUM_BYTES_PER_KEY+1u) ] =
{ {
//0b10101110, 0b10110010, 0b00001010 , // 10101110 10110010 0000 1010 0 AUF, 10101110 10110010 0000 1110 0 ZU //0b10101110, 0b10110010, 0b00001010 , // 10101110 10110010 0000 1010 0 AUF, 10101110 10110010 0000 1110 0 ZU
0xae, 0xb2, 0x0a , 0x0e, 0xae, 0xb2, 0x0a , 0x0e,
0xa4, 0x30, 0x0a , 0x0e, // 0xa auf, zu: 0xe 0xa4, 0x30, 0x0a , 0x0e, // 0xa auf, zu: 0xe
0xa1, 0x4a, 0x0a , 0x0e, // 0xa auf, zu: 0xe 0xa1, 0x4a, 0x0a , 0x0e, // 0xa auf, zu: 0xe
0xe6, 0x80, 0x46 , 0x49 // 0x49 auf, zu 0x46 0xe6, 0x80, 0x46 , 0x49 // 0x49 auf, zu 0x46
}; };
/*******************************************************************/ /*******************************************************************/
ReceiverAiggend receiverAiggend; ReceiverAiggend receiverAiggend;
/*******************************************************************/ /*******************************************************************/
ReceiverAiggend::ReceiverAiggend() : Receiver3ByteKey() ReceiverAiggend::ReceiverAiggend() : Receiver3ByteKey()
{ {
config.name = nameAiggend; config.name = nameAiggend;
config.tShortMin = 370u; config.tShortMin = 370u;
config.tShortMax = 680u; config.tShortMax = 680u;
config.tLongMin = 1100u; config.tLongMin = 1100u;
config.tLongMax = 1540u; config.tLongMax = 1540u;
config.numberKeys = NUM_KEYS_AIGGEND; config.numberKeys = NUM_KEYS_AIGGEND;
config.keys = keysAiggend; config.keys = keysAiggend;
} }
@@ -1,23 +1,23 @@
/* /*
* ReceiverAiggend.h * ReceiverAiggend.h
* *
* Created on: 21.10.2020 * Created on: 21.10.2020
* Author: flori * Author: flori
*/ */
#ifndef RECEIVERAIGGEND_H_ #ifndef RECEIVERAIGGEND_H_
#define RECEIVERAIGGEND_H_ #define RECEIVERAIGGEND_H_
#include "Receiver3ByteKey.h" #include "Receiver3ByteKey.h"
class ReceiverAiggend : public Receiver3ByteKey class ReceiverAiggend : public Receiver3ByteKey
{ {
public: public:
ReceiverAiggend(); ReceiverAiggend();
}; };
extern ReceiverAiggend receiverAiggend; extern ReceiverAiggend receiverAiggend;
#endif /* RECEIVERAIGGEND_H_ */ #endif /* RECEIVERAIGGEND_H_ */
@@ -1,46 +1,46 @@
/* /*
* ReceiverKerui.cpp * ReceiverKerui.cpp
* *
* Created on: 12.10.2022 * Created on: 12.10.2022
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "ReceiverKerui.h" #include "ReceiverKerui.h"
/*******************************************************************/ /*******************************************************************/
#define KEY_NIBBLE_OPEN 0x0E #define KEY_NIBBLE_OPEN 0x0E
#define KEY_NIBBLE_CLOSE 0x07 #define KEY_NIBBLE_CLOSE 0x07
#define NUM_KEYS_KERUI 3u #define NUM_KEYS_KERUI 3u
/*******************************************************************/ /*******************************************************************/
static const char* nameKerui = "Kerui"; static const char* nameKerui = "Kerui";
static const uint8_t keysKerui[NUM_KEYS_KERUI* (NUM_BYTES_PER_KEY+1u) ] = static const uint8_t keysKerui[NUM_KEYS_KERUI* (NUM_BYTES_PER_KEY+1u) ] =
{ {
0x3c, 0xf3, 0x0E, 0x07 , /* key, key, open, close */ 0x3c, 0xf3, 0x0E, 0x07 , /* key, key, open, close */
0xea, 0x3a, 0x0E, 0x07 , 0xea, 0x3a, 0x0E, 0x07 ,
0xbd, 0x14, 0x0E, 0x07 0xbd, 0x14, 0x0E, 0x07
}; };
/*******************************************************************/ /*******************************************************************/
ReceiverKerui receiverKerui = ReceiverKerui(); ReceiverKerui receiverKerui = ReceiverKerui();
/*******************************************************************/ /*******************************************************************/
ReceiverKerui::ReceiverKerui() : Receiver3ByteKey() ReceiverKerui::ReceiverKerui() : Receiver3ByteKey()
{ {
config.name = nameKerui; config.name = nameKerui;
config.tShortMin = 250u; config.tShortMin = 250u;
config.tShortMax = 450u; config.tShortMax = 450u;
config.tLongMin = 850u; config.tLongMin = 850u;
config.tLongMax = 1150u; config.tLongMax = 1150u;
config.numberKeys = NUM_KEYS_KERUI; config.numberKeys = NUM_KEYS_KERUI;
config.keys = keysKerui; config.keys = keysKerui;
} }
@@ -1,22 +1,22 @@
/* /*
* ReceiverKerui.h * ReceiverKerui.h
* *
* Created on: 12.10.2022 * Created on: 12.10.2022
* Author: flori * Author: flori
*/ */
#ifndef RECEIVERKERUI_H_ #ifndef RECEIVERKERUI_H_
#define RECEIVERKERUI_H_ #define RECEIVERKERUI_H_
#include "Receiver3ByteKey.h" #include "Receiver3ByteKey.h"
class ReceiverKerui : public Receiver3ByteKey class ReceiverKerui : public Receiver3ByteKey
{ {
public: public:
ReceiverKerui(); ReceiverKerui();
}; };
extern ReceiverKerui receiverKerui; extern ReceiverKerui receiverKerui;
#endif /* RECEIVERKERUI_H_ */ #endif /* RECEIVERKERUI_H_ */
@@ -1,52 +1,52 @@
/* /*
* ReceiverOval.cpp * ReceiverOval.cpp
* *
* Created on: 12.10.2022 * Created on: 12.10.2022
* Author: flori * Author: flori
*/ */
#include "main.h" #include "main.h"
#include "ReceiverOval.h" #include "ReceiverOval.h"
/*******************************************************************/ /*******************************************************************/
#define KEY_NIBBLE_OPEN 0x03 #define KEY_NIBBLE_OPEN 0x03
#define KEY_NIBBLE_CLOSE 0x09 #define KEY_NIBBLE_CLOSE 0x09
#define NUM_KEYS_OVAL 6u #define NUM_KEYS_OVAL 6u
/*******************************************************************/ /*******************************************************************/
static const char* nameOval = "Oval"; static const char* nameOval = "Oval";
static const uint8_t keysOval[NUM_KEYS_OVAL * (NUM_BYTES_PER_KEY+1u)] = static const uint8_t keysOval[NUM_KEYS_OVAL * (NUM_BYTES_PER_KEY+1u)] =
{ {
0xdc, 0x86, 0x03 , 0x09, // 0x3 auf 0x9 zu, 0xdc, 0x86, 0x03 , 0x09, // 0x3 auf 0x9 zu,
0x30, 0xa5, 0x03 , 0x09, // 0x3 auf 0x9 zu, 0x30, 0xa5, 0x03 , 0x09, // 0x3 auf 0x9 zu,
0x4c, 0xe6, 0x03 , 0x09, // 0x3 auf 0x9 zu, 0x4c, 0xe6, 0x03 , 0x09, // 0x3 auf 0x9 zu,
0x74, 0xa5, 0x03 , 0x09, // 0x3 auf 0x9 zu, 0x74, 0xa5, 0x03 , 0x09, // 0x3 auf 0x9 zu,
0x29, 0x66, 0x03 , 0x09, // 0x3 auf 0x9 zu, 0x29, 0x66, 0x03 , 0x09, // 0x3 auf 0x9 zu,
0xe4, 0x0f, 0x76 , 0x79 // 0x3 auf 0x9 zu, 0xe4, 0x0f, 0x76 , 0x79 // 0x3 auf 0x9 zu,
}; };
/*******************************************************************/ /*******************************************************************/
ReceiverOval receiverOval; ReceiverOval receiverOval;
/*******************************************************************/ /*******************************************************************/
ReceiverOval::ReceiverOval() : Receiver3ByteKey() ReceiverOval::ReceiverOval() : Receiver3ByteKey()
{ {
config.name = nameOval; config.name = nameOval;
config.tShortMin = 320u; config.tShortMin = 320u;
config.tShortMax = 510u; config.tShortMax = 510u;
config.tLongMin = 1100u; config.tLongMin = 1100u;
config.tLongMax = 1330u; config.tLongMax = 1330u;
config.numberKeys = NUM_KEYS_OVAL; config.numberKeys = NUM_KEYS_OVAL;
config.keys = keysOval; config.keys = keysOval;
} }
@@ -1,23 +1,23 @@
/* /*
* ReceiverOval.h * ReceiverOval.h
* *
* Created on: 12.10.2022 * Created on: 12.10.2022
* Author: flori * Author: flori
*/ */
#ifndef RECEIVEROVAL_H_ #ifndef RECEIVEROVAL_H_
#define RECEIVEROVAL_H_ #define RECEIVEROVAL_H_
#include "Receiver3ByteKey.h" #include "Receiver3ByteKey.h"
class ReceiverOval : public Receiver3ByteKey class ReceiverOval : public Receiver3ByteKey
{ {
public: public:
ReceiverOval(); ReceiverOval();
}; };
extern ReceiverOval receiverOval; extern ReceiverOval receiverOval;
#endif /* RECEIVEROVAL_H_ */ #endif /* RECEIVEROVAL_H_ */
+30 -30
View File
@@ -1,30 +1,30 @@
/* /*
* Seconds.cpp * Seconds.cpp
* *
* Created on: 10.09.2020 * Created on: 10.09.2020
* Author: flori * Author: flori
*/ */
#include "Seconds.h" #include "Seconds.h"
uint32_t Seconds::lastMillisShifted = 0; uint32_t Seconds::lastMillisShifted = 0;
uint32_t Seconds::seconds = 0; uint32_t Seconds::seconds = 0;
uint32_t Seconds::secondsOverflow = 0; uint32_t Seconds::secondsOverflow = 0;
boolean volatile Seconds::semaphore = false; boolean volatile Seconds::semaphore = false;
uint32_t Seconds::Get(void) uint32_t Seconds::Get(void)
{ {
uint32_t secRet; uint32_t secRet;
uint32_t secNow = millis() / 1000; uint32_t secNow = millis() / 1000;
if (secNow < seconds) if (secNow < seconds)
{ {
secondsOverflow += seconds + 1; secondsOverflow += seconds + 1;
} }
seconds = secNow; seconds = secNow;
secRet = seconds + secondsOverflow; secRet = seconds + secondsOverflow;
return secRet; return secRet;
} }
+25 -25
View File
@@ -1,25 +1,25 @@
/* /*
* Seconds.h * Seconds.h
* *
* Created on: 10.09.2020 * Created on: 10.09.2020
* Author: flori * Author: flori
*/ */
#ifndef SECONDS_H_ #ifndef SECONDS_H_
#define SECONDS_H_ #define SECONDS_H_
#include "Arduino.h" #include "Arduino.h"
class Seconds class Seconds
{ {
public: public:
static uint32_t Get(); static uint32_t Get();
private: private:
static uint32_t lastMillisShifted; static uint32_t lastMillisShifted;
static uint32_t seconds; static uint32_t seconds;
static uint32_t secondsOverflow; static uint32_t secondsOverflow;
static volatile boolean semaphore; static volatile boolean semaphore;
}; };
#endif /* SECONDS_H_ */ #endif /* SECONDS_H_ */
+122 -122
View File
@@ -1,122 +1,122 @@
/* /*
* UpdateHandler.c * UpdateHandler.c
* *
* Created on: 04.08.2023 * Created on: 04.08.2023
* Author: flori * Author: flori
*/ */
#include "WebServer.h" #include "WebServer.h"
#include <Update.h> #include <Update.h>
#include "Version.h" #include "Version.h"
#include "InterruptHandler.h" #include "InterruptHandler.h"
#include "MyMqttClient.h" #include "MyMqttClient.h"
WebServer webServer; WebServer webServer;
const char* serverIndex = const char* serverIndex =
"<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>" "<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>"
"<br>" PROJECT_NAME " " VERSION_STR "<br><br>" "<br>" PROJECT_NAME " " VERSION_STR "<br><br>"
"<form method='POST' action='#' enctype='multipart/form-data' id='upload_form'>" "<form method='POST' action='#' enctype='multipart/form-data' id='upload_form'>"
"<input type='file' name='update'>" "<input type='file' name='update'>"
"<input type='submit' value='Update'>" "<input type='submit' value='Update'>"
"</form>" "</form>"
"<div id='prg'>progress: 0%</div>" "<div id='prg'>progress: 0%</div>"
"<script>" "<script>"
"$('form').submit(function(e){" "$('form').submit(function(e){"
"e.preventDefault();" "e.preventDefault();"
"var form = $('#upload_form')[0];" "var form = $('#upload_form')[0];"
"var data = new FormData(form);" "var data = new FormData(form);"
" $.ajax({" " $.ajax({"
"url: '/update'," "url: '/update',"
"type: 'POST'," "type: 'POST',"
"data: data," "data: data,"
"contentType: false," "contentType: false,"
"processData:false," "processData:false,"
"xhr: function() {" "xhr: function() {"
"var xhr = new window.XMLHttpRequest();" "var xhr = new window.XMLHttpRequest();"
"xhr.upload.addEventListener('progress', function(evt) {" "xhr.upload.addEventListener('progress', function(evt) {"
"if (evt.lengthComputable) {" "if (evt.lengthComputable) {"
"var per = evt.loaded / evt.total;" "var per = evt.loaded / evt.total;"
"$('#prg').html('progress: ' + Math.round(per*100) + '%');" "$('#prg').html('progress: ' + Math.round(per*100) + '%');"
"}" "}"
"}, false);" "}, false);"
"return xhr;" "return xhr;"
"}," "},"
"success:function(d, s) {" "success:function(d, s) {"
"$('#prg').html('success!');" "$('#prg').html('success!');"
"}," "},"
"error: function (a, b, c) {" "error: function (a, b, c) {"
"}" "}"
"});" "});"
"});" "});"
"</script>"; "</script>";
void UpdateHandler() void UpdateHandler()
{ {
static bool initDone = false; static bool initDone = false;
if (false == WiFi.isConnected()) if (false == WiFi.isConnected())
{ {
initDone = false; initDone = false;
} }
else else
{ {
if (initDone == false) if (initDone == false)
{ {
initDone = true; initDone = true;
webServer.on("/", HTTP_GET, []() webServer.on("/", HTTP_GET, []()
{ {
Serial.printf("HTTP_GET"); Serial.printf("HTTP_GET");
webServer.sendHeader("Connection", "close"); webServer.sendHeader("Connection", "close");
webServer.send(200, "text/html", serverIndex); webServer.send(200, "text/html", serverIndex);
}); });
/*handling uploading firmware file */ /*handling uploading firmware file */
webServer.on("/update", HTTP_POST, []() webServer.on("/update", HTTP_POST, []()
{ {
webServer.sendHeader("Connection", "close"); webServer.sendHeader("Connection", "close");
webServer.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK"); webServer.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
ESP.restart(); ESP.restart();
}, []() }, []()
{ {
HTTPUpload& upload = webServer.upload(); HTTPUpload& upload = webServer.upload();
if (upload.status == UPLOAD_FILE_START) if (upload.status == UPLOAD_FILE_START)
{ {
InterruptHandler_Stop(); InterruptHandler_Stop();
Serial.printf("Update: %s\n", upload.filename.c_str()); Serial.printf("Update: %s\n", upload.filename.c_str());
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) if (!Update.begin(UPDATE_SIZE_UNKNOWN))
{ //start with max available size { //start with max available size
Update.printError(Serial); Update.printError(Serial);
} }
} }
else if (upload.status == UPLOAD_FILE_WRITE) else if (upload.status == UPLOAD_FILE_WRITE)
{ {
/* flashing firmware to ESP*/ /* flashing firmware to ESP*/
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) if (Update.write(upload.buf, upload.currentSize) != upload.currentSize)
{ {
Update.printError(Serial); Update.printError(Serial);
} }
} }
else if (upload.status == UPLOAD_FILE_END) else if (upload.status == UPLOAD_FILE_END)
{ {
if (Update.end(true)) if (Update.end(true))
{ //true to set the size to the current progress { //true to set the size to the current progress
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize); Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
} }
else else
{ {
Update.printError(Serial); Update.printError(Serial);
} }
} }
}); });
webServer.begin(80u); webServer.begin(80u);
Serial.print("IP address: "); Serial.print("IP address: ");
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
Serial.printf("webServer init done"); Serial.printf("webServer init done");
} }
webServer.handleClient(); webServer.handleClient();
} }
} }
+15 -15
View File
@@ -1,15 +1,15 @@
/* /*
* UpdateHandler.h * UpdateHandler.h
* *
* Created on: 04.08.2023 * Created on: 04.08.2023
* Author: flori * Author: flori
*/ */
#ifndef UPDATEHANDLER_H_ #ifndef UPDATEHANDLER_H_
#define UPDATEHANDLER_H_ #define UPDATEHANDLER_H_
void UpdateHandler(void); void UpdateHandler(void);
#endif /* UPDATEHANDLER_H_ */ #endif /* UPDATEHANDLER_H_ */
+23 -23
View File
@@ -1,23 +1,23 @@
/* /*
* Version.h * Version.h
* *
* Created on: 04.08.2023 * Created on: 04.08.2023
* Author: flori * Author: flori
*/ */
#ifndef VERSION_H_ #ifndef VERSION_H_
#define VERSION_H_ #define VERSION_H_
#include "main.h" #include "main.h"
#if VERSION_DG_ONLY #if VERSION_DG_ONLY
#define PROJECT_VARIANT "DG" #define PROJECT_VARIANT "DG"
#else #else
#define PROJECT_VARIANT "EG" #define PROJECT_VARIANT "EG"
#endif #endif
#define PROJECT_NAME "FENSTER_PIEPSER_NODEMCU_32_S_" PROJECT_VARIANT #define PROJECT_NAME "FENSTER_PIEPSER_NODEMCU_32_S_" PROJECT_VARIANT
#define VERSION_STR "_v2.0.8" #define VERSION_STR "_v2.0.8"
#endif /* VERSION_H_ */ #endif /* VERSION_H_ */
+22 -22
View File
@@ -1,22 +1,22 @@
// Only modify this file to include // Only modify this file to include
// - function definitions (prototypes) // - function definitions (prototypes)
// - include files // - include files
// - extern variable definitions // - extern variable definitions
// In the appropriate section // In the appropriate section
#ifndef _fensterPIEP_H_ #ifndef _fensterPIEP_H_
#define _fensterPIEP_H_ #define _fensterPIEP_H_
#include "Arduino.h" #include "Arduino.h"
//add your includes for the project fensterPIEP here //add your includes for the project fensterPIEP here
//end of add your includes here //end of add your includes here
//add your function definitions for the project fensterPIEP here //add your function definitions for the project fensterPIEP here
//Do not add code below this line //Do not add code below this line
#endif /* _fensterPIEP_H_ */ #endif /* _fensterPIEP_H_ */
File diff suppressed because it is too large Load Diff
+12 -12
View File
@@ -1,12 +1,12 @@
// Only modify this file to include // Only modify this file to include
// - function definitions (prototypes) // - function definitions (prototypes)
// - include files // - include files
// - extern variable definitions // - extern variable definitions
// In the appropriate section // In the appropriate section
#ifndef _fenster_PIEPSER_NodeMCU32S_H_ #ifndef _fenster_PIEPSER_NodeMCU32S_H_
#define _fenster_PIEPSER_NodeMCU32S_H_ #define _fenster_PIEPSER_NodeMCU32S_H_
/* USE main.h */ /* USE main.h */
#endif /* _fenster_PIEPSER_NodeMCU32S_H_ */ #endif /* _fenster_PIEPSER_NodeMCU32S_H_ */
+102 -102
View File
@@ -1,102 +1,102 @@
/* /*
* main.h * main.h
* *
* Created on: 22.02.2020 * Created on: 22.02.2020
* Author: flori * Author: flori
*/ */
#ifndef MAIN_H_ #ifndef MAIN_H_
#define MAIN_H_ #define MAIN_H_
/* -------------- INCLUDES --------------*/ /* -------------- INCLUDES --------------*/
#include "Arduino.h" #include "Arduino.h"
#include "typedefs.h" #include "typedefs.h"
#include "PiepPattern.h" #include "PiepPattern.h"
#include "ReceiverFunkThermometer.h" #include "ReceiverFunkThermometer.h"
#include "Fenster.h" #include "Fenster.h"
/* --------------- TYPEDEFS -------------*/ /* --------------- TYPEDEFS -------------*/
/* --------- SYMBOLIC CONSTANTS ---------*/ /* --------- SYMBOLIC CONSTANTS ---------*/
#ifndef VERSION_DG_ONLY #ifndef VERSION_DG_ONLY
#define VERSION_DG_ONLY 0 /* default: EG — overridden by build environment */ #define VERSION_DG_ONLY 0 /* default: EG — overridden by build environment */
#endif #endif
#define VERSION_SMALL_DISPLAY 1 #define VERSION_SMALL_DISPLAY 1
#define VERSION_BIG_DISPLAY (! VERSION_SMALL_DISPLAY) #define VERSION_BIG_DISPLAY (! VERSION_SMALL_DISPLAY)
/* singal pins */ /* singal pins */
#define TFT_PIN_CLK 14 /* SCK */ #define TFT_PIN_CLK 14 /* SCK */
#define TFT_PIN_MOSI 13 /* SDA */ #define TFT_PIN_MOSI 13 /* SDA */
#define TFT_PIN_RST 22 // RES #define TFT_PIN_RST 22 // RES
#define TFT_PIN_DC 21 // RS (Data/Command = Register select) #define TFT_PIN_DC 21 // RS (Data/Command = Register select)
#define TFT_PIN_CS 15 /* CS Chip select */ #define TFT_PIN_CS 15 /* CS Chip select */
#define DOUT_TEST_TIMER 16 #define DOUT_TEST_TIMER 16
#define DOUT_FUNK_VCC 12 #define DOUT_FUNK_VCC 12
#define DOUT_FUNK_GND 32 #define DOUT_FUNK_GND 32
#define DIN_FUNK 26 #define DIN_FUNK 26
#define DOUT_PIEP_PWM 33 #define DOUT_PIEP_PWM 33
#define DOUT_PIEP_VCC 18 #define DOUT_PIEP_VCC 18
#define TONE_PWM_CHANNEL 12 #define TONE_PWM_CHANNEL 12
#define TONE_REQUEST_ON(source) toneRequest |= (1u<<source) /* the pwm output is always active, only the supply gets switched */ #define TONE_REQUEST_ON(source) toneRequest |= (1u<<source) /* the pwm output is always active, only the supply gets switched */
#define TONE_REQUEST_OFF(source) toneRequest &= (~(1u<<source)) #define TONE_REQUEST_OFF(source) toneRequest &= (~(1u<<source))
#define TONE_REQUEST_SOURCE_MODE 1u #define TONE_REQUEST_SOURCE_MODE 1u
#define TONE_REQUEST_SOURCE_SHORTPIEP 0u #define TONE_REQUEST_SOURCE_SHORTPIEP 0u
#if VERSION_SMALL_DISPLAY #if VERSION_SMALL_DISPLAY
#define NUM_FENSTER 4 #define NUM_FENSTER 4
#elif VERSION_BIG_DISPLAY #elif VERSION_BIG_DISPLAY
#define NUM_FENSTER 8 #define NUM_FENSTER 8
#endif #endif
#define DIRECTION_OPEN (1u) #define DIRECTION_OPEN (1u)
#define DIRECTION_CLOSE (0u) #define DIRECTION_CLOSE (0u)
/* ------------- GLOBAL VARIABLES --------*/ /* ------------- GLOBAL VARIABLES --------*/
extern uint8_t numberWindowsOpen; extern uint8_t numberWindowsOpen;
extern uint32_t waitTimeDs; extern uint32_t waitTimeDs;
extern char textBuf[100]; extern char textBuf[100];
extern bool bRequestShortBeep; extern bool bRequestShortBeep;
extern bool bIsNightTime; extern bool bIsNightTime;
extern PiepPattern *piepPattern; extern PiepPattern *piepPattern;
extern DeciSeconds_t tDecis; extern DeciSeconds_t tDecis;
extern ReceiverFunkThermometerData_t thermoData; extern ReceiverFunkThermometerData_t thermoData;
extern uint32_t loopCountSincePause; extern uint32_t loopCountSincePause;
extern uint8_t toneRequest; extern uint8_t toneRequest;
extern Fenster fensterFloBuero; extern Fenster fensterFloBuero;
extern Fenster fensterGefrier; extern Fenster fensterGefrier;
extern Fenster fensterBadOben; extern Fenster fensterBadOben;
extern Fenster fensterBadUnten; extern Fenster fensterBadUnten;
extern Fenster fensterFlo; extern Fenster fensterFlo;
extern Fenster fensterHanna; extern Fenster fensterHanna;
extern Fenster fensterWz; extern Fenster fensterWz;
extern Fenster fensterWz2; extern Fenster fensterWz2;
extern Fenster fensterX; extern Fenster fensterX;
extern Fenster fensterToniNeu; extern Fenster fensterToniNeu;
extern Fenster fensterKueche; extern Fenster fensterKueche;
extern Fenster fensterKeller; extern Fenster fensterKeller;
extern Fenster fensterGaeste; extern Fenster fensterGaeste;
extern Fenster* alleFenster[NUM_FENSTER]; extern Fenster* alleFenster[NUM_FENSTER];
/* ----------------------------------------*/ /* ----------------------------------------*/
#endif /* MAIN_H_ */ #endif /* MAIN_H_ */
+16 -16
View File
@@ -1,16 +1,16 @@
/* /*
* typedefs.h * typedefs.h
* *
* Created on: 24.05.2020 * Created on: 24.05.2020
* Author: flori * Author: flori
*/ */
#ifndef TYPEDEFS_H_ #ifndef TYPEDEFS_H_
#define TYPEDEFS_H_ #define TYPEDEFS_H_
#include "Arduino.h" #include "Arduino.h"
typedef uint32_t DeciSeconds_t; typedef uint32_t DeciSeconds_t;
#endif /* TYPEDEFS_H_ */ #endif /* TYPEDEFS_H_ */
+160 -160
View File
@@ -1,160 +1,160 @@
#ifndef RINGBUFFER_H #ifndef RINGBUFFER_H
#define RINGBUFFER_H #define RINGBUFFER_H
#include "Arduino.h" #include "Arduino.h"
/** /**
* the buffer always begins at iRead and ends at iBufEnd * the buffer always begins at iRead and ends at iBufEnd
* writing is allowed as long as iWrite != iBufEnd * writing is allowed as long as iWrite != iBufEnd
* reading is possible as long as iRead != iWrite * reading is possible as long as iRead != iWrite
* start (no data to read, 6 elements [0..5] free to write ): * start (no data to read, 6 elements [0..5] free to write ):
* [ 0 1 2 3 4 5 6 ] * [ 0 1 2 3 4 5 6 ]
* iRead * iRead
* iWrite x x x x x iBufEnd * iWrite x x x x x iBufEnd
* *
* 4 elements available to read: * 4 elements available to read:
* [ x x x iBufEnd iRead x x x iWrite x x x ] * [ x x x iBufEnd iRead x x x iWrite x x x ]
* after reading 4 elements: * after reading 4 elements:
* [ x x x x x x x iBufEnd iWrite x x x ] * [ x x x x x x x iBufEnd iWrite x x x ]
* iRead * iRead
* *
* 1 more element can be written, 8 can be read * 1 more element can be written, 8 can be read
* [ x x x iWrite iBufEnd iRead x x x x ] * [ x x x iWrite iBufEnd iRead x x x x ]
* after writing 1 element: * after writing 1 element:
* buffer is full, 9 to be read * buffer is full, 9 to be read
* [ x x x x iBufEnd iRead x x x x ] * [ x x x x iBufEnd iRead x x x x ]
* iWrite * iWrite
* *
* *
* writing is split up into three calls : * writing is split up into three calls :
* 1. canWrite -> check if the buffer has space left * 1. canWrite -> check if the buffer has space left
* 2. getWritePointer returns the pointer to the element * 2. getWritePointer returns the pointer to the element
* that can be written on (or NULL if writing is forbidden) * that can be written on (or NULL if writing is forbidden)
* 3. write moves the write index to the next position and thereby * 3. write moves the write index to the next position and thereby
* signals that the just written element can be read now * signals that the just written element can be read now
* *
* reading is done by * reading is done by
* 1. canRead -> check if there are elements that have been written * 1. canRead -> check if there are elements that have been written
* but not yet read * but not yet read
* 2. getReadPointer : returns pointer to the next available element * 2. getReadPointer : returns pointer to the next available element
* and increments the read index. Reading from the pointer * and increments the read index. Reading from the pointer
* is safe (data will not be overwritten) until the next call of * is safe (data will not be overwritten) until the next call of
* getReadPointer * getReadPointer
* *
*/ */
template<class T> class RingBuffer template<class T> class RingBuffer
{ {
public: public:
/** /**
* The RingBuffer does not create the underlying array itself, it must be * The RingBuffer does not create the underlying array itself, it must be
* created outside. * created outside.
* \param : array : pointer to first element of the array * \param : array : pointer to first element of the array
* arraySize : number of elements in the array * arraySize : number of elements in the array
*/ */
RingBuffer<T>(T * array, uint32_t arraySize) RingBuffer<T>(T * array, uint32_t arraySize)
{ {
this->array = array; //constant this->array = array; //constant
this->arraySize = arraySize; //constant this->arraySize = arraySize; //constant
iBufEnd = arraySize-1; iBufEnd = arraySize-1;
iWrite = 0; iWrite = 0;
iRead = 0; iRead = 0;
} }
/** /**
* return if the buffer has at least one element left to write on * return if the buffer has at least one element left to write on
* without overwriting unread elements * without overwriting unread elements
*/ */
bool canWrite(void) bool canWrite(void)
{ {
return iWrite != iBufEnd; return iWrite != iBufEnd;
} }
/** /**
* returns NULL if write is not permitted! * returns NULL if write is not permitted!
* (Check can be done with canWrite()) * (Check can be done with canWrite())
* When the writing to the pointer is finished call write()! * When the writing to the pointer is finished call write()!
*/ */
T* getWritePointer(void) T* getWritePointer(void)
{ {
T* pWrite = NULL; T* pWrite = NULL;
if (canWrite()) if (canWrite())
{ {
pWrite = &array[iWrite]; pWrite = &array[iWrite];
} }
return pWrite; return pWrite;
} }
/** /**
* to be called as soon as the data has been written. * to be called as soon as the data has been written.
* Don't put this into getWritePointer to allow reading * Don't put this into getWritePointer to allow reading
* the element immediately * the element immediately
*/ */
void write(void) void write(void)
{ {
if ( canWrite() ) if ( canWrite() )
{ {
/* should always be true, otherwise there was an error before */ /* should always be true, otherwise there was an error before */
if (++iWrite==arraySize){ if (++iWrite==arraySize){
iWrite = 0; //wrap iWrite = 0; //wrap
} }
} }
} }
/** /**
* return true if there are elements that can be read * return true if there are elements that can be read
*/ */
bool canRead(void) bool canRead(void)
{ {
return iRead != iWrite; return iRead != iWrite;
} }
/** /**
* return the number of received elements that haven't been read yet * return the number of received elements that haven't been read yet
*/ */
uint32_t getNumberUnread(void) uint32_t getNumberUnread(void)
{ {
uint32_t numUnread; uint32_t numUnread;
if ( iRead == iWrite ) if ( iRead == iWrite )
{ {
numUnread = 0; numUnread = 0;
} }
else if ( iWrite > iRead ) else if ( iWrite > iRead )
{ {
numUnread = iWrite-iRead; numUnread = iWrite-iRead;
} }
else else
{ {
numUnread = arraySize + iWrite - iRead; numUnread = arraySize + iWrite - iRead;
} }
return numUnread; return numUnread;
} }
/** /**
* get Pointer to next received frame that hasn't been read yet. * get Pointer to next received frame that hasn't been read yet.
* the data will be safe to read until the next call of the function * the data will be safe to read until the next call of the function
* (because array[iBufEnd] will not be overwritten) * (because array[iBufEnd] will not be overwritten)
* The function increments the read index, so it may only be called once per element * The function increments the read index, so it may only be called once per element
*/ */
T* getReadPointer(void) T* getReadPointer(void)
{ {
T* pEntry = &array[iRead]; T* pEntry = &array[iRead];
iBufEnd = iRead; iBufEnd = iRead;
if (++iRead==arraySize){ if (++iRead==arraySize){
iRead = 0; //wrap iRead = 0; //wrap
} }
return pEntry; return pEntry;
} }
private: private:
T* array; T* array;
uint32_t arraySize; uint32_t arraySize;
uint32_t iWrite; uint32_t iWrite;
uint32_t iRead; uint32_t iRead;
uint32_t iBufEnd; uint32_t iBufEnd;
}; };
#endif #endif
+19 -19
View File
@@ -1,19 +1,19 @@
/* /*
* XcpApplInterface.h * XcpApplInterface.h
* *
* Created on: 30.07.2022 * Created on: 30.07.2022
* Author: flori * Author: flori
*/ */
#ifndef XCP_XCPAPPINTERFACE_H_ #ifndef XCP_XCPAPPINTERFACE_H_
#define XCP_XCPAPPINTERFACE_H_ #define XCP_XCPAPPINTERFACE_H_
#include "xcp_cfg.h" #include "xcp_cfg.h"
extern const vuint8 kXcpEventDirection[kXcpMaxEvent]; //DAQ extern const vuint8 kXcpEventDirection[kXcpMaxEvent]; //DAQ
extern const vuint8 kXcpEventCycle[kXcpMaxEvent]; extern const vuint8 kXcpEventCycle[kXcpMaxEvent];
extern const vuint8 kXcpEventUnit[kXcpMaxEvent]; extern const vuint8 kXcpEventUnit[kXcpMaxEvent];
extern const char kXcpEventName[kXcpMaxEvent][7]; extern const char kXcpEventName[kXcpMaxEvent][7];
extern const vuint8 kXcpEventNameLength[kXcpMaxEvent]; extern const vuint8 kXcpEventNameLength[kXcpMaxEvent];
#endif /* XCP_XCPAPPINTERFACE_H_ */ #endif /* XCP_XCPAPPINTERFACE_H_ */
+139 -139
View File
@@ -1,139 +1,139 @@
/* /*
* XcpApplnterface.c * XcpApplnterface.c
* *
* Created on: 30.07.2022 * Created on: 30.07.2022
* Author: flori * Author: flori
*/ */
/****************************************************************************/ /****************************************************************************/
#include "XcpBasic.h" #include "XcpBasic.h"
#include "XcpFrameReceiver.h" #include "XcpFrameReceiver.h"
#include "XcpDriverCom.h" #include "XcpDriverCom.h"
#include "XcpAppInterface.h" #include "XcpAppInterface.h"
/****************************************************************************/ /****************************************************************************/
#define XCPFRAME_BUFFERSIZE 5 /* x frames are sufficient */ #define XCPFRAME_BUFFERSIZE 5 /* x frames are sufficient */
/****************************************************************************/ /****************************************************************************/
const vuint8 kXcpEventDirection[kXcpMaxEvent] = { 4, 4, 4, 4 }; //DAQ const vuint8 kXcpEventDirection[kXcpMaxEvent] = { 4, 4, 4, 4 }; //DAQ
const vuint8 kXcpEventCycle[kXcpMaxEvent] = { 1, 1, 5, 1 }; const vuint8 kXcpEventCycle[kXcpMaxEvent] = { 1, 1, 5, 1 };
const vuint8 kXcpEventUnit[kXcpMaxEvent] = { 7, 8, 8, 9 }; const vuint8 kXcpEventUnit[kXcpMaxEvent] = { 7, 8, 8, 9 };
const char kXcpEventName[kXcpMaxEvent][7] = { {"10ms "}, {"100ms "}, {"500ms "}, {"1000ms"}}; const char kXcpEventName[kXcpMaxEvent][7] = { {"10ms "}, {"100ms "}, {"500ms "}, {"1000ms"}};
const vuint8 kXcpEventNameLength[kXcpMaxEvent] = { 4, 5, 5, 6 }; const vuint8 kXcpEventNameLength[kXcpMaxEvent] = { 4, 5, 5, 6 };
/****************************************************************************/ /****************************************************************************/
static XcpFrame tlComXcpRxPackets[XCPFRAME_BUFFERSIZE]; static XcpFrame tlComXcpRxPackets[XCPFRAME_BUFFERSIZE];
static XcpFrameReceiver xcpFrameReceiver( tlComXcpRxPackets, XCPFRAME_BUFFERSIZE, false ); static XcpFrameReceiver xcpFrameReceiver( tlComXcpRxPackets, XCPFRAME_BUFFERSIZE, false );
#define XCP_SEND_BUFFER_SIZE 10u #define XCP_SEND_BUFFER_SIZE 10u
static XcpFrame sendBuffer[XCP_SEND_BUFFER_SIZE]; static XcpFrame sendBuffer[XCP_SEND_BUFFER_SIZE];
static vuint16 xcpSendBufWritePos = 0; static vuint16 xcpSendBufWritePos = 0;
static vuint16 xcpSendBufReadPos = 0; static vuint16 xcpSendBufReadPos = 0;
/****************************************************************************/ /****************************************************************************/
/** /**
* *
*/ */
void XcpPoll() void XcpPoll()
{ {
/* receive message */ /* receive message */
if (XCP_COM_AVAILABLE()) if (XCP_COM_AVAILABLE())
{ {
while (XCP_COM_AVAILABLE()) while (XCP_COM_AVAILABLE())
{ {
uint8_t serData = XCP_COM_READ(); uint8_t serData = XCP_COM_READ();
if (xcpFrameReceiver.hasSpace()) if (xcpFrameReceiver.hasSpace())
{ {
xcpFrameReceiver.putData(1, &serData); xcpFrameReceiver.putData(1, &serData);
} }
if (xcpFrameReceiver.hasFrames()) if (xcpFrameReceiver.hasFrames())
{ {
XcpFrame *pFrame = xcpFrameReceiver.getFrame(); XcpFrame *pFrame = xcpFrameReceiver.getFrame();
XcpCommand(pFrame->data.u32); XcpCommand(pFrame->data.u32);
break; break;
} }
} }
} }
} }
/** /**
* *
*/ */
void ApplXcpSend( uint8_t len, MEMORY_ROM BYTEPTR msg ) void ApplXcpSend( uint8_t len, MEMORY_ROM BYTEPTR msg )
{ {
uint8_t iBuf = 0; uint8_t iBuf = 0;
sendBuffer[xcpSendBufWritePos].data.u8[iBuf++] = XcpFrameReceiver::ESCBYTE; sendBuffer[xcpSendBufWritePos].data.u8[iBuf++] = XcpFrameReceiver::ESCBYTE;
sendBuffer[xcpSendBufWritePos].data.u8[iBuf++] = len; sendBuffer[xcpSendBufWritePos].data.u8[iBuf++] = len;
for (uint8_t iMsg = 0; iMsg<len; iMsg++ ) for (uint8_t iMsg = 0; iMsg<len; iMsg++ )
{ {
sendBuffer[xcpSendBufWritePos].data.u8[iBuf++] = msg[iMsg]; sendBuffer[xcpSendBufWritePos].data.u8[iBuf++] = msg[iMsg];
} }
sendBuffer[xcpSendBufWritePos].len = iBuf; sendBuffer[xcpSendBufWritePos].len = iBuf;
if (++xcpSendBufWritePos >= XCP_SEND_BUFFER_SIZE) if (++xcpSendBufWritePos >= XCP_SEND_BUFFER_SIZE)
{ {
xcpSendBufWritePos = 0u; xcpSendBufWritePos = 0u;
} }
XcpSendCallBack(); XcpSendCallBack();
} }
/** /**
* send max one frame from buffer * send max one frame from buffer
*/ */
void XcpSendLoop() void XcpSendLoop()
{ {
#define SEND_MAX_FRAMES_PER_CALL 3u #define SEND_MAX_FRAMES_PER_CALL 3u
for (uint8_t i=0; i<SEND_MAX_FRAMES_PER_CALL; i++) for (uint8_t i=0; i<SEND_MAX_FRAMES_PER_CALL; i++)
{ {
if (xcpSendBufReadPos != xcpSendBufWritePos) if (xcpSendBufReadPos != xcpSendBufWritePos)
{ {
Serial.write(sendBuffer[xcpSendBufReadPos].data.u8, sendBuffer[xcpSendBufReadPos].len); Serial.write(sendBuffer[xcpSendBufReadPos].data.u8, sendBuffer[xcpSendBufReadPos].len);
if (++xcpSendBufReadPos >= XCP_SEND_BUFFER_SIZE) if (++xcpSendBufReadPos >= XCP_SEND_BUFFER_SIZE)
{ {
xcpSendBufReadPos = 0u; xcpSendBufReadPos = 0u;
} }
} }
} }
} }
/** /**
* *
*/ */
MTABYTEPTR ApplXcpGetPointer( uint8_t addr_ext, uint32_t addr ) MTABYTEPTR ApplXcpGetPointer( uint8_t addr_ext, uint32_t addr )
{ {
//return (MTABYTEPTR)&kXcpEventName; //return (MTABYTEPTR)&kXcpEventName;
return (MTABYTEPTR)(addr + 0*addr_ext); return (MTABYTEPTR)(addr + 0*addr_ext);
} }
/** /**
* *
*/ */
void ApplXcpInterruptEnable() void ApplXcpInterruptEnable()
{ {
//interrupts(); //interrupts();
} }
/** /**
* *
*/ */
void ApplXcpInterruptDisable() void ApplXcpInterruptDisable()
{ {
//noInterrupts(); //noInterrupts();
} }
/** /**
* *
*/ */
uint16_t ApplXcpGetTimestamp(void) uint16_t ApplXcpGetTimestamp(void)
{ {
return (uint16_t) millis(); return (uint16_t) millis();
} }
+3742 -3742
View File
File diff suppressed because it is too large Load Diff
+2368 -2368
View File
File diff suppressed because it is too large Load Diff
+17 -17
View File
@@ -1,17 +1,17 @@
/* /*
* XcpDriverCom.h * XcpDriverCom.h
* *
* Created on: 30.07.2022 * Created on: 30.07.2022
* Author: flori * Author: flori
*/ */
#ifndef XCPDRIVERCOM_H_ #ifndef XCPDRIVERCOM_H_
#define XCPDRIVERCOM_H_ #define XCPDRIVERCOM_H_
#define XCP_COM_AVAILABLE() Serial.available() #define XCP_COM_AVAILABLE() Serial.available()
#define XCP_COM_READ() Serial.read() #define XCP_COM_READ() Serial.read()
#define XCP_COM_WRITE_BYTE(b) Serial.write(b) #define XCP_COM_WRITE_BYTE(b) Serial.write(b)
#endif /* XCPDRIVERCOM_H_ */ #endif /* XCPDRIVERCOM_H_ */
+18 -18
View File
@@ -1,18 +1,18 @@
#ifndef XCPFRAME_H #ifndef XCPFRAME_H
#define XCPFRAME_H #define XCPFRAME_H
#include "Arduino.h" #include "Arduino.h"
#define DTOBUF_PACKETSIZE 16u /* packet size in bytes */ #define DTOBUF_PACKETSIZE 16u /* packet size in bytes */
class XcpFrame class XcpFrame
{ {
public: public:
uint16_t len; uint16_t len;
union{ union{
uint32_t u32[DTOBUF_PACKETSIZE/4u]; uint32_t u32[DTOBUF_PACKETSIZE/4u];
uint8_t u8[DTOBUF_PACKETSIZE]; uint8_t u8[DTOBUF_PACKETSIZE];
} data; /* the xcp driver needs uint32 aligned data */ } data; /* the xcp driver needs uint32 aligned data */
}; };
#endif #endif
+146 -146
View File
@@ -1,146 +1,146 @@
#include "XcpFrameReceiver.h" #include "XcpFrameReceiver.h"
template class RingBuffer<XcpFrame>; template class RingBuffer<XcpFrame>;
/** /**
* XcpFrameReceiver : protocol class to decode frame data with SOF byte and * XcpFrameReceiver : protocol class to decode frame data with SOF byte and
* byte stuffing (with preceding escape byte). A valid frame must be transmitted * byte stuffing (with preceding escape byte). A valid frame must be transmitted
* like this: * like this:
* SOF len(LSB) len(MSB) cs(LSB) cs(MSB) data0 data1 .. * SOF len(LSB) len(MSB) cs(LSB) cs(MSB) data0 data1 ..
* *
* len: uint16 , number of data bytes * len: uint16 , number of data bytes
* cs : uint16 , checksum (sum over all data bytes) * cs : uint16 , checksum (sum over all data bytes)
* *
* if there is any escape byte or SOF byte inside the len, cs, or data field * if there is any escape byte or SOF byte inside the len, cs, or data field
* it must be transmitted with a preceding escape byte (this does not affect the * it must be transmitted with a preceding escape byte (this does not affect the
* len or cs itself). * len or cs itself).
* *
* Usage: * Usage:
* 1. initialize with existing array * 1. initialize with existing array
* 2. call hasSpace, putData to write and decode the received data and * 2. call hasSpace, putData to write and decode the received data and
* store it into the given array * store it into the given array
* 3. call hasFrames, getFrame to get the decoded frames * 3. call hasFrames, getFrame to get the decoded frames
* *
*/ */
/* /*
* constructor: Init everything * constructor: Init everything
* \param : frameArray : pointer to first element of frame array * \param : frameArray : pointer to first element of frame array
* arraySize : number of elements inside the array * arraySize : number of elements inside the array
* *
*/ */
XcpFrameReceiver::XcpFrameReceiver(XcpFrame *frameArray, uint32_t arraySize, bool useChecksum ) XcpFrameReceiver::XcpFrameReceiver(XcpFrame *frameArray, uint32_t arraySize, bool useChecksum )
{ {
ringBuffer = new RingBuffer<XcpFrame>(frameArray, arraySize); ringBuffer = new RingBuffer<XcpFrame>(frameArray, arraySize);
state = NONE_XCP_DATA; state = NONE_XCP_DATA;
frameLen = 0; frameLen = 0;
frameCount = 0; frameCount = 0;
iFrameData = 0; iFrameData = 0;
pWriteFrame = NULL; pWriteFrame = NULL;
numProtocolErrors = 0; numProtocolErrors = 0;
} }
/** /**
* return false if the underlying buffer has no space left * return false if the underlying buffer has no space left
*/ */
bool XcpFrameReceiver::hasSpace(void) bool XcpFrameReceiver::hasSpace(void)
{ {
return ringBuffer->canWrite(); return ringBuffer->canWrite();
} }
/** /**
* return true if there are readable elements in the underlying buffer * return true if there are readable elements in the underlying buffer
*/ */
bool XcpFrameReceiver::hasFrames(void) bool XcpFrameReceiver::hasFrames(void)
{ {
return ringBuffer->canRead(); return ringBuffer->canRead();
} }
/** /**
* get the available number of frames that have not been read yet * get the available number of frames that have not been read yet
*/ */
uint32_t XcpFrameReceiver::getNumberFrames(void) uint32_t XcpFrameReceiver::getNumberFrames(void)
{ {
return ringBuffer->getNumberUnread(); return ringBuffer->getNumberUnread();
} }
/** /**
* return the frame that was received next and yet not read. * return the frame that was received next and yet not read.
* -> call only once per receive frame (increments the index) * -> call only once per receive frame (increments the index)
*/ */
XcpFrame *XcpFrameReceiver::getFrame(void) XcpFrame *XcpFrameReceiver::getFrame(void)
{ {
return ringBuffer->getReadPointer(); return ringBuffer->getReadPointer();
} }
/** check canWrite before putting new data ! */ /** check canWrite before putting new data ! */
void XcpFrameReceiver::putData(uint32_t lenData, uint8_t * data) void XcpFrameReceiver::putData(uint32_t lenData, uint8_t * data)
{ {
uint32_t i; uint32_t i;
pWriteFrame = ringBuffer->getWritePointer(); pWriteFrame = ringBuffer->getWritePointer();
i = 0; i = 0;
while (i<lenData) while (i<lenData)
{ {
/* data must be processed byte by byte because SOF/ESC bytes need to be detected */ /* data must be processed byte by byte because SOF/ESC bytes need to be detected */
if ( NULL == pWriteFrame ) if ( NULL == pWriteFrame )
{ {
/* pWriteFrame might become NULL in processing function */ /* pWriteFrame might become NULL in processing function */
break; //while loop break; //while loop
} }
else else
{ {
processByte(data[i]); processByte(data[i]);
} }
i++; i++;
} //while (i<lenData) } //while (i<lenData)
} }
/** /**
* *
*/ */
void XcpFrameReceiver::processByte(uint8_t byte) void XcpFrameReceiver::processByte(uint8_t byte)
{ {
switch ( state) switch ( state)
{ {
case NONE_XCP_DATA: case NONE_XCP_DATA:
if (byte == ESCBYTE) if (byte == ESCBYTE)
{ {
state = ESCAPED; state = ESCAPED;
} }
else else
{ {
//std::cout << byte << std::flush; //std::cout << byte << std::flush;
} }
break; break;
case ESCAPED: case ESCAPED:
if (byte == ESCBYTE) if (byte == ESCBYTE)
{ {
//std::cout << byte << std::flush; //std::cout << byte << std::flush;
state = NONE_XCP_DATA; state = NONE_XCP_DATA;
} }
else else
{ {
frameLen = byte; frameLen = byte;
iFrameData = 0u; iFrameData = 0u;
state = XCP_DATA; state = XCP_DATA;
} }
break; break;
case XCP_DATA: case XCP_DATA:
pWriteFrame->data.u8[iFrameData++] = byte; pWriteFrame->data.u8[iFrameData++] = byte;
if (iFrameData == frameLen) if (iFrameData == frameLen)
{ {
pWriteFrame->len = frameLen; pWriteFrame->len = frameLen;
ringBuffer->write(); ringBuffer->write();
state = NONE_XCP_DATA; state = NONE_XCP_DATA;
} }
break; break;
} }
} }
+61 -61
View File
@@ -1,61 +1,61 @@
#ifndef XCPFRAMERECEIVER_H #ifndef XCPFRAMERECEIVER_H
#define XCPFRAMERECEIVER_H #define XCPFRAMERECEIVER_H
#include "RingBuffer.h" #include "RingBuffer.h"
#include "XcpFrame.h" #include "XcpFrame.h"
class XcpFrameReceiver class XcpFrameReceiver
{ {
public : public :
static const uint8_t ESCBYTE = 0xFF; static const uint8_t ESCBYTE = 0xFF;
/* /*
* constructor: Init everything * constructor: Init everything
*/ */
XcpFrameReceiver(XcpFrame *frameArray, uint32_t arraySize, bool useChecksum = true); XcpFrameReceiver(XcpFrame *frameArray, uint32_t arraySize, bool useChecksum = true);
/** /**
* return false if the back buffer has no space left * return false if the back buffer has no space left
*/ */
bool hasSpace(void); bool hasSpace(void);
/** /**
* return true if there are readable frames in the back buffer * return true if there are readable frames in the back buffer
*/ */
bool hasFrames(void); bool hasFrames(void);
/** /**
* get the available number of frames that have not been read yet * get the available number of frames that have not been read yet
*/ */
uint32_t getNumberFrames(void); uint32_t getNumberFrames(void);
/** /**
* return the frame that was received next and yet not read. * return the frame that was received next and yet not read.
*/ */
XcpFrame *getFrame(void); XcpFrame *getFrame(void);
/** check canWrite before putting new data ! */ /** check canWrite before putting new data ! */
void putData(uint32_t lenData, uint8_t * data); void putData(uint32_t lenData, uint8_t * data);
private : private :
uint32_t frameCount; /** counter for every XCP ethernet frame to be compared with received counter */ uint32_t frameCount; /** counter for every XCP ethernet frame to be compared with received counter */
class RingBuffer<XcpFrame> *ringBuffer; class RingBuffer<XcpFrame> *ringBuffer;
XcpFrame* pWriteFrame; XcpFrame* pWriteFrame;
uint16_t iFrameData; /* temporary index for received Xcp Frame data */ uint16_t iFrameData; /* temporary index for received Xcp Frame data */
uint8_t frameLen; uint8_t frameLen;
uint32_t numProtocolErrors; uint32_t numProtocolErrors;
enum receiveState { NONE_XCP_DATA, ESCAPED, XCP_DATA } state; enum receiveState { NONE_XCP_DATA, ESCAPED, XCP_DATA } state;
/** /**
* destuff escape bytes, detect start of frame, forward data bytes * destuff escape bytes, detect start of frame, forward data bytes
*/ */
void processByte(uint8_t byte); void processByte(uint8_t byte);
}; };
#endif #endif
+18 -18
View File
@@ -1,18 +1,18 @@
/* /*
* XcpPort.h * XcpPort.h
* *
* Created on: 30.07.2022 * Created on: 30.07.2022
* Author: flori * Author: flori
*/ */
#ifndef XCP_XCPPORT_H_ #ifndef XCP_XCPPORT_H_
#define XCP_XCPPORT_H_ #define XCP_XCPPORT_H_
#include "xcp_typedefs.h" #include "xcp_typedefs.h"
vuint8 XcpEvent( vuint8 event ); vuint8 XcpEvent( vuint8 event );
extern void XcpInit( void ); extern void XcpInit( void );
extern void XcpPoll(); extern void XcpPoll();
extern void XcpSendLoop(); extern void XcpSendLoop();
#endif /* XCP_XCPPORT_H_ */ #endif /* XCP_XCPPORT_H_ */
+140 -140
View File
@@ -1,140 +1,140 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
C O P Y R I G H T C O P Y R I G H T
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (c) 2001-2006 by Vector Informatik GmbH. All rights reserved. Copyright (c) 2001-2006 by Vector Informatik GmbH. All rights reserved.
This software is copyright protected and proprietary to Vector Informatik This software is copyright protected and proprietary to Vector Informatik
GmbH. GmbH.
Vector Informatik GmbH grants to you only those rights as set out in the Vector Informatik GmbH grants to you only those rights as set out in the
license conditions. license conditions.
All other rights remain with Vector Informatik GmbH. All other rights remain with Vector Informatik GmbH.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
----------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
#if !defined(__XCP_CFG_H__) #if !defined(__XCP_CFG_H__)
#define __XCP_CFG_H__ #define __XCP_CFG_H__
#undef EXTERN #undef EXTERN
/* */ /* */
/* CPU */ /* CPU */
#define C_CPUTYPE_LITTLEENDIAN #define C_CPUTYPE_LITTLEENDIAN
#define XCP_ENABLE_CANAPE_5_5_X_SUPPORT //nur fuer EVENT_TIME_UNIT bei GET_DAQ_EVENT_INFO #define XCP_ENABLE_CANAPE_5_5_X_SUPPORT //nur fuer EVENT_TIME_UNIT bei GET_DAQ_EVENT_INFO
/* General settings */ /* General settings */
#define XCP_ENABLE_PARAMETER_CHECK #define XCP_ENABLE_PARAMETER_CHECK
#define XCP_ENABLE_SEND_EVENT #define XCP_ENABLE_SEND_EVENT
#define XCP_DISABLE_TESTMODE #define XCP_DISABLE_TESTMODE
#define XCP_DISABLE_BOOTLOADER_DOWNLOAD #define XCP_DISABLE_BOOTLOADER_DOWNLOAD
#define XCP_DISABLE_WRITE_PROTECTION #define XCP_DISABLE_WRITE_PROTECTION
#define XCP_DISABLE_READ_PROTECTION #define XCP_DISABLE_READ_PROTECTION
#define XCP_ENABLE_CONTROL #define XCP_ENABLE_CONTROL
#define XCP_DISABLE_GET_XCP_DATA_POINTER #define XCP_DISABLE_GET_XCP_DATA_POINTER
#define XCP_DISABLE_OPENCMDIF #define XCP_DISABLE_OPENCMDIF
#define XCP_ENABLE_MEM_MAPPING #define XCP_ENABLE_MEM_MAPPING
#define XCP_DISABLE_VERSION_INFO_API #define XCP_DISABLE_VERSION_INFO_API
/* */ /* */
/* EEPROM access */ /* EEPROM access */
#define XCP_DISABLE_READ_EEPROM #define XCP_DISABLE_READ_EEPROM
#define XCP_DISABLE_WRITE_EEPROM #define XCP_DISABLE_WRITE_EEPROM
/* */ /* */
/* Service request message */ /* Service request message */
#define XCP_DISABLE_SERV_TEXT #define XCP_DISABLE_SERV_TEXT
#define XCP_DISABLE_SERV_TEXT_PUTCHAR #define XCP_DISABLE_SERV_TEXT_PUTCHAR
#define XCP_DISABLE_SERV_TEXT_PRINTF #define XCP_DISABLE_SERV_TEXT_PRINTF
/* */ /* */
/* Standard commands */ /* Standard commands */
#define XCP_ENABLE_COMM_MODE_INFO #define XCP_ENABLE_COMM_MODE_INFO
#define XCP_DISABLE_SEED_KEY #define XCP_DISABLE_SEED_KEY
#define XCP_ENABLE_MODIFY_BITS #define XCP_ENABLE_MODIFY_BITS
#define XCP_ENABLE_SHORT_DOWNLOAD #define XCP_ENABLE_SHORT_DOWNLOAD
#define XCP_DISABLE_USER_COMMAND #define XCP_DISABLE_USER_COMMAND
#define XCP_DISABLE_VECTOR_MAPNAMES #define XCP_DISABLE_VECTOR_MAPNAMES
#define XCP_ENABLE_TL_COMMAND #define XCP_ENABLE_TL_COMMAND
/* */ /* */
/* Block transfer */ /* Block transfer */
#define XCP_ENABLE_BLOCK_UPLOAD #define XCP_ENABLE_BLOCK_UPLOAD
#define XCP_ENABLE_BLOCK_DOWNLOAD #define XCP_ENABLE_BLOCK_DOWNLOAD
/* */ /* */
/* Checksum */ /* Checksum */
#define XCP_DISABLE_CHECKSUM #define XCP_DISABLE_CHECKSUM
#define XCP_DISABLE_AUTOSAR_CRC_MODULE #define XCP_DISABLE_AUTOSAR_CRC_MODULE
#define kXcpChecksumMethod XCP_CHECKSUM_TYPE_ADD12 #define kXcpChecksumMethod XCP_CHECKSUM_TYPE_ADD12
#define kXcpChecksumBlockSize 0 #define kXcpChecksumBlockSize 0
/* */ /* */
/* Synchronous Data Acquisition (DAQ) */ /* Synchronous Data Acquisition (DAQ) */
#define XCP_ENABLE_DAQ #define XCP_ENABLE_DAQ
#define kXcpDaqMemSize 256 #define kXcpDaqMemSize 256
#define XCP_DISABLE_STIM #define XCP_DISABLE_STIM
#define XCP_DISABLE_UNALIGNED_MEM_ACCESS #define XCP_DISABLE_UNALIGNED_MEM_ACCESS
#define XCP_ENABLE_SEND_DIRECT #define XCP_ENABLE_SEND_DIRECT
#define XCP_DISABLE_SEND_QUEUE #define XCP_DISABLE_SEND_QUEUE
#define kXcpStimOdtCount 0x04u #define kXcpStimOdtCount 0x04u
#define XCP_ENABLE_DAQ_PRESCALER #define XCP_ENABLE_DAQ_PRESCALER
#define XCP_ENABLE_DAQ_OVERRUN_INDICATION #define XCP_ENABLE_DAQ_OVERRUN_INDICATION
#define XCP_ENABLE_WRITE_DAQ_MULTIPLE #define XCP_ENABLE_WRITE_DAQ_MULTIPLE
#undef XCP_ENABLE_DAQ_HDR_ODT_DAQ #undef XCP_ENABLE_DAQ_HDR_ODT_DAQ
#undef XCP_ALLIGN_WORD #undef XCP_ALLIGN_WORD
#undef XCP_ENABLE_ODT_SIZE_WORD #undef XCP_ENABLE_ODT_SIZE_WORD
#define XCP_ENABLE_DAQ_RESUME #define XCP_ENABLE_DAQ_RESUME
#define XCP_ENABLE_DAQ_PROCESSOR_INFO #define XCP_ENABLE_DAQ_PROCESSOR_INFO
#define XCP_ENABLE_DAQ_RESOLUTION_INFO #define XCP_ENABLE_DAQ_RESOLUTION_INFO
/* */ /* */
// CALIBRATION // CALIBRATION
#define XCP_ENABLE_CALIBRATION #define XCP_ENABLE_CALIBRATION
/* Events */ /* Events */
#define XCP_ENABLE_DAQ_EVENT_INFO #define XCP_ENABLE_DAQ_EVENT_INFO
#define kXcpMaxEvent 4 #define kXcpMaxEvent 4
/* */ /* */
/* DAQ Timestamp */ /* DAQ Timestamp */
#define XCP_ENABLE_DAQ_TIMESTAMP #define XCP_ENABLE_DAQ_TIMESTAMP
#define XCP_ENABLE_DAQ_TIMESTAMP_FIXED #define XCP_ENABLE_DAQ_TIMESTAMP_FIXED
#define kXcpDaqTimestampUnit DAQ_TIMESTAMP_UNIT_1MS #define kXcpDaqTimestampUnit DAQ_TIMESTAMP_UNIT_1MS
#define kXcpDaqTimestampTicksPerUnit 1 #define kXcpDaqTimestampTicksPerUnit 1
#define kXcpDaqTimestampSize DAQ_TIMESTAMP_WORD #define kXcpDaqTimestampSize DAQ_TIMESTAMP_WORD
/* */ /* */
/* Page switching */ /* Page switching */
#undef XCP_DISABLE_CALIBRATION_PAGE #undef XCP_DISABLE_CALIBRATION_PAGE
#define kXcpMaxSegment 1 #define kXcpMaxSegment 1
#undef XCP_ENABLE_PAGE_INFO #undef XCP_ENABLE_PAGE_INFO
#define kXcpMaxPages 2 #define kXcpMaxPages 2
#define XCP_DISABLE_PAGE_COPY #define XCP_DISABLE_PAGE_COPY
#define XCP_DISABLE_PAGE_FREEZE #define XCP_DISABLE_PAGE_FREEZE
/* */ /* */
/* Programming */ /* Programming */
#define XCP_DISABLE_PROGRAM #define XCP_DISABLE_PROGRAM
#define kXcpProgramMinStPgm 0 #define kXcpProgramMinStPgm 0
#define kXcpProgramMaxSector 1 #define kXcpProgramMaxSector 1
#define XCP_DISABLE_PROGRAM_INFO #define XCP_DISABLE_PROGRAM_INFO
/* */ /* */
#define CP_XCPDLL_VERSION 0x0209u #define CP_XCPDLL_VERSION 0x0209u
#define CP_XCPDLL_RELEASE_VERSION 0x00u #define CP_XCPDLL_RELEASE_VERSION 0x00u
#define XCP_SEND_QUEUE_SAMPLE_ODT #define XCP_SEND_QUEUE_SAMPLE_ODT
//#define XCP_TRANSPORT_LAYER_TYPE_FLEXRAY_ASR //#define XCP_TRANSPORT_LAYER_TYPE_FLEXRAY_ASR
//#define XCP_TRANSPORT_LAYER_TYPE_CAN //#define XCP_TRANSPORT_LAYER_TYPE_CAN
/* begin Fileversion check */ /* begin Fileversion check */
#ifndef SKIP_MAGIC_NUMBER #ifndef SKIP_MAGIC_NUMBER
#ifdef MAGIC_NUMBER #ifdef MAGIC_NUMBER
#if MAGIC_NUMBER != 2124540520 #if MAGIC_NUMBER != 2124540520
#error "The magic number of the generated file <D:\USR\_PROJECTS\Audi\EE-82\D4_MJ09_FR\E50_Verification\XCPonFlexRay\zTsi_XcpOnFlexRay\V85x\GHS\StandardECU_TTXSWV01.12.02\_Demo\DemoXcp\schedule\xcp_cfg.h> is different. Please check time and date of generated files!" #error "The magic number of the generated file <D:\USR\_PROJECTS\Audi\EE-82\D4_MJ09_FR\E50_Verification\XCPonFlexRay\zTsi_XcpOnFlexRay\V85x\GHS\StandardECU_TTXSWV01.12.02\_Demo\DemoXcp\schedule\xcp_cfg.h> is different. Please check time and date of generated files!"
#endif #endif
#else #else
#define MAGIC_NUMBER 2124540520 #define MAGIC_NUMBER 2124540520
#endif /* MAGIC_NUMBER */ #endif /* MAGIC_NUMBER */
#endif /* SKIP_MAGIC_NUMBER */ #endif /* SKIP_MAGIC_NUMBER */
/* end Fileversion check */ /* end Fileversion check */
#endif /* __XCP_CFG_H__ */ #endif /* __XCP_CFG_H__ */
+172 -172
View File
@@ -1,172 +1,172 @@
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
| File: | File:
| XCP_DEF.H | XCP_DEF.H
| |
| Project: | Project:
| XCP samples | XCP samples
| |
| Description | Description
| XCP default settings | XCP default settings
| Don't change this file | Don't change this file
| |
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#if defined ( __XCP_DEF_H__ ) #if defined ( __XCP_DEF_H__ )
#else #else
#define __XCP_DEF_H__ #define __XCP_DEF_H__
#ifdef VAR_DEF #ifdef VAR_DEF
#define EXTERN #define EXTERN
#else #else
#define EXTERN extern #define EXTERN extern
#endif #endif
/*------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------*/
/* Default settings */ /* Default settings */
/* XCP transport layer */ /* XCP transport layer */
#if !defined(XCP_TRANSPORT_LAYER_VERSION) #if !defined(XCP_TRANSPORT_LAYER_VERSION)
#define XCP_TRANSPORT_LAYER_VERSION 0x0100 #define XCP_TRANSPORT_LAYER_VERSION 0x0100
#endif #endif
#undef EXTERN #undef EXTERN
#define GRANULARITY_ODT_ENTRY_SIZE_ODT 1 #define GRANULARITY_ODT_ENTRY_SIZE_ODT 1
/* ROM memory qualifiers */ /* ROM memory qualifiers */
#if !defined(MEMORY_ROM) #if !defined(MEMORY_ROM)
#define MEMORY_ROM const #define MEMORY_ROM const
#endif #endif
#if !defined(V_MEMROM0) #if !defined(V_MEMROM0)
#define V_MEMROM0 #define V_MEMROM0
#endif #endif
#if !defined(MEMORY_CONST) #if !defined(MEMORY_CONST)
#define MEMORY_CONST #define MEMORY_CONST
#endif #endif
/* Alignment requirements */ /* Alignment requirements */
/* Specify, whether the microcontroller allows unaligned memory access or not */ /* Specify, whether the microcontroller allows unaligned memory access or not */
#if !defined(XCP_ENABLE_UNALIGNED_MEM_ACCESS) && !defined(XCP_DISABLE_UNALIGNED_MEM_ACCESS) #if !defined(XCP_ENABLE_UNALIGNED_MEM_ACCESS) && !defined(XCP_DISABLE_UNALIGNED_MEM_ACCESS)
#define XCP_DISABLE_UNALIGNED_MEM_ACCESS #define XCP_DISABLE_UNALIGNED_MEM_ACCESS
#endif #endif
/* General settings */ /* General settings */
#if !defined(XCP_ENABLE_PARAMETER_CHECK) && !defined(XCP_DISABLE_PARAMETER_CHECK) #if !defined(XCP_ENABLE_PARAMETER_CHECK) && !defined(XCP_DISABLE_PARAMETER_CHECK)
#define XCP_DISABLE_PARAMETER_CHECK #define XCP_DISABLE_PARAMETER_CHECK
#endif #endif
#if !defined(XCP_ENABLE_COMM_MODE_INFO) && !defined(XCP_DISABLE_COMM_MODE_INFO) #if !defined(XCP_ENABLE_COMM_MODE_INFO) && !defined(XCP_DISABLE_COMM_MODE_INFO)
#define XCP_ENABLE_COMM_MODE_INFO #define XCP_ENABLE_COMM_MODE_INFO
#endif #endif
#if !defined(XCP_ENABLE_USER_COMMAND) && !defined(XCP_DISABLE_USER_COMMAND) #if !defined(XCP_ENABLE_USER_COMMAND) && !defined(XCP_DISABLE_USER_COMMAND)
#define XCP_DISABLE_USER_COMMAND #define XCP_DISABLE_USER_COMMAND
#endif #endif
/* Block transfer */ /* Block transfer */
#if !defined(XCP_ENABLE_BLOCK_UPLOAD) && !defined(XCP_DISABLE_BLOCK_UPLOAD) #if !defined(XCP_ENABLE_BLOCK_UPLOAD) && !defined(XCP_DISABLE_BLOCK_UPLOAD)
#define XCP_DISABLE_BLOCK_UPLOAD #define XCP_DISABLE_BLOCK_UPLOAD
#endif #endif
#if !defined(XCP_ENABLE_BLOCK_DOWNLOAD) && !defined(XCP_DISABLE_BLOCK_DOWNLOAD) #if !defined(XCP_ENABLE_BLOCK_DOWNLOAD) && !defined(XCP_DISABLE_BLOCK_DOWNLOAD)
#define XCP_DISABLE_BLOCK_DOWNLOAD #define XCP_DISABLE_BLOCK_DOWNLOAD
#endif #endif
/* Enable transmission of event messages */ /* Enable transmission of event messages */
#if !defined(XCP_ENABLE_SEND_EVENT) && !defined(XCP_DISABLE_SEND_EVENT) #if !defined(XCP_ENABLE_SEND_EVENT) && !defined(XCP_DISABLE_SEND_EVENT)
#define XCP_DISABLE_SEND_EVENT #define XCP_DISABLE_SEND_EVENT
#endif #endif
/* Service request message */ /* Service request message */
#if !defined(XCP_ENABLE_SERV_TEXT) && !defined(XCP_DISABLE_SERV_TEXT) #if !defined(XCP_ENABLE_SERV_TEXT) && !defined(XCP_DISABLE_SERV_TEXT)
#define XCP_DISABLE_SERV_TEXT #define XCP_DISABLE_SERV_TEXT
#endif #endif
#if !defined(XCP_ENABLE_SERV_TEXT_PUTCHAR) && !defined(XCP_DISABLE_SERV_TEXT_PUTCHAR) #if !defined(XCP_ENABLE_SERV_TEXT_PUTCHAR) && !defined(XCP_DISABLE_SERV_TEXT_PUTCHAR)
#define XCP_DISABLE_SERV_TEXT_PUTCHAR #define XCP_DISABLE_SERV_TEXT_PUTCHAR
#endif #endif
#if !defined(XCP_ENABLE_SERV_TEXT_PRINTF) && !defined(XCP_DISABLE_SERV_TEXT_PRINTF) #if !defined(XCP_ENABLE_SERV_TEXT_PRINTF) && !defined(XCP_DISABLE_SERV_TEXT_PRINTF)
#define XCP_DISABLE_SERV_TEXT_PRINTF #define XCP_DISABLE_SERV_TEXT_PRINTF
#endif #endif
/* Disable/Enable Interrupts */ /* Disable/Enable Interrupts */
/* Has to be defined only if xcpSendCallBack may interrupt xcpEvent */ /* Has to be defined only if xcpSendCallBack may interrupt xcpEvent */
#if !defined(XcpInterruptDisable) #if !defined(XcpInterruptDisable)
#define XcpInterruptDisable() #define XcpInterruptDisable()
#endif #endif
#if !defined(XcpInterruptEnable) #if !defined(XcpInterruptEnable)
#define XcpInterruptEnable() #define XcpInterruptEnable()
#endif #endif
/* Custom initialization not needed */ /* Custom initialization not needed */
#if !defined(ApplXcpInit) #if !defined(ApplXcpInit)
#define ApplXcpInit() #define ApplXcpInit()
#endif #endif
/* Custom background processing not needed */ /* Custom background processing not needed */
#if !defined(ApplXcpBackground) #if !defined(ApplXcpBackground)
#define ApplXcpBackground() #define ApplXcpBackground()
#endif #endif
/* Flush of transmit queue not needed */ /* Flush of transmit queue not needed */
#if !defined(ApplXcpSendFlush) #if !defined(ApplXcpSendFlush)
#define ApplXcpSendFlush() #define ApplXcpSendFlush()
#endif #endif
/* XCP page switching */ /* XCP page switching */
#if !defined ( XCP_ENABLE_CALIBRATION_PAGE ) && !defined ( XCP_DISABLE_CALIBRATION_PAGE ) #if !defined ( XCP_ENABLE_CALIBRATION_PAGE ) && !defined ( XCP_DISABLE_CALIBRATION_PAGE )
#define XCP_DISABLE_CALIBRATION_PAGE #define XCP_DISABLE_CALIBRATION_PAGE
#endif #endif
/* XCP protocol data acquisition parameters (DAQ) */ /* XCP protocol data acquisition parameters (DAQ) */
#if defined(XCP_DISABLE_DAQ) #if defined(XCP_DISABLE_DAQ)
#define XCP_DISABLE_SEND_QUEUE #define XCP_DISABLE_SEND_QUEUE
#define XCP_ENABLE_SEND_DIRECT #define XCP_ENABLE_SEND_DIRECT
#else #else
#if !defined(XCP_ENABLE_DAQ) && !defined(XCP_DISABLE_DAQ) #if !defined(XCP_ENABLE_DAQ) && !defined(XCP_DISABLE_DAQ)
#define XCP_ENABLE_DAQ #define XCP_ENABLE_DAQ
#endif #endif
#if !defined(XCP_ENABLE_SEND_DIRECT) && !defined(XCP_ENABLE_SEND_QUEUE) #if !defined(XCP_ENABLE_SEND_DIRECT) && !defined(XCP_ENABLE_SEND_QUEUE)
#define XCP_ENABLE_SEND_QUEUE #define XCP_ENABLE_SEND_QUEUE
#define XCP_DISABLE_SEND_DIRECT #define XCP_DISABLE_SEND_DIRECT
#endif #endif
#if defined(XCP_ENABLE_SEND_QUEUE) #if defined(XCP_ENABLE_SEND_QUEUE)
#define XCP_DISABLE_SEND_DIRECT #define XCP_DISABLE_SEND_DIRECT
#endif #endif
#if !defined(XCP_ENABLE_DAQ_HDR_ODT_DAQ) && !defined(XCP_DISABLE_DAQ_HDR_ODT_DAQ) #if !defined(XCP_ENABLE_DAQ_HDR_ODT_DAQ) && !defined(XCP_DISABLE_DAQ_HDR_ODT_DAQ)
#define XCP_DISABLE_DAQ_HDR_ODT_DAQ #define XCP_DISABLE_DAQ_HDR_ODT_DAQ
#endif #endif
#if !defined(kXcpDaqMemSize) #if !defined(kXcpDaqMemSize)
#define kXcpDaqMemSize 256 #define kXcpDaqMemSize 256
#endif #endif
#if !defined(kXcpStiOdtCount) #if !defined(kXcpStiOdtCount)
#define kXcpStiOdtCount 1 #define kXcpStiOdtCount 1
#endif #endif
#if !defined(XCP_ENABLE_DAQ_PROCESSOR_INFO) && !defined(XCP_DISABLE_DAQ_PROCESSOR_INFO) #if !defined(XCP_ENABLE_DAQ_PROCESSOR_INFO) && !defined(XCP_DISABLE_DAQ_PROCESSOR_INFO)
#define XCP_ENABLE_DAQ_PROCESSOR_INFO #define XCP_ENABLE_DAQ_PROCESSOR_INFO
#endif #endif
#if !defined(XCP_ENABLE_DAQ_RESOLUTION_INFO) && !defined(XCP_DISABLE_DAQ_RESOLUTION_INFO) #if !defined(XCP_ENABLE_DAQ_RESOLUTION_INFO) && !defined(XCP_DISABLE_DAQ_RESOLUTION_INFO)
#define XCP_ENABLE_DAQ_RESOLUTION_INFO #define XCP_ENABLE_DAQ_RESOLUTION_INFO
#endif #endif
#if !defined(XCP_ENABLE_DAQ_PRESCALER) && !defined(XCP_DISABLE_DAQ_PRESCALER) #if !defined(XCP_ENABLE_DAQ_PRESCALER) && !defined(XCP_DISABLE_DAQ_PRESCALER)
#define XCP_DISABLE_DAQ_PRESCALER #define XCP_DISABLE_DAQ_PRESCALER
#endif #endif
#if !defined(XCP_ENABLE_DAQ_OVERRUN_INDICATION) && !defined(XCP_DISABLE_DAQ_OVERRUN_INDICATION) #if !defined(XCP_ENABLE_DAQ_OVERRUN_INDICATION) && !defined(XCP_DISABLE_DAQ_OVERRUN_INDICATION)
#define XCP_ENABLE_DAQ_OVERRUN_INDICATION #define XCP_ENABLE_DAQ_OVERRUN_INDICATION
#endif #endif
#if !defined(XCP_ENABLE_DAQ_RESUME) && !defined(XCP_DISABLE_DAQ_RESUME) #if !defined(XCP_ENABLE_DAQ_RESUME) && !defined(XCP_DISABLE_DAQ_RESUME)
#define XCP_DISABLE_DAQ_RESUME #define XCP_DISABLE_DAQ_RESUME
#endif #endif
#if !defined(XCP_ENABLE_DAQ_TIMESTAMP) && !defined(XCP_DISABLE_DAQ_TIMESTAMP) #if !defined(XCP_ENABLE_DAQ_TIMESTAMP) && !defined(XCP_DISABLE_DAQ_TIMESTAMP)
#define XCP_DISABLE_DAQ_TIMESTAMP #define XCP_DISABLE_DAQ_TIMESTAMP
#endif #endif
#if !defined(XCP_ENABLE_DAQ_EVENT_INFO) && !defined(XCP_DISABLE_DAQ_EVENT_INFO) #if !defined(XCP_ENABLE_DAQ_EVENT_INFO) && !defined(XCP_DISABLE_DAQ_EVENT_INFO)
#define XCP_DISABLE_DAQ_EVENT_INFO #define XCP_DISABLE_DAQ_EVENT_INFO
#endif #endif
#endif #endif
#if !defined(XCP_ENABLE_STIM) && !defined(XCP_DISABLE_STIM) #if !defined(XCP_ENABLE_STIM) && !defined(XCP_DISABLE_STIM)
#define XCP_DISABLE_STIM #define XCP_DISABLE_STIM
#endif #endif
#endif #endif
+37 -37
View File
@@ -1,37 +1,37 @@
/***************************************************************************** /*****************************************************************************
| Project Name: XCP Protocol Layer | Project Name: XCP Protocol Layer
| File Name: xcp_par.c | File Name: xcp_par.c
| |
| Description: Implementation of the XCP Protocol Layer | Description: Implementation of the XCP Protocol Layer
| XCP V1.0 slave device driver | XCP V1.0 slave device driver
| Basic Version (see feature list below) | Basic Version (see feature list below)
| |
| |
| |
|----------------------------------------------------------------------------- |-----------------------------------------------------------------------------
| C O P Y R I G H T | C O P Y R I G H T
|----------------------------------------------------------------------------- |-----------------------------------------------------------------------------
| Copyright (c) 2008 by Vector Informatik GmbH. All rights reserved. | Copyright (c) 2008 by Vector Informatik GmbH. All rights reserved.
| |
| This software is copyright protected and | This software is copyright protected and
| proporietary to Vector Informatik GmbH. | proporietary to Vector Informatik GmbH.
| Vector Informatik GmbH grants to you only | Vector Informatik GmbH grants to you only
| those rights as set out in the license conditions. | those rights as set out in the license conditions.
| All other rights remain with Vector Informatik GmbH. | All other rights remain with Vector Informatik GmbH.
| |
| Diese Software ist urheberrechtlich geschuetzt. | Diese Software ist urheberrechtlich geschuetzt.
| Vector Informatik GmbH raeumt Ihnen an dieser Software nur | Vector Informatik GmbH raeumt Ihnen an dieser Software nur
| die in den Lizenzbedingungen ausdruecklich genannten Rechte ein. | die in den Lizenzbedingungen ausdruecklich genannten Rechte ein.
| Alle anderen Rechte verbleiben bei Vector Informatik GmbH. | Alle anderen Rechte verbleiben bei Vector Informatik GmbH.
| |
|***************************************************************************/ |***************************************************************************/
#include "XcpBasic.h" #include "XcpBasic.h"
// Slave device id // Slave device id
#if defined ( kXcpStationIdLength ) #if defined ( kXcpStationIdLength )
V_MEMROM0 MEMORY_ROM vuint8 kXcpStationId[kXcpStationIdLength] = kXcpStationIdString; V_MEMROM0 MEMORY_ROM vuint8 kXcpStationId[kXcpStationIdLength] = kXcpStationIdString;
#endif #endif
+41 -41
View File
@@ -1,41 +1,41 @@
/***************************************************************************** /*****************************************************************************
| Project Name: XCP Protocol Layer | Project Name: XCP Protocol Layer
| File Name: xcp_par.h | File Name: xcp_par.h
| |
| Description: Header of XCP Protocol Layer | Description: Header of XCP Protocol Layer
| XCP V1.0 slave device driver | XCP V1.0 slave device driver
| Basic Version | Basic Version
| |
|| ||
|----------------------------------------------------------------------------- |-----------------------------------------------------------------------------
| C O P Y R I G H T | C O P Y R I G H T
|----------------------------------------------------------------------------- |-----------------------------------------------------------------------------
| Copyright (c) 2008 by Vector Informatik GmbH. All rights reserved. | Copyright (c) 2008 by Vector Informatik GmbH. All rights reserved.
| |
| This software is copyright protected and | This software is copyright protected and
| proporietary to Vector Informatik GmbH. | proporietary to Vector Informatik GmbH.
| Vector Informatik GmbH grants to you only | Vector Informatik GmbH grants to you only
| those rights as set out in the license conditions. | those rights as set out in the license conditions.
| All other rights remain with Vector Informatik GmbH. | All other rights remain with Vector Informatik GmbH.
| |
| Diese Software ist urheberrechtlich geschuetzt. | Diese Software ist urheberrechtlich geschuetzt.
| Vector Informatik GmbH raeumt Ihnen an dieser Software nur | Vector Informatik GmbH raeumt Ihnen an dieser Software nur
| die in den Lizenzbedingungen ausdruecklich genannten Rechte ein. | die in den Lizenzbedingungen ausdruecklich genannten Rechte ein.
| Alle anderen Rechte verbleiben bei Vector Informatik GmbH. | Alle anderen Rechte verbleiben bei Vector Informatik GmbH.
| |
| |
|***************************************************************************/ |***************************************************************************/
#if defined ( __XCP_PAR_H__ ) #if defined ( __XCP_PAR_H__ )
#else #else
#define __XCP_PAR_H__ #define __XCP_PAR_H__
/* XCP default settings */ /* XCP default settings */
#include "xcp_def.h" #include "xcp_def.h"
V_MEMROM0 extern vuint8 MEMORY_ROM kXcpStationId[]; V_MEMROM0 extern vuint8 MEMORY_ROM kXcpStationId[];
#endif #endif
+10 -10
View File
@@ -1,10 +1,10 @@
#ifndef XCP_TYPEDEFS_H #ifndef XCP_TYPEDEFS_H
#define XCP_TYPEDEFS_H #define XCP_TYPEDEFS_H
#include "Arduino.h" #include "Arduino.h"
typedef uint32_t vuint32; typedef uint32_t vuint32;
typedef uint16_t vuint16; typedef uint16_t vuint16;
typedef uint8_t vuint8; typedef uint8_t vuint8;
#endif #endif
+11 -11
View File
@@ -1,11 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests. This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early determine whether they are fit for use. Unit testing finds problems early
in the development cycle. in the development cycle.
More information about PlatformIO Unit Testing: More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html - https://docs.platformio.org/en/latest/advanced/unit-testing/index.html