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
void main_display(void) { tft.fillScreen(BLACK); tft.setFont(&FreeSans9pt7b); // Show mid screen tune position tft.drawFastVLine(80, 0, 60, RED); show_s_meter_layout(); }
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); } }
void show_spectrum(void) { static int startx = 0, endx; endx = startx + 16; int scale = 1; //digitalWrite(DEBUG_PIN,1); // for timing measurements for (int16_t x = startx; x < endx; x += 2) { int bar = abs(myFFT.output[x * 8 / 10]) / scale; if (bar > 60) bar = 60; if (x != 80) { tft.drawFastVLine(x, 60 - bar, bar, GREEN); tft.drawFastVLine(x, 0, 60 - bar, BLACK); } } startx += 16; if (startx >= 160) startx = 0; //digitalWrite(DEBUG_PIN,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"); }
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