Browse Source

Initial structure of ARM cap sense controller

capsense
Jacob Alexander 8 years ago
parent
commit
39dbb85c1a

+ 11
- 0
Scan/CapSense/capabilities.kll View File

@@ -0,0 +1,11 @@
Name = CapSenseCapabilities;
Version = 0.1;
Author = "HaaTa (Jacob Alexander) 2016";
KLL = 0.3d;

# Modified Date
Date = 2016-04-11;

# Defines available to the CapSense sub-module
# TODO Add cap sense configuration here


+ 126
- 0
Scan/CapSense/matrix_scan.c View File

@@ -0,0 +1,126 @@
/* Copyright (C) 2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file. If not, see <http://www.gnu.org/licenses/>.
*/

// ----- Includes -----

// Compiler Includes
#include <Lib/ScanLib.h>

// Project Includes
#include <cli.h>
#include <kll_defs.h>
#include <led.h>
#include <print.h>
#include <macro.h>
#include <Lib/delay.h>

// Local Includes
#include "matrix_scan.h"

// Matrix Configuration
//#include <matrix.h>



// ----- Defines -----

// ----- Function Declarations -----

// CLI Functions
void cliFunc_matrixDebug( char* args );
void cliFunc_matrixInfo( char* args );
void cliFunc_matrixState( char* args );



// ----- Variables -----

// 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
};



// ----- Functions -----

void Matrix_setup()
{
// Register Matrix CLI dictionary
CLI_registerDictionary( matrixCLIDict, matrixCLIDictName );
}

// Scan the matrix for keypresses
// NOTE: scanNum should be reset to 0 after a USB send (to reset all the counters)
void Matrix_scan( uint16_t scanNum )
{
}


// Called by parent scan module whenever the available current changes
// current - mA
void Matrix_currentChange( unsigned int current )
{
// TODO - Any potential power savings?
}



// ----- CLI Command Functions -----

void cliFunc_matrixInfo( char* args )
{
}

void cliFunc_matrixDebug( char* args )
{
// Parse number from argument
// NOTE: Only first argument is used
char* arg1Ptr;
char* arg2Ptr;
CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );

// Set the matrix debug flag depending on the argument
// If no argument, set to scan code only
// If set to T, set to state transition
switch ( arg1Ptr[0] )
{
// T as argument
case 'T':
case 't':
break;

// No argument
case '\0':
break;

// Invalid argument
default:
return;
}
}

void cliFunc_matrixState( char* args )
{
}


+ 38
- 0
Scan/CapSense/matrix_scan.h View File

@@ -0,0 +1,38 @@
/* Copyright (C) 2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

// ----- Includes -----

// KLL Generated Defines
#include <kll_defs.h>



// ----- Defines -----

// ----- Enums -----

// ----- Structs -----

// ----- Functions -----

void Matrix_setup();
void Matrix_scan( uint16_t scanNum );

void Matrix_currentChange( unsigned int current );


+ 20
- 0
Scan/CapSense/matrix_setup.h View File

@@ -0,0 +1,20 @@
/* Copyright (C) 2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

// TODO


+ 30
- 0
Scan/CapSense/setup.cmake View File

@@ -0,0 +1,30 @@
###| CMake Kiibohd Controller Scan Module |###
#
# Written by Jacob Alexander in 2016 for the Kiibohd Controller
#
# Released into the Public Domain
#
###


###
# Sub-module flag, cannot be included stand-alone
#
set ( SubModule 1 )


###
# Module C files
#
set ( Module_SRCS
matrix_scan.c
)


###
# Compiler Family Compatibility
#
set ( ModuleCompatibility
arm
)


+ 73
- 0
Scan/CapTest1/defaultMap.kll View File

@@ -0,0 +1,73 @@
Name = CapTest1;
Version = 0.3d;
Author = "HaaTa (Jacob Alexander) 2016";
KLL = 0.3c;

# Modified Date
Date = 2016-04-11;

# TODO
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


+ 32
- 0
Scan/CapTest1/matrix.h View File

@@ -0,0 +1,32 @@
/* Copyright (C) 2014-2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

// ----- Includes -----

// Project Includes
#include <matrix_setup.h>



// ----- Matrix Definition -----

// TODO
// Define possible strobes
// Define possible senses
// Misc pins required for control


+ 92
- 0
Scan/CapTest1/scan_loop.c View File

@@ -0,0 +1,92 @@
/* Copyright (C) 2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file. If not, see <http://www.gnu.org/licenses/>.
*/

// ----- Includes -----

// Compiler Includes
#include <Lib/ScanLib.h>

// Project Includes
#include <cli.h>
#include <led.h>
#include <print.h>
#include <matrix_scan.h>
#include <macro.h>
#include <output_com.h>

// Local Includes
#include "scan_loop.h"



// ----- Function Declarations -----

// ----- Variables -----

// Number of scans since the last USB send
uint16_t Scan_scanCount = 0;



// ----- Functions -----

// Setup
inline void Scan_setup()
{
// Setup cap sense matrix pins for scanning
Matrix_setup();

// Reset scan count
Scan_scanCount = 0;
}


// Main Detection Loop
inline uint8_t Scan_loop()
{
Matrix_scan( Scan_scanCount++ );

return 0;
}


// Signal from Macro Module that all keys have been processed (that it knows about)
inline void Scan_finishedWithMacro( uint8_t sentKeys )
{
}


// Signal from Output Module that all keys have been processed (that it knows about)
inline void Scan_finishedWithOutput( uint8_t sentKeys )
{
// Reset scan loop indicator (resets each key debounce state)
// TODO should this occur after USB send or Macro processing?
Scan_scanCount = 0;
}


// 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 );
}



// ----- Capabilities -----


+ 40
- 0
Scan/CapTest1/scan_loop.h View File

@@ -0,0 +1,40 @@
/* Copyright (C) 2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

// ----- Includes -----

// Compiler Includes
#include <stdint.h>



// ----- Functions -----

// Functions to be called by main.c
void Scan_setup();
uint8_t Scan_loop();

// Call-backs
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 -----


+ 32
- 0
Scan/CapTest1/setup.cmake View File

@@ -0,0 +1,32 @@
###| CMake Kiibohd Controller Scan Module |###
#
# Written by Jacob Alexander in 2016 for the Kiibohd Controller
#
# Released into the Public Domain
#
###


###
# Required Submodules
#

AddModule ( Scan CapSense )


###
# Module C files
#

set ( Module_SRCS
scan_loop.c
)


###
# Compiler Family Compatibility
#
set ( ModuleCompatibility
arm
)