bool TSSSystem::isElecTouched(uint8_t elec_num) const { if (elec_num < TSS_N_ELECTRODES) { uint8_t elec_shift = (uint8_t)(elec_num >> 3u); uint8_t elec_touched_temp = (uint8_t)TSS_GetSystemConfig(System_ElectrodeStatus_Register + elec_shift); return (elec_touched_temp & (uint8_t)(1u << (uint8_t)(elec_num & 0x07u))); }
/*FUNCTION*---------------------------------------------------------------- * * Function Name : hmi_tss_get_value * Returned Value : bool * Comments : * This function gets value of requested TSS element. * *END*--------------------------------------------------------------------*/ static bool hmi_tss_get_value(HMI_PROVIDER_STRUCT_PTR provider_struct, uint32_t uid, uint32_t *value) { /* get context structure */ HMI_TSS_CONTEXT_STRUCT_PTR context_struct = (HMI_TSS_CONTEXT_STRUCT_PTR) provider_struct->CONTEXT_PTR; uint8_t i; bool result = FALSE; uint8_t electrodes_status; uint8_t electrode_index; /* get TSS control structure */ uint8_t *tss_control_struct_ptr = (uint8_t *)TSS_GetControlStruct(context_struct->CONTROL_NUMBER); if (tss_control_struct_ptr == NULL || context_struct == NULL) { return result; } if ((((TSS_CSRotary *)tss_control_struct_ptr)->ControlId.ControlType) == TSS_CT_ROTARY) /* rotary */ { if (context_struct->TSS_TABLE[0].UID == uid) { *value = (*(TSS_CSRotary *)tss_control_struct_ptr).StaticStatus.Position; /* actual absolute position */ result = TRUE; } } else if ((((TSS_CSSlider *)tss_control_struct_ptr)->ControlId.ControlType) == TSS_CT_SLIDER) /* slider */ { if (context_struct->TSS_TABLE[0].UID == uid) { *value = (*(TSS_CSSlider *)tss_control_struct_ptr).StaticStatus.Position; /* actual absolute position */ result = TRUE; } } else if ((((TSS_CSKeypad *)tss_control_struct_ptr)->ControlId.ControlType) == TSS_CT_KEYPAD) /* keypad */ { for (i=0; i<context_struct->TSS_COUNT; i++) { if (context_struct->TSS_TABLE[i].UID == uid) { /* get index */ electrode_index = (TSS_GetControlFirstElectrodeIndex(context_struct->CONTROL_NUMBER) + i); /* electrodes status */ electrodes_status = TSS_GetSystemConfig(System_ElectrodeStatus_Register + (electrode_index/8u)); /* status of requested electrode */ *value = (uint32_t)(electrodes_status >> (electrode_index % 8u)) & 0x1; result = TRUE; break; } } }
/* ** =================================================================== ** Method : TSS1_Configure (component TSS_Library) ** This method can be used also under name "Configure" ** ** Description : ** Whole TSS initialization and configuration of registers. ** Contains main TSS_Init() function, TSS System Config ** registers and all Control Config registers initialization ** according to setting of Component properties. The user have ** to place this function into the proper location in the ** source code. ** Parameters : None ** Returns : ** --- - Error status code of Configure method. If ** the configuration is successful the ** TSS_STATUS_OK is reported, otherwise is ** reported one of error status codes ** described in TSSAPIRM document. ** =================================================================== */ byte TSS1_Configure(void) { byte u8Temp; byte u8Result = TSS_STATUS_OK; /* Main TSS Initialization */ u8Result |= TSS_Init(); /* Configure the Keypad Control to report the touch and release events */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_Events_Register, TSS_KEYPAD_TOUCH_EVENT_EN_MASK); /* Configure the Keypad Max Touches Register */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_MaxTouches_Register, 0x08); /* Configure the Auto-Repeat Rate Register */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_AutoRepeatRate_Register, 0x00); /* Configure the Auto-Repeat Start Register */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_AutoRepeatStart_Register, 0x00); /* Configure Keypad Control configuration registers */ u8Result |= TSS_SetKeypadConfig(TSS1_cKey0.ControlId, Keypad_ControlConfig_Register, TSS_KEYPAD_CONTROL_EN_MASK | TSS_KEYPAD_CALLBACK_EN_MASK); /* Enables electrodes */ u8Temp = (byte) TSS_GetSystemConfig(System_ElectrodeEnablers_Register+0); u8Result |= TSS_SetSystemConfig(System_ElectrodeEnablers_Register+0, (u8Temp | 0xFF) & ~0x00); /* Electrode dc-tracker enablers */ u8Result |= TSS_SetSystemConfig(System_DCTrackerEnablers_Register+0, 0xFF); /* Sets Trigger Mode */ u8Result |= TSS_SetSystemConfig(System_SystemTrigger_Register, TSS_TRIGGER_MODE_ALWAYS); /* Sets the Number of samples for all electrodes */ u8Result |= TSS_SetSystemConfig(System_NSamples_Register, 0x08); /* Configures the DC Tracker value */ u8Result |= TSS_SetSystemConfig(System_DCTrackerRate_Register, 0x64); /* Configures the Slow DC Tracker Factor value */ u8Result |= TSS_SetSystemConfig(System_SlowDCTrackerFactor_Register, 0x64); /* Configures the Response Time */ u8Result |= TSS_SetSystemConfig(System_ResponseTime_Register, 0x04); /* Configures the Stuck-key Timeout */ u8Result |= TSS_SetSystemConfig(System_StuckKeyTimeout_Register, 0x00); /* Configures System SystemConfig Register */ u8Result |= TSS_SetSystemConfig(System_SystemConfig_Register, TSS_SYSTEM_EN_MASK | TSS_DC_TRACKER_EN_MASK | TSS_WATER_TOLERANCE_EN_MASK | TSS_LOWPOWER_EN_MASK); return u8Result; }
/* ** =================================================================== ** Method : TSSTouch_Configure (component TSS_Library) ** This method can be used also under name "Configure" ** ** Description : ** Whole TSS initialization and configuration of registers. ** Contains main TSS_Init() function, TSS System Config ** registers and all Control Config registers initialization ** according to setting of Component properties. The user have ** to place this function into the proper location in the ** source code. ** Parameters : None ** Returns : ** --- - Error status code of Configure method. If ** the configuration is successful the ** TSS_STATUS_OK is reported, otherwise is ** reported one of error status codes ** described in TSSAPIRM document. ** =================================================================== */ byte TSSTouch_Configure(void) { byte u8Temp; byte u8Result = TSS_STATUS_OK; /* Main TSS Initialization */ u8Result |= TSS_Init(); /* Configure the Analog Slider Control to report the touch and release events */ u8Result |= TSS_SetASliderConfig(TSSTouch_cKey0.ControlId, ASlider_Events_Register, TSS_ASLIDER_MOVEMENT_EVENT_EN_MASK | TSS_ASLIDER_INITIAL_TOUCH_EVENT_EN_MASK); /* Configure the Analog Slider Auto-Repeat Rate Register */ u8Result |= TSS_SetASliderConfig(TSSTouch_cKey0.ControlId, ASlider_AutoRepeatRate_Register, 0x00); /* Configure the Analog Slider Movement Timeout Register */ u8Result |= TSS_SetASliderConfig(TSSTouch_cKey0.ControlId, ASlider_MovementTimeout_Register, 0x00); /* Configure the Analog Slider Range Register */ u8Result |= TSS_SetASliderConfig(TSSTouch_cKey0.ControlId, ASlider_Range_Register, 0x40); /* Configure ASlider Control configuration registers */ u8Result |= TSS_SetASliderConfig(TSSTouch_cKey0.ControlId, ASlider_ControlConfig_Register, TSS_ASLIDER_CONTROL_EN_MASK | TSS_ASLIDER_CALLBACK_EN_MASK); /* Enables electrodes */ u8Temp = TSS_GetSystemConfig(System_ElectrodeEnablers_Register+0); u8Result |= TSS_SetSystemConfig(System_ElectrodeEnablers_Register+0, (u8Temp | 0x03) & ~0x00); /* Electrode dc-tracker enablers */ u8Result |= TSS_SetSystemConfig(System_DCTrackerEnablers_Register+0, 0x03); /* Sets Trigger Mode */ u8Result |= TSS_SetSystemConfig(System_SystemTrigger_Register, TSS_TRIGGER_MODE_ALWAYS); /* Sets the Number of samples for all electrodes */ u8Result |= TSS_SetSystemConfig(System_NSamples_Register, 0x08); /* Configures the DC Tracker value */ u8Result |= TSS_SetSystemConfig(System_DCTrackerRate_Register, 0x64); /* Configures the Slow DC Tracker Factor value */ u8Result |= TSS_SetSystemConfig(System_SlowDCTrackerFactor_Register, 0x64); /* Configures the Response Time */ u8Result |= TSS_SetSystemConfig(System_ResponseTime_Register, 0x04); /* Configures the Stuck-key Timeout */ u8Result |= TSS_SetSystemConfig(System_StuckKeyTimeout_Register, 0x00); /* Configures System SystemConfig Register */ u8Result |= TSS_SetSystemConfig(System_SystemConfig_Register, TSS_SYSTEM_EN_MASK | TSS_DC_TRACKER_EN_MASK); return u8Result; }