invalid conversion from 'int' to 'const char*' [-fpermissive]

Hi,
I have demo project for a small oled display where a gauge and progressbar goes from 0 to 100, using GUISlice library.
There is also a label where I would like to display the numbers, but I get this error.

exit status 1
invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]

This is the code:

void loop()
{
 for (int i = 0; i <= 100; i++) {
[b]   [/b]gslc_ElemXProgressSetVal(&m_gui, m_pElemProgress1, i);
[b]   gslc_ElemSetTxtStr(&m_gui, m_pElemTxt1, i);
[/b]    Serial.println(i);
   delay(20);
   gslc_Update(&m_gui);
 }
 delay(20);
}

Please post your complete sjetch so that the problem can be seen in context such how and where variables are declared

Please follow the advice on posting code given in posting code

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

As far as I am aware, I have to convert the “int” value to a text, but I do not know how. Please correct me if I am wrong.
This is the full code:

//<App !Start!>
// FILE: [GUI_dynamic_test.ino]
// Created by GUIslice Builder version: [0.16.0]
//
// GUIslice Builder Generated File
//
// For the latest guides, updates and support view:
// https://github.com/ImpulseAdventure/GUIslice
//
//<App !End!>

// ------------------------------------------------
// Headers to include
// ------------------------------------------------
#include "GUI_dynamic_test_GSLC.h"


// ------------------------------------------------
// Program Globals
// ------------------------------------------------

// Save some element references for direct access
//<Save_References !Start!>
gslc_tsElemRef* m_pElemProgress1  = NULL;
gslc_tsElemRef* m_pElemRadial1    = NULL;
gslc_tsElemRef* m_pElemTxt1       = NULL;
gslc_tsElemRef* m_pElemVal1       = NULL;
gslc_tsElemRef* m_pElemXRingGauge1 = NULL;
gslc_tsElemRef* m_pElemKeyPadNum  = NULL;
//<Save_References !End!>

// Define debug message function
static int16_t DebugOut(char ch) {
  if (ch == (char)'\n') Serial.println("");
  else Serial.write(ch);
  return 0;
}

// ------------------------------------------------
// Callback Methods
// ------------------------------------------------
// Common Button callback
bool CbBtnCommon(void* pvGui, void *pvElemRef, gslc_teTouch eTouch, int16_t nX, int16_t nY)
{
  // Typecast the parameters to match the GUI and element types
  gslc_tsGui*     pGui     = (gslc_tsGui*)(pvGui);
  gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
  gslc_tsElem*    pElem    = gslc_GetElemFromRef(pGui, pElemRef);

  if ( eTouch == GSLC_TOUCH_UP_IN ) {
    // From the element's ID we can determine which button was pressed.
    switch (pElem->nId) {
      //<Button Enums !Start!>
      case E_ELEM_NUMINPUT1:
        // Clicked on edit field, so show popup box and associate with this text field
        gslc_ElemXKeyPadInputAsk(&m_gui, m_pElemKeyPadNum, E_POP_KEYPAD_NUM, m_pElemVal1);
        break;
      //<Button Enums !End!>
      default:
        break;
    }
  }
  return true;
}
//<Checkbox Callback !Start!>
//<Checkbox Callback !End!>
// KeyPad Input Ready callback
bool CbKeypad(void* pvGui, void *pvElemRef, int16_t nState, void* pvData)
{
  gslc_tsGui*     pGui     = (gslc_tsGui*)pvGui;
  gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
  gslc_tsElem*    pElem    = gslc_GetElemFromRef(pGui, pElemRef);

  // From the pvData we can get the ID element that is ready.
  int16_t nTargetElemId = gslc_ElemXKeyPadDataTargetIdGet(pGui, pvData);
  if (nState == XKEYPAD_CB_STATE_DONE) {
    // User clicked on Enter to leave popup
    // - If we have a popup active, pass the return value directly to
    //   the corresponding value field
    switch (nTargetElemId) {
      //<Keypad Enums !Start!>
      case E_ELEM_NUMINPUT1:
        gslc_ElemXKeyPadInputGet(pGui, m_pElemVal1, pvData);
        gslc_PopupHide(&m_gui);
        break;

      //<Keypad Enums !End!>
      default:
        break;
    }
  } else if (nState == XKEYPAD_CB_STATE_CANCEL) {
    // User escaped from popup, so don't update values
    gslc_PopupHide(&m_gui);
  }
  return true;
}
//<Spinner Callback !Start!>
//<Spinner Callback !End!>
//<Listbox Callback !Start!>
//<Listbox Callback !End!>
//<Draw Callback !Start!>
//<Draw Callback !End!>
//<Slider Callback !Start!>
//<Slider Callback !End!>
//<Tick Callback !Start!>
//<Tick Callback !End!>

void setup()
{
  // ------------------------------------------------
  // Initialize
  // ------------------------------------------------
  Serial.begin(9600);
  // Wait for USB Serial
  //delay(1000);  // NOTE: Some devices require a delay after Serial.begin() before serial port can be used

  gslc_InitDebug(&DebugOut);

  // ------------------------------------------------
  // Create graphic elements
  // ------------------------------------------------
  InitGUIslice_gen();

}

// -----------------------------------
// Main event loop
// -----------------------------------
void loop()
{
  for (int i = 0; i <= 100; i++) {
    gslc_ElemXProgressSetVal(&m_gui, m_pElemProgress1, i);
    gslc_ElemSetTxtStr(&m_gui, m_pElemTxt1, i);
    Serial.println(i);
    delay(20);
    gslc_Update(&m_gui);
  }
  delay(20);
}

Thanks for posting the code. Please post the full error message

The full error message:

Arduino: 1.8.13 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 3000000"



C:\Users\Lenovo\Documents\GUI_dynamic_test\GUI_dynamic_test.ino: In function 'void loop()':

GUI_dynamic_test:135:46: error: invalid conversion from 'int' to 'const char*' [-fpermissive]

     gslc_ElemSetTxtStr(&m_gui, m_pElemTxt1, i);

                                              ^

In file included from sketch\GUI_dynamic_test_GSLC.h:18:0,

                 from C:\Users\Lenovo\Documents\GUI_dynamic_test\GUI_dynamic_test.ino:15:

C:\Users\Lenovo\Documents\Arduino\libraries\GUIslice-master\src/GUIslice.h:2113:6: error:   initializing argument 3 of 'void gslc_ElemSetTxtStr(gslc_tsGui*, gslc_tsElemRef*, const char*)' [-fpermissive]

 void gslc_ElemSetTxtStr(gslc_tsGui* pGui,gslc_tsElemRef* pElemRef,const char* pStr);

      ^

exit status 1

invalid conversion from 'int' to 'const char*' [-fpermissive]



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

ryzen3:
As far as I am aware, I have to convert the "int" value to a text, but I do not know how.

Yes you do. Take a look at itoa.

You could also use sprintf.

micahfriesen:
You could also use sprintf.

thank you I will give it a try.