Esempio n. 1
0
void setup_display(void) {
  
  // initialize the LCD display
//  tft.init();
//  tft.initR(INITR_BLACKTAB);   // initialize a S6D02A1S chip, black tab
  tft.setRotation(1);
  tft.fillScreen(BLACK); //BLACK);
  //tft.fillRect(0, pos, 160, 128-pos, BLACK); // erase old string
  tft.setCursor(0, 119);
  tft.setTextColor(WHITE);
  tft.setTextWrap(true);
//  tft.print("DD4WH SDR 5.00");
  
  // Show mid screen tune position
  tft.drawFastVLine(pos_centre_f, 0,pos+1, RED); //WHITE);
 // tft.drawFastHLine(0, pos,79, YELLOW);// WHITE);
  //tft.drawFastHLine(81, pos,79, YELLOW);

// draw S-Meter layout
  tft.drawFastHLine (pos_x_smeter, pos_y_smeter-1, 9*s_w, WHITE);
  tft.drawFastHLine (pos_x_smeter, pos_y_smeter+3, 9*s_w, WHITE);
  tft.fillRect(pos_x_smeter, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+8*s_w, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+2*s_w, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+4*s_w, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+6*s_w, pos_y_smeter-3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter+7*s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter+3*s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter+5*s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter+s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter+9*s_w, pos_y_smeter-4, 2, 3, WHITE);
  tft.drawFastHLine (pos_x_smeter+9*s_w, pos_y_smeter-1, 3*s_w*2+2, GREEN);
  tft.drawFastHLine (pos_x_smeter+9*s_w, pos_y_smeter+3, 3*s_w*2+2, GREEN);
  tft.fillRect(pos_x_smeter+11*s_w, pos_y_smeter-4, 2, 3, GREEN);
  tft.fillRect(pos_x_smeter+13*s_w, pos_y_smeter-4, 2, 3, GREEN);
  tft.fillRect(pos_x_smeter+15*s_w, pos_y_smeter-4, 2, 3, GREEN);
  tft.drawFastVLine (pos_x_smeter-1, pos_y_smeter-1, 5, WHITE); 
  tft.drawFastVLine (pos_x_smeter+15*s_w+2, pos_y_smeter-1, 5, GREEN);

  tft.setCursor(pos_x_smeter - 4, pos_y_smeter - 13);
  tft.setTextColor(WHITE);
  tft.setTextWrap(true);
  tft.print("S 1");
  tft.setCursor(pos_x_smeter + 28, pos_y_smeter - 13);
  tft.print("3");
  tft.setCursor(pos_x_smeter + 48, pos_y_smeter - 13);
  tft.print("5");
  tft.setCursor(pos_x_smeter + 68, pos_y_smeter - 13);
  tft.print("7");
  tft.setCursor(pos_x_smeter + 88, pos_y_smeter - 13);
  tft.print("9");
  tft.setCursor(pos_x_smeter + 120, pos_y_smeter - 13);
  tft.print("+20dB");

} // end void setupdisplay
Esempio n. 2
0
void loop() {
    Serial.println("printing though!");
    tft.fillScreen(ST7735_BLACK);
    // tft.setCursor(0, 0);
    tft.setTextColor(ST7735_WHITE);
    tft.setTextWrap(true);
    // tft.setTextSize(3);
    // tft.setCursor(30, 3);
    tft.setFont(HERO_10);
    tft.drawRightString("OTTAWA",  3);

    tft.setFont(HERO_16);
    tft.setTextSize(2);
    // tft.setCursor(25, 20);
    tft.drawRightString("-1  C", 20);

    tft.setTextSize(1);
    // tft.setCursor(35, 60);
    tft.drawRightString("2:35 PM", 60);

    tft.drawFastHLine(0, 90, tft.width(), ST7735_CYAN);

    tft.setTextWrap(true);
    tft.setFont(CENTURY_8);
    tft.setTextSize(1);
    // tft.setCursor(0, tft.height()-65);
    int yPos = tft.drawString("Stay Hungry, Stay Foolish!",  0,tft.height()-65);
    tft.setTextColor(ST7735_CYAN);
    tft.drawRightString(" - Steve Jobs   ", yPos);
    tft.setTextColor(ST7735_MAGENTA);
    delay(5000);
}
Esempio n. 3
0
void testfastlines(uint16_t color1, uint16_t color2) {
    tft.fillScreen(ST7735_BLACK);
    for (int16_t y=0; y < tft.height(); y+=5) {
        tft.drawFastHLine(0, y, tft.width(), color1);
    }
    for (int16_t x=0; x < tft.width(); x+=5) {
        tft.drawFastVLine(x, 0, tft.height(), color2);
    }
}
Esempio n. 4
0
// indicate filter bandwidth on spectrum display
void show_bandwidth(int filtermode) {
  tft.drawFastHLine(0, 61, 160, BLACK); // erase old indicator
  tft.drawFastHLine(0, 62, 160, BLACK); // erase old indicator

  switch (filtermode)	{
    case LSB_NARROW:
      tft.drawFastHLine(72, 61, 6, RED);
      tft.drawFastHLine(72, 62, 6, RED);
      break;
    case LSB_WIDE:
      tft.drawFastHLine(61, 61, 20, RED);
      tft.drawFastHLine(61, 62, 20, RED);
      break;
    case USB_NARROW:
      tft.drawFastHLine(83, 61, 6, RED);
      tft.drawFastHLine(83, 62, 6, RED);
      break;
    case USB_WIDE:
      tft.drawFastHLine(80, 61, 20, RED);
      tft.drawFastHLine(80, 62, 20, RED);
      break;
  }
}
Esempio n. 5
0
void show_s_meter_layout() {
  tft.drawFastHLine (pos_x_smeter, pos_y_smeter - 1, 9 * s_w, WHITE);
  tft.drawFastHLine (pos_x_smeter, pos_y_smeter + 3, 9 * s_w, WHITE);
  tft.fillRect(pos_x_smeter, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 8 * s_w, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 2 * s_w, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 4 * s_w, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 6 * s_w, pos_y_smeter - 3, 2, 2, WHITE);
  tft.fillRect(pos_x_smeter + 7 * s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter + 3 * s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter + 5 * s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter + s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.fillRect(pos_x_smeter + 9 * s_w, pos_y_smeter - 4, 2, 3, WHITE);
  tft.drawFastHLine (pos_x_smeter + 9 * s_w, pos_y_smeter - 1, 3 * s_w * 2 + 2, GREEN);
  tft.drawFastHLine (pos_x_smeter + 9 * s_w, pos_y_smeter + 3, 3 * s_w * 2 + 2, GREEN);
  tft.fillRect(pos_x_smeter + 11 * s_w, pos_y_smeter - 4, 2, 3, GREEN);
  tft.fillRect(pos_x_smeter + 13 * s_w, pos_y_smeter - 4, 2, 3, GREEN);
  tft.fillRect(pos_x_smeter + 15 * s_w, pos_y_smeter - 4, 2, 3, GREEN);
  tft.drawFastVLine (pos_x_smeter - 1, pos_y_smeter - 1, 5, WHITE);
  tft.drawFastVLine (pos_x_smeter + 15 * s_w + 2, pos_y_smeter - 1, 5, GREEN);

  tft.setFont();
  tft.setCursor(pos_x_smeter - 4, pos_y_smeter - 13);
  tft.setTextColor(WHITE);
  tft.setTextWrap(true);
  tft.print("S 1");
  tft.setCursor(pos_x_smeter + 28, pos_y_smeter - 13);
  tft.print("3");
  tft.setCursor(pos_x_smeter + 48, pos_y_smeter - 13);
  tft.print("5");
  tft.setCursor(pos_x_smeter + 68, pos_y_smeter - 13);
  tft.print("7");
  tft.setCursor(pos_x_smeter + 88, pos_y_smeter - 13);
  tft.print("9");
  tft.setCursor(pos_x_smeter + 120, pos_y_smeter - 13);
  tft.print("+20dB");
}
Esempio n. 6
0
void show_notch(int notchF, int MODE) {
  // pos_centre_f is the x position of the Rx centre
  // pos is the y position of the spectrum display 
  // notch display should be at x = pos_centre_f +- notch frequency and y = 20 
  //  LSB: 
  pos_centre_f+=1; // = pos_centre_f + 1;
          // delete old indicator
          tft.drawFastVLine(pos_centre_f + 1 + 160/spectrum_span * oldnotchF / 1000, notchpos, notchL, BLACK);
          tft.drawFastVLine(pos_centre_f + 160/spectrum_span * oldnotchF / 1000, notchpos, notchL, BLACK);
          tft.drawFastVLine(pos_centre_f -1 + 160/spectrum_span * oldnotchF / 1000, notchpos, notchL, BLACK);
          tft.drawFastHLine(pos_centre_f -4 + 160/spectrum_span * oldnotchF / 1000, notchpos+notchL, 9, BLACK);
          tft.drawFastHLine(pos_centre_f -3 + 160/spectrum_span * oldnotchF / 1000, notchpos+notchL + 1, 7, BLACK);
          tft.drawFastHLine(pos_centre_f -2 + 160/spectrum_span * oldnotchF / 1000, notchpos+notchL + 2, 5, BLACK);
          tft.drawFastHLine(pos_centre_f -1 + 160/spectrum_span * oldnotchF / 1000, notchpos+notchL + 3, 3, BLACK);
          tft.drawFastVLine(pos_centre_f + 160/spectrum_span * oldnotchF / 1000, notchpos+notchL + 4, 2, BLACK);

          tft.drawFastVLine(pos_centre_f +1 - 160/spectrum_span * oldnotchF / 1000, notchpos, notchL, BLACK);
          tft.drawFastVLine(pos_centre_f - 160/spectrum_span * oldnotchF / 1000, notchpos, notchL, BLACK);
          tft.drawFastVLine(pos_centre_f -1 - 160/spectrum_span * oldnotchF / 1000, notchpos, notchL, BLACK);
          tft.drawFastHLine(pos_centre_f -4 - 160/spectrum_span * oldnotchF / 1000, notchpos+notchL, 9, BLACK);
          tft.drawFastHLine(pos_centre_f -3 - 160/spectrum_span * oldnotchF / 1000, notchpos+notchL + 1, 7, BLACK);
          tft.drawFastHLine(pos_centre_f -2 - 160/spectrum_span * oldnotchF / 1000, notchpos+notchL + 2, 5, BLACK);
          tft.drawFastHLine(pos_centre_f -1 - 160/spectrum_span * oldnotchF / 1000, notchpos+notchL + 3, 3, BLACK);
          tft.drawFastVLine(pos_centre_f - 160/spectrum_span * oldnotchF / 1000, notchpos+notchL + 4, 2, BLACK);
          // Show mid screen tune position
          tft.drawFastVLine(pos_centre_f - 1, 0,pos+1, RED); //WHITE);

      if (notchF >= 400 || notchF <= -400) {
          // draw new indicator according to mode
      switch (MODE)  {
          case 2: //modeLSB:
          tft.drawFastVLine(pos_centre_f + 1 - 160/spectrum_span * notchF / -1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f - 160/spectrum_span * notchF / -1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f -1 - 160/spectrum_span * notchF / -1000, notchpos, notchL, notchColour);
          tft.drawFastHLine(pos_centre_f -4 - 160/spectrum_span * notchF / -1000, notchpos+notchL, 9, notchColour);
          tft.drawFastHLine(pos_centre_f -3 - 160/spectrum_span * notchF / -1000, notchpos+notchL + 1, 7, notchColour);
          tft.drawFastHLine(pos_centre_f -2 - 160/spectrum_span * notchF / -1000, notchpos+notchL + 2, 5, notchColour);
          tft.drawFastHLine(pos_centre_f -1 - 160/spectrum_span * notchF / -1000, notchpos+notchL + 3, 3, notchColour);
          tft.drawFastVLine(pos_centre_f - 160/spectrum_span * notchF / -1000, notchpos+notchL + 4, 2, notchColour);
          break;
          case 1: //modeUSB:
          tft.drawFastVLine(pos_centre_f +1 + 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f + 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f -1 + 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastHLine(pos_centre_f -4 + 160/spectrum_span * notchF / 1000, notchpos+notchL, 9, notchColour);
          tft.drawFastHLine(pos_centre_f -3 + 160/spectrum_span * notchF / 1000, notchpos+notchL + 1, 7, notchColour);
          tft.drawFastHLine(pos_centre_f -2 + 160/spectrum_span * notchF / 1000, notchpos+notchL + 2, 5, notchColour);
          tft.drawFastHLine(pos_centre_f -1 + 160/spectrum_span * notchF / 1000, notchpos+notchL + 3, 3, notchColour);
          tft.drawFastVLine(pos_centre_f + 160/spectrum_span * notchF / 1000, notchpos+notchL + 4, 2, notchColour);
          break;
          case 0: // modeAM:
          tft.drawFastVLine(pos_centre_f + 1 + 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f + 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f - 1 + 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastHLine(pos_centre_f -4 + 160/spectrum_span * notchF / 1000, notchpos+notchL, 9, notchColour);
          tft.drawFastHLine(pos_centre_f -3 + 160/spectrum_span * notchF / 1000, notchpos+notchL + 1, 7, notchColour);
          tft.drawFastHLine(pos_centre_f -2 + 160/spectrum_span * notchF / 1000, notchpos+notchL + 2, 5, notchColour);
          tft.drawFastHLine(pos_centre_f -1 + 160/spectrum_span * notchF / 1000, notchpos+notchL + 3, 3, notchColour);
          tft.drawFastVLine(pos_centre_f + 160/spectrum_span * notchF / 1000, notchpos+notchL + 4, 2, notchColour);

          tft.drawFastVLine(pos_centre_f + 1 - 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f - 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f - 1 - 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastHLine(pos_centre_f -4 - 160/spectrum_span * notchF / 1000, notchpos+notchL, 9, notchColour);
          tft.drawFastHLine(pos_centre_f -3 - 160/spectrum_span * notchF / 1000, notchpos+notchL + 1, 7, notchColour);
          tft.drawFastHLine(pos_centre_f -2 - 160/spectrum_span * notchF / 1000, notchpos+notchL + 2, 5, notchColour);
          tft.drawFastHLine(pos_centre_f -1 - 160/spectrum_span * notchF / 1000, notchpos+notchL + 3, 3, notchColour);
          tft.drawFastVLine(pos_centre_f - 160/spectrum_span * notchF / 1000, notchpos+notchL + 4, 2, notchColour);
          break;
          case 3: //modeDSB:
          case 4: //modeStereoAM:
          if (notchF <=-400) {
          tft.drawFastVLine(pos_centre_f + 1 - 160/spectrum_span * notchF / -1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f - 160/spectrum_span * notchF / -1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f - 1 - 160/spectrum_span * notchF / -1000, notchpos, notchL, notchColour);
          tft.drawFastHLine(pos_centre_f -4 - 160/spectrum_span * notchF / -1000, notchpos+notchL, 9, notchColour);
          tft.drawFastHLine(pos_centre_f -3 - 160/spectrum_span * notchF / -1000, notchpos+notchL + 1, 7, notchColour);
          tft.drawFastHLine(pos_centre_f -2 - 160/spectrum_span * notchF / -1000, notchpos+notchL + 2, 5, notchColour);
          tft.drawFastHLine(pos_centre_f -1 - 160/spectrum_span * notchF / -1000, notchpos+notchL + 3, 3, notchColour);
          tft.drawFastVLine(pos_centre_f - 160/spectrum_span * notchF / -1000, notchpos+notchL + 4, 2, notchColour);
          }
          if (notchF >=400) {
          tft.drawFastVLine(pos_centre_f + 1 + 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f + 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastVLine(pos_centre_f - 1 + 160/spectrum_span * notchF / 1000, notchpos, notchL, notchColour);
          tft.drawFastHLine(pos_centre_f -4 + 160/spectrum_span * notchF / 1000, notchpos+notchL, 9, notchColour);
          tft.drawFastHLine(pos_centre_f -3 + 160/spectrum_span * notchF / 1000, notchpos+notchL + 1, 7, notchColour);
          tft.drawFastHLine(pos_centre_f -2 + 160/spectrum_span * notchF / 1000, notchpos+notchL + 2, 5, notchColour);
          tft.drawFastHLine(pos_centre_f -1 + 160/spectrum_span * notchF / 1000, notchpos+notchL + 3, 3, notchColour);
          tft.drawFastVLine(pos_centre_f + 160/spectrum_span * notchF / 1000, notchpos+notchL + 4, 2, notchColour);
          }
          break;
      }
      }
      oldnotchF = notchF;
      pos_centre_f-=1; // = pos_centre_f - 1;
  } // end void show_notch
Esempio n. 7
0
void show_bandwidth (int M, long int FU, long int FL) {

   tft.drawFastHLine(0,pos+1,160, BLACK); // erase old indicator
   tft.drawFastHLine(0,pos+2,160, BLACK); // erase old indicator 
   tft.drawFastHLine(0,pos+3,160, BLACK); // erase old indicator
   tft.drawFastHLine(0,pos,160, BLACK); // erase old indicator

      bwhelp = FU /100;
      int leU = bwhelp*16/spectrum_span;
      bwhelp = FL /100;
      int leL = bwhelp*16/spectrum_span;
      float kHz = (FU + FL) / 1000.0;
      
  switch (M) {
  case 0: //AM
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("AM"); 
      break;
  case 3: //DSB
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("DSB"); 
      break;
  case 4: //StereoAM
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("SteAM"); 
      break;
  
  case 2: //LSB
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("LSB"); 
      break;
  case 1:  //USB
      tft.fillRect(4, pos_y_frequency-3, 32, 8, BLACK); // erase old string
      tft.setTextColor(GREEN);
      tft.setCursor(4, pos_y_frequency-3);
      tft.print("USB"); 
      break;
} // end switch
      //print bandwidth !
        tft.fillRect(4, pos_y_frequency+7, 32, 8, BLACK); // erase old string
        tft.setCursor(4, pos_y_frequency+7);
        sprintf(string,"%02.1fk",kHz);
        tft.print(string);
        tft.setTextColor(WHITE); // set text color to white for other print routines not to get confused ;-)
      // draw upper sideband indicator
      tft.drawFastHLine(pos_centre_f, pos+1, leU, RED);
      tft.drawFastHLine(pos_centre_f, pos+2, leU, RED);
      tft.drawFastHLine(pos_centre_f, pos+3, leU, RED);
      tft.drawFastHLine(pos_centre_f, pos, leU, RED);
      // draw lower sideband indicator   
      left = pos_centre_f - leL; 
      tft.drawFastHLine(left+1, pos+1, leL, RED);
      tft.drawFastHLine(left+1, pos+2, leL, RED);
      tft.drawFastHLine(left+1,pos+3, leL, RED);
      tft.drawFastHLine(left+1,pos, leL, RED);

  tft.fillRect(pos_centre_f  + 160/spectrum_span * 5, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  + 160/spectrum_span * 10, pos, 2, 4, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 5, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f - 160/spectrum_span * 10, pos, 2, 4, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 15, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  + 160/spectrum_span * 15, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 20, pos, 2, 4, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 25, pos, 2, 3, YELLOW); // erase old string
  tft.fillRect(pos_centre_f  - 160/spectrum_span * 30, pos, 2, 4, YELLOW); // erase old string
}  
Esempio n. 8
0
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); // 
}
Esempio n. 9
0
void show_Smeter(void) {
  float s_sample = 0;  // Raw signal strength (max per 1ms)
  // Collect S-meter data
  if (Smeter.available()) s_sample = Smeter.read(); // Highest sample within 1 millisecond
  // Calculate S units. 50uV = S9
  uv = (s_sample - 0.005) * 10000; // microvolts, roughly calibrated
  if (uv < 0.1) uv = 0.1; // protect for negative uv
  uv = 0.3 * uv + 0.7 * uvold; // low pass filtering for Smeter values
  dbuv = 20.0 * log10(uv);
  s = 1.0 + (14.0 + dbuv) / 6.0;

#ifdef DEBUG_SMETER
  if (five_sec.check() == 1)
  {
    Serial.print("s_sample = ");
    Serial.print(s_sample);
    Serial.print(" uv = ");
    Serial.print(uv);
    Serial.print(" s =");
    Serial.print(s);
    Serial.print(" dbuv = ");
    Serial.print(dbuv);
    Serial.println("");
  }
#endif
  if (s < 0.0) s = 0.0;
  if (s > 9.0)
  {
    dbuv = dbuv - 34.0;
    s = 9.0;
  }
  else dbuv = 0;
  uvold = uv;

  tft.drawFastHLine(pos_x_smeter, pos_y_smeter, s * s_w + 1, YELLOW);
  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, YELLOW);
  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, YELLOW);
  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);
}