Free arduino oscilloscope code (requires seeedstudio 2.8 tft

I just wrote some code that allows you to use your mega or uno as an oscilloscope to make it work on the uno you must removes the pins that cover a4 and a5 and make sure you are only removing those pins and be sure to triple check that they are the ones that say unused on the wiki (link below) or else you will break your screen or at least touch screen support even thought the lcd appears to take up all the analog pins on the uno it does not according to the wiki seeedstudio.com/wiki/2.8%27%27_T … on_Arduino
This defaults to a15 but you can change it just by editing the #define in_pin
line anyways here is the code
Edit:almost forgot to view this correctly the digital pins face down and the analog pins face up.

#include <TFT.h>
#include <TouchScreen.h>
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
//realtime lcd osiloscope
int line;
unsigned char buffer[320];
unsigned char temp_val;
//this works on both the uno and the mega
//change it to 4 or 5 for the uno
#define in_pin 15
#define fast_adc

void setup()
{
  Tft.init();//init TFT
  #ifdef fast_adc
  sbi(ADCSRA,ADPS2);
cbi(ADCSRA,ADPS1);
cbi(ADCSRA,ADPS0);
#endif
}
void loop()
{
  //320-0 so count down to draw left to right
   for (line=0; line < 320;line++)
   {
     temp_val=analogRead(in_pin)/4;
     if (temp_val > 238)
     {
      temp_val=239; 
     }
     buffer[line]=temp_val;
     //Tft.setPixel(temp_val, line,WHITE); 
     Tft.setXY(temp_val,line);
     CS_LOW;
    RS_HIGH;
    RD_HIGH;

    WR_LOW;
     Tft.pushData(0xff);
     WR_HIGH;
    WR_LOW;
     Tft.pushData(0xff);
     WR_HIGH;
    CS_HIGH;
   }
   //now clear it
   for (line=0; line < 320;line++)
   {
     temp_val=buffer[line];//analogRead(in_pin)/4;
    // buffer[line]=temp_val;
    // Tft.setPixel(temp_val, line,BLACK); 
    Tft.setXY(temp_val,line);
     CS_LOW;
    RS_HIGH;
    RD_HIGH;

    WR_LOW;
     Tft.pushData(0);
     WR_HIGH;
    WR_LOW;
     Tft.pushData(0);
     WR_HIGH;
    CS_HIGH;
   }
}

Dear customer,

Thanks for you sharing.

Best regards,

Yuri

Sure anytime!

I make it work on the uno you must removes the pins that cover a4 and a5 and make sure you are only removing those pins and be sure to triple check that they are the ones that say unused on the wiki???