|
Post by fixitchris on Jul 9, 2015 6:05:57 GMT -8
Hello. I am having a hard time getting GD2 and redbearlab.com/bleshield/ to cooperate. For the BLE shield I am using The BLE shield uses SPI on D11, D12, and D13. And SS on D10. I have changed the default REQN and RDYN pins from D9, D8 to D6, D5.
With both GD2 and BLE plugged in (SD card removed) I can run GD.begin(0) and run all the GUI no problem, as long as I do not setup BLE. The SD card inserted works fine with only the GD2 shield. When I stack BLE and GD2 with SD card inserted, the GUI runs for 30 seconds and then GD2 goes dark. So I removed the SD card for now. Also when I run the self-test I do get 'RAM failed' (GD2 only on UNO). Here is what I tried next but BLE never starts up and GD2 stays black, never even goes into the calibration routine. Any help would be appreciated. Thanks Chris void setup() { Serial.begin(57600);
SPI.begin(); pinMode(10,OUTPUT); //idle ble digitalWrite(10,HIGH); //pinMode(9,OUTPUT); //spin sd //digitalWrite(9,LOW); pinMode(8,OUTPUT); //spin gpu digitalWrite(8,LOW);
GD.begin(0); GD.cmd_calibrate();
GD.__end(); ble_set_pins(5,6); ble_set_name("Aloha"); ble_begin(); GD.resume(); }
|
|
|
Post by jamesbowman on Jul 9, 2015 6:29:40 GMT -8
Hi Chris,
Quick first question... have you confirmed that BLE starts up with the GD2 physically connected but no GD.begin(), e.g.:
void setup() { Serial.begin(57600);
SPI.begin(); pinMode(10,OUTPUT); //idle ble digitalWrite(10,HIGH); //pinMode(9,OUTPUT); //spin sd //digitalWrite(9,LOW); pinMode(8,OUTPUT); //spin gpu digitalWrite(8,LOW);
// GD.begin(0); / GD.cmd_calibrate();
// GD.__end(); ble_set_pins(5,6); ble_set_name("Aloha"); ble_begin(); // GD.resume(); }
|
|
|
Post by fixitchris on Jul 9, 2015 6:42:36 GMT -8
James:
No it does not. Building from 1.6.5 leaves the GD2 lit up white. (both SD card in and out)
void setup() { Serial.begin(57600);
SPI.begin(); pinMode(10,OUTPUT); //idle ble digitalWrite(10,HIGH); pinMode(8,OUTPUT); //spin gpu digitalWrite(8,LOW);
ble_set_pins(5,6); ble_set_name("Aloha"); ble_begin();
Serial.println("done"); }
void loop() { ble(); }
void ble() { if ( ble_available() ) { while ( ble_available() ) Serial.write(ble_read()); Serial.println(); } if ( Serial.available() ) { delay(5); while ( Serial.available() ) ble_write( Serial.read() ); } ble_do_events(); }
|
|
|
Post by jamesbowman on Jul 9, 2015 7:00:19 GMT -8
OK, then that suggests a power issue - if everything were fine I would expect the GD2 screen to stay dark and the BLE to start up happily.
Have you tried a different USB cable, and port?
|
|
|
Post by fixitchris on Jul 9, 2015 7:07:38 GMT -8
Let me try a different power source. I will try an iPad charger. What is the appropriate amperage at 5V for this setup?
BLE does work when I change pin 8 to high (GD2 + BLE stacked)
void setup() { Serial.begin(57600);
SPI.begin(); pinMode(10,OUTPUT); //idle ble digitalWrite(10,HIGH); pinMode(8,OUTPUT); //idle gpu digitalWrite(8,HIGH);
ble_set_pins(5,6); ble_set_name("Aloha"); ble_begin(); }
|
|
|
Post by fixitchris on Jul 9, 2015 7:12:28 GMT -8
I tried the iPad charger 5.2V, 2.4A, 12W. Same effect with pin 8 LOW. GD2 lights up and no BLE.
|
|
|
Post by jamesbowman on Jul 9, 2015 7:56:07 GMT -8
GD2 draws around 240mA, but I have had reports of up to 400mA draw from some people.
OK, so does adding GD.begin(0); to the end of this code get the GD2 screen running?
|
|
|
Post by fixitchris on Jul 9, 2015 8:03:39 GMT -8
No, it gets stuck in GD.begin(). I am also reading up on SPI issues in the RedBearLab forum, but nothing so far has helped. redbearlab.zendesk.com/entries/74247699-BLE-Shield-with-SDvoid setup() { Serial.begin(57600);
SPI.begin(); pinMode(10,OUTPUT); //idle ble digitalWrite(10,HIGH); pinMode(8,OUTPUT); //idle gpu digitalWrite(8,HIGH);
ble_set_pins(5,6); ble_set_name("Aloha"); ble_begin();
Serial.println(F("setup 1"));
GD.begin(0);
Serial.println(F("setup 2")); }
|
|
|
Post by fixitchris on Jul 9, 2015 8:16:55 GMT -8
I have also seen this... does this make sense?
|
|
|
Post by fixitchris on Jul 9, 2015 8:33:31 GMT -8
GD2 draws around 240mA, but I have had reports of up to 400mA draw from some people. OK, so does adding GD.begin(0); to the end of this code get the GD2 screen running? I was able to reorder and the calls and the GD2 stays black. If I replace the loop() with BLE logic then BLE works. So at least this gets past GD.begin(). But GD2 stays black, no text. void loop() { GD.ClearColorRGB(0x103000); GD.Clear(); GD.cmd_text(240, 136, 31, OPT_CENTER, "Hello world"); GD.swap(); }
void setup() { Serial.begin(57600);
pinMode(10,OUTPUT); // spi ble pinMode(9,OUTPUT); // spi sd pinMode(8,OUTPUT); // spi gpu SPI.begin(); GD.begin(0);
ble_set_pins(5,6); ble_set_name("Aloha"); ble_begin();
Serial.println(F("setup done")); }
|
|
|
Post by fixitchris on Jul 9, 2015 10:05:02 GMT -8
|
|
|
Post by fixitchris on Jul 9, 2015 10:50:58 GMT -8
James: I have tried this.
BLE outputs to the console that it is advertising, but I am unable to detect it still. GD draws to screen.
If I comment the below to lines in the loop() then of course GD stops drawing but BLE is detectable. useGdSpi(); gui();
void loop() { //if(ble_busy()) { useBleSpi(); ble(); //} useGdSpi(); gui(); }
void setup() { Serial.begin(57600);
pinMode(10,OUTPUT); // spi ble pinMode(9,OUTPUT); // spi sd pinMode(8,OUTPUT); // spi gpu GD.begin(0);
useBleSpi(); ble_set_pins(5,6); ble_set_name("Aloha"); ble_begin();
Serial.println(F("setup done")); }
void useBleSpi() { deactivateGdSpi(); activateBleSpi(); }
void useGdSpi() { deactivateBleSpi(); activateGdSpi(); }
void activateBleSpi() { SPI.setBitOrder(LSBFIRST); digitalWrite(10,LOW); }
void deactivateBleSpi() { digitalWrite(10,LOW); }
void activateGdSpi() { SPI.setBitOrder(MSBFIRST); digitalWrite(9,LOW); digitalWrite(8,LOW); }
void deactivateGdSpi() { digitalWrite(9,HIGH); digitalWrite(8,HIGH); }
|
|
|
Post by fixitchris on Jul 9, 2015 12:36:45 GMT -8
OK, so I have a couple different behaviors happening.
In the below code if I use GD.finish() then it never completes. If I use GD.flush() then it runs and BLE works but nothing gets drawn to GD.
any more ideas ?
void loop() { // perform GD tasks first // this allows the calibration to halt execution on the first loop iteration
// if ble SPI is free then do GD if(!ble_busy()) { Serial.println(F("gui")); useGdSpi();
GD.ClearColorRGB(0x103000); GD.Clear(); GD.cmd_text(240, 136, 31, OPT_CENTER, "Hello world"); GD.swap(); GD.finish(); //GD.flush();
Serial.println(F("gui 2")); //gui(); //touch(); }
// do BLE useBleSpi(); ble();
Serial.println(F("loop")); }
void setup() { Serial.begin(57600);
Serial.println(F("setup start"));
pinMode(10,OUTPUT); // spi ble pinMode(9,OUTPUT); // spi sd pinMode(8,OUTPUT); // spi gpu
GD.begin(0); //GD.cmd_calibrate();
useBleSpi();
ble_set_pins(5,6); ble_set_name("Aloha"); ble_begin(); Serial.println(F("setup done")); }
void useBleSpi() { if(_spi_ble==1) return; deactivateGdSpi(); activateBleSpi(); _spi_gd = 0; _spi_ble = 1; }
void useGdSpi() { if(_spi_gd==1) return; deactivateBleSpi(); activateGdSpi(); _spi_ble = 0; _spi_gd =1; }
void activateBleSpi() { //SPI.setDataMode(SPI_MODE0); //SPI.setClockDivider(SPI_CLOCK_DIV16); SPI.setBitOrder(LSBFIRST); digitalWrite(10,LOW); }
void deactivateBleSpi() { digitalWrite(10,HIGH); }
void activateGdSpi() { SPI.setBitOrder(MSBFIRST); digitalWrite(9,LOW); digitalWrite(8,LOW); //GD.resume(); }
void deactivateGdSpi() { //GD.pause(); digitalWrite(9,HIGH); digitalWrite(8,HIGH); }
|
|
|
Post by fixitchris on Jul 10, 2015 6:52:40 GMT -8
Ok, here is another iteration and GD2 + BLE Shield Work!
The only odd thing happens is that when I insert the SD card, GD goes black, when I remove it, GD continues to draw.
void setup() { Serial.begin(57600);
Serial.println(F("setup start"));
pinMode(10,OUTPUT); // spi ble pinMode(9,OUTPUT); // spi sd pinMode(8,OUTPUT); // spi gpu
GD.begin(0); // BUG: touches are incorrect // perform and write calibration to EEPROM //GD.cmd_calibrate(); //GD.force_calibrate(); Serial.println(F("setup done")); }
void loop() { // if ble SPI is free then do GD if(!ble_busy()) { useGdSpi(); gui(); touch(); }
// do BLE useBleSpi(); ble();
//rfReceive(); }
void useBleSpi() { if(_spi_ble==1) return; deactivateGdSpi(); activateBleSpi(); _spi_gd = 0; _spi_ble = 1; }
void useGdSpi() { if(_spi_gd==1) return; deactivateBleSpi(); activateGdSpi(); _spi_ble = 0; _spi_gd =1; }
void activateBleSpi() { digitalWrite(10,LOW); SPI.begin(); //SPI.setDataMode(SPI_MODE0); //SPI.setClockDivider(SPI_CLOCK_DIV16); SPI.setBitOrder(LSBFIRST); }
void deactivateBleSpi() { digitalWrite(10,HIGH); }
void activateGdSpi() { digitalWrite(9,LOW); digitalWrite(8,LOW); SPI.begin(); SPI.setBitOrder(MSBFIRST); GD.resume(); }
void deactivateGdSpi() { GD.__end(); digitalWrite(9,HIGH); digitalWrite(8,HIGH); }
|
|
|
Post by jamesbowman on Jul 10, 2015 8:52:32 GMT -8
Aha, so activateGdSpi() is actually turning on both SD and GPU. GD.resume() itself lowers pin 8 (GPU sel), so I think this will work:
void activateGdSpi() { SPI.begin(); SPI.setBitOrder(MSBFIRST); GD.resume(); }
|
|