Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Picaso_4DGL-32PTU_Response.cpp
- Revision:
- 17:5bf7947c3c19
- Child:
- 18:829f3e2c064c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Picaso_4DGL-32PTU_Response.cpp Thu Sep 15 12:28:47 2016 +0000
@@ -0,0 +1,195 @@
+//
+// Picaso_4DGL-32PTU is a class to drive 4D Systems TFT touch screens with PICASO processor
+// Tested with NUCLEO L152RE development board
+// Copyright (C) <2016> Rihards Balass <rihards.balass@gmail.com>
+//
+// Picaso_4DGL-32PTU is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Picaso_4DGL-32PTU is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You can see GNU General Public License at <http://www.gnu.org/licenses/>.
+//
+
+#include "mbed.h"
+#include "Picaso_4DGL-32PTU.h"
+
+
+//**************************************************************************
+bool PICASO_4DGL :: getResponse(int count) {
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Wait for answer...");
+#endif
+ //pc.printf("\n\r count = %i, index = %i", count, index);
+ while (index < count) wait_ms(100); // wait for screen answer
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Answer = ");
+ for (int i = 0; i < index; i++) {
+ pc.printf("%02X ", rxBuf[i]);
+ }
+ pc.printf("\n\r");
+#endif
+ if (rxBuf[0] == 0x06) {
+ index = 0; // set buffer index to 0
+ return true;
+ }
+ else {
+ index = 0;
+ return false;
+ }
+}
+
+//**************************************************************************
+bool PICASO_4DGL :: calculateOrbitResponse() {
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Wait for answer...");
+#endif
+ while (index < 5) wait_ms(100); // wait for screen answer
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Answer = ");
+ for (int i = 0; i < index; i++) {
+ pc.printf("%02X ", rxBuf[i]);
+ }
+ pc.printf("\n\r");
+#endif
+ Xdest = rxBuf[1] << 8 | rxBuf[2];
+ Ydest = rxBuf[3] << 8 | rxBuf[4];
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: New coordiantes = %i x %i\n\r", Xdest, Ydest);
+#endif
+ index = 0; // set buffer index to 0
+ return true;
+}
+
+
+//**************************************************************************
+short PICASO_4DGL :: getGraphicsResponse() {
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Wait for answer...");
+#endif
+ while (index < 3) wait_ms(100); // wait for screen answer
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Answer = ");
+ for (int i = 0; i < index; i++) {
+ pc.printf("%02X ", rxBuf[i]);
+ }
+ pc.printf("\n\r");
+#endif
+ short answer = rxBuf[1] << 8 | rxBuf[2]; // set response variable
+ index = 0; // set buffer index to 0
+ return answer;
+}
+
+//**************************************************************************
+short PICASO_4DGL :: mediaInitResponse() {
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Wait for answer...");
+#endif
+ while (index < 3) wait_ms(100); // wait for screen answer
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Answer = ");
+ for (int i = 0; i < index; i++) {
+ pc.printf("%02X ", rxBuf[i]);
+ }
+ pc.printf("\n\r");
+#endif
+ short answer = rxBuf[1] << 8 | rxBuf[2];
+ index = 0;
+ return answer;
+}
+
+//**************************************************************************
+bool PICASO_4DGL :: readSectorResponse(int count) {
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Wait for answer");
+#endif
+
+ while (index < count) wait_ms(100); // wait for screen answer
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Answer = ");
+ pc.printf("%02X %02X %02X\n\r", rxBuf[0], rxBuf[1], rxBuf[2]);
+#endif
+
+ int j = 3;
+ for (int i = 0; i < BUFFER_SIZE; i++) {
+ buffer[i] = rxBuf[j];
+ j++;
+ }
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Buffer = ");
+ for (int i = 0; i < BUFFER_SIZE; i++) {
+ pc.printf("%02X ", buffer[i]);
+ }
+ pc.printf("\n\r");
+#endif
+ if (rxBuf[2] == 1) {
+ index = 0; // set buffer index to 0
+ return true;
+ }
+ else {
+ index = 0;
+ return false;
+ }
+}
+
+//**************************************************************************
+bool PICASO_4DGL :: writeSectorResponse(int count) {
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Wait for answer");
+#endif
+ while (index < count) wait_ms(100); // wait for screen answer
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Answer = ");
+ pc.printf("%02X %02X %02X\n\r", rxBuf[0], rxBuf[1], rxBuf[2]);
+#endif
+
+ if (rxBuf[2] == 1) {
+ index = 0; // set buffer index to 0
+ return true;
+ }
+ else {
+ index = 0;
+ return false;
+ }
+}
+
+//**************************************************************************
+bool PICASO_4DGL :: readByteResponse(int count) {
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Wait for answer");
+#endif
+
+ while (index < count) wait_ms(100); // wait for screen answer
+
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Answer = ");
+ pc.printf("%02X %02X %02X\n\r", rxBuf[0], rxBuf[1], rxBuf[2]);
+#endif
+
+ if (rxBuf[0] == 6) {
+ index = 0; // set buffer index to 0
+ return true;
+ }
+ else {
+ index = 0;
+ return false;
+ }
+}