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 ");
|
||||
}
|
||||
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");
|
||||
}
|
||||
// Save old telegram counter
|
||||
|
|
|
@ -63,6 +63,6 @@ SunData calcSunsetSunrise(GwApi *api, double time, double date, double latitude,
|
|||
|
||||
void batteryGraphic(uint x, uint y, float percent, int pcolor, int bcolor); // Battery graphic with fill level
|
||||
void solarGraphic(uint x, uint y, int pcolor, int bcolor); // Solar graphic with fill level
|
||||
void generatorGraphic(uint x, uint y, int pcolor, int bcolor); // Generator graphic with fill level
|
||||
void generatorGraphic(uint x, uint y, int pcolor, int bcolor); // Generator graphic with fill level
|
||||
|
||||
#endif
|
|
@ -61,7 +61,6 @@
|
|||
#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)
|
||||
// Touch buttons
|
||||
#define TOUCHTHRESHOLD 50000// Touch sensitivity, lower values more sensitiv
|
||||
#define TP1 14 // Left outside
|
||||
#define TP2 13
|
||||
#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
|
||||
|
||||
|
||||
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
|
||||
keycode = 0;
|
||||
|
||||
// Read key code
|
||||
if(touchRead(14) > TOUCHTHRESHOLD){ // Touch pad 1
|
||||
if(touchRead(14) > touchthreshold){ // Touch pad 1
|
||||
keypad[1] = 1;
|
||||
}
|
||||
else{
|
||||
keypad[1] = 0;
|
||||
}
|
||||
if(touchRead(13) > TOUCHTHRESHOLD){ // Touch pad 2
|
||||
if(touchRead(13) > touchthreshold){ // Touch pad 2
|
||||
keypad[2] = 1;
|
||||
}
|
||||
else{
|
||||
keypad[2] = 0;
|
||||
}
|
||||
if(touchRead(12) > TOUCHTHRESHOLD){ // Touch pad 3
|
||||
if(touchRead(12) > touchthreshold){ // Touch pad 3
|
||||
keypad[3] = 1;
|
||||
}
|
||||
else{
|
||||
keypad[3] = 0;
|
||||
}
|
||||
if(touchRead(11) > TOUCHTHRESHOLD){ // Touch pad 4
|
||||
if(touchRead(11) > touchthreshold){ // Touch pad 4
|
||||
keypad[4] = 1;
|
||||
}
|
||||
else{
|
||||
keypad[4] = 0;
|
||||
}
|
||||
if(touchRead(10) > TOUCHTHRESHOLD){ // Touch pad 5
|
||||
if(touchRead(10) > touchthreshold){ // Touch pad 5
|
||||
keypad[5] = 1;
|
||||
}
|
||||
else{
|
||||
keypad[5] = 0;
|
||||
}
|
||||
if(touchRead(9) > TOUCHTHRESHOLD){ // Touch pad 6
|
||||
if(touchRead(9) > touchthreshold){ // Touch pad 6
|
||||
keypad[6] = 1;
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -73,7 +73,7 @@ void sensorTask(void *param){
|
|||
Timer1.start(); // Start Timer1 for undervoltage detection
|
||||
}
|
||||
Timer1.start(); // Start Timer2 for blinking LED
|
||||
|
||||
|
||||
// Direction settings for NMEA0183
|
||||
String nmea0183Mode = api->getConfig()->getConfigItem(api->getConfig()->serialDirection, true)->asString();
|
||||
api->getLogger()->logDebug(GwLog::LOG, "NMEA0183 Mode is: %s", nmea0183Mode);
|
||||
|
|
|
@ -567,6 +567,20 @@
|
|||
"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",
|
||||
"label": "VSensor Offset",
|
||||
|
|
|
@ -83,20 +83,20 @@ typedef struct {
|
|||
int page0=0;
|
||||
QueueHandle_t queue;
|
||||
GwLog* logger = NULL;
|
||||
// GwApi* api = NULL;
|
||||
uint sensitivity = 100;
|
||||
} MyData;
|
||||
|
||||
// Keyboard Task
|
||||
//####################################################################################
|
||||
int readKeypad();
|
||||
|
||||
void keyboardTask(void *param){
|
||||
MyData *data=(MyData *)param;
|
||||
|
||||
int keycode = 0;
|
||||
data->logger->logDebug(GwLog::LOG,"Start keyboard task");
|
||||
|
||||
// Loop for keyboard task
|
||||
while (true){
|
||||
keycode = readKeypad();
|
||||
keycode = readKeypad(data->sensitivity);
|
||||
//send a key event
|
||||
if(keycode != 0){
|
||||
xQueueSend(data->queue, &keycode, 0);
|
||||
|
@ -382,6 +382,7 @@ void OBP60Task(GwApi *api){
|
|||
allParameters.logger=api->getLogger();
|
||||
allParameters.page0=3;
|
||||
allParameters.queue=xQueueCreate(10,sizeof(int));
|
||||
allParameters.sensitivity= api->getConfig()->getInt(GwConfigDefinitions::tSensitivity);
|
||||
xTaskCreate(keyboardTask,"keyboard",2000,&allParameters,configMAX_PRIORITIES-1,NULL);
|
||||
SharedData *shared=new SharedData(api);
|
||||
createSensorTask(shared);
|
||||
|
|
Loading…
Reference in New Issue