Pantallas OLED

Hola buenas noches, estoy trabajando con un oxímetro de pulso, todos mis parámetros están bien pero mi gráfica en la pantalla se me despliega pegada aunque en el osciloscopio se ve bien y quisiera saber si alguien podria ayudarme a que se vea más como me la muestra el osciloscopio, aqui adjunto mi código, gracias.

#include <Adafruit_GFX.h>
#include <gfxfont.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <SPI.h>
#define ANCHO 128
#define ALTO 64
#define OLED_RESET 4
#define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_64 defined
#define SSD1306_LCDHEIGHT 64 ///< DEPRECATED: height w/SSD1306_128_64 defined

Adafruit_SSD1306 oled(ANCHO, ALTO, &Wire, OLED_RESET);
Adafruit_SSD1306 display(OLED_RESET); //OLED 4 PINES

//#define OLED_MOSI 11 //9
//#define OLED_CLK 12 //10
//#define OLED_DC 9 //11
//#define OLED_CS 12
//#define OLED_RESET 10 //13
//Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

//Variables//
float spo2=0; //%spo2
float spo2total=0; //sumatoria de ambas señales

//Sensores Fototransistores//
int sensor=A0; //Fototransistor 790nm - 1050nm IR (950nm)
int valorSensor;
int sensor2=A1; //Fototransistor 400nm - 1100nm ROJO
int valorSensor2;

unsigned int intensidad_infrarrojo; // intensidad reflejada HbO2 (oxihemoglobina)
unsigned int intensidad_rojo; // Intensidad reflejada Hb (hemoglobina)

//***********************************//
const int numReadings = 50; //numero de muestras para promedio
int readings [numReadings]; //Lecturas de la entrada análogica
int indexs = 0; //El indice de la lectura actual
int total = 0; //Total
float average = 0; //Promedio
//LECTURAS SEÑAL OLED////
byte data[64] ; //Para guardar las lecturas
byte index=0;
byte anterior;
//VARIABLES DE CALCULO DE BPM
*//
int buzzer=5;
//////FRECUENCIOMETRO/////
long rango=5; //este es el rango por el que se disparara la salida 2 y pasa a estado logico 1
long ultimamedicion; //contiene el valor de la ultima medición que disparó a lógico 1, la salida 2
int ciclo=0; //1=alto 0=bajo
int cambiodeciclo=0;
int picodetension;
int valledetension;
long contadorciclo;
int senal;
/////*****MILLIS/////////////
boolean estadoBPM =true; //guarda el estado del led (encendido o apagado)
boolean estadoLed = true; //guarda el estado del led (encendido o apagado)
int IntervaloEncendido =200; //tiempo que esta encendido el led
int IntervaloApagado =50; //tiempo que esta apagado el led
int IntervaloBPM = 15000; //tiempo en que esta apagado el led
int IntervaloBPM2 = 1; //tiempo en que esta apagado el led

unsigned long tiempoAnteriorEncendido =0; //guarda el tiepo de la referencia para comparar
unsigned long tiempoAnteriorApagado = 0; //guarda tiempo de referencia para compararlo
unsigned long tiempoAnteriorBPM =0; //guarda tiempo de referencia para comparar
unsigned long tiempoAnteriorBPM2 = 0; //guarda tiempo de referencia para comparar
//////////

int pulsos=0;
int pulsos2=0;
//****************************************************************//

void setup()
{
Serial.begin(115200);

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);

for (int i =0; i<6; i++) //0 el array
data = 0 ;

  • for (int thisReading = 0; thisReading < numReadings; thisReading++)*
  • readings[thisReading] = 0;*
    }
    void loop()
    {
  • display.clearDisplay();*
    _ //**************PARAMETROS OLED//_
    _ //MAPEO DE SEÑAL EN OLED
    /////////_
  • index = index % 64 ;*
    _ data[index] = 64 * analogRead(A0)/1024;_
  • index++ ;*
  • byte i = index ;*
  • for(byte x=0; x <64 ; x++)*
  • {*
  • i = i % 64;*
    _ display.drawLine(x, data*, x, anterior, 1);_
    _ anterior=data;
    i++ ;
    if(x==0) //quita que se repita la linea 0 y 128*
    * {
    display.clearDisplay();
    }*_

* }*

* display.setCursor(0,55);*
* display.print("BPM=");*
* //display.setCursor(10,20);*
* display.setCursor(25,55);*
_ display.print(pulsos2*6);_

display.setCursor(56,55);
display.print("%SpO2=");
//display.setCursor(50,20);
display.setCursor(95,55);
display.print(average);
display.display();
delayMicroseconds(1);
//LECTURA DE FOTOTRANSISTORES//
valorSensor=analogRead(sensor);
intensidad_infrarrojo=valorSensor;
valorSensor2=analogRead(sensor2);
intensidad_rojo=valorSensor2;
//CALCULO SPO2//
spo2total=((float)intensidad_rojo+(float)intensidad_infrarrojo);
spo2=((float)intensidad_infrarrojo/spo2total);
spo2=100.0*spo2;
spo2=spo2+45;
//PROMEDIO SPO2****///
//Restamos la ultima lectura:
total= total - readings[indexs];
//Leemos del sensor:
readings[indexs] = spo2;
//Añadimos la lectura total:
total= total + readings[indexs];
//Avanzamos a la proxima posición del array
indexs = indexs + 1;
//Si estamos en el final del array...
if (indexs >= numReadings)
//.....volveos al inicio:
indexs =0;
//Calculamos el promedio:
average = total / numReadings;
//Lo mandamos a la PC como un valor ASCII
//CALCULO BPM*//
senal=analogRead(A0);
if (senal >= ( ultimamedicion+200))
{
* ultimamedicion = senal;*
* ciclo=1;*
* if (senal>picodetension)*
* {*
* picodetension=senal;*
* }*
* }*
* if (senal<= (ultimamedicion-200))*
* {*
* ultimamedicion = senal;*
* ciclo=0;*
* if (senal<valledetension)*
* {*
* valledetension=senal;*
* }*
* }*

_ /////**************///////
* ////////////////////////1 minuto///////////////////
if(millis()-tiempoAnteriorBPM>=IntervaloBPM){
estadoBPM=false;
pulsos2=pulsos;
tiempoAnteriorBPM=millis();
pulsos=0;
}
if(millis()-tiempoAnteriorBPM2>=IntervaloBPM2){
estadoBPM=true;
pulsos2=(pulsos2+pulsos2)/2;
Serial.print(pulsos26);

* tiempoAnteriorBPM2=millis();
}
///////////////////////////////
if((millis()-tiempoAnteriorEncendido>=IntervaloEncendido)&&estadoLed==true && ciclo==0)
{
estadoLed=false;
picodetension=senal;
valledetension=senal;
digitalWrite(12,estadoLed);
tiempoAnteriorApagado=millis();
}
if((millis()-tiempoAnteriorApagado>=IntervaloApagado)&&estadoLed==false && ciclo==1) //pulso
{
pulsos++;
picodetension=senal;
valledetension=senal;
estadoLed=true;
digitalWrite(12,estadoLed);
/////////
tiempoAnteriorEncendido=millis();
}
}

*_