Merge branch 'master' into ICPad

Integrating upstream changes into PixelMap modifications
This commit is contained in:
Jacob Alexander 2016-04-19 15:02:01 -07:00
commit 8ed4daa2c6
20 changed files with 531 additions and 178 deletions

View file

@ -1,85 +1,132 @@
Name = CK3;
Version = 0.3;
Author = "Crystal Hammer 2016";
KLL = 0.3c;
KLL = 0.3d;
# Modified Date
Date = 2016-02-19;
Date = 2016-03-01;
# this is nearly the default map
S0x0F : U"Esc";
S0x8C : U"F1";
S0x8B : U"F2";
S0x67 : U"F3";
S0x0D : U"F4";
S0x6E : U"F5";
S0x06 : U"F6";
S0x5F : U"F7";
S0x83 : U"F8";
S0x7F : U"F9";
S0x6D : U"F10";
S0x01 : U"F11";
S0x13 : U"F12";
S0x6F : U"PrintScreen";
S0x4B : U"ScrollLock";
S0x4A : U"Pause";
S0x39 : U"F16";
S0x8D : U"BackTick";
S0x7B : U"1";
S0x7A : U"2";
S0x79 : U"3";
S0x74 : U"4";
S0x86 : U"5";
S0x85 : U"6";
S0x73 : U"7";
S0x72 : U"8";
S0x71 : U"9";
S0x6C : U"0";
S0x7E : U"-";
S0x84 : U"=";
S0x5B : U"Backspace";
S0x00 : U"Esc";
S0x01 : U"1";
S0x02 : U"2";
S0x03 : U"3";
S0x04 : U"4";
S0x05 : U"5";
S0x06 : U"6";
S0x07 : U"7";
S0x08 : U"8";
S0x09 : U"9";
S0x0A : U"0";
S0x0B : U"Minus";
S0x0C : U"Equal";
S0x0D : U"Backslash";
S0x0E : U"Backtick";
S0x0F : U"Tab";
S0x10 : U"Q";
S0x11 : U"W";
S0x12 : U"E";
S0x13 : U"R";
S0x14 : U"T";
S0x15 : U"Y";
S0x16 : U"U";
S0x17 : U"I";
S0x18 : U"O";
S0x19 : U"P";
S0x1A : U"LBrace";
S0x1B : U"RBrace";
S0x1C : U"Backspace";
S0x1D : U"Ctrl";
S0x1E : U"A";
S0x1F : U"S";
S0x20 : U"D";
S0x21 : U"F";
S0x22 : U"G";
S0x23 : U"H";
S0x24 : U"J";
S0x25 : U"K";
S0x26 : U"L";
S0x27 : U"Semicolon";
S0x28 : U"Quote";
S0x29 : U"Enter";
S0x2A : U"LShift";
S0x2B : U"Z";
S0x2C : U"X";
S0x2D : U"C";
S0x2E : U"V";
S0x2F : U"B";
S0x30 : U"N";
S0x31 : U"M";
S0x32 : U"Comma";
S0x33 : U"Period";
S0x34 : U"Slash";
S0x35 : U"RShift";
S0x36 : U"Function1"; # Fun key
S0x37 : U"Function2"; # Left Blank Key
S0x38 : U"LAlt";
S0x39 : U"LGui";
S0x3A : U"Space";
S0x3B : U"RGui";
S0x3C : U"RAlt";
S0x3D : U"Function3"; # Right Blank Key 1
S0x3E : U"Function4"; # Right Blank Key 2
S0x69 : U"Tab";
S0x57 : U"Q";
S0x56 : U"W";
S0x55 : U"E";
S0x50 : U"R";
S0x62 : U"T";
S0x61 : U"Y";
S0x4F : U"U";
S0x4E : U"I";
S0x4D : U"O";
S0x48 : U"P";
S0x5A : U"[";
S0x60 : U"]";
S0x37 : U"\";
S0x68 : U"CapsLock";
S0x45 : U"A";
S0x44 : U"S";
S0x43 : U"D";
S0x3E : U"F";
S0x08 : U"G";
S0x07 : U"H";
S0x3D : U"J";
S0x3C : U"K";
S0x3B : U"L";
S0x36 : U";";
S0x00 : U"'";
S0x25 : U"Enter";
# Custom Action Examples
S0x5E : U"LShift";
S0x33 : U"Z";
S0x32 : U"X";
S0x31 : U"C";
S0x2C : U"V";
S0x1A : U"B";
S0x19 : U"N";
S0x2B : U"M";
S0x2A : U",";
S0x29 : U".";
S0x12 : U"/";
S0x3A : U"RShift";
# Example capability, prints to cli
action1 => CustomAction_action1_capability(); # No arguments
# bottom
S0x80 : U"LCtrl";
S0x6A : U"LGui";
S0x0E : U"LAlt";
S0x03 : U"LAlt";
S0x09 : U"Space";
S0x15 : U"RAlt";
S0x17 : U"RGui";
S0x88 : U"RCtrl";
S0x87 : U"RCtrl";
# Blocks given USB Code, must be used with blockLink
# Simple example, supports only blocking a single key at a time
# Keys must be specified using numbers see Macro/PartialMap/usb_hid.h
blockHold => CustomAction_blockHold_capability( usbCode : 1 ); # Single 8-bit argument
blockKey => CustomAction_blockKey_capability( usbCode : 1 );
# middle right column, custom
S0x8A : U"Esc";
S0x89 : U"Backspace";
S0x77 : U"Enter";
S0x78 : U"RShift";
# arrows
S0x1E : U"Left";
S0x0C : U"Up";
S0x1B : U"Down";
S0x1C : U"Right";
# S0x1C : U"RCtrl";
# numpad
S0x2D : U"NumLock";
S0x2E : U"P/";
S0x2F : U"P*";
S0x1D : U"P-";
S0x51 : U"P7";
S0x52 : U"P8";
S0x53 : U"P9";
S0x54 : U"P+";
S0x63 : U"P4";
S0x64 : U"P5";
S0x65 : U"P6";
S0x3F : U"P1";
S0x40 : U"P2";
S0x41 : U"P3";
S0x42 : U"PEnter";
S0x0A : U"P0";
S0x0B : U"P.";

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2014-2015 by Jacob Alexander
/* Copyright (C) 2014-2016 by Jacob Alexander, Crystal Hammer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -27,28 +27,42 @@
#include <matrix_setup.h>
// ----- Matrix Definition -----
// CK3
// Columns (Strobe) 18
// Rows (Sense) 8
// Freescale ARM MK20's support GPIO PTA, PTB, PTC, PTD and PTE 0..31
// Not all chips have access to all of these pins (most don't have 160 pins :P)
//
// NOTE:
// Before using a pin, make sure it supports being a GPIO *and* doesn't have a default pull-up/pull-down
// Checking this is completely on the ownness of the user
// This is the default map of just A4Tech KX-100 matrix
// scan codes for keys are defined in defaultMap.kll
/*
1| 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
-
1 Mcmp Bstp Esc \ F4 Up Del Ins Spc G H F6 == Vol- AltL xx F11 '
2 Calc ExA4 ExC2 ExE2 ExE1 <- Sub -> Dn B N ExC1 Apps Mnxt AltR xx F12 /
3 Mstp Bbck Z X C Mpau Mul Div NumL V M , . Vol+ xx CtrR Ent \
4 GuiR Bfwd A S D Ent PgDn Dn End F J K L ShiR xx == \ ;
5 xx Mail Q W E Add PgUp Up Home R U I O xx ScrL Paus ExE3 P
6 ExB1 GuiL Tab Caps F3 RB~ -> Del <- T Y ] F7 ShiL == Pwr Back [
7 xx Bsch 1 2 3 End PgDn xx Pwr 4 7 8 9 Msel Ptr F5 F10 0
8 Bhom Vmut `~ F1 F2 Home PgUp Ins Del 5 6 = F8 Mprv == CtrL F9 -
//
// Columns (Strobe) // PTB0..3,16,17 PTC4,5 PTD0
// Rows (Sense) // PTD1..7
// Define Rows (Sense) and Columns (Strobes)
GPIO_Pin Matrix_cols[] = { gpio(B,0), gpio(B,1), gpio(B,2), gpio(B,3), gpio(B,16), gpio(B,17), gpio(C,4), gpio(C,6), gpio(D,0) };
GPIO_Pin Matrix_rows[] = { gpio(D,1), gpio(D,2), gpio(D,3), gpio(D,4), gpio(D,5), gpio(D,6), gpio(D,7) };
rows - columns |
1 3 5 7 1 3 5 7 9 11 13 15 17
2 4 6 8 2 4 6 8 10 12 14 16 18 connectors, PCB view
*/
GPIO_Pin Matrix_cols[] = {
gpio(B,16), gpio(B,17), gpio(D,0), gpio(A,12), gpio(A,13), gpio(D,7), gpio(D,4), gpio(D,2), gpio(D,3),
gpio(C,2), gpio(C,1), gpio(D,6), gpio(D,5), gpio(B,2), gpio(B,3), gpio(B,1), gpio(B,0), gpio(C,0) };
GPIO_Pin Matrix_rows[] = {
gpio(C,10), gpio(C,11), gpio(B,18), gpio(A,4), gpio(A,5), gpio(B,19), gpio(C,9), gpio(C,8) };
// Define type of scan matrix
Config Matrix_type = Config_Pulldown;
Config Matrix_type = Config_Pullup;
// Define this if your matrix has ghosting (i.e. regular keyboard without diodes)
// this will enable the anti-ghosting code
#define GHOSTING_MATRIX
// delay in microseconds before and after each strobe change during matrix scan
#define STROBE_DELAY 10

View file

@ -175,6 +175,15 @@ void CustomAction_blockKey_capability( uint8_t state, uint8_t stateType, uint8_t
}
// Signal from the Output Module that the available current has changed
// current - mA
void Scan_currentChange( unsigned int current )
{
// Indicate to all submodules current change
Matrix_currentChange( current );
}
// ----- CLI Command Functions -----

View file

@ -38,6 +38,8 @@ uint8_t Scan_loop( void );
void Scan_finishedWithMacro( uint8_t sentKeys ); // Called by Macro Module
void Scan_finishedWithOutput( uint8_t sentKeys ); // Called by Output Module
void Scan_currentChange( unsigned int current ); // Called by Output Module
// ----- Capabilities -----

View file

@ -36,3 +36,5 @@ void LED_scan();
void LED_currentChange( unsigned int current );
void LED_currentChange( unsigned int current );

View file

@ -30,6 +30,7 @@
#include <led.h>
#include <print.h>
#include <macro.h>
#include <Lib/delay.h>
// Local Includes
#include "matrix_scan.h"
@ -51,6 +52,7 @@ nat_ptr_t Matrix_divCounter = 0;
// CLI Functions
void cliFunc_matrixDebug( char* args );
void cliFunc_matrixInfo( char* args );
void cliFunc_matrixState( char* args );
@ -59,10 +61,12 @@ void cliFunc_matrixState( char* args );
// Scan Module command dictionary
CLIDict_Entry( matrixDebug, "Enables matrix debug mode, prints out each scan code." NL "\t\tIf argument \033[35mT\033[0m is given, prints out each scan code state transition." );
CLIDict_Entry( matrixInfo, "Print info about the configured matrix." );
CLIDict_Entry( matrixState, "Prints out the current scan table N times." NL "\t\t \033[1mO\033[0m - Off, \033[1;33mP\033[0m - Press, \033[1;32mH\033[0m - Hold, \033[1;35mR\033[0m - Release, \033[1;31mI\033[0m - Invalid" );
CLIDict_Def( matrixCLIDict, "Matrix Module Commands" ) = {
CLIDict_Item( matrixDebug ),
CLIDict_Item( matrixInfo ),
CLIDict_Item( matrixState ),
{ 0, 0, 0 } // Null entry for dictionary end
};
@ -110,7 +114,9 @@ uint8_t Matrix_pin( GPIO_Pin gpio, Type type )
// Assumes 0x40 between GPIO Port registers and 0x1000 between PORT pin registers
// See Lib/mk20dx.h
volatile unsigned int *GPIO_PDDR = (unsigned int*)(&GPIOA_PDDR) + gpio_offset;
#ifndef GHOSTING_MATRIX
volatile unsigned int *GPIO_PSOR = (unsigned int*)(&GPIOA_PSOR) + gpio_offset;
#endif
volatile unsigned int *GPIO_PCOR = (unsigned int*)(&GPIOA_PCOR) + gpio_offset;
volatile unsigned int *GPIO_PDIR = (unsigned int*)(&GPIOA_PDIR) + gpio_offset;
volatile unsigned int *PORT_PCR = (unsigned int*)(&PORTA_PCR0) + port_offset;
@ -119,13 +125,19 @@ uint8_t Matrix_pin( GPIO_Pin gpio, Type type )
switch ( type )
{
case Type_StrobeOn:
*GPIO_PSOR |= (1 << gpio.pin);
#ifdef GHOSTING_MATRIX
*GPIO_PDDR |= (1 << gpio.pin); // output
*GPIO_PCOR |= (1 << gpio.pin);
*GPIO_PDDR |= (1 << gpio.pin); // output, low
#else
*GPIO_PSOR |= (1 << gpio.pin);
#endif
break;
case Type_StrobeOff:
#ifdef GHOSTING_MATRIX
// Ghosting martix needs to put not used (off) strobes in high impedance state
*GPIO_PDDR &= ~(1 << gpio.pin); // input, high Z state
#endif
*GPIO_PCOR |= (1 << gpio.pin);
#ifdef GHOSTING_MATRIX
// Ghosting martix needs to put not used (off) strobes in high impedance state
@ -134,8 +146,13 @@ uint8_t Matrix_pin( GPIO_Pin gpio, Type type )
break;
case Type_StrobeSetup:
#ifdef GHOSTING_MATRIX
*GPIO_PDDR &= ~(1 << gpio.pin); // input, high Z state
*GPIO_PCOR |= (1 << gpio.pin);
#else
// Set as output pin
*GPIO_PDDR |= (1 << gpio.pin);
#endif
// Configure pin with slow slew, high drive strength and GPIO mux
*PORT_PCR = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
@ -154,7 +171,11 @@ uint8_t Matrix_pin( GPIO_Pin gpio, Type type )
break;
case Type_Sense:
#ifdef GHOSTING_MATRIX // inverted
return *GPIO_PDIR & (1 << gpio.pin) ? 0 : 1;
#else
return *GPIO_PDIR & (1 << gpio.pin) ? 1 : 0;
#endif
case Type_SenseSetup:
// Set as input pin
@ -190,30 +211,18 @@ void Matrix_setup()
// Register Matrix CLI dictionary
CLI_registerDictionary( matrixCLIDict, matrixCLIDictName );
info_msg("Columns: ");
printHex( Matrix_colsNum );
// Setup Strobe Pins
for ( uint8_t pin = 0; pin < Matrix_colsNum; pin++ )
{
Matrix_pin( Matrix_cols[ pin ], Type_StrobeSetup );
}
print( NL );
info_msg("Rows: ");
printHex( Matrix_rowsNum );
// Setup Sense Pins
for ( uint8_t pin = 0; pin < Matrix_rowsNum; pin++ )
{
Matrix_pin( Matrix_rows[ pin ], Type_SenseSetup );
}
print( NL );
info_msg("Max Keys: ");
printHex( Matrix_maxKeys );
print( NL );
// Clear out Debounce Array
for ( uint8_t item = 0; item < Matrix_maxKeys; item++ )
{
@ -294,9 +303,19 @@ void Matrix_scan( uint16_t scanNum )
// For each strobe, scan each of the sense pins
for ( uint8_t strobe = 0; strobe < Matrix_colsNum; strobe++ )
{
#ifdef STROBE_DELAY
uint32_t start = micros();
while ((micros() - start) < STROBE_DELAY);
#endif
// Strobe Pin
Matrix_pin( Matrix_cols[ strobe ], Type_StrobeOn );
#ifdef STROBE_DELAY
start = micros();
while ((micros() - start) < STROBE_DELAY);
#endif
// Scan each of the sense pins
for ( uint8_t sense = 0; sense < Matrix_rowsNum; sense++ )
{
@ -578,7 +597,22 @@ void Matrix_currentChange( unsigned int current )
// ----- CLI Command Functions -----
void cliFunc_matrixDebug ( char* args )
void cliFunc_matrixInfo( char* args )
{
print( NL );
info_msg("Columns: ");
printHex( Matrix_colsNum );
print( NL );
info_msg("Rows: ");
printHex( Matrix_rowsNum );
print( NL );
info_msg("Max Keys: ");
printHex( Matrix_maxKeys );
}
void cliFunc_matrixDebug( char* args )
{
// Parse number from argument
// NOTE: Only first argument is used
@ -612,7 +646,7 @@ void cliFunc_matrixDebug ( char* args )
printInt8( matrixDebugMode );
}
void cliFunc_matrixState ( char* args )
void cliFunc_matrixState( char* args )
{
// Parse number from argument
// NOTE: Only first argument is used

View file

@ -95,7 +95,7 @@ ISSILedMask1 = "
0xFF, 0x00, /* C6-1 -> C6-16 */
0xFF, 0x00, /* C7-1 -> C7-16 */
0xFF, 0x00, /* C8-1 -> C8-16 */
0xFE, 0x00, /* C9-1 -> C9-16 */
0xFF, 0x00, /* C9-1 -> C9-16 */
";
# LED Brightness Override
@ -124,6 +124,6 @@ ISSILedBrightness1 = "
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C6-1 -> C6-16 */
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C7-1 -> C7-16 */
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C8-1 -> C8-16 */
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C9-1 -> C9-16 */
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C9-1 -> C9-16 */
";