migration repo
This commit is contained in:
46
lib/README
Normal file
46
lib/README
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
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
|
||||
("lib/your_library_name/[Code]").
|
||||
|
||||
For example, see the structure of the following example libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional. for 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
|
||||
|
||||
Example contents of `src/main.c` using Foo and Bar:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
The PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries by scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
119
lib/sailplane/airspeed.cpp
Normal file
119
lib/sailplane/airspeed.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#include "../windentelemetry.h"
|
||||
#include "airspeed.h"
|
||||
#include <ms4525do.h>
|
||||
#include <airdata.h>
|
||||
#include <units.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_BMP085.h>
|
||||
|
||||
extern TwoWire Wire1;
|
||||
bfs::Ms4525do pres;
|
||||
Adafruit_BMP085 bmp;
|
||||
|
||||
float pressure_avg[10];
|
||||
float basicaltitude;
|
||||
void init_2ndi2c(){
|
||||
Wire1.begin(dp_sda, dp_scl);
|
||||
Wire1.setClock(400000);
|
||||
}
|
||||
void init_airspeed_sensor(void)
|
||||
{
|
||||
|
||||
/*
|
||||
* I2C address of 0x28, on bus 0, with a -1 to +1 PSI range
|
||||
*/
|
||||
pres.Config(&Wire1, 0x28, 1.0f, -1.0f);
|
||||
/* Starting communication with the pressure transducer */
|
||||
if (!pres.Begin())
|
||||
{
|
||||
Serial.println("Error communicating with sensor");
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int get_airspeed_kmh(void)
|
||||
{
|
||||
int vel_kmh = round(bfs::convvel(get_airspeed(), bfs::LinVelUnit::MPS, bfs::LinVelUnit::KPH));
|
||||
return vel_kmh;
|
||||
}
|
||||
float get_airspeed(void)
|
||||
{
|
||||
if (pres.Read())
|
||||
{
|
||||
float ms = bfs::Ias_mps(pres.pres_pa());
|
||||
|
||||
return ms;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
void init_pressure_sensor(void)
|
||||
{
|
||||
bmp.begin(BMP085_ULTRAHIGHRES, &Wire1);
|
||||
basicaltitude=bmp.readPressure();
|
||||
Serial.print("Pressure = ");
|
||||
Serial.print(basicaltitude);
|
||||
Serial.println(" Pa");
|
||||
|
||||
// Calculate altitude assuming 'standard' barometric
|
||||
// pressure of 1013.25 millibar = 101325 Pascal
|
||||
Serial.print("Altitude = ");
|
||||
Serial.print(get_altitude(basicaltitude));
|
||||
Serial.println(" meters");
|
||||
}
|
||||
|
||||
float get_pressure()
|
||||
{
|
||||
float pressure;
|
||||
pressure = bmp.readPressure();
|
||||
memcpy(pressure_avg, &pressure_avg[1], sizeof(pressure_avg) - sizeof(int));
|
||||
pressure_avg[9] = pressure;
|
||||
return pressure;
|
||||
}
|
||||
|
||||
float get_pressure_avg(void)
|
||||
{
|
||||
int i;
|
||||
float total;
|
||||
for (i = 0; i <10; i++)
|
||||
{
|
||||
total = total + pressure_avg[i];
|
||||
}
|
||||
return (total / 10);
|
||||
}
|
||||
float get_vario(void)
|
||||
{
|
||||
float vario;
|
||||
vario = get_altitude(pressure_avg[9]) - get_altitude(pressure_avg[8]);
|
||||
return vario;
|
||||
}
|
||||
|
||||
float get_vario_avg(void)
|
||||
{
|
||||
float vario;
|
||||
|
||||
int i;
|
||||
float total;
|
||||
for (i = 0; i <9; i++)
|
||||
{
|
||||
int n=i+1;
|
||||
vario = get_altitude(pressure_avg[n]) - get_altitude(pressure_avg[i]);
|
||||
total = total + vario;
|
||||
}
|
||||
return (total / 10);
|
||||
}
|
||||
|
||||
float get_altitude(float pressure)
|
||||
{
|
||||
float altitude;
|
||||
altitude = 44330 * (1.0 - pow(pressure / 101325, 0.1903));
|
||||
return altitude;
|
||||
}
|
||||
|
||||
float get_altitude_diff(void){
|
||||
return bmp.readPressure() - basicaltitude;
|
||||
}
|
||||
25
lib/sailplane/airspeed.h
Normal file
25
lib/sailplane/airspeed.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef WINDENTELEMETRY_AIRSPEED_H
|
||||
#define WINDENTELEMETRY_AIRSPEED_H
|
||||
|
||||
void init_2ndi2c(void);
|
||||
void init_airspeed_sensor(void);
|
||||
|
||||
int get_airspeed_kmh(void);
|
||||
/*!
|
||||
@brief Holt die Indikates Airspeed vom Sensor über Druckunterschied und gibt m/s
|
||||
*/
|
||||
float get_airspeed(void);
|
||||
|
||||
void init_pressure_sensor(void);
|
||||
float get_pressure(void);
|
||||
float get_pressure_adv(void);
|
||||
float get_altitude(float pressure);
|
||||
float get_vario(void);
|
||||
float get_vario_avg(void);
|
||||
/*!
|
||||
@brief Gibt den Höhenunterschied seit Device Start
|
||||
*/
|
||||
float get_altitude_diff(void);
|
||||
|
||||
|
||||
#endif
|
||||
82
lib/winde/tacho.cpp
Normal file
82
lib/winde/tacho.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#include "../windentelemetry.h"
|
||||
#include "tacho.h"
|
||||
#include <ESP32Servo.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
Servo myservo;
|
||||
Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIN, NEO_GRB + NEO_KHZ800);
|
||||
void init_servo(void)
|
||||
{
|
||||
myservo.setPeriodHertz(50);
|
||||
myservo.attach(servoPin);
|
||||
set_tacho(0, 70, 150);
|
||||
}
|
||||
|
||||
void set_tacho(int speed, int speed_min, int speed_max)
|
||||
{
|
||||
int val = map(speed, -25, 220, 0, 155);
|
||||
#ifdef DEBUG
|
||||
Serial.print("Tacho Mapping: ")
|
||||
Serial.println(val);
|
||||
#endif
|
||||
myservo.write(val);
|
||||
pixels.clear();
|
||||
// normal speed
|
||||
if ((speed >= speed_min) && (speed <= speed_max))
|
||||
{
|
||||
int n;
|
||||
for (n = speed_min + 5; n < speed_max - 5; n = n + 10)
|
||||
{
|
||||
int i = map(n, 0, 220, 1, 12);
|
||||
pixels.setPixelColor(setoffsetpixel(i), pixels.Color(0, 150, 0));
|
||||
}
|
||||
}
|
||||
// knapp am minimum
|
||||
if ((speed <= speed_min + 5) && (speed >= speed_min))
|
||||
{
|
||||
int i = map(speed, 0, 220, 1, 12);
|
||||
pixels.setPixelColor(setoffsetpixel(i - 1), pixels.Color(150, 150, 0));
|
||||
}
|
||||
// knapp über max
|
||||
if ((speed <= speed_max) && (speed >= speed_max - 5))
|
||||
{
|
||||
int i = map(speed, 0, 220, 1, 12);
|
||||
pixels.setPixelColor(setoffsetpixel(i), pixels.Color(150, 0, 0));
|
||||
}
|
||||
// kleiner minimium
|
||||
if ((speed < speed_min) && (speed > 20))
|
||||
{
|
||||
int n;
|
||||
for (n = 0; n < speed_min; n = n + 10)
|
||||
{
|
||||
int i = map(n, 0, 220, 1, 12);
|
||||
pixels.setPixelColor(setoffsetpixel(i - 1), pixels.Color(150, 150, 0));
|
||||
}
|
||||
}
|
||||
// größer max
|
||||
if (speed > speed_max)
|
||||
{
|
||||
int n;
|
||||
for (n = speed_max; n <= 220; n = n + 10)
|
||||
{
|
||||
int i = map(n, 0, 220, 1, 12);
|
||||
pixels.setPixelColor(setoffsetpixel(i), pixels.Color(150, 0, 0));
|
||||
}
|
||||
}
|
||||
pixels.show();
|
||||
}
|
||||
|
||||
void init_pixel(void)
|
||||
{
|
||||
pixels.begin();
|
||||
}
|
||||
|
||||
int setoffsetpixel(int pixel)
|
||||
{
|
||||
int newpixel;
|
||||
newpixel = pixel + pixeloffset;
|
||||
if (newpixel >= NUMPIXELS)
|
||||
{
|
||||
newpixel = newpixel - NUMPIXELS;
|
||||
}
|
||||
return newpixel;
|
||||
}
|
||||
15
lib/winde/tacho.h
Normal file
15
lib/winde/tacho.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef WINDENTELEMETRY_TACHO_H
|
||||
#define WINDENTELEMETRY_TACHO_H
|
||||
#include "../windentelemetry.h"
|
||||
|
||||
void init_servo(void);
|
||||
/*!
|
||||
@brief Set die Geschwidigkeit des Tachos über den Servo
|
||||
@param speed die Geschwindigkeit als int in km/h, kt oder m/s je nach Tacho
|
||||
*/
|
||||
void set_tacho(int speed, int speed_min, int speed_max);
|
||||
|
||||
void init_pixel(void);
|
||||
|
||||
int setoffsetpixel(int pixel);
|
||||
#endif
|
||||
48
lib/windentelemetry.h
Normal file
48
lib/windentelemetry.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef WINDENTELEMETRY_CONFIG_H
|
||||
#define WINDENTELEMETRY_CONFIG_H
|
||||
|
||||
#define LORA_FREQ 868.0
|
||||
#ifdef HELTEC_WIFI_LORA_32_V3
|
||||
// SX1262 on HELTEC_WIFI_LORA_32_V3 has the following connections:
|
||||
// NSS pin: 8
|
||||
// DIO1 pin: 14
|
||||
// NRST pin: 12
|
||||
// BUSY pin: 13
|
||||
#define LORA_NSS 8
|
||||
#define LORA_DIO1 14
|
||||
#define LORA_NRST 12
|
||||
#define LORA_BUSY 13
|
||||
|
||||
// OLED SSD1306 on HELTEC_WIFI_LORA_32_V3 has the following connections:
|
||||
#define OLED_RST 21
|
||||
#define OLED_CLK 18
|
||||
#define OLED_DATA 17
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef DEVICE_SAILPLANE
|
||||
/*********************************devices*********************************************/
|
||||
/**difference pressure**/
|
||||
#define dp_scl 20
|
||||
#define dp_sda 19
|
||||
#define default_min_tow_speed 80
|
||||
#define default_max_tow_speed 150
|
||||
#endif
|
||||
|
||||
#ifdef DEVICE_WINDE
|
||||
/*********************************devices*********************************************/
|
||||
/**Servo**/
|
||||
#define servoPin 7
|
||||
/**WS8212 **/
|
||||
// Which pin on is connected to the WS8212?
|
||||
#define NEOPIN 6
|
||||
|
||||
// How many NeoPixels are attached
|
||||
#define NUMPIXELS 12
|
||||
#define pixeloffset 6
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user