Need help! Txt+variable+txt to serial txt?

I have a serial tft color display ( Byvac BV4629/lenny).
It uses VT100 commands to draw lines pixels etc.

Now i want to dynamicly change the value off the command send.

I added a picture of what i came up with.

Allthough this code just prints out {20 over and over.
It stops right where the variable is...

Any help is appreciated!

Why is "varPlus" in single quotes?
Why are you posting a JPEG when you could post code?

The format specifier looks really strange to. There should be one % sign per variable.

Could you give a small example of what you mean. I am not that advanced in programming.

Where did you get the example for snprintf?

Post the actual code, inside code tags (not a screenshot). Then we can all see it and copy and paste snippets.

i'm sorry but i can't seem to find it anymore.

so for now this is all i have. i haven't made much changes to the code.
allthough i've tried quite some different setups. allthough i can get no expected output.

here is the code i'm using:

void setup()  {
  Serial.begin(115200);//,0,'*');
  Serial.write("\n"); //send <CR>
  Serial.write("\e[2J"); // clear screen
  delay(400);
}

void loop() {
int varPlus=0;
char buf[32];
  varPlus=analogRead(A0)/4;
  snprintf(buf, 32, "\e{20 ", varPlus, "L");
  Serial.println(buf);
  delay(1000);
 
}

though the code that does work is:

Serial.println("\e{0 0p");    //set pixel location 0,0
  Serial.println("\e[0;63;20f");     //set color rgb
  Serial.println("\e{10 50L");        //draw line from current pos to 10,50
  Serial.println("\e{20 20L");
  Serial.println("\e{30 30L");
  Serial.println("\e{40 40L");

iSpider:

  snprintf(buf, 32, "\e{20 ", varPlus, "L");

That is just printing "\e{20 " - the arguments varPLus and "L" are unused because the format string does not include any format specifiers.

If you wanted to include the value of varPlus in the string, you could do it using something like this:

  snprintf(buf, 32, "\e{20%dL", varPlus);

The %d in the format string is replaced by a decimal representation of the value of varPlus.

YES YES YES YES!!!!

It's working now! Thank you so much! i have been breaking my head over this for over a week!

thanks again!

Here is the working code:

void setup()  {
  Serial.begin(232558);//,0,'*');
  Serial.write("\n"); //send <CR>
  Serial.begin(115200);
  Serial.write("\e[?10L") //set landscape mode
  Serial.write("\e[2J"); // clear screen
  delay(400);
}

// hello world program for the BV4308
void loop() {
int varPlus=0;
int i=0;
char buf[32];
Serial.println("\e[2J");
  for (i = 0; i < 320; i++) {
    Serial.println("\e[0;63;20f");
    varPlus=analogRead(A0)/8;
    snprintf(buf, 32, "\e{%d %dL", i, varPlus);
    Serial.println(buf);
    
    //delay(100);
    }
 delay(300);
 i=0;
 for (i = 0; i < 320; i++) {
    Serial.println("\e[0;0;0f");
    varPlus=analogRead(A0)/8;
    snprintf(buf, 32, "\e{%d %dL", i, varPlus);
    Serial.println(buf);
    
    //delay(100);
    }
 delay(100);
 i=0;
}

One more question though....

I need to record 320x analogRead to a array in memory, so i can (later in the script) overwrite the same values with a black color to erase them.I could write an array of 320 values but that might be a bit memory exhausting. I would do a "cls" but this is much to slow. so i have to do it this way. i just need it to remember these 320 values until lateron...

I attached a picture of my now much better working oscilloscope.
Not finished at all but a good start.. Thanks!

i just need it to remember these 320 values until lateron...

So, what's the problem? A 320 byte array might fit in memory. Or not. It's impossible to tell, Mr. Snippets.

yeah sorry. i wasn't really clear.

I meant to say:

While an array of 320 values take up a lot of space, is there maybe a formula or little piece of code that does the same but without writing the entire array in the code?

for examle: when changes, write/add value to array.
then: turn color to black, write entire array again.

is there maybe a formula

There's run-length coding. That might work, but then again, it may give you more data than you started with.
Or delta coding. Or delta coding with Huffman.
The compression technique chosen depends on the nature and behaviour of the data.