Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/04/03 19:16
Read: times


 
#50085 - RE: 16-bit keyscan to 4-bit
Responding to: ???'s previous message
Here is the code that I came up with, but its probably very inefficient. Are there any ways to make this more efficient?

char ScanKeySingle(void)
{
unsigned int key16;
char key8 = 0;
int i;
unsigned int mask = 0x8000;
bit multiple = 0;

// scan and produce 16-bit key
key16 = ScanKey();

// if it was zero then noise
if(key16 == 0)
return 0x80;

// check each bit, keeping track of the
// 4-bit encoded value and multiple
// keypresses
for(i=0; i<16; i++)
{
if(mask & ~key16)
{
if(multiple)
return 0x10;
key8 += i;
multiple = 1;
}
mask = mask >> 1;
}

return key8;
}


List of 6 messages in thread
TopicAuthorDate
16-bit keyscan to 4-bit            01/01/70 00:00      
   RE: 16-bit keyscan to 4-bit            01/01/70 00:00      
   RE: 16-bit keyscan to 4-bit            01/01/70 00:00      
   RE: 16-bit keyscan to 4-bit            01/01/70 00:00      
   RE: 16-bit keyscan to 4-bit            01/01/70 00:00      
      RE: 16-bit keyscan to 4-bit            01/01/70 00:00      

Back to Subject List