Writing only used bytes instead of all, how? I2C

So I’m having a little issue with my third I2C build.

I have the code attached below and it uses a “buffer” of 133 bytes.

But if I write for example “HELLO” that uses only 25 bytes, but my code still pushes out 133.
The rest are pushed out as 0x00. How do I avoid this?

Any help or tips are welcome

  byte Display[133] = { dev, 0xF0, x }; //Device, 240, X-Position
  byte len = (strlen(character));
  for (uint8_t i = 3; i <= len * 5; i += 5 , character++)
  {
    memcpy (Display + i, &_ASCIIchars[(int)*character][0], 5);
  }
  Wire.beginTransmission(_Addr);
  Wire.write(Display, sizeof(Display));
  Wire.sendTransmission();
  delay(50);

You have

  byte Display[133] = { dev, 0xF0, x }; //Device, 240, X-Position

and

  Wire.write(Display, sizeof(Display));

Could it be that sizeof(Display) is 133 bytes? What should go here instead?

  byte len = (strlen(character));

character is a stupid name for an array. It implies a single character, but, clearly, it is used as an array.

  for (uint8_t i = 3; i <= len * 5; i += 5 , character++)

Why are you diddling with the address of the array?

    memcpy (Display + i, &_ASCIIchars[(int)*character][0], 5);

What, exactly, are you multiplying character by? Why?

vaj4088:
Could it be that sizeof(Display) is 133 bytes? What should go here instead?

WOW! I'm obviously way to tired to do this right now! But Thanks a billion!

Wire.write(Display, (3+(len*5)));

PaulS:
character is a stupid name for an array. It implies a single character, but, clearly, it is used as an array.

Why are you diddling with the address of the array?

What, exactly, are you multiplying character by? Why?

Character is the input, output is the bytes for the display driver. " Lets be a little positive? :slight_smile: "

And to know the bytes I have a lookup array for the character.

So if input is char("H"), output from that array would be {0xFE, 0x10, 0x10, 0x10, 0xFE}

Lets be a little positive

OK. I'm POSITIVE that you need to post ALL of your code!