Hi @afcec as discussed by @MichalH
As far as I know, the Touch UI script running in FreeMASTER project tries to locate all electrodes and touch controls dynamically by reading chains and trees of RAM structures pointing to each other.
If your touch controls and electrode structures are defined the same way in the C code as in the original project, they should appear in the FreeMASTER Touch UI automatically. If not, the FreeMASTER has probably problems to access RAM or get symbolic data from the ELF file.
This is discussed previously in the community, and is as below.
https://community.nxp.com/t5/FreeMASTER/Touch-Tuning-variables-not-plotted-on-Oscilloscope-for-a-Cus...
Two methods are specified in the above link, you can use one of this method.
The simple method of using global variable is as below.
When u receive the "NT_SYSTEM_EVENT_MODULE_DATA_READY" event from the NXP touch library, you can use this event to save data in these global variables, as shown below.
static void system_callback(uint32_t event, union nt_system_event_context *context)
{
uint32_t touch_scan_cmplt_time = 0;
switch (event)
{
case NT_SYSTEM_EVENT_OVERRUN:
DBG_PRINTF_RED( "system_callback: NT_SYSTEM_EVENT_OVERRUN\n");
break;
case NT_SYSTEM_EVENT_DATA_READY:
DBG_PRINTF_GREEN( "system_callback: NT_SYSTEM_EVENT_DATA_READY\n");
break;
case NT_SYSTEM_EVENT_MODULE_DATA_READY:
// DBG_PRINTF_GREEN( "system_callback: NT_SYSTEM_EVENT_MODULE_DATA_READY\n");
touch_scan_cmplt_time = millis();
touch_meas_time = touch_scan_cmplt_time - touch_start_time;
touch_log_electrode();
break;
case NT_SYSTEM_EVENT_DATA_OVERFLOW:
DBG_PRINTF_GREEN( "system_callback: NT_SYSTEM_EVENT_DATA_OVERFLOW\n");
break;
// and so on.......
// your code....
}
static void touch_log_electrode( void )
{
struct nt_control *control = NULL;
struct nt_electrode_data *electrode = NULL;
struct nt_keydetector_usafa_data *usafa = NULL;
control = (struct nt_control*)&keypad_1;
for( uint8_t idx=0; idx<TOUCH_ELECTRODES_NUM; idx++ )
{
electrode = NULL;
electrode = nt_electrode_get_data( control->electrodes[idx] );
if( NULL != electrode )
{
usafa = electrode->keydetector_data.usafa;
dbg_baseline[idx] = electrode->baseline;
dbg_signal[idx] = electrode->signal;
dbg_deadband_h[idx] = usafa->deadband_h;
dbg_predicted[idx] = usafa->predicted_signal;
dbg_noise[idx] = usafa->noise;
dbg_entry_event_cnt[idx] = usafa->entry_event_cnt;
dbg_deadband_cnt[idx] = usafa->deadband_cnt;
}
}
}
and then u can use these "dbg_*" variables to plot the baseline, predicted, signal etc.. on FreeMASTER oscilloscope.
I hope this helps.