Updates
This commit is contained in:
BIN
Variometer.fzz
BIN
Variometer.fzz
Binary file not shown.
BIN
Variometer.png
BIN
Variometer.png
Binary file not shown.
|
Before Width: | Height: | Size: 667 KiB After Width: | Height: | Size: 657 KiB |
@@ -4,7 +4,7 @@
|
|||||||
#include <Encoder.h>
|
#include <Encoder.h>
|
||||||
#include <Wire.h> //i2c library
|
#include <Wire.h> //i2c library
|
||||||
#include <Adafruit_Sensor.h>
|
#include <Adafruit_Sensor.h>
|
||||||
#include <Adafruit_BMP085_U.h> //bmp085 library, download from url link (1)
|
#include <Adafruit_BMP085_U.h>
|
||||||
#include <toneAC.h>
|
#include <toneAC.h>
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
#include <Adafruit_PCD8544.h>
|
#include <Adafruit_PCD8544.h>
|
||||||
@@ -147,16 +147,16 @@ struct Stat
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void readStat(uint8_t index = conf.stat_index, Stat &value = stat)
|
void readStat(uint8_t index = conf.stat_index, Stat &value = stat)
|
||||||
{
|
{
|
||||||
EEPROM_readAnything(sizeof(Conf) + sizeof(Stat) * index, value);
|
EEPROM_readAnything(sizeof(Conf) + sizeof(Stat) * index, value);
|
||||||
}
|
}
|
||||||
void writeStat(uint8_t index = conf.stat_index, Stat &value = stat)
|
void writeStat(uint8_t index = conf.stat_index, Stat &value = stat)
|
||||||
{
|
{
|
||||||
EEPROM_writeAnything(sizeof(Conf) + sizeof(Stat) * index, value);
|
EEPROM_writeAnything(sizeof(Conf) + sizeof(Stat) * index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void incrementStatIndex()
|
void incrementStatIndex()
|
||||||
{
|
{
|
||||||
conf.stat_index++;
|
conf.stat_index++;
|
||||||
if (conf.stat_index > NB_STATS - 1)
|
if (conf.stat_index > NB_STATS - 1)
|
||||||
@@ -165,7 +165,7 @@ void incrementStatIndex()
|
|||||||
readStat();
|
readStat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetStat(uint8_t index = conf.stat_index, bool sound = true)
|
void resetStat(uint8_t index = conf.stat_index, bool sound = true)
|
||||||
{
|
{
|
||||||
stat.chrono_start = 0;
|
stat.chrono_start = 0;
|
||||||
stat.chrono = 0;
|
stat.chrono = 0;
|
||||||
@@ -185,7 +185,7 @@ void resetStat(uint8_t index = conf.stat_index, bool sound = true)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetAllStats()
|
void resetAllStats()
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < NB_STATS; i++) {
|
for (uint8_t i = 0; i < NB_STATS; i++) {
|
||||||
readStat(i);
|
readStat(i);
|
||||||
@@ -198,20 +198,20 @@ void resetAllStats()
|
|||||||
playConfirmMelody();
|
playConfirmMelody();
|
||||||
}
|
}
|
||||||
|
|
||||||
void playConfirmMelody()
|
void playConfirmMelody()
|
||||||
{
|
{
|
||||||
toneAC(700, 8, 150);
|
toneAC(700, 8, 150);
|
||||||
toneAC(500, 8, 150);
|
toneAC(500, 8, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initEeprom()
|
void initEeprom()
|
||||||
{
|
{
|
||||||
EEPROM_writeAnything(0, conf);
|
EEPROM_writeAnything(0, conf);
|
||||||
resetAllStats();
|
resetAllStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void renderChrono(Stat value = stat)
|
void renderChrono(Stat value = stat)
|
||||||
{
|
{
|
||||||
uint16_t s;
|
uint16_t s;
|
||||||
if (value.chrono == 0 && value.chrono_start != 0) {
|
if (value.chrono == 0 && value.chrono_start != 0) {
|
||||||
@@ -236,7 +236,7 @@ void renderChrono(Stat value = stat)
|
|||||||
display.print(s);
|
display.print(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderVario()
|
void renderVario()
|
||||||
{
|
{
|
||||||
display.fillRect(0, 0, 84, 32, WHITE);
|
display.fillRect(0, 0, 84, 32, WHITE);
|
||||||
// text display tests
|
// text display tests
|
||||||
@@ -297,7 +297,7 @@ void renderVario()
|
|||||||
display.setTextColor(BLACK);
|
display.setTextColor(BLACK);
|
||||||
display.setCursor(0, 41);
|
display.setCursor(0, 41);
|
||||||
display.fillRect(0, 41, 84, 7, WHITE);
|
display.fillRect(0, 41, 84, 7, WHITE);
|
||||||
|
|
||||||
display.print(F("M"));
|
display.print(F("M"));
|
||||||
display.print(conf.stat_index + 1);
|
display.print(conf.stat_index + 1);
|
||||||
display.print(F(" "));
|
display.print(F(" "));
|
||||||
@@ -318,7 +318,7 @@ void renderVarioBar()
|
|||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderVolume(uint8_t dir = MENU_RIGHT)
|
void renderVolume(uint8_t dir = MENU_RIGHT)
|
||||||
{
|
{
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(2);
|
display.setTextSize(2);
|
||||||
@@ -337,7 +337,7 @@ void renderVolume(uint8_t dir = MENU_RIGHT)
|
|||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
float updateConfItem(float var, uint8_t dir = 2, float increment = 1)
|
float updateConfItem(float var, uint8_t dir = 2, float increment = 1)
|
||||||
{
|
{
|
||||||
// save the configuration if a parameter is validate.
|
// save the configuration if a parameter is validate.
|
||||||
if (menuUsed_last == true && menuUsed == false) {
|
if (menuUsed_last == true && menuUsed == false) {
|
||||||
@@ -355,15 +355,15 @@ float updateConfItem(float var, uint8_t dir = 2, float increment = 1)
|
|||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderStatItem(float value, const __FlashStringHelper *unit, bool integer = false)
|
void renderStatItem(float value, const __FlashStringHelper *unit, bool integer = false)
|
||||||
{
|
{
|
||||||
menuUsed = false;
|
menuUsed = false;
|
||||||
display.setTextColor(BLACK);
|
display.setTextColor(BLACK);
|
||||||
|
|
||||||
if (integer == true){
|
if (integer == true) {
|
||||||
display.print((int)value);
|
display.print((int)value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
display.print(F("-"));
|
display.print(F("-"));
|
||||||
float value_abs = abs(value);
|
float value_abs = abs(value);
|
||||||
@@ -376,63 +376,63 @@ void renderStatItem(float value, const __FlashStringHelper *unit, bool integer =
|
|||||||
display.println(unit);
|
display.println(unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderZero(int value)
|
void renderZero(int value)
|
||||||
{
|
{
|
||||||
if (value < 10)
|
if (value < 10)
|
||||||
display.print(F("0"));
|
display.print(F("0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void renderDateTime(DateTime d, uint8_t bold = 0)
|
void renderDateTime(DateTime d, uint8_t bold = 0)
|
||||||
{
|
{
|
||||||
//display date
|
//display date
|
||||||
if (bold == DATE_DAY)
|
if (bold == DATE_DAY)
|
||||||
display.setTextColor(WHITE, BLACK);
|
display.setTextColor(WHITE, BLACK);
|
||||||
renderZero(d.day());
|
renderZero(d.day());
|
||||||
display.print(d.day());
|
display.print(d.day());
|
||||||
|
|
||||||
if (bold != 0)
|
if (bold != 0)
|
||||||
display.setTextColor(BLACK);
|
display.setTextColor(BLACK);
|
||||||
display.print(F("/"));
|
display.print(F("/"));
|
||||||
|
|
||||||
if (bold == DATE_MONTH)
|
if (bold == DATE_MONTH)
|
||||||
display.setTextColor(WHITE, BLACK);
|
display.setTextColor(WHITE, BLACK);
|
||||||
renderZero(d.month());
|
renderZero(d.month());
|
||||||
display.print(d.month());
|
display.print(d.month());
|
||||||
|
|
||||||
if (bold != 0)
|
if (bold != 0)
|
||||||
display.setTextColor(BLACK);
|
display.setTextColor(BLACK);
|
||||||
display.print(F("/"));
|
display.print(F("/"));
|
||||||
|
|
||||||
if (bold == DATE_YEAR)
|
if (bold == DATE_YEAR)
|
||||||
display.setTextColor(WHITE, BLACK);
|
display.setTextColor(WHITE, BLACK);
|
||||||
renderZero(d.year() - 2000);
|
renderZero(d.year() - 2000);
|
||||||
display.print(d.year() - 2000); //reduces the length of the year string
|
display.print(d.year() - 2000); //reduces the length of the year string
|
||||||
|
|
||||||
if (bold != 0)
|
if (bold != 0)
|
||||||
display.setTextColor(BLACK);
|
display.setTextColor(BLACK);
|
||||||
display.print(F(" "));
|
display.print(F(" "));
|
||||||
|
|
||||||
//display time
|
//display time
|
||||||
if (bold == DATE_HOUR)
|
if (bold == DATE_HOUR)
|
||||||
display.setTextColor(WHITE, BLACK);
|
display.setTextColor(WHITE, BLACK);
|
||||||
renderZero(d.hour());
|
renderZero(d.hour());
|
||||||
display.print(d.hour());
|
display.print(d.hour());
|
||||||
|
|
||||||
if (bold != 0)
|
if (bold != 0)
|
||||||
display.setTextColor(BLACK);
|
display.setTextColor(BLACK);
|
||||||
display.print(F(":"));
|
display.print(F(":"));
|
||||||
|
|
||||||
if (bold == DATE_MINUTE)
|
if (bold == DATE_MINUTE)
|
||||||
display.setTextColor(WHITE, BLACK);
|
display.setTextColor(WHITE, BLACK);
|
||||||
renderZero(d.minute());
|
renderZero(d.minute());
|
||||||
display.print(d.minute());
|
display.print(d.minute());
|
||||||
|
|
||||||
if (bold != 0)
|
if (bold != 0)
|
||||||
display.setTextColor(BLACK);
|
display.setTextColor(BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
||||||
{
|
{
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
@@ -479,11 +479,11 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
|||||||
if (menuUsed) {
|
if (menuUsed) {
|
||||||
menuUsed = false;
|
menuUsed = false;
|
||||||
display.print(F("Ok"));
|
display.print(F("Ok"));
|
||||||
|
|
||||||
sensors_event_t event;
|
sensors_event_t event;
|
||||||
bmp085.getEvent(&event);
|
bmp085.getEvent(&event);
|
||||||
conf.p0 = event.pressure;
|
conf.p0 = event.pressure;
|
||||||
|
|
||||||
//prevent chrono start and beeping
|
//prevent chrono start and beeping
|
||||||
resetAltitudeSensor();
|
resetAltitudeSensor();
|
||||||
|
|
||||||
@@ -497,7 +497,7 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
|||||||
conf.currentAltitude = updateConfItem(conf.currentAltitude, dir, 5);
|
conf.currentAltitude = updateConfItem(conf.currentAltitude, dir, 5);
|
||||||
//prevent chrono start and beeping
|
//prevent chrono start and beeping
|
||||||
resetAltitudeSensor();
|
resetAltitudeSensor();
|
||||||
|
|
||||||
display.print(conf.currentAltitude);
|
display.print(conf.currentAltitude);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.print(F("m"));
|
display.print(F("m"));
|
||||||
@@ -573,12 +573,12 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
|||||||
{
|
{
|
||||||
if (menuUsed_last == false) {
|
if (menuUsed_last == false) {
|
||||||
|
|
||||||
menuUsed_last = true;
|
menuUsed_last = true;
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
|
|
||||||
DateTime now = rtc.now();
|
DateTime now = rtc.now();
|
||||||
renderDateTime(now);
|
renderDateTime(now);
|
||||||
|
|
||||||
date_year = now.year();
|
date_year = now.year();
|
||||||
date_month = now.month();
|
date_month = now.month();
|
||||||
date_day = now.day();
|
date_day = now.day();
|
||||||
@@ -609,9 +609,9 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (conf_date_displayed) {
|
switch (conf_date_displayed) {
|
||||||
|
|
||||||
case DATE_DAY:
|
case DATE_DAY:
|
||||||
if (dir == MENU_RIGHT) (date_day >= 31) ? date_day = 1 : date_day++;
|
if (dir == MENU_RIGHT) (date_day >= 31) ? date_day = 1 : date_day++;
|
||||||
if (dir == MENU_LEFT) (date_day == 1) ? date_day = 31 : date_day--;
|
if (dir == MENU_LEFT) (date_day == 1) ? date_day = 31 : date_day--;
|
||||||
//display.println(F("Jour"));
|
//display.println(F("Jour"));
|
||||||
break;
|
break;
|
||||||
@@ -626,18 +626,18 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
|||||||
//display.println(F("Annee"));
|
//display.println(F("Annee"));
|
||||||
break;
|
break;
|
||||||
case DATE_HOUR:
|
case DATE_HOUR:
|
||||||
if (dir == MENU_RIGHT) (date_hour >= 23) ? date_hour = 0 : date_hour++;
|
if (dir == MENU_RIGHT) (date_hour >= 23) ? date_hour = 0 : date_hour++;
|
||||||
if (dir == MENU_LEFT) (date_hour == 0) ? date_hour = 23 : date_hour--;
|
if (dir == MENU_LEFT) (date_hour == 0) ? date_hour = 23 : date_hour--;
|
||||||
//display.println(F("Heure"));
|
//display.println(F("Heure"));
|
||||||
break;
|
break;
|
||||||
case DATE_MINUTE:
|
case DATE_MINUTE:
|
||||||
if (dir == MENU_RIGHT) (date_minute >= 59) ? date_minute = 0 : date_minute++;
|
if (dir == MENU_RIGHT) (date_minute >= 59) ? date_minute = 0 : date_minute++;
|
||||||
if (dir == MENU_LEFT)(date_minute == 0) ? date_minute = 59 : date_minute--;
|
if (dir == MENU_LEFT)(date_minute == 0) ? date_minute = 59 : date_minute--;
|
||||||
//display.println(F("Minute"));
|
//display.println(F("Minute"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
display.setTextColor(BLACK);
|
display.setTextColor(BLACK);
|
||||||
renderDateTime(DateTime(date_year, date_month, date_day, date_hour, date_minute, 0), conf_date_displayed);
|
renderDateTime(DateTime(date_year, date_month, date_day, date_hour, date_minute, 0), conf_date_displayed);
|
||||||
//display.print(date_conf[conf_date_displayed]);
|
//display.print(date_conf[conf_date_displayed]);
|
||||||
}
|
}
|
||||||
@@ -653,19 +653,19 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
|||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.setTextColor(WHITE, BLACK);
|
display.setTextColor(WHITE, BLACK);
|
||||||
|
|
||||||
if (stat_to_display.chrono == 0){
|
if (stat_to_display.chrono == 0) {
|
||||||
display.print(F("M"));
|
display.print(F("M"));
|
||||||
display.print(stat_displayed);
|
display.print(stat_displayed);
|
||||||
display.print(F(" vide"));
|
display.print(F(" vide"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if (stat_blink_status){
|
if (stat_blink_status) {
|
||||||
|
|
||||||
renderDateTime(DateTime(stat_to_display.chrono_start));
|
renderDateTime(DateTime(stat_to_display.chrono_start));
|
||||||
display.println();
|
display.println();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
display.print(F("Chrono:"));
|
display.print(F("Chrono:"));
|
||||||
@@ -680,17 +680,17 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
|||||||
|
|
||||||
display.print(F("Alt min:"));
|
display.print(F("Alt min:"));
|
||||||
renderStatItem(stat_to_display.alti_min, F("m"), true);
|
renderStatItem(stat_to_display.alti_min, F("m"), true);
|
||||||
|
|
||||||
display.print(F("Tx max:"));
|
display.print(F("Tx max:"));
|
||||||
float m = floor(stat_to_display.txchutemax);
|
float m = floor(stat_to_display.txchutemax);
|
||||||
m = m + (round(10 * stat_to_display.txchutemax) - (10 * m))/10;
|
m = m + (round(10 * stat_to_display.txchutemax) - (10 * m)) / 10;
|
||||||
renderStatItem(m, F("m/s"));
|
renderStatItem(m, F("m/s"));
|
||||||
|
|
||||||
display.print(F("Tx Min:"));
|
display.print(F("Tx Min:"));
|
||||||
m = floor(stat_to_display.txchutemin);
|
m = floor(stat_to_display.txchutemin);
|
||||||
m = m + (round(10 * stat_to_display.txchutemin) - (10 * m))/10;
|
m = m + (round(10 * stat_to_display.txchutemin) - (10 * m)) / 10;
|
||||||
renderStatItem(m, F("m/s"));
|
renderStatItem(m, F("m/s"));
|
||||||
|
|
||||||
display.print(F("Cumul:"));
|
display.print(F("Cumul:"));
|
||||||
renderStatItem(round(stat_to_display.cumul_alt), F("m"), true);
|
renderStatItem(round(stat_to_display.cumul_alt), F("m"), true);
|
||||||
}
|
}
|
||||||
@@ -735,14 +735,19 @@ void menuSetup()
|
|||||||
This is the structure of the modelled menu
|
This is the structure of the modelled menu
|
||||||
|
|
||||||
Vario
|
Vario
|
||||||
|
Stats
|
||||||
|
Retour
|
||||||
|
Statistiques
|
||||||
|
Reset
|
||||||
Options
|
Options
|
||||||
Retour
|
Retour
|
||||||
Tare
|
Tare
|
||||||
Altitude
|
Altitude
|
||||||
Montée
|
Montee
|
||||||
Descente
|
Descente
|
||||||
Light
|
Light
|
||||||
Contra
|
Contra
|
||||||
|
Date
|
||||||
|
|
||||||
*/
|
*/
|
||||||
m_vario.addAfter(m_stats);
|
m_vario.addAfter(m_stats);
|
||||||
@@ -767,10 +772,7 @@ void menuSetup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is an important function
|
Here all menu use events are handled
|
||||||
Here all use events are handled
|
|
||||||
|
|
||||||
This is where you define a behaviour for a menu item
|
|
||||||
*/
|
*/
|
||||||
void menuUseEvent(MenuUseEvent used)
|
void menuUseEvent(MenuUseEvent used)
|
||||||
{
|
{
|
||||||
@@ -787,17 +789,15 @@ void menuUseEvent(MenuUseEvent used)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is an important function
|
That is when the user changes the menu
|
||||||
Here we get a notification whenever the user changes the menu
|
|
||||||
That is, when the menu is navigated
|
|
||||||
*/
|
*/
|
||||||
void menuChangeEvent(MenuChangeEvent changed)
|
void menuChangeEvent(MenuChangeEvent changed)
|
||||||
{
|
{
|
||||||
renderMenu(changed.to);
|
renderMenu(changed.to);
|
||||||
}
|
}
|
||||||
|
|
||||||
int readVccPercent()
|
int readVccPercent()
|
||||||
{
|
{
|
||||||
//unsigned int raw_bat = analogRead(A0);
|
//unsigned int raw_bat = analogRead(A0);
|
||||||
float real_bat = ((analogRead(A0) * (3.7 / 1024)) * 2);
|
float real_bat = ((analogRead(A0) * (3.7 / 1024)) * 2);
|
||||||
average_vcc = average_vcc * 0.94 + real_bat * 0.06;
|
average_vcc = average_vcc * 0.94 + real_bat * 0.06;
|
||||||
@@ -805,7 +805,7 @@ int readVccPercent()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resetAltitudeSensor()
|
void resetAltitudeSensor()
|
||||||
{
|
{
|
||||||
// get a new sensor event
|
// get a new sensor event
|
||||||
sensors_event_t event;
|
sensors_event_t event;
|
||||||
bmp085.getEvent(&event);
|
bmp085.getEvent(&event);
|
||||||
@@ -838,8 +838,8 @@ void setup()
|
|||||||
pinMode(PIN_LIGHT, OUTPUT);
|
pinMode(PIN_LIGHT, OUTPUT);
|
||||||
|
|
||||||
bmp085.begin();
|
bmp085.begin();
|
||||||
resetAltitudeSensor();
|
resetAltitudeSensor();
|
||||||
|
|
||||||
display.begin();
|
display.begin();
|
||||||
display.setContrast(conf.contrast_default);
|
display.setContrast(conf.contrast_default);
|
||||||
display.setTextWrap(false);
|
display.setTextWrap(false);
|
||||||
@@ -868,20 +868,20 @@ void loop()
|
|||||||
Altitude = bmp085.pressureToAltitude(conf.p0, average_pressure, my_temperature) + conf.currentAltitude;
|
Altitude = bmp085.pressureToAltitude(conf.p0, average_pressure, my_temperature) + conf.currentAltitude;
|
||||||
|
|
||||||
float tempo = millis();
|
float tempo = millis();
|
||||||
|
|
||||||
float D2 = (tim - tempo);
|
float D2 = (tim - tempo);
|
||||||
float N1 = D2 * alt;
|
float N1 = D2 * alt;
|
||||||
float N2 = D2 * (alt + Altitude);
|
float N2 = D2 * (alt + Altitude);
|
||||||
float D1 = D2 * D2;
|
float D1 = D2 * D2;
|
||||||
|
|
||||||
alt = Altitude;
|
alt = Altitude;
|
||||||
tim = tempo;
|
tim = tempo;
|
||||||
/*
|
/*
|
||||||
2 * (D2 * alt) - D2 * (alt + Altitude)
|
2 * (D2 * alt) - D2 * (alt + Altitude)
|
||||||
2 * (D2 * alt) - (D2 * alt + D2 * Altitude)
|
2 * (D2 * alt) - (D2 * alt + D2 * Altitude)
|
||||||
(D2 * alt) + (D2 * alt) - D2 * alt + D2 * Altitude
|
(D2 * alt) + (D2 * alt) - D2 * alt + D2 * Altitude
|
||||||
*/
|
*/
|
||||||
|
|
||||||
vario = vario * 0.80 + (1000 * (2 * N1 - N2) / D1) * 0.2;
|
vario = vario * 0.80 + (1000 * (2 * N1 - N2) / D1) * 0.2;
|
||||||
|
|
||||||
// Update stats if chrono is running
|
// Update stats if chrono is running
|
||||||
@@ -901,7 +901,7 @@ void loop()
|
|||||||
|
|
||||||
// make some beep...
|
// make some beep...
|
||||||
if (vario < 15 && vario > -15) {
|
if (vario < 15 && vario > -15) {
|
||||||
|
|
||||||
if (vario > conf.vario_climb_rate_start && conf.vario_climb_rate_start != 0) {
|
if (vario > conf.vario_climb_rate_start && conf.vario_climb_rate_start != 0) {
|
||||||
//when climbing make faster and shorter beeps
|
//when climbing make faster and shorter beeps
|
||||||
//toneAC(300 + (100 * vario), conf.volume, (vario * 100) + 100, (vario < 1));
|
//toneAC(300 + (100 * vario), conf.volume, (vario * 100) + 100, (vario < 1));
|
||||||
@@ -927,10 +927,10 @@ void loop()
|
|||||||
get_time2 = millis();
|
get_time2 = millis();
|
||||||
|
|
||||||
if (stat.chrono_start != 0 && vario > 0) {
|
if (stat.chrono_start != 0 && vario > 0) {
|
||||||
stat.cumul_alt += vario;
|
stat.cumul_alt += vario;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu.getCurrent().getShortkey() == MENU_STAT){
|
if (menu.getCurrent().getShortkey() == MENU_STAT) {
|
||||||
menu.use();
|
menu.use();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -997,14 +997,14 @@ void loop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void readButtons()
|
void readButtons()
|
||||||
{
|
{
|
||||||
long newKnobPosition = knob.read();
|
long newKnobPosition = knob.read();
|
||||||
if (newKnobPosition != knobPosition) {
|
if (newKnobPosition != knobPosition) {
|
||||||
//Serial.print(newKnobPosition);
|
//Serial.print(newKnobPosition);
|
||||||
//Serial.print(F(" / "));
|
//Serial.print(F(" / "));
|
||||||
//Serial.println(knobPosition);
|
//Serial.println(knobPosition);
|
||||||
if (abs(newKnobPosition-knobPosition) >= ENCODER_STEP) {
|
if (abs(newKnobPosition - knobPosition) >= ENCODER_STEP) {
|
||||||
if (newKnobPosition > knobPosition) { //Right
|
if (newKnobPosition > knobPosition) { //Right
|
||||||
if (!menuUsed && varioState == false) {
|
if (!menuUsed && varioState == false) {
|
||||||
if (menu.getCurrent().getShortkey() == MENU_STAT && stat_displayed < NB_STATS) {
|
if (menu.getCurrent().getShortkey() == MENU_STAT && stat_displayed < NB_STATS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user