T3.6 USB Host - Bluetooth

Code:
if ((((bluetooth_class & 0xff00) == 0x2500) || (((bluetooth_class & 0xff00) == 0x500))) && (bluetooth_class & 0x40)) {

I guess this is where I should be looking for?
 
This is what I get with other keyboard device :

Code:
*** Device Bluet a5c:21e8 - connected ***
  manufacturer: Broadcom Corp
  product: BCM20702A0
  Serial: 5CF3708B497F
    control callback (bluetooth) 1
0E 04 01 03 0C 00 
    control callback (bluetooth) 3
0E 04 01 24 0C 00 
    control callback (bluetooth) 4
0E 0A 01 09 10 00 7F 49 8B 70 F3 5C 
    control callback (bluetooth) 4
0E 0C 01 01 10 00 06 00 10 06 0F 00 0E 22 
    control callback (bluetooth) 6
0E 04 01 45 0C 00 
    control callback (bluetooth) 7
0E 04 01 01 0C 00 
    control callback (bluetooth) 8
0F 04 00 01 01 04 
2F FF 01 D0 7A BE 6A 6A D4 01 00 3C 04 08 E7 62 
C3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 
2F FF 01 D0 7A BE 6A 6A D4 01 00 3C 04 08 E7 62 
C2 0C 09 58 42 52 2D 34 39 58 38 30 30 45 09 03 
0A 11 0C 11 0E 11 00 12 01 05 01 07 03 3D 07 64 
06 FF 0F 00 00 01 64 02 0A 07 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00


I am using serial0 now and trying to figure out what needs to be changed to make this keyboard like device pair as well.
 
@mjs513 - I hope you don't mind I did a little updating (mostly comments) and remove compiler warning on Packman... I removed the ili9341_due_config.h file as I commented out the whole file and it still built.

I also put in comments talking about currently requiring libraries from my github. Also mentioned the which IO pins were used...

Also to let people know that the screen is actually working, I put a message on the screen saying waiting for joystick to connect.

Kurt
 
That sounds like welcome additions/edits Kurt - now maybe I can even see it work. Will update when I get to that as I'd like to see it.
 
@milan7 - Not sure what you are asking. If I remember correctly you are using one of the RII BT keyboards?

To get it to connect you need to compile in the version of Bluetooth controller object that does the pairing:
BluetoothController bluet(myusb, true, "0000"); // Version does pairing to device

Then when the program runs, you should hit the Bluetooth button and then hopefully be able to hit the PIN number: 0000 <enter>
And hopefully then it should bind.

Again Note: At some point I would love to clean up some of this stuff and to not necessarily have to build in the pairing version of constructor, but later be able to do something (like enter command) or button on unit or... Which would call off to start a pairing. Then it should also output messages like waiting for you to enter your keycode.... Also maybe allow you to type in what keycode you want...

But until then ...
 
@mjs513 - I hope you don't mind I did a little updating (mostly comments) and remove compiler warning on Packman... I removed the ili9341_due_config.h file as I commented out the whole file and it still built.

I also put in comments talking about currently requiring libraries from my github. Also mentioned the which IO pins were used...

Also to let people know that the screen is actually working, I put a message on the screen saying waiting for joystick to connect.

Kurt

Kurt
No pride of authorship here :) Community effort will make it better Glad you made the changes and good idea about comment on screen :)

Mike
 
@KurtE

Ok loaded up the pacman sketch and it ran fine no problem, just way too fast so I went in to make 1 change and T$ hung again - lost usb: Board at usb:0/140000/0/A/7 is not available. Have you tried it, i.e., load and reload
 
@mjs513 - yes and no... I have loaded multiple times and have not seen that.... but I am trying to get the display to work when dc is not on cs pin, and having some issues.
 
@mjs513 - yes and no... I have loaded multiple times and have not seen that.... but I am trying to get the display to work when dc is not on cs pin, and having some issues.

Interesting, could just be something with my T4.

Good luck with the making change over, sounds like its going to be a bear.
 
Interesting, could just be something with my T4.

Good luck with the making change over, sounds like its going to be a bear.

Thanks, some of it was remembering some of the issues I ran into earlier with things not working... Things like better not tell the SPI to set the CS Continue bit if are then going to want to drain the queue... It will hold the clock high... So checking some of that and making some progress. At least when I first tried it, it only output the first byte of the init code, Now it looks like it has fully output the init, and now maybe now I am too the setRotation call appearing not to work...
 
@milan7 - Not sure what you are asking. If I remember correctly you are using one of the RII BT keyboards?

To get it to connect you need to compile in the version of Bluetooth controller object that does the pairing:
BluetoothController bluet(myusb, true, "0000"); // Version does pairing to device

Then when the program runs, you should hit the Bluetooth button and then hopefully be able to hit the PIN number: 0000 <enter>
And hopefully then it should bind.

Again Note: At some point I would love to clean up some of this stuff and to not necessarily have to build in the pairing version of constructor, but later be able to do something (like enter command) or button on unit or... Which would call off to start a pairing. Then it should also output messages like waiting for you to enter your keycode.... Also maybe allow you to type in what keycode you want...

But until then ...

Yes, I got the RII BT keyboard working. Now I am trying to modify the code to work with another HID Keyboard device. The new device that I am testing doesn't require the step that you enter 0000 and press enter. I am trying to change the advertising report part. The only issue is that it shows up as a bluetooth device when it's in pairing mode for few seconds.
 
@KurtE

Progress is still progress.

I found another ILI9341 library that has a ton of examples that look like a lot of fun. A couple work out of the box. But a couple I have questions on if I may. The sketch is calling writecommand and writedata from a function directly. What is the equivalent I can use?

EDIT: Never mind rolled my own...
 
Last edited:
@KurtE

Since we are beginning to digress from Bluetooth to Displays maybe its time to start a new thread on the changes to ILI9341 library?
 
PacAman { [sp] github comment :) } works on FrankB's TFT C64/Teensy64 with T_3.6, using PS3 - with needed edits below.
I see PATIENCE allows it to connect - I was unplugging Dongle and retrying. Using the OLD MSI dongle as it was paired and the LED is on the wrong side to see blink.
Isn't this a Joystick game … buttons? - I compiled at 120 MHz ... doesn't help me play, even speed=SLOW., though I do okay in DEMO mode :)
Did anyone try VGA mode? I have that with FrankB's PCB here.
Code:
#define __C64__ 1

// Connection konfiguration of ILI9341 LCD TFT
#if defined(__MK66FX1M0__) 
[COLOR="#FF0000"]#if defined(__C64__) 
#define SCK       14
#define MISO      39
#define MOSI      28
#define TFT_RST 255
#define TFT_DC 20
#define TFT_CS 21
[/COLOR]#else
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
#endif
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
// On Teensy 4 beta with Paul's breakout out: 
// Using pins (MOSI, MISO, SCK which are labeled on Audio board breakout location 
// which are not in the Normal processor positions
// Also DC=10(CS), CS=9(BCLK) and RST 23(MCLK)
#define TFT_RST 23
#define TFT_DC 10
#define TFT_CS 9
#else
#error "This example App will only work with Teensy 3.6 or Teensy 4."
#endif

[COLOR="#FF0000"]#if defined(__C64__) 
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST, MOSI, SCK, MISO, &SPIN );
[/COLOR]#else
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST);
#endif

And in setup:
Code:
#if defined(__C64__) 
SPIN.setMOSI(MOSI);
SPIN.setMISO(MISO);
SPIN.setSCK(SCK);
#endif

And I have it with USB cord up so:
Code:
#if defined(__C64__) 
  tft.setRotation(0); // 0
#else
  tft.setRotation(2); // 180
#endif
 
@defragster

Isn't this a Joystick game … buttons? - I compiled at 120 MHz ... doesn't help me play, even speed=SLOW., though I do okay in DEMO mode
Actually it was originally designed for buttons but he had a modification to allow to be used with a SNES controller. Was thinking at some point to change it to use the joystick :). Think I mentioned that a bunch of posts ago.

Anyway I found that it was way too fast for me play so I just made a mod to slow the game down:
Code:
        //  Calculate speed
        s->_speed += (GetSpeed(s)*0.4);
Added 0.4 to slow the game down even more for the Teensy. Give it a try. Probably should make it a define.
 
Last edited:
@KurtE and @defragster and others

In going through this https://github.com/Bodmer/TFT_ILI9341_ESP ILI9341 library there are some interesting functions that might be worth it to add to a ILI9341 library. Would simplify drawing strings:
Code:
           drawNumber(long long_num,int poX, int poY, int font),
		   drawNumber(long long_num,int poX, int poY),
           drawFloat(float floatNumber,int decimal,int poX, int poY, int font),
           drawFloat(float floatNumber,int decimal,int poX, int poY),
		   
		   // Handle char arrays
           drawString(const char *string, int poX, int poY, int font),
           drawString(const char *string, int poX, int poY),
           drawCentreString(const char *string, int dX, int poY, int font), // Deprecated, use setTextDatum() and drawString()
           drawRightString(const char *string, int dX, int poY, int font),  // Deprecated, use setTextDatum() and drawString()

		   // Handle String type
		   drawString(const String& string, int poX, int poY, int font),
		   drawString(const String& string, int poX, int poY),
           drawCentreString(const String& string, int dX, int poY, int font), // Deprecated, use setTextDatum() and drawString()
           drawRightString(const String& string, int dX, int poY, int font);  // Deprecated, use setTextDatum() and drawString()

What do you all think?
 
Hi @defragster and @mjs513 and ...

I put up some responses to ili9341_t3n changes up in my earlier thread on this library: https://forum.pjrc.com/threads/3875..._t3-library-(ILI9341_t3n)?p=201644#post201644

Note: I pushed up a change to my ili9341_t3n library to make it run without having DC pin be the hardware CS pin. It won't be as fast, but it sure is faster than not working ;)

I may soon push the T4 WIP branches back into the master branch, especially if Paul pulls in the PR request to the USB Host code that supports Bluetooth.
 
Hi @defragster and @mjs513 and ...

I put up some responses to ili9341_t3n changes up in my earlier thread on this library: https://forum.pjrc.com/threads/3875..._t3-library-(ILI9341_t3n)?p=201644#post201644
Cool. Amazing how one thing leads to another :)

Note: I pushed up a change to my ili9341_t3n library to make it run without having DC pin be the hardware CS pin. It won't be as fast, but it sure is faster than not working ;)
Congratulations, that must have been a lot of worked and headaches to get it going.

I may soon push the T4 WIP branches back into the master branch, especially if Paul pulls in the PR request to the USB Host code that supports Bluetooth.
I hope so too. Think he is real busy about now... I just ordered by Beta breakout board - just to test USB design and things. Doing a redesign for the new one.
 
I'm getting better at Pacman in DEMO mode - at least consistent :) - The Speed 0.4 adjustment works! May seem visually boring in comparison - but it gives me a chance to play. Adding as a #define would be good - the game itself seems to be clocked independent of F_CPU - 96 and 256 MHz seem to run the same? Maybe use some spare buttons to adjust the speed at runtime? There seems to be plenty of spare cycles on T_3.6.

Bt Joystick is very reliable/accurate: It starts and inputs are recognized. By Joystick Design - I meant the Arcade box ;) If it is going to be a 'keyboard' we could add support for keyboard - the Rii Bt keyboard has U/D/L/R area. Reading the code I learned to test the button once received in advance will act to turn at the next opprotunity while continuing so it isn't as bas as I thought trying to RACE the turns with left thumb.

Seeing the use of " if (buttons == 32768 ) " is a bit obscure - is the a map I should find somewhere to associate buttons/inputs?

Good work again KurtE on the supporting device libs - and Mike in the port - will be nice having this cleaned and prepped to make an included PJRC library as possible for T3.6/T4. The linked video must be private - I wonder how good this looked on Due?
 
@defragster

I did it for the wired versions with the values shown in hex - the values in the lib are decimal. To be honest got lazy and was going to clean it when I got it working on the T$ but having problems as you can see in my previous posts. Anyway I did a mapping for wired versions that will probably hold:

View attachment Controller mapping.zip

See if this helps

Mike
 
@mjs513 - now I see - I was watching 0's when I was not pushing buttons to see the values pass. EDITed to not print unless button>0, and print HEX and DEC. Very helpful having that print - this is a DEMO app - could be left in as for help

Code:
bool bShowVals = false;
void KeyPadLoop() {
  buttons = joystick1.getButtons();

  if (bShowVals && buttons > 0 ) {
    Serial.print( buttons, HEX );
    Serial.print( "\t" );
    Serial.println(buttons);
  }
// …
    if (buttons == 512) {  // right trigger #1
      bShowVals = !bShowVals;
      delay(200); //debounce
    }
 
New version of Debug helper button print - only active toggle is for PS3 shown above on 512 - XL sheet calls that 'r2' isn't that 'r1'? That would be 0x80 for PS4?

Starts enabled to print, prints note to disable, only prints each key once in succession [debounced printing]
Code:
bool bShowVals = true;
uint32_t buttonsLast = 0;

void KeyPadLoop() {
  buttons = joystick1.getButtons();

  if (bShowVals && buttons > 0 ) {
    if ( 0 == buttonsLast ) {
      Serial.println( "Press right trigger 1 to toggle this printing.");
    }
    else if ( buttonsLast != buttons ) {
      Serial.print( buttons, HEX );
      Serial.print( "\t" );
      Serial.println(buttons);
    }
    buttonsLast = buttons;
  }

//...
 
Back
Top