Skip to content
Snippets Groups Projects
Commit c82e3a89 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Update for PlatformIO

parent 262b8211
Branches
No related tags found
No related merge requests found
...@@ -4,3 +4,7 @@ ...@@ -4,3 +4,7 @@
*~ *~
*.tmp *.tmp
*.part *.part
.pioenvs
.piolibdeps
.clang_complete
.gcc-flags.json
/*
NodeManager is intended to take care on your behalf of all those common tasks a MySensors node has to accomplish, speeding up the development cycle of your projects.
NodeManager includes the following main components:
- Sleep manager: allows managing automatically the complexity behind battery-powered sensors spending most of their time sleeping
- Power manager: allows powering on your sensors only while the node is awake
- Battery manager: provides common functionalities to read and report the battery level
- Remote configuration: allows configuring remotely the node without the need to have physical access to it
- Built-in personalities: for the most common sensors, provide embedded code so to allow their configuration with a single line
Documentation available on: https://github.com/mysensors/NodeManager
*/
// load user settings
#include "config.h"
// include supporting libraries
#ifdef MY_GATEWAY_ESP8266
#include <ESP8266WiFi.h>
#endif
// load MySensors library
#include <MySensors.h>
// load NodeManager library
#include "NodeManager.h"
// create a NodeManager instance
NodeManager nodeManager;
// before
void before() {
// setup the serial port baud rate
Serial.println(F("BEFORE"));
printFM();
Serial.begin(MY_BAUD_RATE);
/*
* Register below your sensors
*/
nodeManager.setSleep(SLEEP, 2, MINUTES);
Serial.print(F("BEFORE registerSensor0: ")); printFM();
nodeManager.registerSensor(SENSOR_MQ, A0, 0);
Serial.print(F("BEFORE registerSensor1: ")); printFM();
nodeManager.registerSensor(SENSOR_MQ, A1, 1);
Serial.print(F("BEFORE registerSensor2: ")); printFM();
nodeManager.registerSensor(SENSOR_MQ, A2, 2);
Serial.print(F("BEFORE registerSensor3: ")); printFM();
nodeManager.registerSensor(SENSOR_MQ, A3, 3);
Serial.print(F("BEFORE reg.Sens. MHZ19: ")); printFM();
int co2 = nodeManager.registerSensor(SENSOR_MHZ19, 6, 4);
SensorMHZ19* co2Sensor = ((SensorMHZ19*)nodeManager.getSensor(co2));
co2Sensor->setRxTx(6, 7);
Serial.print(F("AFTER reg. sensors: "));printFM();
/*
* Register above your sensors
*/
nodeManager.before();
}
// presentation
void presentation() {
// call NodeManager presentation routine
nodeManager.presentation();
}
// setup
void setup() {
// call NodeManager setup routine
nodeManager.setup();
}
// loop
void loop() {
// call NodeManager loop routine
nodeManager.loop();
}
// receive
void receive(const MyMessage &message) {
// call NodeManager receive routine
nodeManager.receive(message);
}
// receiveTime
void receiveTime(unsigned long ts) {
// call NodeManager receiveTime routine
nodeManager.receiveTime(ts);
}
This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file.
The source code of each library should be placed in separate directory, like
"lib/private_lib/[here are source files]".
For example, see how can be organized `Foo` and `Bar` libraries:
|--lib
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |- readme.txt --> THIS FILE
|- platformio.ini
|--src
|- main.c
Then in `src/main.c` you should use:
#include <Foo.h>
#include <Bar.h>
// rest H/C/CPP code
PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.
More information about PlatformIO Library Dependency Finder
- http://docs.platformio.org/page/librarymanager/ldf.html
; 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
; http://docs.platformio.org/page/projectconf.html
[platformio]
src_dir = .
[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
lib_deps = MySensors
upload_port = /dev/ttyUSB1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment