2023-03-01 07:32 AM
Hello,
I am using the TouchGFX application to display data gathered from CANbus communication, which I have verified is working. One feature I wanted to have is the following logic for fault error codes:
If a fault is present, display the error code in hexadecimal (with a user manual to outline the meaning of said error codes) in red.
If no fault is present, then I want NO text to be present. I do not want to show "0x00000000". I just want no text to be there at all.
I've attached a snippet of my code that writes the value into the wildcard currently. This solution does not work.
void Screen1View::UpdateFaults(uint64_t value){
if(value != 0x00000000){
Unicode::snprintf(textFaultSigBuffer, TEXTFAULTSIG_SIZE, "%x", value);
}
else{
Unicode::snprintf(textFaultSigBuffer,TEXTFAULTSIG_SIZE, "%x","" );
}
// Invalidate text area, which will result in it being redrawn in next tick.
textFaultSig.invalidate();
}
Instead of displaying a blank space, it shows 8031650 (like in the picture).
Does anyone know how to make it just display no text at all?
Solved! Go to Solution.
2023-03-01 07:49 AM
void Screen1View::UpdateFaults(uint64_t value){
if(value != 0x00000000){
Unicode::snprintf(textFaultSigBuffer, TEXTFAULTSIG_SIZE, "%x", value);
textFaultSig.setVisible(1); // Shows to object
}
else{
// Unicode::snprintf(textFaultSigBuffer,TEXTFAULTSIG_SIZE, "%x","" );
textFaultSig.setVisible(0); // Hides to object
}
// Invalidate text area, which will result in it being redrawn in next tick.
textFaultSig.invalidate();
}
Just set it visible or not, if I understand right what you need ?
2023-03-01 07:49 AM
void Screen1View::UpdateFaults(uint64_t value){
if(value != 0x00000000){
Unicode::snprintf(textFaultSigBuffer, TEXTFAULTSIG_SIZE, "%x", value);
textFaultSig.setVisible(1); // Shows to object
}
else{
// Unicode::snprintf(textFaultSigBuffer,TEXTFAULTSIG_SIZE, "%x","" );
textFaultSig.setVisible(0); // Hides to object
}
// Invalidate text area, which will result in it being redrawn in next tick.
textFaultSig.invalidate();
}
Just set it visible or not, if I understand right what you need ?
2023-03-01 07:54 AM
Hello JTP,
Yes, this is exactly what I needed! I just tried it and it worked exactly as I wanted.
Thank you!
2023-03-01 10:45 AM
Your error is
Unicode::snprintf(textFaultSigBuffer,TEXTFAULTSIG_SIZE, "%x","" );
right is
Unicode::snprintf(textFaultSigBuffer,TEXTFAULTSIG_SIZE, "" );
or
Unicode::snprintf(textFaultSigBuffer,TEXTFAULTSIG_SIZE, "%s","" );
2023-03-01 10:48 AM
Ooohh interesting.
So if I did it your way, whatever was in the wildcard spot would go away and the non-wildcard part would stay, correct? For example:
"Fault: " - Non wildcard, so it would stay
But the wildcard part (the actual error code in hex) would be blank.
JTP's way gets rid of all wildcard and non-wildcard text, while yours gets rid of just the wildcard portion. This is most helpful! Now I can do both options.
Thank you MM!