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_main.cpp
- Revision:
- 12:29f5ad896382
- Parent:
- 11:3ebd2263f3e9
- Child:
- 13:1a0800957412
diff -r 3ebd2263f3e9 -r 29f5ad896382 Picaso_4DGL-32PTU_main.cpp
--- a/Picaso_4DGL-32PTU_main.cpp Tue Sep 13 11:37:04 2016 +0000
+++ b/Picaso_4DGL-32PTU_main.cpp Wed Sep 14 13:27:37 2016 +0000
@@ -25,10 +25,9 @@
PICASO_4DGL :: PICASO_4DGL(PinName tx, PinName rx, PinName rst) : pc(USBTX, USBRX), _cmd(tx, rx), _rst(rst) { // Constructor
rxBuf[RXBUFLEN] = 0; // create buffer
+ buffer[BUFFER_SIZE] = 0;
index = 0;
- //trig = 0;
- _cmd.attach(this, &PICASO_4DGL::rxCallback, Serial::RxIrq); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- //responseBuild(10);
+ _cmd.attach(this, &PICASO_4DGL::rxCallback, Serial::RxIrq);
pc.baud(115200);
#if DEBUGMODE
@@ -37,10 +36,8 @@
pc.printf("PICASO_4DGL CONSTRUCTOR\n\r");
pc.printf("********************\n\r");
#endif
-
_rst = 1; // put RESET pin to high to start TFT screen
- //wait_ms(10000);
- //reset();
+
#if DEBUGMODE
pc.printf("Wait 3 seconds for startup...\n\r");
#endif
@@ -54,18 +51,16 @@
#if DEBUGMODE
pc.printf("clear screen...\n\r");
#endif
- cls(); // clear screen
wait_ms(1000);
- screenMode(1);
- setFont(3);
- //graphicsDemo();
+ screenMode(landscape);
+ setFont(font3);
+ cls();
-#if DEBUGMODE
- pc.printf("Start Demo...\n\r");
- wait_ms(1000);
+#if DEMO
//mainDemo();
//textDemo();
- graphicsDemo();
+ //graphicsDemo();
+ mediaDemo();
#endif
}
@@ -222,67 +217,143 @@
freeBUFFER();
//Change baudrates - as instructed by 4DGL
- if (speed == 128000) speed = 133928;
- if (speed == 256000) speed = 282353;
+ if (speed == 128000) speed = 133929;
+ if (speed == 256000) speed = 281250;
if (speed == 300000) speed = 312500;
- if (speed == 375000) speed = 401785;
+ if (speed == 375000) speed = 401786;
if (speed == 500000) speed = 562500;
if (speed == 600000) speed = 703125;
for (i = 0; i <4; i++) writeBYTE(command[i]); // send command to serial port
- _cmd.baud(speed); // set mbed to same speed
-
+ _cmd.baud(speed);
getResponse(1);
}
//**************************************************************************
-void PICASO_4DGL :: getResponse(int count) {
+bool PICASO_4DGL :: getResponse(int count) {
- pc.printf("\n\r Wait for answer...");
- while (index < count) wait_ms(100); // wait for screen answer
+#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
- pc.printf("\n\r INDEX = %i\n\r", index);
- pc.printf("\n\r 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");
- index = 0;
+#endif
+ if (rxBuf[0] == 0x06) {
+ index = 0; // set buffer index to 0
+ return true;
+ }
+ else {
+ index = 0;
+ return false;
+ }
}
//**************************************************************************
-void PICASO_4DGL :: calculateOrbitResponse() {
+bool PICASO_4DGL :: calculateOrbitResponse() {
- pc.printf("\n\r Wait for answer...");
- while (index < 5) wait_ms(100); // wait for screen answer
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Wait for answer...");
+#endif
+ while (index < 5) wait_ms(100); // wait for screen answer
- pc.printf("\n\r INDEX = %i\n\r", index);
- pc.printf("\n\r 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];
- pc.printf("\n\r New coordiantes = %i x %i\n\r", Xdest, Ydest);
- index = 0;
+#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() {
- short answer = 0;
- pc.printf("\n\r Wait for answer...");
- while (index < 3) wait_ms(100); // wait for screen answer
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Wait for answer...");
+#endif
+ while (index < 3) wait_ms(100); // wait for screen answer
- pc.printf("\n\r INDEX = %i\n\r", index);
- pc.printf("\n\r 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]);
}
- answer = rxBuf[1] << 8 | rxBuf[2];
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(".");
+#endif
+ }
+#if DEBUGMODE
+ pc.printf("\n\r");
+#endif
+
+#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
+ int j = 3;
+ for (int i = 0; i < BUFFER_SIZE; i++) {
+ buffer[i] = rxBuf[j];
+ j++;
+ }
+ if (rxBuf[0] == 0x06) {
+ index = 0; // set buffer index to 0
+ return true;
+ }
+ else {
+ index = 0;
+ return false;
+ }
+}