Qwiic Alphanumeric Display

Hello,

I have my Qiic Alphanumeric Display showing a live measurement from a range finder.

With this code:

String stringOne = String(feet);
  String stringTwo = String(round(inches));
  String stringDisplay = (stringOne +  stringTwo);

  display.print(stringDisplay);

However this outputs in only the first two digit holders like this: [5][2]

This means I can’t tell (without context) if it is measuring 5’2 or 52 feet.

How can I make the feet use the first two digits and the inches use the last to digits?

I tried manually inserting 2 spaces but then it doesn’t know to write over them in it is 10’10 for example.

Thanks in advance.

What language are you using? Arduino?

Yes. This is running on a Sparkfun Qwiic Uno Arduino.

Update:

I have tried a number of other things, including using the display.shiftRight function, but that would make it scroll right will printing every time it does, so it ends up as a mess of different numbers printed on top of each other and flickering.

Any guidance would be greatly appreciated.

Thanks

Can you please provide me a picture of your first setup without the shiftRight()

Here is the display with no troubleshooting. This is what I get with the original code.

Let me know if this link works: https://photos.app.goo.gl/d9vhHpeqhmCLC1k39

In addition

display.print("5.2");

outputs: [5][2].

instead of: [5].[2]

I think that you should look at using printChar() from the library: https://github.com/sparkfun/SparkFun_Al … ntChar.ino, so you have control over which space prints which character.

Awesomemcguy:
outputs: [5][2].

instead of: [5].[2]

The "." is static to just that third (from the left) space. Can't change that.

Thanks for the reply.

I fooled around with print.Char a bit. Unfortunately I’m not sure how to print a two digit variable with it though. I could easily print.Char just one digit, but how would I separate say 23 feet into “2” and “3” while also keeping it a variable that couldalso be only one digit or two digits but one of them is “0”?

Thanks.

You could try setting all four spaces to 0’s. Then when you need to print say 5’3" you can have something like [0][5][0][3]. For 23’: [2][3][0][0]. Or even 1’11": [0][1][1][1]. From here it’s up to you on how you want to format it.

In case this helps anyone, I figured it out. It is not as elegant as I had hoped, but it works…

if((cm >274.32) && (inches > 9)){
        display.print(stringDisplay);
         display.updateDisplay();
      }
       else if (cm >30.48) {
       display.print(stringOne + " " + stringTwo);
       display.updateDisplay();
    }
      else if(cm<30.48){
       display.print("0" + stringDisplay);
        display.updateDisplay();
      }

the first if statement is so the display can show two 2 digit numbers at a time if needed.

the second is so the display can have a space between feet and inches normally

the third is to right justify anything under a foot to differentiate from anything over 9 feet.

The LiDAR measures in cm which is why that is the name of the variable. But it gets converted with ft/in before being displayed using a modulo (%)

I tried to use displayChar but it wasn’t happy printing two digit variables.