Adafruit #570 in Inc 5000 & #11 in manufacturing - fastest-growing private companies in America - INC 5000 - Read more!

New Trinket Library!

by PyroAVR on Fri Oct 11, 2013 6:43 pm

Hello All,
I thought that I would announce a library which I have ported to work with the Adafruit Trinket. I ported the Wii Nunchuck Library to work with the Trinket, and all of the functions except for the debug-over-serial work without any issues. I have removed any functions which do not work in the library to eliminate any confusions. Also, I have completed the code which was originally posted at the Arduino Forums to support syntax highlighting in the Arduino IDE and have included a demo sketch along with the library to make sure your controller is working. The hookup instructions are different, so I have also included those at the top of the demo sketch.

You can download it from my Github, located at: http://www.github.com/PyroAVR/TrinketNunchuck

Note that it requires TinyWireM to be installed in your Arduino library path as well.

I hope that someone can make use of this!
PyroAVR
 
Posts: 23
Joined: Sun Sep 02, 2012 5:11 pm

Re: New Trinket Library!

by adafruit_support_mike on Fri Oct 11, 2013 9:43 pm

Nice! Thank you.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 8990
Joined: Thu Feb 11, 2010 1:51 pm

Re: New Trinket Library!

by frank26080115 on Mon Oct 14, 2013 2:33 am

cool stuff

If you restructure your code a bit, you can also work with the Wiimote Classic Controller. You can also read back data from the Wiimote's infrared camera

TWI is a synchronous bus, I think you might benefit from using a software bit bang implementation of TWI instead of one that uses the USI, this will free up the USI to do other things. Just food for thought. Go to Atmel's site and search for "Atmel AVR156: TWI Master Bit Bang Driver" to learn more.

I might end up writing a TinyWireM replacement using AVR156 but it's not high on my priorities list
frank26080115
 
Posts: 120
Joined: Fri Jun 15, 2007 12:04 am

Re: New Trinket Library!

by indiwerwlf on Mon Oct 14, 2013 3:40 pm

Hey we should brainstorm and work together on a project. I would love to use a classic controller over usb!
User avatar
indiwerwlf
 
Posts: 128
Joined: Mon Sep 23, 2013 5:58 pm

Re: New Trinket Library!

by frank26080115 on Tue Oct 15, 2013 2:34 am

indiwerwlf wrote:Hey we should brainstorm and work together on a project. I would love to use a classic controller over usb!


I've already done that, also done that with PS2 controllers, stuff like that takes me 30 minutes now. I can probably turn my old code into Trinket friendly code... not high on my priorities list though.

Meanwhile, check out http://wiibrew.org/wiki/Wiimote/Extensi ... Controller for data format and identifier information
frank26080115
 
Posts: 120
Joined: Fri Jun 15, 2007 12:04 am

Re: New Trinket Library!

by indiwerwlf on Thu Oct 17, 2013 10:31 pm

But think how cool it would be to cut the classic controllers cable, wire everything up with a trinket inside the classic controller and leave the mini USB poking out. Is there enough room in there for an arduino mico at least? Then I wouldn't really have to do much to the code...
User avatar
indiwerwlf
 
Posts: 128
Joined: Mon Sep 23, 2013 5:58 pm

Re: New Trinket Library!

by frank26080115 on Fri Oct 18, 2013 12:13 pm

indiwerwlf wrote:But think how cool it would be to cut the classic controllers cable, wire everything up with a trinket inside the classic controller and leave the mini USB poking out. Is there enough room in there for an arduino mico at least? Then I wouldn't really have to do much to the code...


Trinket 3.3 is probably the best choice in terms of size, the next smallest option is probably Teensy (but make sure you install the 3.3V mod for it)

Arduino Micro is the same chip as the Teensy but almost twice as large
frank26080115
 
Posts: 120
Joined: Fri Jun 15, 2007 12:04 am

Re: New Trinket Library!

by PyroAVR on Tue Jan 07, 2014 4:27 pm

indiwerwlf wrote:Hey we should brainstorm and work together on a project. I would love to use a classic controller over usb!

I'm working on that one, hold on!
PyroAVR
 
Posts: 23
Joined: Sun Sep 02, 2012 5:11 pm

Re: New Trinket Library!

by PyroAVR on Tue Jan 07, 2014 4:29 pm

indiwerwlf wrote:But think how cool it would be to cut the classic controllers cable, wire everything up with a trinket inside the classic controller and leave the mini USB poking out. Is there enough room in there for an arduino mico at least? Then I wouldn't really have to do much to the code...

That too, for that matter...
PyroAVR
 
Posts: 23
Joined: Sun Sep 02, 2012 5:11 pm

Re: New Trinket Library!

by PyroAVR on Tue Jan 07, 2014 4:31 pm

frank26080115 wrote:cool stuff

If you restructure your code a bit, you can also work with the Wiimote Classic Controller. You can also read back data from the Wiimote's infrared camera

TWI is a synchronous bus, I think you might benefit from using a software bit bang implementation of TWI instead of one that uses the USI, this will free up the USI to do other things. Just food for thought. Go to Atmel's site and search for "Atmel AVR156: TWI Master Bit Bang Driver" to learn more.

I might end up writing a TinyWireM replacement using AVR156 but it's not high on my priorities list


I'm still learning how to bit-bang serial buses. When I figure it out, I'll definitely give that a shot. Right now I'm making an FPV helmet with the BBB and reading data from the WiiMote would make an interesting control scheme. I'll port it back to Trinket when I finish, perhaps...
PyroAVR
 
Posts: 23
Joined: Sun Sep 02, 2012 5:11 pm