Received: from ultb.isc.rit.edu by karazm.math.UH.EDU with SMTP id AA13401 (5.65c/IDA-1.4.4 for ); Wed, 9 Oct 1991 16:38:30 -0500 Received: by ultb.isc.rit.edu (5.57/5.3 (Postmaster DPMSYS)) id AA14510; Wed, 9 Oct 91 17:34:34 -0400 Received: from chromium.CS (chromium.ARPA) by junior.rit.edu (4.1/5.17) id AA10489; Wed, 9 Oct 91 17:24:08 EDT From: jdb9608@cs.rit.edu (John D Beutel) Message-Id: <9110092124.AA10489@junior.rit.edu> Subject: Re: standard interface To: glove-list@karazm.math.uh.edu Date: Wed, 9 Oct 91 17:36:34 EDT X-Mailer: ELM [version 2.3 PL8] > I uploaded source code for a PC... I converted the ST code and fixed it up > a little. Wonderful! > I was thinking, we should probably have a standard interface of > some sort so that our code will be relatively compatible. Here is my proposal: > typedef struct _glove_data { > unsigned char dum0; > signed char x,y,z; > unsigned char rot,fingers,keys,dum7,dum8,dum9,dumA,dumB; > } glove_data; > > void Hires(); > void getglove(glove_data *); > > > possibly better function names would be glove_init() and glove_sample() > Also, the byte that I called "dum9" seems to be used to tell if the glove > is not aimed at the receivers. That sounds good to me. I would have favored the structure that already comes from the "black box", since it's already been around, but the data itself is exactly the same form so conversions should be trivial, and the "black box" has no specific structure defined (i.e., no names that I'm aware of). So, I'd say lets use these names. Should we define a whole .h file? (E.g., constants for the bits in keys, macros to mask and shift the two bits in fingers...) I hate to start a senseless meta-discusion, but I don't want to go to over-plan anything. > The other thing to start brainstorming about is > how to solve the problem of the 5 long pauses. Each one is 14 milliseconds, > so you waste 70 milliseconds per sample. Surely something useful could be > squeezed into that time somehow. I'm trying to solve that on the ST by using an internal timer to generate an interrupt at the end of each long pause. An ISR would handle the protocol at each interrupt, and the CPU would be free to do other things in the mean time. Lately I've been talking about it more than trying it, but in theory I should get it working. I don't know if other computers have a similar capability, but probably they do. So, for the sake of implementations that take this approach, I propose two more things: void glove_pre(); /* call > 80 ms previous to glove_sample() */ int glove_pend; /* boolean flags glove data as pending */ The glove_pre() is a function which should be called 80 ms or more previous to glove_sample(). When the glove data is ready, the global glove_pend will be set = 0, and then glove_sample() may be called. For implementations like mine, glove_pre() will start the protocol and set glove_pend = 1. When an ISR finishes the protocol, it will set glove_pend = 0, and glove_sample() will just be a dumby that copies the glove_data into the given structure. For implementations using busy loops or external hardware (e.g., 68HC11), the glove_pre() will be a dumby function, glove_pend will always = 0, and glove_sample() will really go get the data each time. This will allow people to write programs that work both ways. The code wouldn't be much more complicated than without glove_pre(): glove_data gd; glove_init(); /* hi-res mode */ glove_pre(); /* start first sample if we need to */ while( 1) { foo(); /* 80 ms worth of graphics stuff */ while( glove_pend); /* wait if we need to */ glove_sample( &gd); /* get the data (one way or the other) */ glove_pre(); /* start the next sample if we need to */ } Also, shouldn't we allow glove_init(), glove_pre(), and glove_sample() to return error codes, at least for recognizable hardware errors? -- J. David Beutel 11011011 jdb9608@cs.rit.edu "I am, therefore I am."