Improved beeps and schema
This commit is contained in:
14
README.md
14
README.md
@@ -1,3 +1,15 @@
|
|||||||
|
# MISE À JOUR #
|
||||||
|
|
||||||
|
**Attention !** Lors de la dernière mise à jour le schéma de connection de l'écran a été modifié pour des soucis d'optimisations du montage.
|
||||||
|
|
||||||
|
- **PIN\_SCLK** : D8 --> D4
|
||||||
|
- **PIN\_LIGHT** : D11 --> Inchangée
|
||||||
|
- **PIN\_SCE** : D7 --> Inchangée
|
||||||
|
- **PIN\_RESET** : D8 --> D6
|
||||||
|
- **PIN\_DC** : D6 --> D5
|
||||||
|
- **PIN\_SDIN** : D5 --> D4
|
||||||
|
|
||||||
|
|
||||||
DIY Arduino variometer
|
DIY Arduino variometer
|
||||||
==================
|
==================
|
||||||
|
|
||||||
@@ -26,7 +38,7 @@ Voici à titre indicatif le matériel utilisé et leur prix d'achat sur eBay int
|
|||||||
- DC-DC Converter Step Up 1-5V 500mA | 1,15€
|
- DC-DC Converter Step Up 1-5V 500mA | 1,15€
|
||||||
- 3,7V 600mAh LiPo Battery | 3,25€
|
- 3,7V 600mAh LiPo Battery | 3,25€
|
||||||
- RTC Module for Arduino | 1,55€
|
- RTC Module for Arduino | 1,55€
|
||||||
- 3x 10k Ohm resistor + 1x 100k Ohm resistor + 1x 120 Ohm resistor | 0,10€
|
- 3x 10k Ohm resistor + 1x 120 Ohm resistor | 0,10€
|
||||||
- Right Angle Mini Slide Switch | 0,10€
|
- Right Angle Mini Slide Switch | 0,10€
|
||||||
- Cables | 3€
|
- Cables | 3€
|
||||||
- Plastic Electronics Project Box Enclosure DIY 27x60x100mm | 2,40€
|
- Plastic Electronics Project Box Enclosure DIY 27x60x100mm | 2,40€
|
||||||
|
|||||||
BIN
Variometer.fzz
BIN
Variometer.fzz
Binary file not shown.
BIN
Variometer.png
BIN
Variometer.png
Binary file not shown.
|
Before Width: | Height: | Size: 657 KiB After Width: | Height: | Size: 667 KiB |
@@ -10,7 +10,6 @@
|
|||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
#include <Adafruit_PCD8544.h>
|
#include <Adafruit_PCD8544.h>
|
||||||
#include <RTClib.h>
|
#include <RTClib.h>
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
bool initialisation = false; //If true, reset and update eeprom memory at arduino start
|
bool initialisation = false; //If true, reset and update eeprom memory at arduino start
|
||||||
@@ -37,7 +36,7 @@ uint8_t date_minute;
|
|||||||
#define Enter 12
|
#define Enter 12
|
||||||
#define ENCODER_STEP 4
|
#define ENCODER_STEP 4
|
||||||
|
|
||||||
Encoder knob(2, 3);
|
Encoder knob(3, 2);
|
||||||
long knobPosition = 0;
|
long knobPosition = 0;
|
||||||
int lastEnterState = HIGH;
|
int lastEnterState = HIGH;
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
@@ -86,12 +85,12 @@ MenuItem m_recreset = MenuItem(NULL, MENU_RECRESET); //Reset records
|
|||||||
|
|
||||||
//////////////////ECRAN///////////////////////
|
//////////////////ECRAN///////////////////////
|
||||||
#define enablePartialUpdate
|
#define enablePartialUpdate
|
||||||
#define PIN_SCLK 8
|
#define PIN_SCLK 4
|
||||||
#define PIN_LIGHT 11
|
#define PIN_LIGHT 11
|
||||||
#define PIN_SCE 7
|
#define PIN_SCE 7
|
||||||
#define PIN_RESET 6
|
#define PIN_RESET 8
|
||||||
#define PIN_DC 5
|
#define PIN_DC 6
|
||||||
#define PIN_SDIN 4
|
#define PIN_SDIN 5
|
||||||
|
|
||||||
Adafruit_PCD8544 display = Adafruit_PCD8544(PIN_SCLK, PIN_SDIN, PIN_DC, PIN_SCE, PIN_RESET);
|
Adafruit_PCD8544 display = Adafruit_PCD8544(PIN_SCLK, PIN_SDIN, PIN_DC, PIN_SCE, PIN_RESET);
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
@@ -104,13 +103,20 @@ int altitude_temp;
|
|||||||
uint8_t chrono_cpt = 0;
|
uint8_t chrono_cpt = 0;
|
||||||
|
|
||||||
float vario = 0;
|
float vario = 0;
|
||||||
|
float vario_old = 0;
|
||||||
|
float vario_diff = 0;
|
||||||
|
uint8_t vario_diff_cpt = 0;
|
||||||
|
uint8_t timeNoPauseBeep = 0;
|
||||||
|
bool noSound = false;
|
||||||
|
unsigned long get_timeBeep = millis();
|
||||||
|
uint8_t beepLatency = 0;
|
||||||
|
|
||||||
bool is_vario_button_push = false;
|
bool is_vario_button_push = false;
|
||||||
uint16_t average_vcc = 0; //variable to hold the value of Vcc from battery
|
uint16_t average_vcc = 0; //variable to hold the value of Vcc from battery
|
||||||
double average_pressure;
|
double average_pressure;
|
||||||
unsigned long get_time1 = millis();
|
unsigned long get_time1 = millis();
|
||||||
unsigned long get_time2 = millis();
|
unsigned long get_time2 = millis();
|
||||||
unsigned long get_timeBeep = millis();
|
|
||||||
uint8_t beebLatency = 0;
|
|
||||||
uint8_t push_write_eeprom = 6;
|
uint8_t push_write_eeprom = 6;
|
||||||
float my_temperature;
|
float my_temperature;
|
||||||
float alt;
|
float alt;
|
||||||
@@ -814,15 +820,15 @@ int readVccPercent()
|
|||||||
return percent;
|
return percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getBeepLatency()
|
uint8_t getBeepLatency(float variation)
|
||||||
{
|
{
|
||||||
int latency = 240 - (vario * 60);
|
int latency = 150 - (variation * 30);
|
||||||
return (latency < 130)? 130: (latency > 240)? 240: latency;
|
return (latency < 70)? 70: (latency > 150)? 150: latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t getBeepFrequency()
|
uint16_t getBeepFrequency(float variation)
|
||||||
{
|
{
|
||||||
int frequency = 790 + (100 * vario);
|
int frequency = 690 + (150 * variation);
|
||||||
return (frequency < 100)? 100: (frequency > 1300)? 1300 :frequency;
|
return (frequency < 100)? 100: (frequency > 1300)? 1300 :frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -876,7 +882,7 @@ void loop()
|
|||||||
readButtons();
|
readButtons();
|
||||||
// screen brightness. AnalogWrite values from 0 to 255
|
// screen brightness. AnalogWrite values from 0 to 255
|
||||||
analogWrite(PIN_LIGHT, conf.light_cpt * 51);
|
analogWrite(PIN_LIGHT, conf.light_cpt * 51);
|
||||||
|
//Serial.println(millis());
|
||||||
// get a new sensor event
|
// get a new sensor event
|
||||||
sensors_event_t event;
|
sensors_event_t event;
|
||||||
bmp085.getEvent(&event);
|
bmp085.getEvent(&event);
|
||||||
@@ -890,6 +896,13 @@ void loop()
|
|||||||
float tempo = millis();
|
float tempo = millis();
|
||||||
// put it in filter and take average
|
// put it in filter and take average
|
||||||
vario = vario * 0.8 + (1000 * 0.2 * ((alt - Altitude) / (tim - tempo)));
|
vario = vario * 0.8 + (1000 * 0.2 * ((alt - Altitude) / (tim - tempo)));
|
||||||
|
|
||||||
|
/* TEST BLOC
|
||||||
|
vario = vario + 0.01;
|
||||||
|
if (vario > 4)
|
||||||
|
vario = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
alt = Altitude;
|
alt = Altitude;
|
||||||
tim = tempo;
|
tim = tempo;
|
||||||
|
|
||||||
@@ -909,18 +922,34 @@ void loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make some beep...
|
// make some beep...
|
||||||
if (millis() >= (get_timeBeep + beebLatency))
|
if (millis() >= (get_timeBeep + beepLatency) || timeNoPauseBeep <= 30)
|
||||||
{
|
{
|
||||||
get_timeBeep = millis();
|
get_timeBeep = millis();
|
||||||
beebLatency = getBeepLatency();
|
|
||||||
|
|
||||||
if (vario > conf.vario_climb_rate_start && conf.vario_climb_rate_start != 0) {
|
noSound = (timeNoPauseBeep <= 30)? false: !noSound;
|
||||||
//when climbing make faster and shorter beeps
|
|
||||||
toneAC(getBeepFrequency(), conf.volume, beebLatency, true);
|
|
||||||
|
|
||||||
} else if (vario < conf.vario_sink_rate_start && conf.vario_sink_rate_start != 0) {
|
if (false == noSound){
|
||||||
|
//beep even if vario has negative value but vario is climbing
|
||||||
|
float variation = (vario < conf.vario_climb_rate_start && vario_diff >= conf.vario_climb_rate_start && conf.vario_climb_rate_start != 0)? vario_diff: vario;
|
||||||
|
|
||||||
toneAC(getBeepFrequency(), conf.volume, beebLatency, true);
|
if (timeNoPauseBeep <= 30){
|
||||||
|
timeNoPauseBeep++;
|
||||||
|
beepLatency = 150;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
beepLatency = getBeepLatency(variation);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((vario > conf.vario_climb_rate_start && conf.vario_climb_rate_start != 0) || (vario < conf.vario_sink_rate_start && conf.vario_sink_rate_start != 0)) {
|
||||||
|
//when climbing make faster and shorter beeps
|
||||||
|
toneAC(getBeepFrequency(variation), conf.volume, beepLatency, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
toneAC(0);
|
||||||
|
timeNoPauseBeep = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
beepLatency = beepLatency / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,6 +961,13 @@ void loop()
|
|||||||
// update vario bar
|
// update vario bar
|
||||||
if (varioState == true)
|
if (varioState == true)
|
||||||
renderVarioBar();
|
renderVarioBar();
|
||||||
|
|
||||||
|
vario_diff_cpt++;
|
||||||
|
if (vario_diff_cpt == 5){
|
||||||
|
vario_diff_cpt = 0;
|
||||||
|
vario_diff = vario - vario_old;
|
||||||
|
vario_old = vario;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//every second
|
//every second
|
||||||
@@ -1009,6 +1045,9 @@ void loop()
|
|||||||
altitude_temp = Altitude;
|
altitude_temp = Altitude;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//correct beep latency
|
||||||
|
beepLatency = 0;
|
||||||
|
noSound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user