Browse Source

migrate to platformio

master
interfisch 12 months ago
parent
commit
dba16cc27e
  1. 39
      include/README
  2. 46
      lib/README
  3. 19
      platformio.ini
  4. 0
      src/effect.h
  5. 0
      src/fx_flash.cpp
  6. 0
      src/fx_flash.h
  7. 0
      src/fx_scanner.cpp
  8. 0
      src/fx_scanner.h
  9. 26
      src/main.cpp
  10. 6
      src/wagon.cpp
  11. 0
      src/wagon.h

39
include/README

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

46
lib/README

@ -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

19
platformio.ini

@ -0,0 +1,19 @@
; 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:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 115200
lib_deps =
adafruit/Adafruit NeoPixel @ ^1.7.0

0
effect.h → src/effect.h

0
fx_flash.cpp → src/fx_flash.cpp

0
fx_flash.h → src/fx_flash.h

0
fx_scanner.cpp → src/fx_scanner.cpp

0
fx_scanner.h → src/fx_scanner.h

26
achterbahn.ino → src/main.cpp

@ -1,5 +1,7 @@
//flash as Wemos D1 R2 & mini
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
@ -15,6 +17,21 @@
#include "fx_flash.h"
void resetHeightmap();
void printHeightmapRaw();
void interpolateHeightValues();
void previewHeightmap(int waittime);
void spawnWagon();
void spawnWagon(float pos, float wagonlength,float startvel, float startacc, float mass, uint8_t wheelcolor);
void checkSerial();
void loop_configmode();
void loop_achterbahn();
void removeAllWagons();
uint32_t Wheel(byte WheelPos);
void loadHeightmapRaw();
void saveHeightmapRaw();
#define PIN D2
#define NUMPIXELS 600
@ -103,6 +120,8 @@ void setup() {
}
void resetHeightmap(){
for (int i=0;i<NUMPIXELS;i++){
heightraw[i]=255; //255 means value need to be interpolated
@ -204,6 +223,8 @@ void previewHeightmap(int waittime){
}
}
void spawnWagon(){
//Wagon tmpr = Wagon(maxid++,NUMPIXELS,&strip, height, 35, 6, 0.5,0); //spawn new wagon
// pos, wagonlength, startvel, startacc, trainmass, wagoncolor
@ -258,6 +279,8 @@ void loop() {
}
void checkSerial(){
static String serialstring_temp="";
String serialstring="";
@ -414,6 +437,7 @@ void loop_configmode(){
}
}
void loop_achterbahn(){
//######################### Update LED Output
if (lastPixelUpdate+PIXELUPDATETIME<loopmillis){
@ -564,6 +588,7 @@ uint32_t Wheel(byte WheelPos) {
void loadHeightmapRaw(){
int c_eepromaddress=EEPROMSTARTADDRESS_HEIGHTMAP;
uint8_t lastvalue=0;
@ -583,3 +608,4 @@ void saveHeightmapRaw(){
}
EEPROM.commit(); //write changes to eeprom. EEPROM.end() will also commit and release the ram copy of eeprom contents
}

6
wagon.cpp → src/wagon.cpp

@ -302,9 +302,9 @@ void Wagon::updateGraphics()
}
_tmpr=(uint16_t)(min(255,_tmpr*_brightnesscorrection));
_tmpg=(uint16_t)(min(255,_tmpg*_brightnesscorrection));
_tmpb=(uint16_t)(min(255,_tmpb*_brightnesscorrection));
_tmpr=(uint16_t)(_min(255,_tmpr*_brightnesscorrection));
_tmpg=(uint16_t)(_min(255,_tmpg*_brightnesscorrection));
_tmpb=(uint16_t)(_min(255,_tmpb*_brightnesscorrection));
_strip->setPixelColor(iCorrected,_tmpr,_tmpg,_tmpb); //draw pixel
}

0
wagon.h → src/wagon.h

Loading…
Cancel
Save