Changing 2 char to 3 char

Hi guys.

Doing some programming with DCS-Bios. (DCS simulator interface) PC to Arduino in a Simulator

One of the issues is the engine RPM is exported as a char of only 2 digits. But will show on the virtual screen as 100-104%.

But in the mimic screen in the simulator the value returns a 10 after 99% as the last 0 is no read.

The mimic screen can accomodate the 3 digits.

Thus.

How can I code the input from DCS to change any value of 10 to 100 (ie 10 x 10).

This seams simple enough in my head but I can’t find the right code. Get lots of errors saying like

“Forbids comparison between a pointer and and integer“

Or

“Invalid operands of types ‘char*’ And ‘Int’ to binary ‘operator*’

Using the Below libraries.

DCSBios.h
Nextion.h
Arduino.h

Code sinipit below is the one that works but only limites the output to the Nextion to the two digits as that’s all the PC will send.

How can I modify the below to change the returned value of 10 (really 100 but the last 0 not sent to the Arduino) show 100 in RPML

Yes I have checked the DCS Bios buffer. There is only 2 digits. The next Hex location is the start of RPMR (Right engine) also only 2 char requested.

Below code is the working code.

int RPML;  // RPM LEFT ENGINE

#####(I have missed code here That is working or not relevant ) ####

void onIfeiRpmLChange (char* RPML) {   // this reads the code Buffer  listed below from the PC game

nextion.print(“t0.txt=\””); // sends code for text box 1 on the Nextion 
nextion.print(RPML);
nextion.print(“\””);
nextion.write(0xFF);
nextion.write(0xFF);
nextion.write(0xFF);
}
DcsBios::StringBuffer<2> ifeiRpmLBuffer(0x7494, onIfeiRpmLChange);

Yes I have changed the above to <3>. But as before there is no 3rd digit in the buffer, it returns the 1st number for the second engine.

You just want to append a zero to the two characters already received?

nextion.print("t0.txt=\""); // sends code for text box 1 on the Nextion 
nextion.print(RPML);
nextion.print("0\"");

Edit: this definition is nonsense, or at the very least not relevant in function onIfeiRpmLChange...

 int RPML;  // RPM LEFT ENGINE

I’ve no idea what you were trying to achieve or indicate by including it.

Function onIfeiRpmLChange has a local variable RPML of type char*. This variable definition replaces the (presumably) global int you have tried to declare above for the duration of the function. As such it is entirely irrelevant to the working of the function.

My personal advice would be never declare a global variables and local variables/function parameters with the same names. This is the programming equivalent of calling both your children “Bob”. Perfectly legal and you can do it, but you’d be crazy to try. Sooner or later you’re going to get confused about exactly which “Bob” you are talking about.

Thanks for that. Yes. Adding the 0 like that is easy. But. I only need to add it if the value is 10. (Which should be 100). All other values need to be 2 digits.

I’ll look at the variables issue.

jabmel:
Thanks for that. Yes. Adding the 0 like that is easy. But. I only need to add it if the value is 10. (Which should be 100). All other values need to be 2 digits.

I’ll look at the variables issue.

Errr...okay. But if “10” means 100, what value actually represents “10”?!?!

if (strcmp(RPML, "10") == 0) {
  nextion.print("0");
}

The 10 is supposed to represent the 100. But the program only exports the first (or only) 2 characters

It’s an oversight I think. This I am trying to accomodate on my side (to at least till the programmers at DCS fix it)

In simple terms

75 = 75%
80 = 80%
90 = 90%
99 = 9l%
But
10 = 100% (Yes it should be 100)

I hope I explain it correctly

So I need all the numbers below 99 to be that and 10 to be 100.

Yes I see an issue. But the RPM is never below 64. (Well nearly all the time unless starting)

pcbbc:
Errr...okay. But if “10” means 100, what value actually represents “10”?!?!

if (strcmp(RPML, "10") == 0) {

nextion.print("0");
}

PS awesome. That works. Thanks so much.

pcbbc:
Errr...okay. But if “10” means 100, what value actually represents “10”?!?!

if (strcmp(RPML, "10") == 0) {

nextion.print("0");
}

thanks so much, complete code attached with fix

welcome any suggestions to simplify it

but again many thanks

DCS-Bios.txt (12.3 KB)

jabmel:
I hope I explain it correctly

Err... not really. Sorry. :o

If “10” = 100% then what the flip = 10%?
It cannot be “10” because “10” is already used to mean 100%!

But if it works for you then I guess that’s it.

Edit: Also, rather that all that repeated code you’d be far better with...

int val = atoi(RPML);
nextion.print("t7.txt=\"");
nextion.print(newValue);  // This is the value you want to send to that object and atribute mention before.
if (val >= 10 && val <= 15) {
 nextion.print("0");
}
nextion.print("\"");
nextion.write(0xFF);
nextion.write(0xFF);
nextion.write(0xFF);