ok..
I have made just an example of my code where you can see by just disable the display function... everything goes ok.
/*
MS561101BA_altitude.pde - Computes altitude from sea level using pressure readings from the sensor.
The algorithm uses the Hypsometric formula as explained in http://keisan.casio.com/has10/SpecExec.cgi?path=06000000.Science%2F02100100.Earth%20science%2F12000300.Altitude%20from%20atmospheric%20pressure%2Fdefault.xml&charset=utf-8
Copyright (C) 2011 Fabio Varesano <fvaresano@yahoo.it>
Development of this code has been supported by the Department of Computer Science,
Universita' degli Studi di Torino, Italy within the Piemonte Project
http://www.piemonte.di.unito.it/
This program is free software: you can redistribute it and/or modify
it under the terms of the version 3 GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#define DEBUG_V
#include <EEPROM.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <Wire.h>
//#include <DebugUtils.h>
#include <MS561101BA.h>
#define MOVAVG_SIZE 32
MS561101BA baro = MS561101BA();
float movavg_buff[MOVAVG_SIZE];
int movavg_i = 0;
const float sea_press = 1013.25;
float press, temperature;
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
void setup() {
Wire.begin();
Serial.begin(9600);
pinMode(9, OUTPUT);
baro.init(MS561101BA_ADDR_CSB_LOW);
delay(100);
display.clearDisplay();
display.begin();
display.setContrast(55);
}
boolean vario_pronto = true;
float vclimb_smooth_macio;
float max_climb;
float vganho_altitude;
void loop() {
static long vconta_para_timer_principal;
if (millis() - vconta_para_timer_principal >= 100)
{
vclimb_smooth_macio = vclimb_smooth_macio + 0.25;
if (vclimb_smooth_macio >= 3)
{
vclimb_smooth_macio = 0;
}
vconta_para_timer_principal = millis();
}
//IF YOU DISABLE THIS FUNCTION EVERYTHING GOES OK
display_tela_1();
////////////////////////////////////////////////
static long vtimer_beep;
static int vteste_beep;
if (millis() - vtimer_beep >= 50)
{
vteste_beep = !vteste_beep;
if (vteste_beep == 1)
{
tone(10, 600);
}
else if (vteste_beep == 0)
{
noTone(10);
}
vtimer_beep = millis();
}
}
float getAltitude(float press, float temp) {
return ((pow((sea_press / press), 1 / 5.257) - 1.0) * (temp + 273.15)) / 0.0065;
}
int maxima_vposicao_barra_indicadora_maximo = 47;
double vtimer_para_apagar_maximo = millis();
float valor_maximo_para_barrinha;
float vclimb_para_cada_segundo;
void display_tela_1()
{
uint8_t seta_baixo = 25;
uint8_t seta_cima = 24;
display.clearDisplay();
display.drawLine(63, 0, 63, 48, BLACK);
for (int x = 3; x <= 60; x = x + 3)
{
display.drawLine(60, x, 63, x, BLACK);
}
display.drawLine(83, 0, 83, 48, BLACK);
display.drawLine(63, 47, 83, 47, BLACK);
float vclimb_smooth_macio_interna_tela_1 = vclimb_smooth_macio;
int valor_inicio_vu = 48;
int valor_atual_vu = vclimb_smooth_macio_interna_tela_1 * 13.0;
valor_atual_vu = valor_atual_vu * -1;
if (valor_atual_vu == 0)
{
valor_atual_vu = 1;
}
if (valor_atual_vu < -156)
{
valor_atual_vu = valor_atual_vu + 156;
}
else if (valor_atual_vu < -117)
{
valor_atual_vu = valor_atual_vu + 117;
}
else if (valor_atual_vu < -78)
{
valor_atual_vu = valor_atual_vu + 78;
}
else if (valor_atual_vu < -39)
{
valor_atual_vu = valor_atual_vu + 39;
}
if (max_climb > 3)
{
display.setTextSize(1);
display.setCursor(57, 0);
display.write(seta_cima);
}
if (vario_pronto == true)
{
if (valor_atual_vu <= 1)
{
display.fillRect(63, valor_inicio_vu, 84, valor_atual_vu, BLACK);
//########################
}
else if (valor_atual_vu > 1)
{
if (valor_atual_vu >= 46)
{
valor_atual_vu = 46;
}
display.fillRect(63, 1, 84, valor_atual_vu, BLACK);
//########################
}
int vposicao_barra_indicadora_maximo = valor_inicio_vu + valor_atual_vu - 1;
if (vposicao_barra_indicadora_maximo == 48){ vposicao_barra_indicadora_maximo = 47; }
if (maxima_vposicao_barra_indicadora_maximo == 0)
{
}
if (vposicao_barra_indicadora_maximo < maxima_vposicao_barra_indicadora_maximo)
{
maxima_vposicao_barra_indicadora_maximo = vposicao_barra_indicadora_maximo;
vtimer_para_apagar_maximo = millis();
}
if (valor_maximo_para_barrinha < vclimb_smooth_macio)
{
valor_maximo_para_barrinha = vclimb_smooth_macio;
}
if (millis() - vtimer_para_apagar_maximo >= 3000)
{
//
}
if (vclimb_smooth_macio >= -0.15)
{
display.drawLine(55, maxima_vposicao_barra_indicadora_maximo, 83, maxima_vposicao_barra_indicadora_maximo, BLACK);
display.fillRect(64, maxima_vposicao_barra_indicadora_maximo, 20, 9, BLACK);
display.drawLine(55, vposicao_barra_indicadora_maximo, 83, vposicao_barra_indicadora_maximo, BLACK);
}
display.setTextSize(1);
if (vclimb_smooth_macio >= -0.15)
{
display.setCursor(65, maxima_vposicao_barra_indicadora_maximo + 1);
display.setTextColor(WHITE, BLACK);
if (valor_maximo_para_barrinha < 10)
{
display.print(valor_maximo_para_barrinha, 1);
}
else if (valor_maximo_para_barrinha >= 10)
{
display.print(valor_maximo_para_barrinha, 0);
}
}
else if (vclimb_smooth_macio < -0.15)
{
display.setCursor(65, valor_atual_vu - 7);
display.setTextColor(WHITE, BLACK);
display.print(abs(vclimb_smooth_macio), 1);
}
display.setTextColor(BLACK);
}
display.setTextSize(1);
display.setCursor(12, 0);
display.print("Climb:");
display.setTextSize(2);
display.setCursor(0, 9);
if (vario_pronto == false)
{
display.print("-----");
}
else
{
if (vclimb_smooth_macio > 0.15)
{
display.write(seta_cima);
}
else if (vclimb_smooth_macio >= -0.15 && vclimb_smooth_macio <= 0.15)
{
display.print(" ");
}
else if (vclimb_smooth_macio < -0.15)
{
display.write(seta_baixo);
}
display.print(abs(vclimb_smooth_macio), 1);
}
display.setTextSize(1);
display.setCursor(48, 16);
display.setTextSize(1);
display.setCursor(12, 25);
display.print("Ganho:");
display.setTextSize(2);
display.setCursor(0, 34);
if (vganho_altitude >= 0 && vganho_altitude < 1)
{
display.print(" ");
}
else if (vganho_altitude >= 1)
{
display.print("+");
}
if (vganho_altitude <= 9999)
{
display.print(vganho_altitude, 0);
}
display.display();
}