Removed Mysensors 2
This commit is contained in:
5
MainDoorMyS/.gitignore
vendored
5
MainDoorMyS/.gitignore
vendored
@@ -1,5 +0,0 @@
|
|||||||
.pio
|
|
||||||
.vscode/.browse.c_cpp.db*
|
|
||||||
.vscode/c_cpp_properties.json
|
|
||||||
.vscode/launch.json
|
|
||||||
.vscode/ipch
|
|
||||||
10
MainDoorMyS/.vscode/extensions.json
vendored
10
MainDoorMyS/.vscode/extensions.json
vendored
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": [
|
|
||||||
"platformio.platformio-ide"
|
|
||||||
],
|
|
||||||
"unwantedRecommendations": [
|
|
||||||
"ms-vscode.cpptools-extension-pack"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project header files.
|
|
||||||
|
|
||||||
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
|
|
||||||
header file in your project source file (C, C++, etc) located in `src` folder
|
|
||||||
by including it, with the C preprocessing directive `#include'.
|
|
||||||
|
|
||||||
```src/main.c
|
|
||||||
|
|
||||||
#include "header.h"
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
||||||
place, and programs that include the header file will automatically use the
|
|
||||||
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
|
|
||||||
find one copy will result in inconsistencies within a program.
|
|
||||||
|
|
||||||
In C, the usual convention is to give header files names that end with `.h'.
|
|
||||||
It is most portable to use only letters, digits, dashes, and underscores in
|
|
||||||
header file names, and at most one dot.
|
|
||||||
|
|
||||||
Read more about using header files in official GCC documentation:
|
|
||||||
|
|
||||||
* Include Syntax
|
|
||||||
* Include Operation
|
|
||||||
* Once-Only Headers
|
|
||||||
* Computed Includes
|
|
||||||
|
|
||||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
|
||||||
PlatformIO will compile them to static libraries and link into executable file.
|
|
||||||
|
|
||||||
The source code of each library should be placed in a an own separate directory
|
|
||||||
("lib/your_library_name/[here are source files]").
|
|
||||||
|
|
||||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
|
||||||
|
|
||||||
|--lib
|
|
||||||
| |
|
|
||||||
| |--Bar
|
|
||||||
| | |--docs
|
|
||||||
| | |--examples
|
|
||||||
| | |--src
|
|
||||||
| | |- Bar.c
|
|
||||||
| | |- Bar.h
|
|
||||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
|
||||||
| |
|
|
||||||
| |--Foo
|
|
||||||
| | |- Foo.c
|
|
||||||
| | |- Foo.h
|
|
||||||
| |
|
|
||||||
| |- README --> THIS FILE
|
|
||||||
|
|
|
||||||
|- platformio.ini
|
|
||||||
|--src
|
|
||||||
|- main.c
|
|
||||||
|
|
||||||
and a contents of `src/main.c`:
|
|
||||||
```
|
|
||||||
#include <Foo.h>
|
|
||||||
#include <Bar.h>
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
PlatformIO Library Dependency Finder will find automatically dependent
|
|
||||||
libraries scanning project source files.
|
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
; PlatformIO Project Configuration File
|
|
||||||
;
|
|
||||||
; Build options: build flags, source filter
|
|
||||||
; Upload options: custom upload port, speed and extra flags
|
|
||||||
; Library options: dependencies, extra library storages
|
|
||||||
; Advanced options: extra scripting
|
|
||||||
;
|
|
||||||
; Please visit documentation for the other options and examples
|
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
|
||||||
|
|
||||||
[env:pro16MHzatmega328]
|
|
||||||
platform = atmelavr
|
|
||||||
board = pro16MHzatmega328
|
|
||||||
framework = arduino
|
|
||||||
monitor_speed = 115200
|
|
||||||
lib_deps =
|
|
||||||
MySensors @ ^2.3.2
|
|
||||||
|
|
||||||
;[env:pro8MHzatmega168]
|
|
||||||
;platform = atmelavr
|
|
||||||
;board = pro8MHzatmega168
|
|
||||||
;framework = arduino
|
|
||||||
;monitor_speed = 115200
|
|
||||||
;lib_deps =
|
|
||||||
; MySensors @ ^2.3.2
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
#define MY_DEBUG
|
|
||||||
|
|
||||||
// Enable and select radio type attached
|
|
||||||
#define MY_RF24_PA_LEVEL RF24_PA_MAX
|
|
||||||
#define MY_REPEATER_FEATURE
|
|
||||||
#define MY_RADIO_RF24
|
|
||||||
#define MY_RF24_CHANNEL (105)
|
|
||||||
#if F_CPU == 8000000L
|
|
||||||
#define MY_BAUD_RATE 38400
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MY_DEFAULT_LED_BLINK_PERIOD 100
|
|
||||||
#define MY_WITH_LEDS_BLINKING_INVERSE
|
|
||||||
#define MY_DEFAULT_ERR_LED_PIN 2 // Error led pin
|
|
||||||
#define MY_DEFAULT_TX_LED_PIN 3 // the PCB, on board LED
|
|
||||||
#define MY_DEFAULT_RX_LED_PIN 4 // Receive led pin
|
|
||||||
|
|
||||||
#include <MySensors.h>
|
|
||||||
|
|
||||||
#define TOP_LOCK A0 // 7 - Green/White
|
|
||||||
#define INT_LOCK A1 // 2 - Green
|
|
||||||
#define DOWN_LOCK A3 // 6 - Blue/White
|
|
||||||
#define SMALL_LOCK A2 // 1 - Blue
|
|
||||||
#define DOOR A4 // 3 - Brown
|
|
||||||
// 4 - 5V - Orange
|
|
||||||
// 8 - GND - Orange/White Brown/White
|
|
||||||
#define TOP_LOCK_ID 0
|
|
||||||
#define INT_LOCK_ID 1
|
|
||||||
#define DOWN_LOCK_ID 2
|
|
||||||
#define SMALL_LOCK_ID 3
|
|
||||||
#define DOOR_ID 4
|
|
||||||
#define CUSTOM_ID 5
|
|
||||||
|
|
||||||
bool bpTop, bpInt, bpDown, bpSmall, bpDoor;
|
|
||||||
|
|
||||||
MyMessage msgTop(TOP_LOCK_ID, V_LOCK_STATUS);
|
|
||||||
MyMessage msgInt(INT_LOCK_ID, V_LOCK_STATUS);
|
|
||||||
MyMessage msgDown(DOWN_LOCK_ID, V_LOCK_STATUS);
|
|
||||||
MyMessage msgSmall(SMALL_LOCK_ID, V_LOCK_STATUS);
|
|
||||||
MyMessage msgDoor(DOOR_ID, V_LOCK_STATUS);
|
|
||||||
MyMessage msgCust(CUSTOM_ID, V_VAR1);
|
|
||||||
void sendData(MyMessage msg, bool status);
|
|
||||||
|
|
||||||
void before()
|
|
||||||
{
|
|
||||||
pinMode(TOP_LOCK, INPUT_PULLUP);
|
|
||||||
pinMode(INT_LOCK, INPUT_PULLUP);
|
|
||||||
pinMode(DOWN_LOCK, INPUT_PULLUP);
|
|
||||||
pinMode(SMALL_LOCK, INPUT_PULLUP);
|
|
||||||
pinMode(DOOR, INPUT_PULLUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
void presentation()
|
|
||||||
{
|
|
||||||
// Send the sketch version information to the gateway and Controller
|
|
||||||
sendSketchInfo("Main Door", "1.0");
|
|
||||||
present(TOP_LOCK_ID, S_LOCK, "Top");
|
|
||||||
present(INT_LOCK_ID, S_LOCK, "Int");
|
|
||||||
present(DOWN_LOCK_ID, S_LOCK, "Down");
|
|
||||||
present(SMALL_LOCK_ID, S_LOCK, "Small");
|
|
||||||
present(DOOR_ID, S_LOCK, "Door");
|
|
||||||
present(CUSTOM_ID, S_CUSTOM);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
bpDoor = !digitalRead(DOOR);
|
|
||||||
bpTop = !digitalRead(TOP_LOCK);
|
|
||||||
bpInt = !digitalRead(INT_LOCK);
|
|
||||||
bpSmall = !digitalRead(SMALL_LOCK);
|
|
||||||
bpDown = !digitalRead(DOWN_LOCK);
|
|
||||||
sendData(msgDoor, bpDoor);
|
|
||||||
wait(100);
|
|
||||||
sendData(msgTop, bpTop);
|
|
||||||
wait(100);
|
|
||||||
sendData(msgInt, bpInt);
|
|
||||||
wait(100);
|
|
||||||
sendData(msgDown, bpDown);
|
|
||||||
wait(100);
|
|
||||||
sendData(msgSmall, bpSmall);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
static uint32_t cRun = millis();
|
|
||||||
bool bTop, bInt, bDown, bSmall, bDoor;
|
|
||||||
bTop = !digitalRead(TOP_LOCK);
|
|
||||||
bInt = !digitalRead(INT_LOCK);
|
|
||||||
bDown = !digitalRead(DOWN_LOCK);
|
|
||||||
bSmall = !digitalRead(SMALL_LOCK);
|
|
||||||
bDoor = !digitalRead(DOOR);
|
|
||||||
if(bTop != bpTop){
|
|
||||||
bpTop = bTop;
|
|
||||||
Serial.print(F("Top Lock-"));Serial.println(bTop);
|
|
||||||
sendData(msgTop, bTop);
|
|
||||||
}
|
|
||||||
if(bInt != bpInt){
|
|
||||||
bpInt = bInt;
|
|
||||||
Serial.print(F("Int Lock-"));Serial.println(bInt);
|
|
||||||
sendData(msgInt, bInt);
|
|
||||||
}
|
|
||||||
if(bDown != bpDown){
|
|
||||||
bpDown = bDown;
|
|
||||||
Serial.print(F("Down Lock-"));Serial.println(bDown);
|
|
||||||
sendData(msgDown, bDown);
|
|
||||||
}
|
|
||||||
if(bSmall != bpSmall){
|
|
||||||
bpSmall = bSmall;
|
|
||||||
Serial.print(F("Small Lock-"));Serial.println(bSmall);
|
|
||||||
sendData(msgSmall, bSmall);
|
|
||||||
}
|
|
||||||
if(bDoor != bpDoor){
|
|
||||||
bpDoor = bDoor;
|
|
||||||
Serial.print(F("Door-"));Serial.println(bDoor);
|
|
||||||
sendData(msgDoor, bDoor);
|
|
||||||
}
|
|
||||||
if((cRun + 29949) < millis()){
|
|
||||||
wait(50);
|
|
||||||
cRun = millis();
|
|
||||||
send(msgCust.set(cRun));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendData(MyMessage msg, bool status)
|
|
||||||
{
|
|
||||||
bool send_data = false;
|
|
||||||
uint8_t count = 0;
|
|
||||||
while(send_data == false){
|
|
||||||
count++;
|
|
||||||
Serial.print("Sending a message, try No."); // Выводим в монитор порта попытку отправки
|
|
||||||
Serial.println(count); // и её номер
|
|
||||||
send_data = send(msg.set(status));
|
|
||||||
if(!send_data)
|
|
||||||
wait(100, C_SET, msg.type);
|
|
||||||
if(send_data)
|
|
||||||
Serial.println("Message sent");
|
|
||||||
if ((count == 3 )&&(send_data == 0)){ // Если сделано 3 попытки и нет подтверждения отправки
|
|
||||||
count = 0; // Обнуляем счётчик
|
|
||||||
send_data = 1; // Выходим из цикла
|
|
||||||
Serial.println("Send failed"); // Выводим сообщение "Отправка не удалась"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Unit Testing and project tests.
|
|
||||||
|
|
||||||
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
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
|
||||||
5
MidRoomNLight/.gitignore
vendored
5
MidRoomNLight/.gitignore
vendored
@@ -1,5 +0,0 @@
|
|||||||
.pio
|
|
||||||
.vscode/.browse.c_cpp.db*
|
|
||||||
.vscode/c_cpp_properties.json
|
|
||||||
.vscode/launch.json
|
|
||||||
.vscode/ipch
|
|
||||||
7
MidRoomNLight/.vscode/extensions.json
vendored
7
MidRoomNLight/.vscode/extensions.json
vendored
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": [
|
|
||||||
"platformio.platformio-ide"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project header files.
|
|
||||||
|
|
||||||
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
|
|
||||||
header file in your project source file (C, C++, etc) located in `src` folder
|
|
||||||
by including it, with the C preprocessing directive `#include'.
|
|
||||||
|
|
||||||
```src/main.c
|
|
||||||
|
|
||||||
#include "header.h"
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
||||||
place, and programs that include the header file will automatically use the
|
|
||||||
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
|
|
||||||
find one copy will result in inconsistencies within a program.
|
|
||||||
|
|
||||||
In C, the usual convention is to give header files names that end with `.h'.
|
|
||||||
It is most portable to use only letters, digits, dashes, and underscores in
|
|
||||||
header file names, and at most one dot.
|
|
||||||
|
|
||||||
Read more about using header files in official GCC documentation:
|
|
||||||
|
|
||||||
* Include Syntax
|
|
||||||
* Include Operation
|
|
||||||
* Once-Only Headers
|
|
||||||
* Computed Includes
|
|
||||||
|
|
||||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
|
||||||
PlatformIO will compile them to static libraries and link into executable file.
|
|
||||||
|
|
||||||
The source code of each library should be placed in a an own separate directory
|
|
||||||
("lib/your_library_name/[here are source files]").
|
|
||||||
|
|
||||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
|
||||||
|
|
||||||
|--lib
|
|
||||||
| |
|
|
||||||
| |--Bar
|
|
||||||
| | |--docs
|
|
||||||
| | |--examples
|
|
||||||
| | |--src
|
|
||||||
| | |- Bar.c
|
|
||||||
| | |- Bar.h
|
|
||||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
|
||||||
| |
|
|
||||||
| |--Foo
|
|
||||||
| | |- Foo.c
|
|
||||||
| | |- Foo.h
|
|
||||||
| |
|
|
||||||
| |- README --> THIS FILE
|
|
||||||
|
|
|
||||||
|- platformio.ini
|
|
||||||
|--src
|
|
||||||
|- main.c
|
|
||||||
|
|
||||||
and a contents of `src/main.c`:
|
|
||||||
```
|
|
||||||
#include <Foo.h>
|
|
||||||
#include <Bar.h>
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
PlatformIO Library Dependency Finder will find automatically dependent
|
|
||||||
libraries scanning project source files.
|
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
; PlatformIO Project Configuration File
|
|
||||||
;
|
|
||||||
; Build options: build flags, source filter
|
|
||||||
; Upload options: custom upload port, speed and extra flags
|
|
||||||
; Library options: dependencies, extra library storages
|
|
||||||
; Advanced options: extra scripting
|
|
||||||
;
|
|
||||||
; Please visit documentation for the other options and examples
|
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
|
||||||
|
|
||||||
[env:pro8MHzatmega328]
|
|
||||||
platform = atmelavr
|
|
||||||
board = pro8MHzatmega328
|
|
||||||
framework = arduino
|
|
||||||
monitor_speed = 115200
|
|
||||||
lib_deps = mysensors/MySensors@^2.3.2
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
#define MY_DEBUG
|
|
||||||
//#define MY_WITH_LEDS_BLINKING_INVERSE
|
|
||||||
#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
|
|
||||||
#define MY_DEFAULT_RX_LED_PIN 5 // Receive led pin
|
|
||||||
#define MY_DEFAULT_TX_LED_PIN 6 // the PCB, on board LED
|
|
||||||
|
|
||||||
// Enable and select radio type attached
|
|
||||||
#define MY_RADIO_RF24
|
|
||||||
#define MY_RF24_CHANNEL (105)
|
|
||||||
#define MY_RF24_PA_LEVEL RF24_PA_MAX
|
|
||||||
#define MY_REPEATER_FEATURE
|
|
||||||
#include <MySensors.h>
|
|
||||||
|
|
||||||
#define RELAY_PIN 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
|
|
||||||
|
|
||||||
//MyMessage msgLev(1, V_DIMMER);
|
|
||||||
uint16_t lightLevel;
|
|
||||||
bool lightOn = false;
|
|
||||||
MyMessage msgMillis(1, V_VAR1);
|
|
||||||
|
|
||||||
void before()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
pinMode(RELAY_PIN, OUTPUT);
|
|
||||||
lightLevel = loadState(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void presentation()
|
|
||||||
{
|
|
||||||
// Send the sketch version information to the gateway and Controller
|
|
||||||
sendSketchInfo("Night Light", "2.1");
|
|
||||||
present(0, S_DIMMER, "Dimmer");
|
|
||||||
present(1, S_CUSTOM, "Service");
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop()
|
|
||||||
{
|
|
||||||
static uint32_t cRun = millis();
|
|
||||||
if((cRun + 10000) <= millis()){
|
|
||||||
cRun = millis();
|
|
||||||
send(msgMillis.set(cRun));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void receive(const MyMessage &message)
|
|
||||||
{
|
|
||||||
switch(message.getType()){
|
|
||||||
case V_STATUS:
|
|
||||||
if(message.getBool() == true) {
|
|
||||||
analogWrite(RELAY_PIN, lightLevel);
|
|
||||||
lightOn = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
analogWrite(RELAY_PIN, 0);
|
|
||||||
lightOn = false;
|
|
||||||
}
|
|
||||||
Serial.print("Incoming change for sensor:");
|
|
||||||
Serial.print(message.getSensor());
|
|
||||||
Serial.print(", New status: ");
|
|
||||||
Serial.println(message.getBool());
|
|
||||||
break;
|
|
||||||
case V_PERCENTAGE:
|
|
||||||
uint16_t lev = message.getUInt();
|
|
||||||
if(lev > 100) lev = 100;
|
|
||||||
saveState(0, int(lev * 2.55));
|
|
||||||
lightLevel = int(lev * 2.55);
|
|
||||||
if(lightOn) analogWrite(RELAY_PIN, lightLevel);
|
|
||||||
Serial.print("Incoming change for dimmer:");
|
|
||||||
Serial.print(message.getSensor());
|
|
||||||
Serial.print(", New value: ");
|
|
||||||
Serial.println(message.getUInt());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Unit Testing and project tests.
|
|
||||||
|
|
||||||
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
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
|
||||||
5
Rozetka/.gitignore
vendored
5
Rozetka/.gitignore
vendored
@@ -1,5 +0,0 @@
|
|||||||
.pio
|
|
||||||
.vscode/.browse.c_cpp.db*
|
|
||||||
.vscode/c_cpp_properties.json
|
|
||||||
.vscode/launch.json
|
|
||||||
.vscode/ipch
|
|
||||||
10
Rozetka/.vscode/extensions.json
vendored
10
Rozetka/.vscode/extensions.json
vendored
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": [
|
|
||||||
"platformio.platformio-ide"
|
|
||||||
],
|
|
||||||
"unwantedRecommendations": [
|
|
||||||
"ms-vscode.cpptools-extension-pack"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project header files.
|
|
||||||
|
|
||||||
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
|
|
||||||
header file in your project source file (C, C++, etc) located in `src` folder
|
|
||||||
by including it, with the C preprocessing directive `#include'.
|
|
||||||
|
|
||||||
```src/main.c
|
|
||||||
|
|
||||||
#include "header.h"
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
||||||
place, and programs that include the header file will automatically use the
|
|
||||||
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
|
|
||||||
find one copy will result in inconsistencies within a program.
|
|
||||||
|
|
||||||
In C, the usual convention is to give header files names that end with `.h'.
|
|
||||||
It is most portable to use only letters, digits, dashes, and underscores in
|
|
||||||
header file names, and at most one dot.
|
|
||||||
|
|
||||||
Read more about using header files in official GCC documentation:
|
|
||||||
|
|
||||||
* Include Syntax
|
|
||||||
* Include Operation
|
|
||||||
* Once-Only Headers
|
|
||||||
* Computed Includes
|
|
||||||
|
|
||||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project specific (private) libraries.
|
|
||||||
PlatformIO will compile them to static libraries and link into executable file.
|
|
||||||
|
|
||||||
The source code of each library should be placed in a an own separate directory
|
|
||||||
("lib/your_library_name/[here are source files]").
|
|
||||||
|
|
||||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
|
||||||
|
|
||||||
|--lib
|
|
||||||
| |
|
|
||||||
| |--Bar
|
|
||||||
| | |--docs
|
|
||||||
| | |--examples
|
|
||||||
| | |--src
|
|
||||||
| | |- Bar.c
|
|
||||||
| | |- Bar.h
|
|
||||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
|
||||||
| |
|
|
||||||
| |--Foo
|
|
||||||
| | |- Foo.c
|
|
||||||
| | |- Foo.h
|
|
||||||
| |
|
|
||||||
| |- README --> THIS FILE
|
|
||||||
|
|
|
||||||
|- platformio.ini
|
|
||||||
|--src
|
|
||||||
|- main.c
|
|
||||||
|
|
||||||
and a contents of `src/main.c`:
|
|
||||||
```
|
|
||||||
#include <Foo.h>
|
|
||||||
#include <Bar.h>
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
PlatformIO Library Dependency Finder will find automatically dependent
|
|
||||||
libraries scanning project source files.
|
|
||||||
|
|
||||||
More information about PlatformIO Library Dependency Finder
|
|
||||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
; PlatformIO Project Configuration File
|
|
||||||
;
|
|
||||||
; Build options: build flags, source filter
|
|
||||||
; Upload options: custom upload port, speed and extra flags
|
|
||||||
; Library options: dependencies, extra library storages
|
|
||||||
; Advanced options: extra scripting
|
|
||||||
;
|
|
||||||
; Please visit documentation for the other options and examples
|
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
|
||||||
|
|
||||||
[env:pro8MHzatmega328]
|
|
||||||
platform = atmelavr
|
|
||||||
board = pro8MHzatmega328
|
|
||||||
framework = arduino
|
|
||||||
monitor_speed = 115200
|
|
||||||
lib_deps =
|
|
||||||
mysensors/MySensors@^2.3.2
|
|
||||||
thomasfredericks/Bounce2 @ ^2.55
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
#define MY_DEBUG
|
|
||||||
#define MY_RADIO_RF24
|
|
||||||
#define MY_RF24_CHANNEL (105)
|
|
||||||
#define MY_RF24_PA_LEVEL RF24_PA_MAX
|
|
||||||
#define MY_REPEATER_FEATURE
|
|
||||||
|
|
||||||
#define SOCK1 2
|
|
||||||
#define SOCK2 3
|
|
||||||
#define RELAY1 A0
|
|
||||||
#define RELAY2 A1
|
|
||||||
#define MY_DEFAULT_ERR_LED_PIN (4) // Error led pin
|
|
||||||
#define MY_DEFAULT_RX_LED_PIN (5) // Receive led pin
|
|
||||||
#define MY_DEFAULT_TX_LED_PIN (6) // the PCB, on board LED
|
|
||||||
#define BUTT1 8
|
|
||||||
#define BUTT2 7
|
|
||||||
|
|
||||||
#include <MySensors.h>
|
|
||||||
#include <Bounce2.h>
|
|
||||||
|
|
||||||
|
|
||||||
// #undef MY_NODE_ID
|
|
||||||
// #define MY_NODE_ID 14
|
|
||||||
|
|
||||||
bool stat1, stat2, Ack;
|
|
||||||
void presentation();
|
|
||||||
void sendData(MyMessage msg, bool status);
|
|
||||||
void sendData(MyMessage msg, uint32_t status);
|
|
||||||
void receive(const MyMessage &message);
|
|
||||||
|
|
||||||
MyMessage msgMillis(2, V_VAR1);
|
|
||||||
MyMessage msgSock1s(0, V_STATUS);
|
|
||||||
MyMessage msgSock2s(1, V_STATUS);
|
|
||||||
MyMessage msgSock1(2, V_VAR2);
|
|
||||||
MyMessage msgSock2(2, V_VAR3);
|
|
||||||
|
|
||||||
Bounce butt1 = Bounce(), butt2 = Bounce();
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
pinMode(SOCK1, OUTPUT);
|
|
||||||
pinMode(SOCK2, OUTPUT);
|
|
||||||
pinMode(RELAY1, OUTPUT);
|
|
||||||
pinMode(RELAY2, OUTPUT);
|
|
||||||
butt1.attach(BUTT1, INPUT_PULLUP);
|
|
||||||
butt2.attach(BUTT2, INPUT_PULLUP);
|
|
||||||
butt1.interval(25);
|
|
||||||
butt2.interval(25);
|
|
||||||
stat1 = loadState(0);
|
|
||||||
digitalWrite(SOCK1, stat1);
|
|
||||||
digitalWrite(RELAY1, !stat1);
|
|
||||||
stat2 = loadState(1);
|
|
||||||
digitalWrite(SOCK2, stat2);
|
|
||||||
digitalWrite(RELAY2, !stat2);
|
|
||||||
sendData(msgSock1s, !stat1);
|
|
||||||
wait(100);
|
|
||||||
sendData(msgSock2s, !stat2);
|
|
||||||
wait(100);
|
|
||||||
sendData(msgSock1, !stat1);
|
|
||||||
wait(100);
|
|
||||||
sendData(msgSock2, !stat2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
static uint32_t cRun = millis() - 60000;
|
|
||||||
butt1.update();
|
|
||||||
butt2.update();
|
|
||||||
if(butt1.fell()){
|
|
||||||
stat1 = !stat1;
|
|
||||||
digitalWrite(SOCK1, stat1);
|
|
||||||
digitalWrite(RELAY1, !stat1);
|
|
||||||
sendData(msgSock1s, !stat1);
|
|
||||||
sendData(msgSock1, !stat1);
|
|
||||||
saveState(0, stat1);
|
|
||||||
Serial.print(F("Change Sock1: ")); Serial.println(stat1);
|
|
||||||
}
|
|
||||||
if(butt2.fell()){
|
|
||||||
stat2 = !stat2;
|
|
||||||
digitalWrite(SOCK2, stat2);
|
|
||||||
digitalWrite(RELAY2, !stat2);
|
|
||||||
sendData(msgSock2s, !stat2);
|
|
||||||
sendData(msgSock2, !stat2);
|
|
||||||
saveState(1, stat2);
|
|
||||||
Serial.print(F("Change Sock2: ")); Serial.println(stat2);
|
|
||||||
}
|
|
||||||
if(stat1 != digitalRead(SOCK1)){
|
|
||||||
Serial.print(F("Curr Sock1: ")); Serial.println(digitalRead(SOCK1));
|
|
||||||
Serial.print(F("Change Sock1: ")); Serial.println(stat1);
|
|
||||||
digitalWrite(SOCK1, stat1);
|
|
||||||
digitalWrite(RELAY1, !stat1);
|
|
||||||
saveState(0, digitalRead(SOCK1));
|
|
||||||
sendData(msgSock1, !stat1);
|
|
||||||
}
|
|
||||||
if(stat2 != digitalRead(SOCK2)){
|
|
||||||
Serial.print(F("Curr Sock2: ")); Serial.println(digitalRead(SOCK2));
|
|
||||||
digitalWrite(SOCK2, stat2);
|
|
||||||
digitalWrite(RELAY2, !stat2);
|
|
||||||
saveState(1, digitalRead(SOCK2));
|
|
||||||
sendData(msgSock2, !stat2);
|
|
||||||
Serial.print(F("Change Sock2: ")); Serial.println(stat2);
|
|
||||||
}
|
|
||||||
if((cRun + 60000) <= millis()){
|
|
||||||
cRun = millis();
|
|
||||||
sendData(msgMillis, cRun);
|
|
||||||
//send(msgMillis.set(cRun));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void presentation()
|
|
||||||
{
|
|
||||||
sendSketchInfo("Rozetka", "1.0");
|
|
||||||
present(0, S_BINARY, "Socket1");
|
|
||||||
present(1, S_BINARY, "Socket2");
|
|
||||||
present(2, S_CUSTOM, "ESMillis");
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendData(MyMessage msg, bool status)
|
|
||||||
{
|
|
||||||
bool send_data = false;
|
|
||||||
uint8_t count = 0;
|
|
||||||
while(send_data == false){
|
|
||||||
count++;
|
|
||||||
send_data = send(msg.set(status), true);
|
|
||||||
wait(1000, C_SET, msg.type);
|
|
||||||
if ((count == 3 )&&(send_data == 0)){ // Если сделано 3 попытки и нет подтверждения отправки
|
|
||||||
count = 0; // Обнуляем счётчик
|
|
||||||
send_data = 1; // Выходим из цикла
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendData(MyMessage msg, uint32_t val)
|
|
||||||
{
|
|
||||||
bool send_data = false;
|
|
||||||
uint8_t count = 0;
|
|
||||||
Ack = false;
|
|
||||||
//Serial.print(millis());
|
|
||||||
//Serial.println(" Send UINT32 Enter");
|
|
||||||
while(send_data == false){
|
|
||||||
count++;
|
|
||||||
send_data = send(msg.set(val), true);
|
|
||||||
wait(1000, C_SET, msg.type);
|
|
||||||
//Serial.print(millis());
|
|
||||||
//Serial.println(" Send UINT32");
|
|
||||||
if ((count == 3) && (send_data == 0)){ // Если сделано 3 попытки и нет подтверждения отправки
|
|
||||||
count = 0; // Обнуляем счётчик
|
|
||||||
send_data = 1; // Выходим из цикла
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if(Ack){
|
|
||||||
// Serial.print(millis());
|
|
||||||
// Serial.println(" Send UINT32 OK");
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
void receive(const MyMessage &message)
|
|
||||||
{
|
|
||||||
if(message.isAck()) {Ack = true; return;}
|
|
||||||
if(message.getType() != V_STATUS) return;
|
|
||||||
switch (message.sensor)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
stat1 = !message.getBool();
|
|
||||||
Serial.print(F("Recv1: ")); Serial.println(stat1);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
stat2 = !message.getBool();
|
|
||||||
Serial.print(F("Recv2: ")); Serial.println(stat2);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Unit Testing and project tests.
|
|
||||||
|
|
||||||
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
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
|
||||||
Reference in New Issue
Block a user