コード例 #1
0
ファイル: assignment2.cpp プロジェクト: adamjford/assignment2
void loop() {
  uint8_t ratingFilter = getRatingFilter();
  uint16_t horiz = getHorizontal();
  uint16_t vert = getVertical();
  lightUpRatingLEDs(ratingFilter);

  tft.drawPixel(horiz, vert, 0);
  if(isButtonPressed()) {
    // wait for button to be released
    while(isButtonPressed()) { }
    displayClosestRestaurants(horiz, vert, ratingFilter * 2);
    drawMap();
  }
  lcd_image_draw(&map_image, &tft, horiz, vert, horiz, vert, 1, 1);
}
コード例 #2
0
ファイル: Starfield.cpp プロジェクト: RifleCreek/Arduino
// Allow this method to be overridden in subclasses
void Starfield::draw_pixel(Adafruit_ST7735 tft, int x, int y, int color) {
  tft.drawPixel(x, y, color);
}
コード例 #3
0
ファイル: display.cpp プロジェクト: DD4WH/Teensy-SDR-Rx
void show_spectrum(float line_gain, float LPFcoeff) {
      static int startx=0, endx;
      endx=startx+16;
      int scale=3;
      float avg = 0.0;
      // Draw spectrum display
      for (int16_t x=startx; x < endx; x+=1) {

                if ((x > 1) && (x < 159)) 
                // moving window - weighted average of 5 points of the spectrum to smooth spectrum in the frequency domain
                // weights:  x: 50% , x-1/x+1: 36%, x+2/x-2: 14% 
                    avg = myFFT.output[(x)*16/10]*0.5 + myFFT.output[(x-1)*16/10]*0.18 + myFFT.output[(x-2)*16/10]*0.07 + myFFT.output[(x+1)*16/10]*0.18 + myFFT.output[(x+2)*16/10]*0.07;
                    else 
                    avg =  myFFT.output[(x)*16/10];
//                pixelnew[x] = LPFcoeff * 2 * sqrt (abs(myFFT.output[(x)*16/10])*scale) + (1 - LPFcoeff) * pixelold[x];
                // low pass filtering of the spectrum pixels to smooth/slow down spectrum in the time domain
                // experimental LPF for spectrum:  ynew = LPCoeff * x + (1-LPCoeff) * yprevious; here: A = 0.3 to 0.5 seems to be a good idea
                pixelnew[x] = LPFcoeff * 2 * sqrt (abs(avg)*scale) + (1 - LPFcoeff) * pixelold[x];
                
/*                for (int16_t i=0; x < 5; x+=1) {
                         
                pixelnew[x+i] = 2 * sqrt (abs(myFFT.output[(x+i)*16/10])*scale);
                if (pixelnew[x+i] > pos-1) pixelnew[x+i] = pos-1;
                }
  */              
//                int bar=2 * sqrt (abs(myFFT.output[x*16/10])*scale);
//                if (bar >pos-1) bar=pos-1;
                  
                              if(x != pos_centre_f) {
// common way: draw bars
//                                    tft.drawFastVLine(x, pos-1-bar,bar, BLUE); // GREEN);
//                                    tft.drawFastVLine(x, 0, pos-1-bar, WHITE); //BLACK);
// alternate way: draw pixels
// only plot pixel, if at a new position
                                      if (pixelold[x] != pixelnew[x]) { 
                                            tft.drawPixel(x, pos-1-pixelold[x], BLACK); // delete old pixel
                                            tft.drawPixel(x, pos-1-pixelnew[x], WHITE); // write new pixel
                                            pixelold[x] = pixelnew[x]; }
/*                                      if (pixelnew[x] > 5 * (pixelnew[x+1] + pixelnew[x-1])) {
                                               tft.drawFastVLine(x, pos-1-pixelnew[x], pixelnew[x], BLUE);
                                               tft.drawFastVLine(x, 0, pos-1- pixelnew[x], BLACK);
                                    }
  */                              }
      }


 
     // Calculate S units. 50uV = S9
    //if (0) {
     if (Smetertimer.check()==1) {
      uv = myFFT.output[159]+myFFT.output[160]+myFFT.output[161]+myFFT.output[162]+myFFT.output[158]+myFFT.output[157]+myFFT.output[156];   // measure signal strength of carrier of AM Transmission at exact frequency
      // low pass filtering for Smeter values 
      uv = 0.1 * uv + 0.9 * uvold;
      
      if (uv == 0) dbm = -130;
      else {
      dbm = 20*log10(uv)-83.5-25.7-1.5*line_gain;} //dbm standardized to 15.26Hz Receiver Bandwidth
      
      // constant 83.5dB determined empirically by measuring a carrier with a Perseus SDR
      // and comparing the output of the Teensy FFT
      // 25.7dB is INA163 gain in frontend 
      //dbm measurement on the Perseus standardized to RBW of 15.26Hz 
     // float vol = analogRead(15);
     // vol = vol / 1023.0;
    // now calculate S-value from dbm
      s = 9.0 + ((dbm + 73.0) / 6.0);
      if (s <0.0) s=0.0;
      if ( s > 9.0)
      {
        dbuv = dbm + 73.0;
        s = 9.0;
      }
      else dbuv = 0.0;
     
      // Print S units
      //s=roundf(s);
/*      tft.fillRect(0,105, 50, 7,ST7735_BLACK);
      tft.fillRect(0,105, 160, 7,ST7735_BLACK);
      tft.setCursor(100,105);
   //   sprintf(string,"%04.0f FFT",uv);
   //     sprintf(string,"%04.0f dbm",dbm);
        sprintf(string,"%02.0f",s);
      tft.print(string);
      tft.setCursor(0,105);
   //   sprintf(string,"%04.0f FFT",uv);
        sprintf(string,"%04.0f dbm",dbm);
      tft.print(string);
*/   
      tft.drawFastHLine(pos_x_smeter, pos_y_smeter, s*s_w+1, BLUE);
      tft.drawFastHLine(pos_x_smeter+s*s_w+1, pos_y_smeter, (9*s_w+1)-s*s_w+1, BLACK);

      tft.drawFastHLine(pos_x_smeter, pos_y_smeter+1, s*s_w+1, WHITE);
      tft.drawFastHLine(pos_x_smeter+s*s_w+1, pos_y_smeter+1, (9*s_w+1)-s*s_w+1, BLACK);
      tft.drawFastHLine(pos_x_smeter, pos_y_smeter+2, s*s_w+1, BLUE);
      tft.drawFastHLine(pos_x_smeter+s*s_w+1, pos_y_smeter+2, (9*s_w+1)-s*s_w+1, BLACK);

   //   tft.drawFastHLine(pos_x_smeter, pos_y_smeter+3, s*s_w+1, BLUE);
   //   tft.drawFastHLine(pos_x_smeter+s*s_w+1, pos_y_smeter+3, (9*s_w+1)-s*s_w+1, BLACK);

      if(dbuv>30) dbuv=30;
      tft.drawFastHLine(pos_x_smeter+9*s_w+1, pos_y_smeter, (dbuv/5)*s_w+1, RED);
      tft.drawFastHLine(pos_x_smeter+9*s_w+(dbuv/5)*s_w+1, pos_y_smeter, (6*s_w+1)-(dbuv/5)*s_w, BLACK);
      tft.drawFastHLine(pos_x_smeter+9*s_w+1, pos_y_smeter+1, (dbuv/5)*s_w+1, RED);
      tft.drawFastHLine(pos_x_smeter+9*s_w+(dbuv/5)*s_w+1, pos_y_smeter+1, (6*s_w+1)-(dbuv/5)*s_w, BLACK);
      tft.drawFastHLine(pos_x_smeter+9*s_w+1, pos_y_smeter+2, (dbuv/5)*s_w+1, RED);
      tft.drawFastHLine(pos_x_smeter+9*s_w+(dbuv/5)*s_w+1, pos_y_smeter+2, (6*s_w+1)-(dbuv/5)*s_w, BLACK);

   //   tft.drawFastHLine(pos_x_smeter+9*s_w+1, pos_y_smeter+3, (dbuv/5)*s_w+1, RED);
   //   tft.drawFastHLine(pos_x_smeter+9*s_w+(dbuv/5)*s_w+1, pos_y_smeter+3, (6*s_w+1)-(dbuv/5)*s_w, BLACK);

               
//      tft.fillRect(0, 105, 70, 7,ST7735_BLACK);
//      tft.setCursor(0, 105);
//      if (dbuv == 0) sprintf(string,"S:%1.0f",s);
//      else {
//        sprintf(string,"S:9+%02.0f dB",dbuv);
        
//        }
//      tft.print(string);
//      tft.fillRect(100,105, 50, 7,ST7735_BLACK);
//      tft.setCursor(100,105);
//      sprintf(string,"%04.0f dBm",dbm);
//      tft.print(string);
      uvold = uv;
      } // end if (Smeter Timer)   
  
  startx+=16;
  if(startx >=160) startx=0;


//digitalWrite(DEBUG_PIN,0); // 
}
コード例 #4
0
void setup(void) {

  pinMode(BUTTON,INPUT);
  digitalWrite(BUTTON,HIGH);

  tft.initR(INITR_BLACKTAB);
  tft.fillScreen(ST7735_BLACK);

  int16_t OFFSET = 30;
  int16_t hOld = 0;
  int16_t vOld = 0;
  int16_t original_v = analogRead(VERT);
  int16_t original_h = analogRead(HOR);
  int16_t v = 143;
  int16_t h = 64;

  while (1){
    //  v = OFFSET_V(analogRead(VERT), v, original_v);
    h = OFFSET_H(analogRead(HOR), h, original_h);

    if(hOld != h){
      for(int y = -1; y < 2; y++){
	for(int x = -2; x < 4; x++){
	  //Erase dot at old cursor postion

	  tft.drawPixel(hOld+x, vOld+y, ST7735_BLACK);
	}
      }
      delay(10);
    }

    for(int y = -1; y < 2; y++){
      for(int x = -2; x < 4; x++){

	//Draw dot a new cursor postion

	tft.drawPixel(h+x,v+y,ST7735_WHITE);
      }
    }

    if (digitalRead(BUTTON) == LOW){
      Serial.begin(9600);
      Serial.print("OK");
      int blah = -2;
      int bullet = v;

	//Draw dot a new cursor postion
      for(int blah = -2; bullet + blah > -2; blah--){

	tft.drawPixel(h, bullet + blah + 1, ST7735_BLACK);
	tft.drawPixel(h, bullet + blah, ST7735_WHITE); 
	tft.drawPixel(h, bullet + blah-1, ST7735_WHITE); 
	tft.drawPixel(h, bullet + blah-2, ST7735_WHITE); 
      }     
    }

    //Update the cursor position

    vOld = v;
    hOld = h;
  }
}
コード例 #5
0
ファイル: tft.cpp プロジェクト: ubirch/ubirch-thgs
void setup(void) {
    Serial.begin(BAUD);
    Serial.print("Hello! professorbunsen, I presume? ");

    // Use this initializer if you're using a 1.8" TFT
    //tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

    // Use this initializer (uncomment) if you're using a 1.44" TFT
    tft.initR(INITR_144GREENTAB);   // initialize a ST7735S chip, black tab

    Serial.println("Initialized");

    uint16_t time = millis();
    tft.fillScreen(ST7735_BLACK);
    time = millis() - time;

    Serial.println(time, DEC);
    delay(500);

    // large block of text
    tft.fillScreen(ST7735_BLACK);
    testdrawtext("Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten Rücken und sah, wenn er den Kopf ein wenig hob, seinen gewölbten, braunen, von bogenförmigen Versteifungen geteilten Bauch, auf dessen Höhe sich die Bettdecke, zum gänzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kläglich dünnen Beine flimmerten ihm hilflos vor den Augen. Was ist mit mir geschehen? dachte er. Es war kein Traum.", ST7735_WHITE);
    delay(1000);

    // tft print function!
    tftPrintTest();
    delay(4000);

    // a single pixel
    tft.drawPixel(tft.width()/2, tft.height()/2, ST7735_GREEN);
    delay(500);

    // line draw test
    testlines(ST7735_YELLOW);
    delay(500);

    // optimized lines
    testfastlines(ST7735_RED, ST7735_BLUE);
    delay(500);

    testdrawrects(ST7735_GREEN);
    delay(500);

    testfillrects(ST7735_YELLOW, ST7735_MAGENTA);
    delay(500);

    tft.fillScreen(ST7735_BLACK);
    testfillcircles(10, ST7735_BLUE);
    testdrawcircles(10, ST7735_WHITE);
    delay(500);

    testroundrects();
    delay(500);

    testtriangles();
    delay(500);

    mediabuttons();
    delay(500);

    Serial.println("done");
    delay(1000);
}