MaxCoderz

for your 1 bit pleasure!

All times are UTC




Post new topic Reply to topic  [ 114 posts ]  Go to page 1, 2, 3, 4, 5 ... 8  Next
Author Message
PostPosted: Tue 15 Nov, 2005 11:50 am 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
This isn't a proper project, but couldn't really decide where to put it. Mods, move as you see fit. :)

It's posted in my GDNet journal;

http://www.gamedev.net/community/forums ... ?jn=273102

Image

EDIT: Changed name :)


Last edited by benryves on Tue 21 Feb, 2006 1:11 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 15 Nov, 2005 1:07 pm 
Offline
Calc Master
User avatar

Joined: Wed 22 Dec, 2004 3:07 am
Posts: 1454
Location: Through the Aura
Heh, my mom actually bought me one of the TI keyboards (they're $40) so that I would take notes on it in class. I still use it all the time, though not much for taking notes I'm afraid- rather for writing my stories and such. Unfortunately, I wish there was a better word processor than NoteFolio that worked with it... :(

_________________
Image


"You're very clever, young man, but it's turtles all the way down!"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 15 Nov, 2005 2:36 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 4095
Location: I cant seem to get out of this cryogenic chamber!
This is pretty sweet Ben :). How funny would it be to turn up to class with your calc and a full sized keyboard, then start taking down notes :).

_________________
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 15 Nov, 2005 3:22 pm 
Offline
Calc Master

Joined: Mon 20 Dec, 2004 10:01 pm
Posts: 1110
Location: In the state of Roo Fearing
dysfunction -- any program that uses _getKey should work with it.

_________________
ImageImage
Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 15 Nov, 2005 3:39 pm 
Offline
Calc King
User avatar

Joined: Sun 23 Jan, 2005 12:37 am
Posts: 1727
Location: Netherlands
That's really cool Ben :P
Especially considered how many people tried this before and failed to properly debug it - I will not point any fingers ;)

Will you release the include once it's finished?

_________________
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 15 Nov, 2005 4:00 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Timendus wrote:
Will you release the include once it's finished?
Yep - I'm sure a link port expert such as yourself could do a better job at this than me (ignore the at_get_byte routine in the journal - I've neatened it up a bit since) but I'm trying my best :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 15 Nov, 2005 5:34 pm 
Offline
Calc King
User avatar

Joined: Sat 18 Dec, 2004 6:46 am
Posts: 2932
This sounds really cool, I want this to be finished don't fail!! :P .


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 15 Nov, 2005 5:45 pm 
Offline
Calc King
User avatar

Joined: Sun 23 Jan, 2005 12:37 am
Posts: 1727
Location: Netherlands
benryves wrote:
I'm sure a link port expert such as yourself could do a better job at this than me

Oh, cut that crap :) First, I think you're at least as good at this shit as I am, probably (much) better. Second; if it works, it works :P

Nonetheless, I am curious to see your final source ;)

_________________
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue 15 Nov, 2005 7:58 pm 
Offline
Calc Wizard
User avatar

Joined: Tue 05 Jul, 2005 11:28 pm
Posts: 549
Congrats Ben! I only was able to get halfway along where you did in this time, excellent work.

_________________
Image Image Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed 16 Nov, 2005 3:47 am 
Offline
Calc Master
User avatar

Joined: Fri 04 Mar, 2005 12:52 am
Posts: 1069
Location: NW Wisconsin
Alright! 'Bout time the TI keyboard came along. Any possiblity of an XXR dancepad? 8)

_________________
My diet consists of nails, code-stealers, and HP fans.
Projects:

Robot War [TI-82, TI Flash App]
Sonic the Hedgehog [Multiplatform]


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed 16 Nov, 2005 3:54 am 
Offline
Calc King

Joined: Thu 13 Oct, 2005 1:54 pm
Posts: 1950
Location: UB
Well, all we need is a USB dancepad, like this one for example, and a calc driver. That is, as long as you have an 84 series calc. :)

_________________
In Memory of the Maxcoderz Trophy Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed 16 Nov, 2005 10:26 am 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
@Timendus; you've done considerably more with any sort of linking than I have, so I'm sure that you wouldn't be making some of the silly mistakes I am making :roll:

@Kerm; thanks! Did you ever get anywhere with connecting a mouse? It uses the AT protocol, I know that much, but I can't receive any bytes from my mouse. The only thing I can guess is that it's sending data at a significantly higher clock rate that the TI can't cope with (it's tight enough with a keyboard!)

@DigiTan; if you can find one that works as an AT or PS/2 keyboard (PS/2 keyboards use the same AT protocol, just a different sized/shaped connector) then yes. ;) Chances are, unfortunately, slim...

I've fixed the at_send_byte routine so that I can now successfully send bytes to the keyboard. Same link as before for the way I'm handling events!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed 16 Nov, 2005 12:16 pm 
Offline
Maxcoderz Staff

Joined: Fri 17 Dec, 2004 5:33 pm
Posts: 790
Location: On the dark side of the moon.
You could also use the calculator as a external MIDI control device. Then you can link output from a calculator to functions in music programs (like Ableton Live). You would have to give it midi output then though. But usefull to mix music, control volume, effects, etc.

_________________
"They say that sea was created by a man named Maarten Zwartbol, a long time ago...." - Duck, an old Corbin version


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed 16 Nov, 2005 1:55 pm 
Offline
Calc King
User avatar

Joined: Sun 23 Jan, 2005 12:37 am
Posts: 1727
Location: Netherlands
benryves wrote:
Same link as before

It keeps loading indefinitely... :?

_________________
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed 16 Nov, 2005 2:00 pm 
Offline
Maxcoderz Staff
User avatar

Joined: Thu 16 Dec, 2004 10:06 pm
Posts: 3064
Location: Croydon, England
Timendus wrote:
benryves wrote:
Same link as before

It keeps loading indefinitely... :?
GDNet is down, by the looks of things.

Reliability

I'm sure you wouldn't want to use a keyboard that was inaccurate. Unfortunately, (as you might have seen me moaning in the past) the keyboard generates the clock signal. This basically means you need to be constantly checking the clock line to see if it goes low - that or use a hardware interrupt the jumps in and receives the scancode packet when the keyboard decides you want to stop sending something.

Well, I don't have the luxury of an extra keyboard chip or a hardware interrupt, so I needed to don my thinking cap. I had thought that one possible way around this would be to send a "disable" command to the keyboard after receiving bytes, running my handler code, then sending an "enable" command - these commands clear the keyboard's buffer, unfortunately, which is not good.

I downloaded another document on the AT protocol to see if they mentioned anything useful, and lo and behold:

The host may inhibit communication at any time by pulling the Clock line low for at least 100 microseconds.

I think I can spare 100us - I added the line ld a,1 \ out (bport),a to the end of my buffer-filling code from earlier (it fills a scancode key buffer) - and the code doesn't drop a single scancode. Result!

Providing useful functionality

All these keyboard routines do at the moment is to display the data coming in on the screen - not exactly a great use of them. What is really needed is a simple two-way handler - it calls two different user-defined routines based on what a key is doing, whether it is being pushed down or released.

For this, I should translate the scancodes into a new format - there are less than 256 keys, so there's no reason why I can't fit every single key into a byte.

As well as user-defined keyboard events, I'll have to add my own to handle toggling the status of the keyboard - the num/caps/scroll lock as well as the shift/alt/ctrl.

It's really quite simple to do. Basically, I just run through all the received bytes. I check for $E0 (if so, switch to the alternate scancode conversion table for the extended codes) then $F0 (if so, load the alternate handler for a key up event rather than a key down event) then look up the scancode on the selected code table.

I created a couple of very basic event handlers - the key down event displays ↓ followed by the adjusted key code, the key up event displays ↑ followed by the adjusted key code.

Image

What would be ideal would be to provide internal event handlers that could be called on keyup/keydown which would then jump over to the user's custom handler. These event handlers could look for special keys and adjust the keyboard LEDs and set internal flags that could be used to detect the status of certain keys. I'd need:

Num Lock
Caps Lock
Scroll Lock
Shift
Ctrl
Alt

Unfortunately, I think that there is a problem with my byte-sending code. Setting the keyboard LEDs starts to do strange things - I now have two options;

1 - After switching status, ignore the LEDs. The status flag is set correctly internally, but you can't see it on the keyboard (which is a bit pants).
2 - Update the status flags every single time we run through the loop to check for any new bytes (which makes the keyboard lag like crazy - there's up to half a second of buffering going on!)

Mixing-and-matching the two - rewriting the branch before we bring the clock high again (for maximum speed) confuses the keyboard - the status LEDs never change and it decides to disable itself in a strop until I send $FF (the reset command) again. I think it's time to revisit the at_send_byte> routine again to see what it's doing wrong!

Well, comparing it to my new notes - it's actually completely wrong at the end, when it comes to sending the parity/stop/ACK bits! A quick rewrite to how I think it should go isn't too hopeful - the keyboard LEDs flash like mad. Tweaking the timing by throwing in a few calls to _wait_bit_low and _wait_bit_high to synchronise my data to the clock stop this completely - and now the code is as it was before, at 100% accuracy - but about twice as fast.

Replacing my branch code still doesn't work all the time - sometimes the LEDs change, sometimes they do not. Not believing it would work, I threw in a check for the ACK bytes returned - if they were $FE, the 'repeat last command' byte, I'd send again.

My routines were clearly not as broken as I thought - the keyboard LEDs now change status perfectly, and as much as I hammer the Num Lock, Caps Lock and Scroll Lock keys, I cannot lock up the program or get the keyboard LEDs to display the wrong value. Not to mention that keying in other keys is back to the lightning fast response they used to be...


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 114 posts ]  Go to page 1, 2, 3, 4, 5 ... 8  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB ® Forum Software © phpBB Group | DVGFX2 by: Matt