Browse Source

Finishing up the Epson QX-10 module

- Typing and modifiers fully working
- Still some features left to implement
  * Stop input
  * Diagnostic test
  * Setting interval before starting repeat rate
  * More comments
  * Handling LED stats
simple
Jacob Alexander 12 years ago
parent
commit
2519ea00e7
5 changed files with 28 additions and 7 deletions
  1. 1
    1
      Keymap/epsonqx10.h
  2. 22
    4
      Scan/EpsonQX-10/scan_loop.c
  3. 1
    0
      Scan/EpsonQX-10/scan_loop.h
  4. 4
    0
      USB/pjrc/usb_com.c
  5. 0
    2
      main.c

+ 1
- 1
Keymap/epsonqx10.h View File

0, // 0x8C 0, // 0x8C
KEY_GUI, // 0x8D KEY_GUI, // 0x8D
0, // 0x8E 0, // 0x8E
KEY_RIGHT_CTRL, // 0x8F
KEY_ALT, // 0x8F
}; };





+ 22
- 4
Scan/EpsonQX-10/scan_loop.c View File

// Prescaler is 1 // Prescaler is 1
// Twice every 1200 baud (actually 1200.1, timer isn't accurate enough) // Twice every 1200 baud (actually 1200.1, timer isn't accurate enough)
// This is close to 820 us, but a bit slower // This is close to 820 us, but a bit slower
cli();
TCCR1B = 0x09; TCCR1B = 0x09;
OCR1AH = 0x1A; OCR1AH = 0x1A;
OCR1AL = 0x09; OCR1AL = 0x09;
// Synchrounous USART mode // Synchrounous USART mode
// Tx Data on Falling Edge, Rx on Rising // Tx Data on Falling Edge, Rx on Rising
UCSR1C = 0x47; UCSR1C = 0x47;
sei();


// Reset the keyboard before scanning, we might be in a wierd state // Reset the keyboard before scanning, we might be in a wierd state
_delay_ms( 1 );
_delay_ms( 50 );
scan_resetKeyboard(); scan_resetKeyboard();


_delay_ms( 5000 ); // Wait for the reset command to finish enough for new settings to take hold afterwards
scan_setRepeatRate( 0x00 ); // Set the fastest repeat rate scan_setRepeatRate( 0x00 ); // Set the fastest repeat rate
} }




// Main Detection Loop // Main Detection Loop
// Nothing is required here with the Epson QX-10 Keyboards as the interrupts take care of the inputs
inline uint8_t scan_loop() inline uint8_t scan_loop()
{ {
return 0; return 0;
// Modifier Release Detected // Modifier Release Detected
else else
{ {
uint8_t actualKeyValue = keyValue | 0x01;

// Check for the released key, and shift the other keys lower on the buffer // Check for the released key, and shift the other keys lower on the buffer
uint8_t c; uint8_t c;
for ( c = 0; c < KeyIndex_BufferUsed; c++ ) for ( c = 0; c < KeyIndex_BufferUsed; c++ )
{ {
// Key to release found // Key to release found
if ( KeyIndex_Buffer[c] == keyValue )
if ( KeyIndex_Buffer[c] == actualKeyValue )
{ {
// Shift keys from c position // Shift keys from c position
for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ ) for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
} }


// Signal KeyIndex_Buffer that it has been properly read // Signal KeyIndex_Buffer that it has been properly read
inline void scan_finishedWithBuffer( void )
{
return;
}

// Signal that the keys have been properly sent over USB
// For the Epson QX-10 only the modifier keys have release signals // For the Epson QX-10 only the modifier keys have release signals
// Therefore, only 5 keys could possibly be assigned as a modifiers // Therefore, only 5 keys could possibly be assigned as a modifiers
// The rest of the keys are single press (like the Kaypro keyboards) // The rest of the keys are single press (like the Kaypro keyboards)
// //
// However, this differentiation causes complications on how the key signals are discarded and used // However, this differentiation causes complications on how the key signals are discarded and used
// The single keypresses must be discarded immediately, while the modifiers must be kept // The single keypresses must be discarded immediately, while the modifiers must be kept
inline void scan_finishedWithBuffer( void )
inline void scan_finishedWithUSBBuffer( void )
{ {
uint8_t foundModifiers = 0; uint8_t foundModifiers = 0;


// Adjust the size of the new Key Buffer // Adjust the size of the new Key Buffer
KeyIndex_BufferUsed = foundModifiers; KeyIndex_BufferUsed = foundModifiers;


return;
/* Non-working, too slow (too much traffic on the bus)
// Poll the modifiers using an input command
uint8_t oldBuffer = KeyIndex_BufferUsed;
KeyIndex_BufferUsed = 0;
if ( oldBuffer )
scan_readSwitchStatus();
*/
} }


// Reset/Hold keyboard // Reset/Hold keyboard

+ 1
- 0
Scan/EpsonQX-10/scan_loop.h View File

uint8_t scan_sendData( uint8_t dataPayload ); uint8_t scan_sendData( uint8_t dataPayload );


void scan_finishedWithBuffer( void ); void scan_finishedWithBuffer( void );
void scan_finishedWithUSBBuffer( void );
void scan_lockKeyboard( void ); void scan_lockKeyboard( void );
void scan_unlockKeyboard( void ); void scan_unlockKeyboard( void );
void scan_resetKeyboard( void ); void scan_resetKeyboard( void );

+ 4
- 0
USB/pjrc/usb_com.c View File

// AVR Includes // AVR Includes


// Project Includes // Project Includes
#include <scan_loop.h>
#include "usb_keyboard_debug.h" #include "usb_keyboard_debug.h"


// Local Includes // Local Includes
// Clear modifiers and keys // Clear modifiers and keys
USBKeys_Modifiers = 0; USBKeys_Modifiers = 0;
USBKeys_Sent = 0; USBKeys_Sent = 0;

// Signal Scan Module we are finishedA
scan_finishedWithUSBBuffer();
} }



+ 0
- 2
main.c View File

while ( 1 ) while ( 1 )
{ {
// Setup the scanning module // Setup the scanning module
cli();
scan_setup(); scan_setup();
sei();


while ( 1 ) while ( 1 )
{ {