T3.6 USB Host - Bluetooth

@KurtE and @defragster

Not having much luck with displays I think today. Using the T3.6 and your sketch - it turns black and I connect (using a PS4) and nothing displays just a blank screen - looks like it wants to draw something
 
Note with ps3 it only displays after I hit the ps button to connect. I also have reset line ser to pin 8
 
Yep did that. I am using your t4-wip version and just tried graphictest but that didn't work either - going to download the master and try again

UPDATE:

@KurtE - loaded the master version. Ran the graphics test sketch with cs=10, dc =9 and rst =8 which is my setup as well. When it runs the tests the screen just keeps blinking but and for the diagnotics:
Code:
Display Power Mode: 0xFF
MADCTL Mode: 0xFF
Pixel Format: 0xFF
Image Format: 0xFF
Self Diagnostic: 0xFF
 
@defragster - Compiles for me... Wondering if USB type set to something else? Or? ???
I believe it is defined in keylayouts.c - maybe need to see who else includes it...

@mjs513 - Wonder what is going on? Maybe should try straight ili9341_t3 library and see if it works. Might need to make sure that pin 8 is defined as reset. If not the pin might float and leave display in reset state.
 
My bad - removed post #430 content - I was testing if the Beta 10 for T$ took away the need for Speed Menu - it does not . . . working now
 
...
@mjs513 - Wonder what is going on? Maybe should try straight ili9341_t3 library and see if it works. Might need to make sure that pin 8 is defined as reset. If not the pin might float and leave display in reset state.

I loaded up the straight ili9341_t3 lib and same thing. Wonder maybe should try different pin. Anyway just tried it with the T4 - what is a valid DC pin for the T4? I am trying to use the shield so I can use USB2

EDIT: If you want to laugh I edited the ILI9488 library to work with the T$ and the graphicstest sketch ran without a problem but not my ILI9341. Good thing I have another one coming today to test :)
 
Last edited:
With T4 and ILI9341_t3n, the only valid CS pin that must be used for DC is pin 10. You can use any digital pin for CS as it just digitalWrites...

Wonder what was going on with your display? Again if you have reset pin set to something (like I did pin 8), you might have to edit the graphic test programs and give it as the third parameter to the constructor for TFT, so that it will set the pin HIGH at the end... I had some displays in past that appeared to need the reset operation to work properly, otherwise just run it to +3.3v and see if that works.
 
With T4 and ILI9341_t3n, the only valid CS pin that must be used for DC is pin 10. You can use any digital pin for CS as it just digitalWrites...

Wonder what was going on with your display? Again if you have reset pin set to something (like I did pin 8), you might have to edit the graphic test programs and give it as the third parameter to the constructor for TFT, so that it will set the pin HIGH at the end... I had some displays in past that appeared to need the reset operation to work properly, otherwise just run it to +3.3v and see if that works.

Morning Kurt
Did it both way (1) set dc = 10 and cs=9 with RST=18 (remember I am using the breakout board) on the T$, (2) for second test I just had rst going to 3.3v. Both tests just had the display blinking but nothing drawn. Yet if I use the Adafruit ILI9341 lib it will work with (1), didn't test with just 3.3v to rst using the Adafruit lib. Something weird is going on with the display. Post wont be here until about 4 EST so just have to wait to see if I have the same problem.

EDIT: Just for reference all the diagnostic values are 0x00. So something strange.

EDIT2: Also just tried it with the T3.6 and no does the same thing.
 
Last edited:
Good Morning... I have not tried the T4 with the display for awhile... When I last did it, I did not have it in Paul's breakout board as I don't think the SPI pins all came out in normal places. So I did it using breadboard. The current stuff with the Pacman I have running with the T3.6 beta board and you might have noticed in the picture.

At some point I am thinking of hacking up a version of ili9341_t3? that works on T4 with or without hardware CS pin on DC... Not sure yet if to build it into my own _t3n or a version of _t3?

More a discussion for the T4 thread, but thinking of making it always have a frame buffer. Then have it maybe run in three different ways:
a) Explicit say update screen now
b) Always update - Once started it just keeps on running...
c) like b) but maybe only when the user calls some graphic primitive.... That is for example you call fillRect, it will set a dirty bit and when the fill rect is done in memory it will if necessary start the DMA operation. When the DMA completes, if nothing dirty it turns off... (maybe it runs an extra screen refresh?)

I see positive things for all three methods. a) gives the app developer the most control over things, b) probably gives you the fastest screen refreshes (most frames per second), c) may be an interesting compromise, for apps that don't have things on the screen constantly updating... Note: maybe have compile option (#define) to allow apps who need the fastest stuff to compile out the c) stuff.

What I sometimes wonder about DMA operations is, suppose I am constantly outputting DMA at something like 30mhz, what does it do to the performance of other things. (Yes I know that DMA runs by itself, but what does it do to memory access for other things, like maybe manipulating other images in memory or doing output UARTS or ...

But sorry I know that this is off topic. Right now in between playing with Annie, I thought I would update the keyPadLoop code in Packman to maybe know which Joystick we have and be able to process the actual buttons.

Example currently in the code for Start it is looking at:
Code:
  if (buttons == 168 ) {
    ClearKeys();   //else but_START=false;
    but_START = true;
    delay(300);
  }
I have no idea what joystick would give you that? 0xA8 (3 bits on) for start button? I might either have tables for PS3/PS4... or ?
 
Odd thing about 'c)' would be a screen update is 2 or more steps … 1:blank Area X, 2:print update to X [3:… areas Y,Z].
That would be the recipe for flash catching partial/in progress updates.
Indeed free parallel DMA has to have some cost - power use or memory/resource/touch conflict in some cases.
 
@KurtE

I like your approach to modifying ILI9341_t3. Gives the user a lot more flexibility. Assuming you will be combining elements from t3n?

Back to the joystick - the funny thing is when I press the buttons associated with the share (start, since ps4 doesn't have a start button) it gives 168 as the button read - that's how I got those numbers for the buttons - weird isn't it. My Shaya (yorkie/maltese) has been keeping me busy this morning as well.

As for breakout board - yep it has all the pins for SPI broken out:
Code:
MISO = 12
MOSI = 11
CS = 10
MEMCS = 9
SCK = 13
SDA = 18
SCL = 19
 
If done properly c) should work like b), just takes a little extra time to start up the update after screen changes are detected... That is if when the screen DMA update completed ISR is triggered, it would see if still dirty and continue...

Another way to implement c) is more or less a) with an IntervalTimer or the like that would trigger if screen image dirty, but I figured that some might complain about the delay... And if it only did a one shot, yes than you could really see flashing.
 
@KurtE

Got the new ILI9341 (2.8 in display) tested and it works - yea - finally. Loaded packman and display works and when I hit start it goes into demo mode. Now to start playing with the code to see whats going on.

I looked at the new function and it looks simpler that I thought to change :)

Thanks Kurt.

EDIT: Change DEMO=1 to DEMO=0 and it will run and you can control pacman right from the start
 
Definitely need a clean thread with all the sausage making and diversions on this thread. Will be good for fresh USBHost_2019 when there are usable samples and working code.

I was going to suggest a timer - waiting some us's...ms after the last 'dirty' set before starting the update. That would allowed paired updates to complete - of course then a user slamming the screen would never see it draw.

I was assuming 'c)' would not leave screen dirty {clear of dirty at DMA start} - just do at least two update DMA passes during screen area clear/update - showing partial updates.

Perhaps adding the 'c)' dirty to 'a)' … if ( FORCED or dirty ){ do update }. Then the tft.update( "a", NO_FORCE ); in loop() {or explicit call} would get hit 100K to 2+M times per second and only do anything when needed, assuming one loop() pass means one screen update is done. That would facilitate using SPI for touch or other - device as long as user could tell when 'a)' DMA SPI from loop() end was done in the next loop … tft.activeDMA( [TEST | WAIT] ) could allow TEST return bool of active state or WAIT to return when done if active.
 
@defragster and @KurtE

First I switch over to the PS3 and it runs a heck of a lot faster - actually too fast to play - need to slow the game down :) But I made the modifications to use a PS3:

ATTACMENT DELETED

Anyway, I agree with defragster think we are going to have 2 threads spawned from this one; (1) new USBHost_t36 and (2) New improved ILI9341_t3

EDIT:
Been playing with this now that screen works. I updated the keypad so it will work with either a PS4 or a PS3 using Bluetooth. So now the question remains do we do it for BT or wired since buttons my change :) Maybe 2 versions

Also there is a big difference in game speed when using a PS4 or a PS3 - not sure why.

View attachment Pacman-Arduino-Due-NESPAD.zip
 

Attachments

  • Pacman-Arduino-Due-NESPAD.zip
    186.5 KB · Views: 65
Last edited:
Hi @mjs513 - Down loaded and tried to compile...

I found I needed to remove the ili9341_due files as we had conflicts of symbols... Once I removed them again it was building again :D

Then found the screen did not work.... Then found you set DC=10 to work with 4.0... So swapped my pins 9 and 10 on T3.6 and now it is working again :D

As for Speed difference with PS3 vs PS4? Maybe how often they generate messages? Or maybe the size of messages? Not sure.

But at least it is working!
 
Evening @KurtE - should have warned you about the change in pins - maybe we should put an define in for different configurations between you, me and @defragster if he was to get into it :)

Was fun playing with it - was thinking instead of the arrows for controlling direction maybe should switch to joystick :)

Now that everything is working having fun playing with it :)

So whats next :)
 
@KurtE and @defragster

Tried an experiment with trying to connect multiple BT devices - but doesn't seem to want to work. Maybe something I did wrong - will have to play tomorrow again a little more carefully - right only can do one at a time. Dongles I have can't connect more than once device at a time.


EDIT: Yes they can but usbhost doesn't seem to want to support more than one device at a time. If I start a mouse it starts reading mouse values no problem and then if I connect the joystick it drops reading the mouse and just joystick values popup. Maybe will try keyboard+mouse next. Stay tuned
 
Last edited:
@defragster and @mjs513 - As far as Game goes? Good question - I was just seeing if I could help make it run... I never was any good at games like PacMan.

Could maybe package it up sort of like the Odroid-GO? https://www.hardkernel.com/shop/odroid-go/ which uses an ESP-32.

As for multiple devices at a time. Yes I was pretty sure that would not work yet. Was sort of hoping to have the current stuff integrated in to Paul's master branch and then we could tear it apart again.

One thing I kept keep meaning to do is to turn off all of the debug stuff (Serial1 stuff), so if/when the PR is actually grabbed it will not need Serial1 setup for BT apps to work, especially for those running on T3.6. (So just pushed up change to do that).
 
@defragster and @mjs513 - As far as Game goes? Good question - I was just seeing if I could help make it run... I never was any good at games like PacMan.

Could maybe package it up sort of like the Odroid-GO? https://www.hardkernel.com/shop/odroid-go/ which uses an ESP-32.

I was just intending on using it as a demo of integrating the controllers via Bluetooth into an application that everyone can load up. That was it - real good app would be a Bluetooth rover which I have done before that is a little more involved :) So maybe just leave it and add it to the examples after some clean up along with a readme which I can put together.

I really do appreciate you getting it working though - was fun watching something I played in my younger years again though along with pong and missile command. :)

As for multiple devices at a time. Yes I was pretty sure that would not work yet. Was sort of hoping to have the current stuff integrated in to Paul's master branch and then we could tear it apart again.

Had to give it a try just for the sake of curiosity and since I had some time.

One thing I kept keep meaning to do is to turn off all of the debug stuff (Serial1 stuff), so if/when the PR is actually grabbed it will not need Serial1 setup for BT apps to work, especially for those running on T3.6. (So just pushed up change to do that).

Good idea - forgot all about that to be honest. Have to pull down the changes.

Oh in regards to XBOX I came across a couple things that might be of interest:https://github.com/computerquip/xpad5. He has a couple of other xbox repositories as well. Ok found this from Linux: https://github.com/torvalds/linux/blob/master/drivers/input/joystick/xpad.c
 
Last edited by a moderator:
Good work Kurt!

Glad I stopped being distracted long enough to fire up and test to catch that issue before it wasn't fresh enough to catch and fix it quickly.

Hopefully @milan7 has a good report?

Also good to edit in to post #1 might be my notes summarizing testing: 'true' versus not for New bind versus existing, Add Serial1 when DEBUG added if desired/needed.

Sorry for the late reply. I had to finish some project.

I had issues with TTL to USB converter and I got a new one and now I am getting gibberish text at different Baud rates with both Serial monitor and Putty.

What Baud rate should I be using?

The test hello world code works but KeyboardBT gives me gibberish.
 
If you are using it for debug output on Serial1, it just needs to match whatever you do a Serial1.begin at. I was using 2000000 which worked with my adapter and putty or in my case kitty.
 
I downloaded the updated code and it connects to the keyboard and I see the keystrokes in serial.

I am going to now get my keyboard like device working.

Where should I look for the keyboard identifiers to change it and make it work with other device?

It's probably mentioned somewhere in previous pages but it's getting confusing.
 
Back
Top