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.

BOOSTXL-K350QVG-S1: Question about defining a grlib ListBox widget. Having compile errors.

Part Number: BOOSTXL-K350QVG-S1

#ifndef SCREEN_H_
#define SCREEN_H_

#include <stdint.h>
#include <stdbool.h>
#include "grlib/grlib.h"
#include "grlib/widget.h"
#include "grlib/canvas.h"
#include "grlib/pushbutton.h"
#include "grlib/slider.h"
#include "grlib/listbox.h"
#include "images.h"


// default variable names
extern tCanvasWidget g_psPanels[];
extern tWidget *infoPage;
extern tWidget *logPage;

extern uint32_t g_ui32Panel;
extern char *g_pcPanei32Names[];
extern tPushButtonWidget g_sPrevious, g_sNext;
extern tCanvasWidget g_sTitle, g_sDashboard,  g_sCAN;
extern tListBoxWidget g_sMenu;

...

#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
#include <Screen.h>
#include "driverlib/sysctl.h"
#include "drivers/Kentec320x240x16_ssd2119_spi.h"
#include "drivers/touch.h"
#include "images.h"
#include "grlib/grlib.h"
#include "grlib/widget.h"
#include "grlib/canvas.h"
#include "grlib/pushbutton.h"
#include "grlib/slider.h"
#include "grlib/listbox.h"



char* error = "test";
char** ppcText = &error;

// Forward declaration of functions
void OnDashboardPaint(tWidget *psWidget, tContext *psContext);
void OnErrorLogPaint(tWidget *psWidget, tContext *psContext);
void OnCanPaint(tWidget *psWidget, tContext *psContext);



// The panel that is currently being displayed.
uint32_t g_ui32Panel;


// An array of canvas widgets, one per panel.  Each canvas is filled with
// black, overwriting the contents of the previous panel.
tCanvasWidget g_psPanels[] = {
        CanvasStruct(0, 0, &g_sDashboard, &g_sKentec320x240x16_SSD2119, 0, 0,
                320, 240, CANVAS_STYLE_FILL, ClrBlack, 0, 0, 0, 0, 0, 0),
        CanvasStruct(0, 0, &g_sMenu, &g_sKentec320x240x16_SSD2119, 0, 0, 320,
                240, CANVAS_STYLE_FILL, ClrBlack, 0, 0, 0, 0, 0, 0),
        };


// The list of panels being displayed on screen
Canvas(g_sDashboard, g_psPanels, 0, 0, &g_sKentec320x240x16_SSD2119, 0, 0, 320,
       240, CANVAS_STYLE_APP_DRAWN, 0, 0, 0, 0, 0, 0, OnDashboardPaint);


//************************************************************************
//"../Screen.c", line 66: error #28: expression must have a constant value
//************************************************************************
ListBox(g_sMenu, g_psPanels + 1, 0, 0, &g_sKentec320x240x16_SSD2119, 0, 0, 320,
       240, LISTBOX_STYLE_WRAP|LISTBOX_STYLE_LOCKED, 0, 0, 0, 0, 0, 0, ppcText,
       8, 0, OnErrorLogPaint);

Canvas(g_sCAN, g_psPanels + 2, 0, 0, &g_sKentec320x240x16_SSD2119, 0, 0, 320,
       240, CANVAS_STYLE_APP_DRAWN, 0, 0, 0, 0, 0, 0, OnCanPaint);
       
...

I didn't find many examples about Listbox, thus this basic question. 

I am using this display on a TM4C board, and I am trying to add a Listbox Widget on the second screen. I defined a ListBox with an empty string table as the child of the second CanvasStruct. Now I get this "expression must have a constant value error". What did I do wrong?

  • Now I get this "expression must have a constant value error".

    From trying you code fragment the error is coming from trying to pass ppcText into the ListBox macro which is setting the initialiser for g_sMenu

    If you replace:

    char* error = "test";
    char** ppcText = &error;

    With:

    const char *ppcText[1] = {"test"};

    Then the code should compile.

    The ppcText above only has a single array entry, which you can expand, or change the const char * pointers in at run-time to change the text.