---------------------------------------------------------------------
#include <string.h>
#include <stdio.h>
#include <stdarg.h>

---------------------------------------------------------------------
extern volatile uint8_t measurement_done_touch;

#define SYS_CONSOLE_PRINT_BUFFER_SIZE   200
static char consolePrintBuffer[SYS_CONSOLE_PRINT_BUFFER_SIZE];

void myprintf(const char *format, ...)
{
    size_t len = 0;
    va_list args = {0};

    va_start(args, format);
    len = vsnprintf(consolePrintBuffer, SYS_CONSOLE_PRINT_BUFFER_SIZE, format, args);
    va_end(args);

    if ((len > 0) && (len < SYS_CONSOLE_PRINT_BUFFER_SIZE))
    {
        consolePrintBuffer[len] = '\0';
        SERCOM5_USART_Write((uint8_t*)consolePrintBuffer, len);
        while (SERCOM5_USART_WriteIsBusy());
    }
}

---------------------------------------------------------------------
    myprintf("\033[2J");
    myprintf("\033[1;1H");
    myprintf("\033[?25l");
    myprintf("------------------\r\n");
    myprintf("  QTouch Button\r\n");
    myprintf("------------------\r\n");
    myprintf("AKS  1    1    2\r\n");

---------------------------------------------------------------------
    bool KeyStatus[3] = {false, false, false};

---------------------------------------------------------------------
        touch_process();

        if( measurement_done_touch == 1 )
        {
            measurement_done_touch = 0;
            switch( get_sensor_state(0) )
            {
            case QTM_KEY_STATE_DETECT:  KeyStatus[0]=true;  LED1_Set();   break;
            case QTM_KEY_STATE_NO_DET:  KeyStatus[0]=false; LED1_Clear(); break;
            }

            switch( get_sensor_state(1) )
            {
            case QTM_KEY_STATE_DETECT:  KeyStatus[1]=true;  LED2_Set();   break;
            case QTM_KEY_STATE_NO_DET:  KeyStatus[1]=false; LED2_Clear(); break;
            }

            switch( get_sensor_state(2) )
            {
            case QTM_KEY_STATE_DETECT:  KeyStatus[2]=true;  LED3_Set();   break;
            case QTM_KEY_STATE_NO_DET:  KeyStatus[2]=false; LED3_Clear(); break;
            }

            myprintf("\033[5;1H");
            myprintf("BTN (%c)  (%c)  [%c]", (KeyStatus[0]?'O':' '),
                                             (KeyStatus[1]?'O':' '),
                                             (KeyStatus[2]?'X':' ') );
        }

---------------------------------------------------------------------

=====================================================================
Discuss
=====================================================================
---------------------------------------------------------------------
        if(BT1_Get()==0)
        {
            while(BT1_Get()==0);
            calibrate_node(0);
            calibrate_node(1);
            calibrate_node(2);
        }
