This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Pushbutton Widget



Hi there, im quite new to CCS and this is my first time using TM4C123G.

I've been trying to create a widget of 4 pushbuttons with different functions.

My intended push button functions are as follow:

-CLEAR (to clear the whole screen)
-SPLIT (to split the screen into two different display)
-LEARN (to memorize a waveform for comparison in the later part)
-ALARM RESET (to reset an alarm buzzer)

The function of the CLEAR has not been set yet because i couldn't get the re-painting thing stop /:
And, i would also like to know how do i; 

1. Include more than one child to one widget?
For example, i would like to link my 4 push buttons to the &g_sBackground.

2. Draw displays into the widgets?
Can i just use stuff like GrStringDraw etc? 

I've tried the lab10 worksheet but it seems like it isnt sufficient for what i need /:
Thankyou!

I've tried to start off with the simplest CLEAR push button function but i came up with a problem whereby the screen keeps repainting on its own.

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "grlib/grlib.h"
#include "grlib/widget.h"
#include "grlib/canvas.h"
#include "grlib/pushbutton.h"
#include "Kentec320x240x16_ssd2119_8bit.h"
#include "touch.h"

extern tCanvasWidget g_sBackground;
extern tPushButtonWidget g_sClearBtn;

void ClearButtonPress(tWidget *pWidget);

Canvas(g_sHeading, &g_sBackground, &g_sLearnBtn, 0,
		&g_sKentec320x240x16_SSD2119, 120, 20, 200, 23,
		(CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT | CANVAS_STYLE_TEXT_LEFT),
		ClrBlack, ClrWhite, ClrWhite, g_psFontCm14, "BREATHING RATE:", 0, 0);

Canvas(g_sBackground, WIDGET_ROOT, 0, 0,
		&g_sKentec320x240x16_SSD2119, 0, 23, 320, (240 - 23),
		CANVAS_STYLE_FILL, ClrBlack, 0, 0, 0, 0, 0, 0);

RectangularButton(g_sClearBtn, &g_sBackground, &g_sHeading, 0,
		&g_sKentec320x240x16_SSD2119, 0, 200, 60, 40,
		(PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
				PB_STYLE_FILL), ClrBlack, ClrWhite, ClrGreen, ClrGreen,
				g_psFontCmss14b, "LEARN", 0, 0, 0, 0, ClearButtonPress);
bool g_RedLedOn = false;

void ClearButtonPress(tWidget *pWidget){

	g_RedLedOn = !g_RedLedOn;

	if(g_RedLedOn){
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0x02);
	}
	else{
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0x00);
	}
}
int main(void){

	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00);

	Kentec320x240x16_SSD2119Init();

	TouchScreenInit();

	WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground);
	WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sClearBtn);

	TouchScreenCallbackSet(WidgetPointerMessage);

	WidgetPaint(WIDGET_ROOT);

	while(1){
		WidgetMessageQueueProcess();
	}
}