Value display tidying

Being a bit fussy I wanted to show a variable in the middle of a value display widget on my dashboard rather than the standard left side so I converted it into a string and added a space to move the display to the right by one character

String hs = String(h);String hss=(" "+hs);
This is the output on the app

but the space is ignored🤔 If I replace the space with an underscore it moves to where I want.

Any thoughts on how to solve this?
I’m very new to c programming so any help appreciated :+1:

I’m guessing this is default behavior. I’ll call out to @vshymanskyy because he probably can answer this in less then two seconds :slight_smile:

1 Like

Our App is actually trying to understand the data you are sending, and interprets it as a number.
We need to understand the expected behaviour, before we change something… @Pavel ?

@Rob.b the value display can be right justified to a certain degree and is done in a similar way to LCD padding. I think you are missing a step with the conversion of int to String. Seems a bit long winded but this is how I do it for the LCD.

String intsize(int testvalue) { // 0 to 1440 for time in minutes
  if (testvalue > 999) {
    ThePrefix = "";
  else if (testvalue > 99) {
    ThePrefix = " ";
  else if (testvalue > 9) {
    ThePrefix = "  ";
  else {
    ThePrefix = "   ";
  return ThePrefix;

void displaylcd() {
  testvalue = CountdownTime;
  intsize(testvalue);  // determines number of digits in the integer and therefore required left padding
  CurrentTime = ThePrefix + CountdownTime;
  lcd.print(0, 1, CurrentTime);

Just tested it with value display and it works ok but I’m not sure what the maximum field size is. For value display maximum minutes per day is shown as 1440 where as 5 minutes is shown as SPACE SPACE 5, should be SPACE SPACE SPACE 5.

@ashvetsov - is it the app behaviour?

Value Display has a field length of 5 so it should handle SPACE SPACE SPACE 5. It pads correctly for LCD but misses a space for the Value Display. Maybe my functions have a bug?

@Rob.b if you put 2 spaces in your code it will give you the required single space in the value display. Not sure why it needs 2 spaces in the string for 1 in the widget.

Strangely with h = 10 if you put 4 leading spaces in the string expecting the first space to be ignored and the 3 spaces and 2 characters for ‘10’ to fit the 5 character value display field it will only show ‘1’ and not ‘10’.

Thanks for the help :grinning: I’ll give it a go :+1:t2: