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.

TM4123CGXL TIVA C SERIES Lab 10 question (About programming multiple buttons on the Kentac LCD display)

Hello,.

currently im stuck at the bonus question, where i am asked to program 2 more buttons to toggle green and blue LED. However, i have already done my coding for the green led push button. The problem is, when i compile and debug the code, the LCD shows only the first button and not the second one. 

Below is my coding. Please pardon me im still a newbie in TIVA C SERIES

#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_sPushBtn;
extern tPushButtonWidget g_sPushBtn2;

void OnButtonPress(tWidget *pWidget);
void OnButtonPress2(tWidget *pWidget);

Canvas(g_sHeading, &g_sBackground, 0, &g_sPushBtn,
&g_sKentec320x240x16_SSD2119, 0, 0, 320, 23,
(CANVAS_STYLE_FILL | CANVAS_STYLE_OUTLINE | CANVAS_STYLE_TEXT),
ClrBlack, ClrWhite, ClrRed, g_psFontCm20, "LED Control", 0, 0);

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

RectangularButton(g_sPushBtn, &g_sHeading, 0, 0,
&g_sKentec320x240x16_SSD2119, 60, 60, 200, 40,
(PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
PB_STYLE_FILL), ClrRed, ClrWhite, ClrWhite, ClrPurple,
g_psFontCmss22b, "Toggle red LED", 0, 0, 0, 0, OnButtonPress);

//Add-ons*********************************************************************************************************

RectangularButton(g_sPushBtn2,
&g_sHeading, //psParent
0, //psNext
0, //psChild
&g_sKentec320x240x16_SSD2119,//psDisplay
50,//i32x
50,//i32y
100,//i32width
20,//i32height
(PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
PB_STYLE_FILL), //ui32style
ClrRed,
ClrYellow,
ClrWhite,
ClrBlack,//uifillcolor
g_psFontCmss22b,//
"Toggle green LED",//13
0, //14
0,//15
0,//16
0,//17
OnButtonPress2);//18

//Add-ons**********************************************************************************************************

bool g_RedLedOn = false;
bool g_GreenLedOn = false;

void OnButtonPress(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);
}
}
//*********************************************************
void OnButtonPress2(tWidget *pWidget)
{
g_GreenLedOn = !g_GreenLedOn;
if(g_GreenLedOn)
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0x08);
}
else
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 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();
TouchScreenCallbackSet(WidgetPointerMessage);

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


while(1)
{

WidgetMessageQueueProcess();
}
}