Add touch sensitivity settimgs
This commit is contained in:
parent
2c9ebcc6a2
commit
f9b685e891
|
@ -264,7 +264,7 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa
|
||||||
getdisplay().print("USB ");
|
getdisplay().print("USB ");
|
||||||
}
|
}
|
||||||
double gpshdop = formatValue(hdop, commonData).value;
|
double gpshdop = formatValue(hdop, commonData).value;
|
||||||
if(commonData.config->getString(commonData.config->useGPS) != "off" && gpshdop > 1.0){
|
if(commonData.config->getString(commonData.config->useGPS) != "off" && gpshdop > 0.3){
|
||||||
getdisplay().print("GPS");
|
getdisplay().print("GPS");
|
||||||
}
|
}
|
||||||
// Save old telegram counter
|
// Save old telegram counter
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
#define MIN_VOLTAGE 10.0 // Min voltage for under voltage detection (then goto deep sleep)
|
#define MIN_VOLTAGE 10.0 // Min voltage for under voltage detection (then goto deep sleep)
|
||||||
#define POWER_FAIL_TIME 2 // in [ms] Accept min voltage until 2 x 1ms (for under voltage gaps by engine start)
|
#define POWER_FAIL_TIME 2 // in [ms] Accept min voltage until 2 x 1ms (for under voltage gaps by engine start)
|
||||||
// Touch buttons
|
// Touch buttons
|
||||||
#define TOUCHTHRESHOLD 50000// Touch sensitivity, lower values more sensitiv
|
|
||||||
#define TP1 14 // Left outside
|
#define TP1 14 // Left outside
|
||||||
#define TP2 13
|
#define TP2 13
|
||||||
#define TP3 12
|
#define TP3 12
|
||||||
|
|
|
@ -20,42 +20,50 @@ bool keylock = false; // Key lock after pressed key is valid (repeat protectio
|
||||||
long starttime = 0; // Start time point for pressed key
|
long starttime = 0; // Start time point for pressed key
|
||||||
|
|
||||||
|
|
||||||
int readKeypad() {
|
int readKeypad(uint thSensitivity) {
|
||||||
|
|
||||||
|
// Touch sensor values
|
||||||
|
// 35000 - Not touched
|
||||||
|
// 50000 - Light toched with fingertip
|
||||||
|
// 70000 - Touched
|
||||||
|
// 170000 - Strong touched
|
||||||
|
uint32_t touchthreshold = (thSensitivity * -1200) + 170000; // thSensitivity 0...100%
|
||||||
|
|
||||||
int keystatus = 0; // Status of key [0...11], 0 = processed, 1...8 = key 1..8, 9 = right swipe , 10 = left swipe, 11 keys disabled
|
int keystatus = 0; // Status of key [0...11], 0 = processed, 1...8 = key 1..8, 9 = right swipe , 10 = left swipe, 11 keys disabled
|
||||||
keycode = 0;
|
keycode = 0;
|
||||||
|
|
||||||
// Read key code
|
// Read key code
|
||||||
if(touchRead(14) > TOUCHTHRESHOLD){ // Touch pad 1
|
if(touchRead(14) > touchthreshold){ // Touch pad 1
|
||||||
keypad[1] = 1;
|
keypad[1] = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
keypad[1] = 0;
|
keypad[1] = 0;
|
||||||
}
|
}
|
||||||
if(touchRead(13) > TOUCHTHRESHOLD){ // Touch pad 2
|
if(touchRead(13) > touchthreshold){ // Touch pad 2
|
||||||
keypad[2] = 1;
|
keypad[2] = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
keypad[2] = 0;
|
keypad[2] = 0;
|
||||||
}
|
}
|
||||||
if(touchRead(12) > TOUCHTHRESHOLD){ // Touch pad 3
|
if(touchRead(12) > touchthreshold){ // Touch pad 3
|
||||||
keypad[3] = 1;
|
keypad[3] = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
keypad[3] = 0;
|
keypad[3] = 0;
|
||||||
}
|
}
|
||||||
if(touchRead(11) > TOUCHTHRESHOLD){ // Touch pad 4
|
if(touchRead(11) > touchthreshold){ // Touch pad 4
|
||||||
keypad[4] = 1;
|
keypad[4] = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
keypad[4] = 0;
|
keypad[4] = 0;
|
||||||
}
|
}
|
||||||
if(touchRead(10) > TOUCHTHRESHOLD){ // Touch pad 5
|
if(touchRead(10) > touchthreshold){ // Touch pad 5
|
||||||
keypad[5] = 1;
|
keypad[5] = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
keypad[5] = 0;
|
keypad[5] = 0;
|
||||||
}
|
}
|
||||||
if(touchRead(9) > TOUCHTHRESHOLD){ // Touch pad 6
|
if(touchRead(9) > touchthreshold){ // Touch pad 6
|
||||||
keypad[6] = 1;
|
keypad[6] = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -567,6 +567,20 @@
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "tSensitivity",
|
||||||
|
"label": "Touch Sensitivity [%]",
|
||||||
|
"type": "number",
|
||||||
|
"default": "100",
|
||||||
|
"check": "checkMinMax",
|
||||||
|
"min": 0,
|
||||||
|
"max": 100,
|
||||||
|
"description": "Touch sensitivity [0...100%] for sensor buttons",
|
||||||
|
"category": "OBP60 Calibrations",
|
||||||
|
"capabilities": {
|
||||||
|
"obp60":"true"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "vOffset",
|
"name": "vOffset",
|
||||||
"label": "VSensor Offset",
|
"label": "VSensor Offset",
|
||||||
|
|
|
@ -83,20 +83,20 @@ typedef struct {
|
||||||
int page0=0;
|
int page0=0;
|
||||||
QueueHandle_t queue;
|
QueueHandle_t queue;
|
||||||
GwLog* logger = NULL;
|
GwLog* logger = NULL;
|
||||||
|
// GwApi* api = NULL;
|
||||||
|
uint sensitivity = 100;
|
||||||
} MyData;
|
} MyData;
|
||||||
|
|
||||||
// Keyboard Task
|
// Keyboard Task
|
||||||
//####################################################################################
|
|
||||||
int readKeypad();
|
|
||||||
|
|
||||||
void keyboardTask(void *param){
|
void keyboardTask(void *param){
|
||||||
MyData *data=(MyData *)param;
|
MyData *data=(MyData *)param;
|
||||||
|
|
||||||
int keycode = 0;
|
int keycode = 0;
|
||||||
data->logger->logDebug(GwLog::LOG,"Start keyboard task");
|
data->logger->logDebug(GwLog::LOG,"Start keyboard task");
|
||||||
|
|
||||||
// Loop for keyboard task
|
// Loop for keyboard task
|
||||||
while (true){
|
while (true){
|
||||||
keycode = readKeypad();
|
keycode = readKeypad(data->sensitivity);
|
||||||
//send a key event
|
//send a key event
|
||||||
if(keycode != 0){
|
if(keycode != 0){
|
||||||
xQueueSend(data->queue, &keycode, 0);
|
xQueueSend(data->queue, &keycode, 0);
|
||||||
|
@ -382,6 +382,7 @@ void OBP60Task(GwApi *api){
|
||||||
allParameters.logger=api->getLogger();
|
allParameters.logger=api->getLogger();
|
||||||
allParameters.page0=3;
|
allParameters.page0=3;
|
||||||
allParameters.queue=xQueueCreate(10,sizeof(int));
|
allParameters.queue=xQueueCreate(10,sizeof(int));
|
||||||
|
allParameters.sensitivity= api->getConfig()->getInt(GwConfigDefinitions::tSensitivity);
|
||||||
xTaskCreate(keyboardTask,"keyboard",2000,&allParameters,configMAX_PRIORITIES-1,NULL);
|
xTaskCreate(keyboardTask,"keyboard",2000,&allParameters,configMAX_PRIORITIES-1,NULL);
|
||||||
SharedData *shared=new SharedData(api);
|
SharedData *shared=new SharedData(api);
|
||||||
createSensorTask(shared);
|
createSensorTask(shared);
|
||||||
|
|
Loading…
Reference in New Issue