|
Post by wetherman on Jul 22, 2014 15:51:50 GMT -8
I am writing an application which uses the USB port for something else so I'd like to print debug output on the Gameduino2 screen. However, when my sketch is running normally, the GD2 is not connected and the sketch blocks (hangs) at GD.begin() {this is in setup() *NOT* GD.Begin() with capital "B"}
I have tried reading analogue inputs to determine if the GD2 is attached, but it's not foolproof. Is there SPI data I can read to see if the thing is connected?
I have also tried GD.begin(0) which also hangs.
|
|
|
Post by jamesbowman on Jul 23, 2014 6:57:27 GMT -8
Hmm, interesting question. Hadn't thought of this use case.
This code is completely standalone, and leaves the connection status. It's safe to call before GD.begin(). It cold starts the FT800, then tries to read its ID register.
And yes, I'll pull this out into "GD.detect()" for the next release.
#define CS 8 pinMode(CS, OUTPUT); digitalWrite(CS, HIGH); pinMode(9, OUTPUT); digitalWrite(9, HIGH); SPI.begin();
digitalWrite(CS, LOW); SPI.transfer(0x00); SPI.transfer(0x00); SPI.transfer(0x00); digitalWrite(CS, HIGH); delay(60);
digitalWrite(CS, LOW); SPI.transfer(0x68); SPI.transfer(0x00); SPI.transfer(0x00); digitalWrite(CS, HIGH); delay(60);
digitalWrite(CS, LOW); SPI.transfer(0x10); SPI.transfer(0x24); SPI.transfer(0x00); SPI.transfer(0x00); byte detected = SPI.transfer(0x00) == 0x7c; digitalWrite(CS, HIGH);
Serial.println(detected);
|
|
|
Post by wetherman on Jul 23, 2014 17:06:05 GMT -8
Thank you sir for your quick reply. I'm honoured. Congratulations on a brilliant product. It makes me smile every time I use it
|
|