init platformio

master
adb 4 years ago
parent 2c9913b9c2
commit 6db2fa5935

1
.gitignore vendored

@ -0,0 +1 @@
.pio

@ -0,0 +1,33 @@
# !!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE
# https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
#
# If you need to override existing CMake configuration or add extra,
# please create `CMakeListsUser.txt` in the root of project.
# The `CMakeListsUser.txt` will not be overwritten by PlatformIO.
cmake_minimum_required(VERSION 3.13)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
project("ArtNet-Node" C CXX)
include(CMakeListsPrivate.txt)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsUser.txt)
include(CMakeListsUser.txt)
endif()
add_custom_target(
Production ALL
COMMAND platformio -c clion run "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(
Debug ALL
COMMAND platformio -c clion run --target debug "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_executable(Z_DUMMY_TARGET ${SRC_LIST})

@ -0,0 +1,121 @@
# !!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE
# https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
#
# If you need to override existing CMake configuration or add extra,
# please create `CMakeListsUser.txt` in the root of project.
# The `CMakeListsUser.txt` will not be overwritten by PlatformIO.
set(CMAKE_CONFIGURATION_TYPES "Upload_UART;Upload_ISP;fuses_bootloader;" CACHE STRING "Build Types reflect PlatformIO Environments" FORCE)
SET(CMAKE_C_COMPILER "$ENV{HOME}/.platformio/packages/toolchain-atmelavr/bin/avr-gcc")
SET(CMAKE_CXX_COMPILER "$ENV{HOME}/.platformio/packages/toolchain-atmelavr/bin/avr-g++")
SET(CMAKE_CXX_FLAGS "-fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega644p")
SET(CMAKE_C_FLAGS "-std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega644p")
SET(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
if (CMAKE_BUILD_TYPE MATCHES "Upload_UART")
add_definitions(-D'PLATFORMIO=50100')
add_definitions(-D'ARDUINO_AVR_ATmega644')
add_definitions(-D'F_CPU=16000000L')
add_definitions(-D'ARDUINO_ARCH_AVR')
add_definitions(-D'ARDUINO=10808')
add_definitions(-D'__AVR_ATmega644P__')
include_directories("${CMAKE_CURRENT_LIST_DIR}/include")
include_directories("${CMAKE_CURRENT_LIST_DIR}/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SPI/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/cores/MightyCore")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/variants/standard")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/AVR_examples/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/EEPROM/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Optiboot_flasher/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SD/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SPI1/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Servo/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SoftwareSerial/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Timer/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src")
include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include-fixed")
include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include")
include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/avr/include")
FILE(GLOB_RECURSE EXTRA_LIB_SOURCES
${CMAKE_CURRENT_LIST_DIR}/.pio/libdeps/Upload_UART/*.*
)
endif()
if (CMAKE_BUILD_TYPE MATCHES "Upload_ISP")
add_definitions(-D'PLATFORMIO=50100')
add_definitions(-D'ARDUINO_AVR_ATmega644')
add_definitions(-D'F_CPU=16000000L')
add_definitions(-D'ARDUINO_ARCH_AVR')
add_definitions(-D'ARDUINO=10808')
add_definitions(-D'__AVR_ATmega644P__')
include_directories("${CMAKE_CURRENT_LIST_DIR}/include")
include_directories("${CMAKE_CURRENT_LIST_DIR}/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SPI/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/cores/MightyCore")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/variants/standard")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/AVR_examples/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/EEPROM/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Optiboot_flasher/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SD/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SPI1/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Servo/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SoftwareSerial/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Timer/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src")
include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include-fixed")
include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include")
include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/avr/include")
FILE(GLOB_RECURSE EXTRA_LIB_SOURCES
${CMAKE_CURRENT_LIST_DIR}/.pio/libdeps/Upload_ISP/*.*
)
endif()
if (CMAKE_BUILD_TYPE MATCHES "fuses_bootloader")
add_definitions(-D'PLATFORMIO=50100')
add_definitions(-D'ARDUINO_AVR_ATmega644')
add_definitions(-D'F_CPU=16000000L')
add_definitions(-D'ARDUINO_ARCH_AVR')
add_definitions(-D'ARDUINO=10808')
add_definitions(-D'__AVR_ATmega644P__')
include_directories("${CMAKE_CURRENT_LIST_DIR}/include")
include_directories("${CMAKE_CURRENT_LIST_DIR}/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SPI/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/cores/MightyCore")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/variants/standard")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/AVR_examples/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/EEPROM/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Optiboot_flasher/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SD/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SPI1/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Servo/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/SoftwareSerial/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Timer/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire/src")
include_directories("$ENV{HOME}/.platformio/packages/framework-arduino-avr-mightycore/libraries/Wire1/src")
include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include-fixed")
include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include")
include_directories("$ENV{HOME}/.platformio/packages/toolchain-atmelavr/avr/include")
FILE(GLOB_RECURSE EXTRA_LIB_SOURCES
${CMAKE_CURRENT_LIST_DIR}/.pio/libdeps/fuses_bootloader/*.*
)
endif()
FILE(GLOB_RECURSE SRC_LIST
${CMAKE_CURRENT_LIST_DIR}/src/*.*
${CMAKE_CURRENT_LIST_DIR}/lib/*.*
)
list(APPEND SRC_LIST ${EXTRA_LIB_SOURCES})

@ -0,0 +1,46 @@
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

@ -0,0 +1,63 @@
; 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
[platformio]
default_envs = Upload_UART
[env]
platform = atmelavr
framework = arduino
board = ATmega644P
board_build.f_cpu = 16000000L
board_build.variant = standard
build_unflags = -flto
build_flags =
monitor_port = ${env:Upload_UART.upload_port}
monitor_speed = 9600
[env:Upload_UART]
upload_protocol = arduino
upload_port = /dev/cu.usbserial*
board_upload.speed = ${env:fuses_bootloader.board_bootloader.speed}
lib_deps =
tmrh20/RF24@^1.3.11
arduino-libraries/ArduinoDMX@^1.0.1
arduino-libraries/ArduinoRS485@^1.0.0
uipethernet/UIPEthernet@^2.0.8
[env:Upload_ISP]
upload_protocol = custom
upload_flags =
-C$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
-p$BOARD_MCU
-PUSB
-cusbasp
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
lib_deps =
tmrh20/RF24@^1.3.11
arduino-libraries/ArduinoDMX@^1.0.1
arduino-libraries/ArduinoRS485@^1.0.0
uipethernet/UIPEthernet@^2.0.8
[env:fuses_bootloader]
board_hardware.oscillator = external
board_hardware.uart = uart0
board_bootloader.speed = 115200
board_hardware.bod = 2.7v
board_hardware.eesave = yes
upload_protocol = usbasp
upload_flags =
-PUSB
-B8
lib_deps =
tmrh20/RF24@^1.3.11
arduino-libraries/ArduinoDMX@^1.0.1
arduino-libraries/ArduinoRS485@^1.0.0
uipethernet/UIPEthernet@^2.0.8

@ -0,0 +1,113 @@
#include <Arduino.h>
//DMX stuff
#include <ArduinoRS485.h>
#include <ArduinoDMX.h>
const int universeSize = 512;
//ArtNet stuff
#include <UIPArtnet.h>
ArtnetReceiver artnet;
uint32_t universe0 = 0;
uint32_t universe1 = 1;
// ethernet stuff
const IPAddress ip(10, 255, 255, 255);
uint8_t mac[] = {0xAA, 0xDD, 0xBB, 0xAA, 0xDD, 0xBB};
//NRF stuff
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
RF24 radio (0, 1);
const uint16_t address = 0xADB0;
uint64_t datasend;
//RGB LED
const int statusLED[] = {23,22, 21}; //RGB
const int statusLEDlength = 3;
int statusLEDstat[3];
//define min interval to show error
unsigned long currentTime = millis();
unsigned long previousTime = 0;
const long waitTime = 100;
const long errorTime = 5000;
//setup
void setup() {
for (int i=0; i < statusLEDlength; i++){
pinMode(statusLED[i], OUTPUT);
digitalWrite(statusLED[i], LOW);
}
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
//start DMX
DMX.begin(universeSize);
//start ethernet
Ethernet.begin(mac, ip);
//start ArtNet
artnet.begin();
artnet.subscribe(universe0, callback);
//start NRF
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_LOW);
radio.setDataRate(RF24_1MBPS);
//radio.disableDynamicPayloads();
radio.setAutoAck(false);
radio.disableCRC();
radio.stopListening();
setRGB(0,0,255);
delay(200);
}
void loop() {
currentTime = millis();
if (artnet.parse()) { // check if artnet packet has come and execute callback
previousTime = currentTime;
setRGB(0,255,0);
}else if(currentTime - previousTime >= errorTime){
setRGB(255,0,0);
}else if(currentTime - previousTime >= waitTime){
setRGB(0,0,255);
}
}
//ArtNet universe0 callback
void callback(byte* artnetdata, uint16_t size) {
digitalWrite(10, HIGH);
//RGB PWM
//setRGB(artnetdata[0], artnetdata[1], artnetdata[2]);
//DMX output
DMX.beginTransmission();
for (int i = 0; i < universeSize; ++i) {
DMX.write(i, artnetdata[i]);
}
DMX.endTransmission();
//send NRF
for (int i = 0; i < 20; i++) {
datasend = i; //package ID
for (int j = 0; j < 7; j++) {
datasend = (datasend << 8) + artnetdata[7 * i + j];
}
radio.writeFast(&datasend, sizeof(datasend));
}
digitalWrite(10, LOW);
}
void setRGB(int r, int g, int b){
if (r != statusLEDstat[0]) analogWrite(statusLED[0], r);
if (g != statusLEDstat[1]) analogWrite(statusLED[1], g);
if (b != statusLEDstat[2]) analogWrite(statusLED[2], b);
statusLEDstat[0] = r;
statusLEDstat[1] = g;
statusLEDstat[2] = b;
}

@ -0,0 +1,11 @@
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
Loading…
Cancel
Save