Hi all,
I'm working on a project in which I'm plotting a real time ECG Signal on my Touch TFT through sensors connected to the ADC.
My problem is that once I Initiate the ECG Signal Acquisition , All the Push button widgets on the canvas freeze and start flickering and only the signal keeps on getting plotted continuously. I want to control the real time signal through my button widgets.
For example, increase/ decrease the sweep speed through touch Pushbutton widgets. ( one push button to increase the sweep & the other button is to decrease the sweep speed). My Application is totally touch based and I do not want use any external keypad. I Know my solution is related to Software/Touchscreen interrupts but I don't know how to create it.
I'am posting my code below . It is just a part of my code. I need support as it is a very important project for me.
My Touch TFT is controlled by TM4C129X MCU.
#include "common.h"
#include "homeUI.h"
#include "pixbuf.h"
#include "driverlib/sysctl.h"
#include "inc/hw_sysctl.h"
#include "utils/ustdlib.h"
#include "driverlib/adc.h"
#include "grlib/Container.h"
extern volatile uint32_t ui32SysClock;
extern volatile uint32_t adcResult;
int x1=6;
int y1;
int y2;
void gui_Init()//function called from main
{
/* Initialize Graphics Driver*/
DisplayInit(ui32SysClock);
GrRaster16BppDriverInit(g_pui32DisplayBuffer);
GrContextInit(&guiMainContext, &g_sGrRaster16BppDriver);
FillScreen(ClrBlack);
TouchScreenInit(ui32SysClock);
TouchScreenCallbackSet(WidgetPointerMessage);
WidgetAdd(WIDGET_ROOT, (tWidget *)&guiBackGround);
//WidgetAdd(WIDGET_ROOT, (tWidget *)&guiAcquisitionPage);
WidgetPaint(WIDGET_ROOT);
WidgetMessageQueueProcess();
void Adc_Read();
void StartSignal(tWidget *psWidget, tContext *psContext);
void DecSweep(tWidget *psWidget);
void IncSignalSweep(tWidget *psWidget, tContext *psContext);
void IncSweep(tWidget *psWidget);
void DecSignalSweep(tWidget *psWidget, tContext *psContext);
}
Canvas(guiBackGround, WIDGET_ROOT, 0, &guiSweepIncButton, &g_sGrRaster16BppDriver,
X_OFFSET, Y_OFFSET, 800, 480,
CANVAS_STYLE_APP_DRAWN,
0, 0, 0, 0, 0, 0, StartSignal);
Canvas(guiSplashImageCanvas, &guiBackGround, 0 , &guiSweepDecButton, &g_sGrRaster16BppDriver,
X_OFFSET, Y_OFFSET, 800, 480,
CANVAS_STYLE_APP_DRAWN, 0, 0, 0, 0, 0, 0, StartSignal);
Canvas(guiSplashImageCanvas1, &guiBackGround, 0 , 0, &g_sGrRaster16BppDriver,
X_OFFSET, Y_OFFSET, 800, 480,
CANVAS_STYLE_APP_DRAWN, 0, 0, 0, 0, 0, 0, DecSignalSweep);
Canvas(guiSplashImageCanvas2, &guiBackGround, 0 , 0, &g_sGrRaster16BppDriver,
X_OFFSET, Y_OFFSET, 800, 480,
CANVAS_STYLE_APP_DRAWN, 0, 0, 0, 0, 0, 0, IncSignalSweep);
RectangularButton(guiSweepIncButton,&guiBackGround, 0, 0, &g_sGrRaster16BppDriver,
45, 35, 250, 50,
PB_STYLE_OUTLINE | PB_STYLE_TEXT |PB_STYLE_FILL|PB_STYLE_RELEASE_NOTIFY , ClrCornsilk, ClrWhite, ClrRed,
ClrBlack, g_psFontCmss36b, "Sweep Increase", 0,
0, 0, 0, IncSweep);
RectangularButton(guiSweepDecButton,&guiBackGround, 0, 0, &g_sGrRaster16BppDriver,
450, 400, 280, 50,
PB_STYLE_OUTLINE | PB_STYLE_TEXT |PB_STYLE_FILL|PB_STYLE_RELEASE_NOTIFY, ClrCornsilk, ClrWhite, ClrRed,
ClrBlack, g_psFontCmss36b, "Sweep Decrease", 0,
0, 0, 0, DecSweep);
void StartSignal(tWidget *psWidget, tContext *psContext)
{
y1=y2;
Adc_Read();
y2= adcResult;
GrContextForegroundSet(psContext, ClrCyan);
GrLineDraw(psContext, x1,y1,x1+1,y2);
GrLineDraw(psContext, x1,y1,x1+1+1,y2);
if (x1<=800)
{
x1=x1+1;
}
else
{
x1=0;
FillScreen(ClrBlack);
GrFlush(psContext);
}
SysCtlDelay(500000);
WidgetAdd((tWidget *)&guiBackGround, (tWidget *)&guiSplashImageCanvas);
WidgetPaint(WIDGET_ROOT);
}
void DecSignalSweep(tWidget *psWidget, tContext *psContext)
{
y1=y2;
Adc_Read();
y2= adcResult;
GrContextForegroundSet(psContext, ClrCyan);
GrLineDraw(psContext, x1,y1,x1+1,y2);
GrLineDraw(psContext, x1,y1,x1+1+1,y2);
if (x1<=800)
{
x1=x1+1;
}
else
{
x1=0;
FillScreen(ClrBlack);
GrFlush(psContext);
}
SysCtlDelay(1000000);
WidgetPaint((tWidget *)&guiSplashImageCanvas1);
}
void DecSweep(tWidget *psWidget)
{
WidgetAdd((tWidget *)&guiBackGround, (tWidget *)&guiSplashImageCanvas1);
WidgetAdd((tWidget *)&guiSplashImageCanvas1, (tWidget *)&guiSweepIncButton);
WidgetAdd((tWidget *)&guiSplashImageCanvas1, (tWidget *)&guiSweepDecButton);
WidgetPaint((tWidget *)&guiSplashImageCanvas1);
}
void IncSignalSweep(tWidget *psWidget, tContext *psContext)
{
y1=y2;
Adc_Read();
y2= adcResult;
GrContextForegroundSet(psContext, ClrCyan);
GrLineDraw(psContext, x1,y1,x1+1,y2);
GrLineDraw(psContext, x1,y1,x1+1+1,y2);
if (x1<=800)
{
x1=x1+1;
}
else
{
x1=0;
FillScreen(ClrBlack);
GrFlush(psContext);
}
SysCtlDelay(20000000);
WidgetPaint((tWidget *)&guiSplashImageCanvas2);
}
void OnSignal(tWidget *psWidget)
{
WidgetAdd((tWidget *)&guiBackGround, (tWidget *)&guiSplashImageCanvas2);
WidgetAdd((tWidget *)&guiSplashImageCanvas2, (tWidget *)&guiSweepIncButton);
WidgetAdd((tWidget *)&guiSplashImageCanvas2, (tWidget *)&guiSweepDecButton);
WidgetPaint((tWidget *)&guiSplashImageCanvas2);
}