/**
******************************************************************************
* @file stm8_tsl_multichannelkey.c
* @author MCD Application Team
* @version V2.5.0
* @date 14-October-2013
* @brief This file provides the functions to manage the multi channel Key (wheel/slider).
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8_tsl_multichannelkey.h"
#include "stm8_tsl_api.h"
#include "stm8_tsl_services.h"
/* CONDITIONAL COMPILING FOR MCKEYS */
#if NUMBER_OF_MULTI_CHANNEL_KEYS > 0
/* Memory section ------------------------------------------------------------*/
#if defined(_COSMIC_) && defined(USE_PRAGMA_SECTION)
#pragma section [TSLMCK_RAM]
#pragma section @tiny [TSLMCK_RAM0]
#pragma section (TSLMCK_CODE)
#pragma section const {TSLMCK_CONST}
#endif
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//----- MCKEY1 __CONSTANT TABLES FOR POSITION CALCULATION -----
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#if CHANNEL_PER_MCKEY == 5
#if MCKEY1_TYPE == 0 // Wheel
#if MCKEY1_LAYOUT_TYPE == 0 // Interlaced electrodes
CONST s16 MCKEY1_TABLE_POSITION_OFFSET[CHANNEL_PER_MCKEY][CHANNEL_PER_MCKEY] =
{
// sec = 1 2 3 4 5
// j = 0 1 2 3 4
0, -19, -83, 122, 58, // maj = 1; i = 0
6, 0, -32, -122, 96, // maj = 2; i = 1
70, 19, 0, -45, -96, // maj = 3; i = 2
-6, 109, 32, 0, -58, // maj = 4; i = 3
-70, -109, 83, 45, 0 // maj = 5; i = 4
};
#define MCKEY1_SECTOR_COMPUTATION (26)
#define MCKEY1_POSITION_CORRECTION (0)
#else // Normal electrodes
CONST s16 MCKEY1_TABLE_POSITION_OFFSET[CHANNEL_PER_MCKEY][CHANNEL_PER_MCKEY] =
{
// sec = 1 2 3 4 5
// j = 0 1 2 3 4
0, -38, 0, 0, 115, // maj = 1; i = 0
13, 0, -64, 0, 0, // maj = 2; i = 1
0, 38, 0, -90, 0, // maj = 3; i = 2
0, 0, 64, 0, -115, // maj = 4; i = 3
-13, 0, 0, 90, 0 // maj = 5; i = 4
};
#define MCKEY1_SECTOR_COMPUTATION (51)
#define MCKEY1_POSITION_CORRECTION (0)
#endif
#endif
#if MCKEY1_TYPE == 1 // Slider
#if MCKEY1_LAYOUT_TYPE == 0 // Interlaced electrodes
CONST s16 MCKEY1_TABLE_POSITION_OFFSET[CHANNEL_PER_MCKEY][CHANNEL_PER_MCKEY] =
{
// sec = 1 2 3 4 5
// j = 0 1 2 3 4
0, -21, -92, 135, 64, // maj = 1; i = 0
7, 0, -36, -135, 107, // maj = 2; i = 1
78, 21, 0, -50, -107, // maj = 3; i = 2
-149, 121, 36, 0, -64, // maj = 4; i = 3
-78, -121, 92, 50, 0 // maj = 5; i = 4
};
#define MCKEY1_SECTOR_COMPUTATION (28)
#define MCKEY1_POSITION_CORRECTION (28)
#else // Normal electrodes
CONST s16 MCKEY1_TABLE_POSITION_OFFSET[CHANNEL_PER_MCKEY][CHANNEL_PER_MCKEY] =
{
// sec = 1 2 3 4 5
// j = 0 1 2 3 4
0, -64, 0, 0, 0, // maj = 1; i = 0
21, 0, -107, 0, 0, // maj = 2; i = 1
0, 64, 0, -149, 0, // maj = 3; i = 2
0, 0, 107, 0, -192, // maj = 4; i = 3
0, 0, 0, 149, 0 // maj = 5; i = 4
};
#define MCKEY1_SECTOR_COMPUTATION (85)
#define MCKEY1_POSITION_CORRECTION (85)
#endif
#endif
#endif // CHANNEL_PER_MCKEY == 5
#if CHANNEL_PER_MCKEY == 8
#if MCKEY1_TYPE == 0 // Wheel
#if MCKEY1_LAYOUT_TYPE == 0 // Interlaced electrodes
CONST s16 MCKEY1_TABLE_POSITION_OFFSET[CHANNEL_PER_MCKEY][CHANNEL_PER_MCKEY] =
{
// sec = 1 2 3 4 5 6 7 8
// j = 0 1 2 3 4 5 6 7
0, -12, 0, -76, 0, 124, 0, 60, // maj = 1; i = 0
4, 0, -20, 0, -100, 0, 84, 0, // maj = 2; i = 1
0, 12, 0, -28, 0, -124, 0, 108, // maj = 3; i = 2
68, 0, 20, 0, -36, 0, -84, 0, // maj = 4; i = 3
0, 92, 0, 28, 0, -44, 0, -108, // maj = 5; i = 4
-4, 0, 116, 0, 36, 0, -52, 0, // maj = 6; i = 5
0, -92, 0, 76, 0, 44, 0, -60, // maj = 7; i = 6
-68, 0, -116, 0, 100, 0, 52, 0 // maj = 8; i = 7
};
#define MCKEY1_SECTOR_COMPUTATION (16)
#define MCKEY1_POSITION_CORRECTION (0)
#else // Normal electrodes
CONST s16 MCKEY1_TABLE_POSITION_OFFSET[CHANNEL_PER_MCKEY][CHANNEL_PER_MCKEY] =
{
// sec = 1 2 3 4 5 6 7 8
// j = 0 1 2 3 4 5 6 7
0, -24, 0, 0, 0, 0, 0, 120, // maj = 1; i = 0
8, 0, -40, 0, 0, 0, 0, 0, // maj = 2; i = 1
0, 24, 0, -56, 0, 0, 0, 0, // maj = 3; i = 2
0, 0, 40, 0, -72, 0, 0, 0, // maj = 4; i = 3
0, 0, 0, 56, 0, -88, 0, 0, // maj = 5; i = 4
0, 0, 0, 0, 72, 0, -104, 0, // maj = 6; i = 5
0, 0, 0, 0, 0, 88, 0, -120, // maj = 7; i = 6
-8, 0, 0, 0, 0, 0, 104, 0 // maj = 8; i = 7
};
#define MCKEY1_SECTOR_COMPUTATION (32)
#define MCKEY1_POSITION_CORRECTION (0)
#endif
#endif
#if MCKEY1_TYPE == 1 // Slider
#if MCKEY1_LAYOUT_TYPE == 0 // Interlaced electrodes
CONST s16 MCKEY1_TABLE_POSITION_OFFSET[CHANNEL_PER_MCKEY][CHANNEL_PER_MCKEY] =
{
// sec = 1 2 3 4 5 6 7 8
// j = 0 1 2 3 4 5 6 7
0, -13, 0, -81, 0, 132, 0, 64, // maj = 1; i = 0
4, 0, -21, 0, -107, 0, 90, 0, // maj = 2; i = 1
0, 13, 0, -30, 0, -132, 0, 115, // maj = 3; i = 2
73, 0, 21, 0, -38, 0, -90, 0, // maj = 4; i = 3
0, 98, 0, 30, 0, -47, 0, -115, // maj = 5; i = 4
-141, 0, 124, 0, 38, 0, -55, 0, // maj = 6; i = 5
0, -98, 0, 81, 0, 47, 0, -64, // maj = 7; i = 6
-73, 0, -124, 0, 107, 0, 55, 0 // maj = 8; i = 7
};
#define MCKEY1_SECTOR_COMPUTATION (17)
#define MCKEY1_POSITION_CORRECTION (17)
#else // Normal electrodes
CONST s16 MCKEY1_TABLE_POSITION_OFFSET[CHANNEL_PER_MCKEY][CHANNEL_PER_MCKEY] =
{
// sec = 1 2 3 4 5 6 7 8
// j = 0 1 2 3 4 5 6 7
0, -32, 0, 0, 0, 0, 0, 0, // maj = 1; i = 0
11, 0, -53, 0, 0, 0, 0, 0, // maj = 2; i = 1
0, 32, 0, -75, 0, 0, 0, 0, // maj = 3; i = 2
0, 0,