HIDKeys converted to Attiny 2313 problems (understand C-code
Posted: Thu Aug 21, 2008 12:38 pm
Hi
I'm a beginner... that said I managed to convert and run the HIDKeys in an Attiny2313.
Problem is that I'm terrible at C.
I can successfully type A,B,C,D,E,F etc but the pin layout for Atmega8 and Attiny2313 differs so when I release the button I get QQQQQQQQQQQ.... - and that indicates PD7 key down (and that one dont even exist on a Attiny2313)
But I only neeed 8 keys instead of 17... so i was going to use PB0-PB7
I don't fully grasp the HIDKeys program... And tried and change this code:
Changed so it uses 0-7 PB instead ot only 0-5..... and then I wiped out the stuff for PINC and PIND
Problem is that PIND keys still work and PB6 and PB7 still don't produce any keypress (PINC dont exist on attiny2313)
I also changed the #define NUM_KEYS 8 /* instead of 17 */
Have some ideas that I need to change something concerning
static const uchar keyReport[NUM_KEYS + 1][2] PROGMEM = {
/* none */ {0, 0}, /* no key pressed */
/* 1 */ {MOD_SHIFT_LEFT, KEY_A},
etc....
But i tried to change all to KEY_Z and I still write A,B,C,D etc so this try didnt help me either.
Some one care to explain a bit and point me into the right direction ?
Saw that a guy on the forum had done a "Hello world" when he pressed the PD0 key but the example code was gone =( maybe that would have helped me to understand.
Appreciate all help and pointers I can get.
Think i got the fuses and hardware all working correctly.... now i only need to understand the C code fully.
////Ricke
[/code]
I'm a beginner... that said I managed to convert and run the HIDKeys in an Attiny2313.
Problem is that I'm terrible at C.
I can successfully type A,B,C,D,E,F etc but the pin layout for Atmega8 and Attiny2313 differs so when I release the button I get QQQQQQQQQQQ.... - and that indicates PD7 key down (and that one dont even exist on a Attiny2313)
But I only neeed 8 keys instead of 17... so i was going to use PB0-PB7
I don't fully grasp the HIDKeys program... And tried and change this code:
Code: Select all
/* The following function returns an index for the first key pressed. It
* returns 0 if no key is pressed.
*/
static uchar keyPressed(void)
{
uchar i, mask, x;
x = PINB;
mask = 1;
for(i=0;i<8;i++){
if((x & mask) == 0)
return i + 1;
mask <<= 1;
}
return 0;
}
Changed so it uses 0-7 PB instead ot only 0-5..... and then I wiped out the stuff for PINC and PIND
Problem is that PIND keys still work and PB6 and PB7 still don't produce any keypress (PINC dont exist on attiny2313)
I also changed the #define NUM_KEYS 8 /* instead of 17 */
Have some ideas that I need to change something concerning
static const uchar keyReport[NUM_KEYS + 1][2] PROGMEM = {
/* none */ {0, 0}, /* no key pressed */
/* 1 */ {MOD_SHIFT_LEFT, KEY_A},
etc....
But i tried to change all to KEY_Z and I still write A,B,C,D etc so this try didnt help me either.
Some one care to explain a bit and point me into the right direction ?
Saw that a guy on the forum had done a "Hello world" when he pressed the PD0 key but the example code was gone =( maybe that would have helped me to understand.
Appreciate all help and pointers I can get.
Think i got the fuses and hardware all working correctly.... now i only need to understand the C code fully.
////Ricke
[/code]