здраствуйте что здес не верно для уно /////////////// // Sketch: Calibrate - Calibrate TFT SPFD5408 Touch // Author: Joao Lopes F. - - вопрос №2714690

joaolopesf@gmail.com // // Versions: // — 0.9.0 First beta — July 2015 // — 0.9.1 Rotation for Mega // Comments: // Show the calibration parameters to put in your code // Please use a small like the eraser on a pencil for best results // // Code for buttons, based on Adafruit arduin_o_phone example /////////////// // library SPFD5408 #include // Core graphics library #include // Hardware-specific library #include // Touch library // Calibrates value #define SENSIBILITY 300 #define MINPRESSURE 10 #define MAXPRESSURE 1000 //These are the pins for the shield! #define YP A1 #define XM A2 #define YM 7 #define XP 6 /* //Macros replaced by variables #define TS_MINX 150 #define TS_MINY 120 #define TS_MAXX 920 #define TS_MAXY 940 */ short TS_MINX=150; short TS_MINY=120; short TS_MAXX=920; short TS_MAXY=940; // Init TouchScreen: TouchScreen ts = TouchScreen(XP, YP, XM, YM, SENSIBILITY); // LCD Pin #define LCD_CS A3 #define LCD_CD A2 #define LCD_WR A1 #define LCD_RD A0 #define LCD_RESET A4 // Optional: otherwise connect to Arduino's reset pin // Assign human-readable names to some common 16-bit color values: #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF // Init LCD Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); // Dimensions uint16_t width = 0; uint16_t height = 0; // Buttons #define BUTTONS 3 #define BUTTON_CLEAR 0 #define BUTTON_SHOW 1 #define BUTTON_RESET 2 Adafruit_GFX_Button buttons[BUTTONS]; uint16_t buttons_y = 0; //-- Setup void setup(void) { // Serial por for debug, not works if shield is plugged in arduino // Serial.begin(9600); // Inicialize the controller tft.reset(); tft.begin(0x9341); tft.setRotation(0); // Need for the Mega, please changed for your choice or rotation initial width = tft.width() — 1; height = tft.height() — 1; // Debug // Serial.println(F(«TFT LCD test»)); // Serial.print(«TFT size is „); // Serial.print(tft.width()); // Serial.print(“x»); // Serial.println(tft.height()); // UI initializeButtons(); // Border drawBorder(); // Initial screen tft.setCursor (55, 50); tft.setTextSize (3); tft.setTextColor(RED); tft.println(«SPFD5408»); tft.setCursor (65, 85); tft.println(«Library»); tft.setCursor (55, 150); tft.setTextSize (2); tft.setTextColor(BLACK); tft.println(«Calibration»); tft.setCursor (80, 250); tft.setTextSize (1); tft.setTextColor(BLACK); tft.println(«Touch to proceed»); // Wait touch waitOneTouch(); // Calibrate it calibrate_TS(); // Wait touch waitOneTouch(); // Calibration showCalibration(); } // — Loop void loop() { // Test of calibration TSPoint p; // Wait a touch digitalWrite(13, HIGH); p = waitOneTouch(); digitalWrite(13, LOW); // Map of values // p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width()); // p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height()); p.x = mapXValue(p); p.y = mapYValue(p); // Draw a point tft.fillCircle(p.x, p.y, 3, BLUE); // Show touch screen point (TSPOINT) showTouched(p); // Buttons // Go thru all the buttons, checking if they were pressed for (uint8_t b=0; b (width — limit) && mapYValue(p2) > (height — limit))); tft.fillScreen(BLACK); delay (300); temp=p2.x-p1.x; // Calculate the new coefficients, get X difference tempL=((long)temp*1024)/(tft.width()-20); TS_MINX=p1.x-( (tempL*10)>>10);// 10 pixels du bord TS_MAXX=p1.x+( (tempL*tft.width())>>10);// 220 pixels entre points temp=p2.y-p1.y; // ¨get Y difference tempL=((long)temp*1024)/(tft.height()-20); TS_MINY=p1.y-( (tempL*10)>>10);// 10 pixels du bord TS_MAXY=TS_MINY+( (tempL*tft.height())>>10); // Show results showResults(); // p1.x = map(p1.x, TS_MAXX,TS_MINX, tft.width(), 0); // p1.y = map(p1.y, TS_MAXY,TS_MINY, tft.height(), 0); // p2.x = map(p2.x, TS_MAXX,TS_MINX, tft.width(), 0); // p2.y = map(p2.y, TS_MAXY,TS_MINY, tft.height(), 0); p1.x = mapXValue(p1); p1.y = mapYValue(p1); p2.x = mapXValue(p2); p2.y = mapYValue(p2); tft.println(); tft.println(«Last touched points: „); tft.print(“Pt 1: „);tft.print(p1.x);tft.print(“: „);tft.println(p1.y); tft.print(“Pt 2: „);tft.print(p2.x);tft.print(“: „);tft.println(p2.y); tft.println(); // Wait a touch tft.println(“Touch to proceed»); waitOneTouch(); } // wait 1 touch to return the point TSPoint waitOneTouch() { TSPoint p; do { p= ts.getPoint(); pinMode(XM, OUTPUT); //Pins configures again for TFT control pinMode(YP, OUTPUT); } while((p.z < MINPRESSURE )|| (p.z > MAXPRESSURE)); return p; } // Draw a border void drawBorder () { uint16_t width = tft.width() — 1; uint16_t height = tft.height() — 1; uint8_t border = 10; tft.fillScreen(RED); tft.fillRect(border, border, (width — border * 2), (height — border * 2), WHITE); } // Show a screen of calibration void showCalibration() { // Clear tft.fillScreen(BLACK); tft.setTextSize (1); // Header tft.fillRect(0, 0, width, 10, RED); tft.setCursor (40, 0); tft.setTextColor(WHITE); tft.println("*** Test of calibration ***"); // Footer TSPoint p; // Only for show initial values p.x=0; p.y=0; p.z=0; showTouched(p); // Buttons for (uint8_t i=0; i

Ответы

Вы всерьез считаете, что кто-то сможет это разобрать? Кусок программы, явно незавершенной, точнее оборванной на половине оператора.  К тому же программа для ардуино рассматривается только вместе со схемой. Да и для этого есть специализированные форумы.
31.12.17

Еva

от 100 p.
Читать ответы
Посмотреть всех экспертов из раздела Учеба и наука > Информатика
Пользуйтесь нашим приложением Доступно на Google Play Загрузите в App Store