more & more memory optimizations
This commit is contained in:
parent
80f2c0936a
commit
65ae2048c5
@ -135,7 +135,7 @@ Lorsqu'il n'y a pas de baisse ou de prise d'altitude significative pendant un ce
|
|||||||
|
|
||||||
A la fin du vol les statistiques sont sauvegardées et ne sont pas perdues à l'extinction du variomètre.
|
A la fin du vol les statistiques sont sauvegardées et ne sont pas perdues à l'extinction du variomètre.
|
||||||
|
|
||||||
Ce programme peut enregistrer 5 rapports de vol. Une fois un vol terminé, la piste suivante d'enregistrement est sélectionnée. Si celle-ci n'est pas vide elle n'est pas écrasée. Il faut alors manuellement effacer la plage de stat en cours ou reset toutes les plages.
|
Ce programme peut enregistrer 7 rapports de vol. Une fois un vol terminé, la piste suivante d'enregistrement est sélectionnée. Si celle-ci n'est pas vide elle n'est pas écrasée. Il faut alors manuellement effacer la plage de stat en cours (avec un appui long sur le bouton depuis l'interface Vario) ou reset toutes les plages (Menu Stats --> Reset).
|
||||||
|
|
||||||
|
|
||||||
**Statistique**
|
**Statistique**
|
||||||
|
@ -119,11 +119,11 @@ float alt;
|
|||||||
float tim;
|
float tim;
|
||||||
|
|
||||||
#define memoryBase 32
|
#define memoryBase 32
|
||||||
// Configuration structure (137 bits)
|
// Configuration structure (89 bits)
|
||||||
struct Conf
|
struct Conf
|
||||||
{
|
{
|
||||||
float vario_climb_rate_start; //minimum climb beeping value(ex. start climbing beeping at 0.4m/s)
|
int8_t vario_climb_rate_start; //minimum climb beeping value(ex. start climbing beeping at 0.4m/s)
|
||||||
float vario_sink_rate_start; //maximum sink beeping value (ex. start sink beep at -1.1m/s)
|
int8_t vario_sink_rate_start; //maximum sink beeping value (ex. start sink beep at -1.1m/s)
|
||||||
int currentAltitude;
|
int currentAltitude;
|
||||||
uint8_t light_cpt;
|
uint8_t light_cpt;
|
||||||
uint8_t contrast_default;
|
uint8_t contrast_default;
|
||||||
@ -131,11 +131,21 @@ struct Conf
|
|||||||
float p0;
|
float p0;
|
||||||
uint8_t stat_index;
|
uint8_t stat_index;
|
||||||
} conf = {
|
} conf = {
|
||||||
0.3, -1.1 , 0, 0, 50, true, 1040.00, 0
|
3, -11 , 0, 0, 50, true, 1040.00, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
float getVarioClimbRateStart()
|
||||||
|
{
|
||||||
|
return (float)conf.vario_climb_rate_start/10;
|
||||||
|
}
|
||||||
|
|
||||||
|
float getVarioSinkRateStart()
|
||||||
|
{
|
||||||
|
return (float)conf.vario_sink_rate_start/10;
|
||||||
|
}
|
||||||
|
|
||||||
// Statistic structure (128 bits)
|
// Statistic structure (128 bits)
|
||||||
#define NB_STATS 6
|
#define NB_STATS 7
|
||||||
struct Stat
|
struct Stat
|
||||||
{
|
{
|
||||||
uint32_t chrono_start;
|
uint32_t chrono_start;
|
||||||
@ -202,7 +212,7 @@ void resetAllStats()
|
|||||||
void playConfirmMelody()
|
void playConfirmMelody()
|
||||||
{
|
{
|
||||||
if (true == conf.volume){
|
if (true == conf.volume){
|
||||||
toneAC(700, 300);
|
toneAC(700, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,14 +491,14 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
|||||||
|
|
||||||
case MENU_MONTEE:
|
case MENU_MONTEE:
|
||||||
{
|
{
|
||||||
conf.vario_climb_rate_start = updateConfItem(conf.vario_climb_rate_start, dir, 0.1);
|
conf.vario_climb_rate_start = updateConfItem(conf.vario_climb_rate_start, dir, 1);
|
||||||
|
|
||||||
if (conf.vario_climb_rate_start < 0.1) {
|
if (conf.vario_climb_rate_start < 1) {
|
||||||
conf.vario_climb_rate_start = 0;
|
conf.vario_climb_rate_start = 0;
|
||||||
display.print(F("Off"));
|
display.print(F("Off"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
display.print(conf.vario_climb_rate_start);
|
display.print(getVarioClimbRateStart(), 1);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.print(F("m/s"));
|
display.print(F("m/s"));
|
||||||
}
|
}
|
||||||
@ -497,14 +507,14 @@ void renderMenu(MenuItem newMenuItem = menu.getCurrent(), uint8_t dir = 2)
|
|||||||
|
|
||||||
case MENU_DESCENTE:
|
case MENU_DESCENTE:
|
||||||
{
|
{
|
||||||
conf.vario_sink_rate_start = updateConfItem(conf.vario_sink_rate_start, dir, 0.1);
|
conf.vario_sink_rate_start = updateConfItem(conf.vario_sink_rate_start, dir, 1);
|
||||||
|
|
||||||
if (conf.vario_sink_rate_start >= 0) {
|
if (conf.vario_sink_rate_start >= 0) {
|
||||||
conf.vario_sink_rate_start = 0;
|
conf.vario_sink_rate_start = 0;
|
||||||
display.print(F("Off"));
|
display.print(F("Off"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
display.print(conf.vario_sink_rate_start);
|
display.print(getVarioSinkRateStart(), 1);
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
display.print(F("m/s"));
|
display.print(F("m/s"));
|
||||||
}
|
}
|
||||||
@ -717,7 +727,6 @@ void menuSetup()
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
m_vario.addAfter(m_stats);
|
m_vario.addAfter(m_stats);
|
||||||
|
|
||||||
m_stats.addAfter(m_options);
|
m_stats.addAfter(m_options);
|
||||||
m_stats.addRight(m_stat);
|
m_stats.addRight(m_stat);
|
||||||
m_stat.addBefore(m_retour2);
|
m_stat.addBefore(m_retour2);
|
||||||
@ -834,8 +843,12 @@ void makeBeeps()
|
|||||||
noSound = (timeNoPauseBeep <= 30)? false: !noSound;
|
noSound = (timeNoPauseBeep <= 30)? false: !noSound;
|
||||||
|
|
||||||
if (false == noSound){
|
if (false == noSound){
|
||||||
|
|
||||||
|
float varioClimbRateStart = getVarioClimbRateStart();
|
||||||
|
float varioSinkRateStart = getVarioSinkRateStart();
|
||||||
|
|
||||||
//beep even if vario has negative value but vario is climbing
|
//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;
|
float variation = (vario < varioClimbRateStart && vario_diff >= varioClimbRateStart && varioClimbRateStart != 0)? vario_diff: vario;
|
||||||
|
|
||||||
if (timeNoPauseBeep <= 30){
|
if (timeNoPauseBeep <= 30){
|
||||||
timeNoPauseBeep++;
|
timeNoPauseBeep++;
|
||||||
@ -845,7 +858,7 @@ void makeBeeps()
|
|||||||
beepLatency = getBeepLatency(variation);
|
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)) {
|
if ((vario > varioClimbRateStart && varioClimbRateStart != 0) || (vario < varioSinkRateStart && varioSinkRateStart != 0)) {
|
||||||
//when climbing make faster and shorter beeps
|
//when climbing make faster and shorter beeps
|
||||||
//toneAC(getBeepFrequency(variation), 10, beepLatency, true);
|
//toneAC(getBeepFrequency(variation), 10, beepLatency, true);
|
||||||
toneAC(getBeepFrequency(variation), beepLatency);
|
toneAC(getBeepFrequency(variation), beepLatency);
|
||||||
@ -912,7 +925,7 @@ void loop()
|
|||||||
vario = vario + 0.01;
|
vario = vario + 0.01;
|
||||||
if (vario > 4)
|
if (vario > 4)
|
||||||
vario = 0;
|
vario = 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Update stats if chrono is running
|
// Update stats if chrono is running
|
||||||
if (stat.chrono_start != 0) {
|
if (stat.chrono_start != 0) {
|
||||||
@ -1008,8 +1021,7 @@ void loop()
|
|||||||
}
|
}
|
||||||
//correction beep latency
|
//correction beep latency
|
||||||
makeBeeps();
|
makeBeeps();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Serial.println((tempo - micros()));
|
//Serial.println((tempo - micros()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
#include <EEPROM.h>
|
#ifndef __EEPROMAnything__
|
||||||
#include <Arduino.h> // for type definitions
|
#define __EEPROMAnything__
|
||||||
|
|
||||||
|
#if (ARDUINO >= 100)
|
||||||
|
#include "Arduino.h"
|
||||||
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class T> int EEPROM_writeAnything(int ee, const T& value)
|
template <class T> int EEPROM_writeAnything(int ee, const T& value)
|
||||||
{
|
{
|
||||||
@ -17,4 +23,6 @@ template <class T> int EEPROM_readAnything(int ee, T& value)
|
|||||||
for (i = 0; i < sizeof(value); i++)
|
for (i = 0; i < sizeof(value); i++)
|
||||||
*p++ = EEPROM.read(ee++);
|
*p++ = EEPROM.read(ee++);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -30,7 +30,7 @@ class MenuItem; //forward declaration of the menu item
|
|||||||
|
|
||||||
struct MenuChangeEvent
|
struct MenuChangeEvent
|
||||||
{
|
{
|
||||||
const MenuItem &from;
|
//const MenuItem &from;
|
||||||
const MenuItem &to;
|
const MenuItem &to;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -264,11 +264,12 @@ class MenuItem
|
|||||||
|| @paramter cb The callback to be fired
|
|| @paramter cb The callback to be fired
|
||||||
|| @return this MenuItem
|
|| @return this MenuItem
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
MenuItem &onChangeFrom(cb_change cb)
|
MenuItem &onChangeFrom(cb_change cb)
|
||||||
{
|
{
|
||||||
cb_onChangeFrom = cb;
|
cb_onChangeFrom = cb;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}*/
|
||||||
/*
|
/*
|
||||||
|| @description
|
|| @description
|
||||||
|| | Set a callback to be fired after any 'move' function is called with this item
|
|| | Set a callback to be fired after any 'move' function is called with this item
|
||||||
@ -278,12 +279,13 @@ class MenuItem
|
|||||||
|| @paramter cb The callback to be fired
|
|| @paramter cb The callback to be fired
|
||||||
|| @return this MenuItem
|
|| @return this MenuItem
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
MenuItem &onChangeTo(cb_change cb)
|
MenuItem &onChangeTo(cb_change cb)
|
||||||
{
|
{
|
||||||
cb_onChangeTo = cb;
|
cb_onChangeTo = cb;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
|| @description
|
|| @description
|
||||||
|| | Set a callback to be fired when 'moveUp' is called with this item as the current MenuItem
|
|| | Set a callback to be fired when 'moveUp' is called with this item as the current MenuItem
|
||||||
@ -292,11 +294,12 @@ class MenuItem
|
|||||||
|| @paramter cb The callback to be fired
|
|| @paramter cb The callback to be fired
|
||||||
|| @return this MenuItem
|
|| @return this MenuItem
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
MenuItem &onUp(cb_move cb)
|
MenuItem &onUp(cb_move cb)
|
||||||
{
|
{
|
||||||
cb_onUp = cb;
|
cb_onUp = cb;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}*/
|
||||||
/*
|
/*
|
||||||
|| @description
|
|| @description
|
||||||
|| | Set a callback to be fired when 'moveDown' is called with this item as the current MenuItem
|
|| | Set a callback to be fired when 'moveDown' is called with this item as the current MenuItem
|
||||||
@ -305,11 +308,12 @@ class MenuItem
|
|||||||
|| @paramter cb The callback to be fired
|
|| @paramter cb The callback to be fired
|
||||||
|| @return this MenuItem
|
|| @return this MenuItem
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
MenuItem &onDown(cb_move cb)
|
MenuItem &onDown(cb_move cb)
|
||||||
{
|
{
|
||||||
cb_onDown = cb;
|
cb_onDown = cb;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}*/
|
||||||
/*
|
/*
|
||||||
|| @description
|
|| @description
|
||||||
|| | Set a callback to be fired when 'moveLeft' is called with this item as the current MenuItem
|
|| | Set a callback to be fired when 'moveLeft' is called with this item as the current MenuItem
|
||||||
@ -318,11 +322,12 @@ class MenuItem
|
|||||||
|| @paramter cb The callback to be fired
|
|| @paramter cb The callback to be fired
|
||||||
|| @return this MenuItem
|
|| @return this MenuItem
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
MenuItem &onLeft(cb_move cb)
|
MenuItem &onLeft(cb_move cb)
|
||||||
{
|
{
|
||||||
cb_onLeft = cb;
|
cb_onLeft = cb;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}*/
|
||||||
/*
|
/*
|
||||||
|| @description
|
|| @description
|
||||||
|| | Set a callback to be fired when 'moveRight' is called with this item as the current MenuItem
|
|| | Set a callback to be fired when 'moveRight' is called with this item as the current MenuItem
|
||||||
@ -331,11 +336,12 @@ class MenuItem
|
|||||||
|| @paramter cb The callback to be fired
|
|| @paramter cb The callback to be fired
|
||||||
|| @return this MenuItem
|
|| @return this MenuItem
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
MenuItem &onRight(cb_move cb)
|
MenuItem &onRight(cb_move cb)
|
||||||
{
|
{
|
||||||
cb_onRight = cb;
|
cb_onRight = cb;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}*/
|
||||||
/*
|
/*
|
||||||
|| @description
|
|| @description
|
||||||
|| | Set a callback to be fired when 'use' is called with this item as the current MenuItem
|
|| | Set a callback to be fired when 'use' is called with this item as the current MenuItem
|
||||||
@ -344,11 +350,12 @@ class MenuItem
|
|||||||
|| @paramter cb The callback to be fired
|
|| @paramter cb The callback to be fired
|
||||||
|| @return this MenuItem
|
|| @return this MenuItem
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
MenuItem &onUse(cb_use cb)
|
MenuItem &onUse(cb_use cb)
|
||||||
{
|
{
|
||||||
cb_onUse = cb;
|
cb_onUse = cb;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t shortkey;
|
uint8_t shortkey;
|
||||||
@ -358,13 +365,13 @@ class MenuItem
|
|||||||
MenuItem *after;
|
MenuItem *after;
|
||||||
MenuItem *left;
|
MenuItem *left;
|
||||||
|
|
||||||
cb_change cb_onChangeFrom;
|
//cb_change cb_onChangeFrom;
|
||||||
cb_change cb_onChangeTo;
|
// cb_change cb_onChangeTo;
|
||||||
cb_move cb_onUp;
|
// cb_move cb_onUp;
|
||||||
cb_move cb_onDown;
|
// cb_move cb_onDown;
|
||||||
cb_move cb_onLeft;
|
// cb_move cb_onLeft;
|
||||||
cb_move cb_onRight;
|
// cb_move cb_onRight;
|
||||||
cb_use cb_onUse;
|
// cb_use cb_onUse;
|
||||||
|
|
||||||
MenuBackend *menuBackend;
|
MenuBackend *menuBackend;
|
||||||
|
|
||||||
@ -396,7 +403,7 @@ class MenuItem
|
|||||||
class MenuBackend
|
class MenuBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MenuBackend(cb_use menuUse, cb_change menuChange = 0) : root(F("MenuRoot"))
|
MenuBackend(cb_use menuUse, cb_change menuChange = 0) : root(F(""))
|
||||||
{
|
{
|
||||||
current = &root;
|
current = &root;
|
||||||
cb_menuChange = menuChange;
|
cb_menuChange = menuChange;
|
||||||
@ -432,12 +439,12 @@ class MenuBackend
|
|||||||
|| #
|
|| #
|
||||||
*/
|
*/
|
||||||
void moveUp()
|
void moveUp()
|
||||||
{
|
{/*
|
||||||
if (current->cb_onUp)
|
if (current->cb_onUp)
|
||||||
{
|
{
|
||||||
MenuMoveEvent mme = { *current };
|
MenuMoveEvent mme = { *current };
|
||||||
(*current->cb_onUp)(mme);
|
(*current->cb_onUp)(mme);
|
||||||
}
|
}*/
|
||||||
setCurrent(current->moveUp());
|
setCurrent(current->moveUp());
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -446,12 +453,12 @@ class MenuBackend
|
|||||||
|| #
|
|| #
|
||||||
*/
|
*/
|
||||||
void moveDown()
|
void moveDown()
|
||||||
{
|
{/*
|
||||||
if (current->cb_onDown)
|
if (current->cb_onDown)
|
||||||
{
|
{
|
||||||
MenuMoveEvent mme = { *current };
|
MenuMoveEvent mme = { *current };
|
||||||
(*current->cb_onDown)(mme);
|
(*current->cb_onDown)(mme);
|
||||||
}
|
}*/
|
||||||
setCurrent(current->moveDown());
|
setCurrent(current->moveDown());
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -461,11 +468,12 @@ class MenuBackend
|
|||||||
*/
|
*/
|
||||||
void moveLeft()
|
void moveLeft()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (current->cb_onLeft)
|
if (current->cb_onLeft)
|
||||||
{
|
{
|
||||||
MenuMoveEvent mme = { *current };
|
MenuMoveEvent mme = { *current };
|
||||||
(*current->cb_onLeft)(mme);
|
(*current->cb_onLeft)(mme);
|
||||||
}
|
}*/
|
||||||
setCurrent(current->moveLeft());
|
setCurrent(current->moveLeft());
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -474,12 +482,12 @@ class MenuBackend
|
|||||||
|| #
|
|| #
|
||||||
*/
|
*/
|
||||||
void moveRight()
|
void moveRight()
|
||||||
{
|
{/*
|
||||||
if (current->cb_onRight)
|
if (current->cb_onRight)
|
||||||
{
|
{
|
||||||
MenuMoveEvent mme = { *current };
|
MenuMoveEvent mme = { *current };
|
||||||
(*current->cb_onRight)(mme);
|
(*current->cb_onRight)(mme);
|
||||||
}
|
}*/
|
||||||
setCurrent(current->moveRight());
|
setCurrent(current->moveRight());
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -514,11 +522,12 @@ class MenuBackend
|
|||||||
void use()
|
void use()
|
||||||
{
|
{
|
||||||
//current->use();
|
//current->use();
|
||||||
|
/*
|
||||||
if (current->cb_onUse)
|
if (current->cb_onUse)
|
||||||
{
|
{
|
||||||
MenuUseEvent mue = { *current };
|
MenuUseEvent mue = { *current };
|
||||||
(*current->cb_onUse)(mue);
|
(*current->cb_onUse)(mue);
|
||||||
}
|
}*/
|
||||||
if (cb_menuUse)
|
if (cb_menuUse)
|
||||||
{
|
{
|
||||||
MenuUseEvent mue = { *current };
|
MenuUseEvent mue = { *current };
|
||||||
@ -540,15 +549,17 @@ class MenuBackend
|
|||||||
{
|
{
|
||||||
if (next)
|
if (next)
|
||||||
{
|
{
|
||||||
MenuChangeEvent mce = { *current, *next };
|
MenuChangeEvent mce = { *next };
|
||||||
|
/*
|
||||||
if (current->cb_onChangeFrom)
|
if (current->cb_onChangeFrom)
|
||||||
{
|
{
|
||||||
(*current->cb_onChangeFrom)(mce);
|
(*current->cb_onChangeFrom)(mce);
|
||||||
}
|
}*/
|
||||||
|
/*
|
||||||
if (next->cb_onChangeTo)
|
if (next->cb_onChangeTo)
|
||||||
{
|
{
|
||||||
(*next->cb_onChangeTo)(mce);
|
(*next->cb_onChangeTo)(mce);
|
||||||
}
|
}*/
|
||||||
if (cb_menuChange)
|
if (cb_menuChange)
|
||||||
{
|
{
|
||||||
(*cb_menuChange)(mce);
|
(*cb_menuChange)(mce);
|
||||||
|
Loading…
Reference in New Issue
Block a user