raptor909 Posted May 5, 2020 Posted May 5, 2020 Hi I'm trying from several days to read data from gauges to LCD. The following code read Left and Right engine fuel Flow from A10C dedicated gauges. ------------------------------------------------------------------------------ #define DCSBIOS_RS485_SLAVE 126 #define TXENABLE_PIN 2 #include <Servo.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> #include "DcsBios.h" LiquidCrystal_I2C lcd(0x27, 20, 4); void onLEngFuelFlowChange(unsigned int NewValue) { lcd.setCursor(12, 1); lcd.print (int((NewValue/65.535)*50)); } DcsBios::IntegerBuffer lEngFuelFlowBuffer(0x10ae, 0xffff, 0, onLEngFuelFlowChange); void onREngFuelFlowChange(unsigned int NewValue) { lcd.setCursor(12, 0); lcd.print (int((NewValue/65.535)*50)); } DcsBios::IntegerBuffer rEngFuelFlowBuffer(0x10b0, 0xffff, 0, onREngFuelFlowChange); DcsBios:: ProtocolParser parser; void setup() { DcsBios::setup(); //Serial.begin(500000); lcd.backlight(); // pinMode(LED_PIN, OUTPUT); // analogWrite(LED_PIN, 50); lcd.init(); lcd.clear(); lcd.begin(20, 4); lcd.setCursor(0, 0); lcd.print("RFlow:PPH"); lcd.setCursor(0, 1); lcd.print("LFlow:PPH"); } void loop() { DcsBios::loop(); } --------------------------------------------------------------------------------------------- So. I read on LCD the correct data form Left and Right Fuel Flow but ONLY till a value of 9999. When the gauges goes over 9999 and then came back, REMAIN THE FIFTH DIGIT. --------------------------------------------------------------------------------------------- !! PLZ HELP ME !!. There is probably in the code that need to be modified or add something. A-10C | A-10C II | F/A-18C | F16C | AV-8B | FW-190 A-8 | MB339 | A-4E | CA [sIGPIC][/sIGPIC] https://simitaliagames.com/dcs/
Vinc_Vega Posted May 5, 2020 Posted May 5, 2020 (edited) Just Put your lcd.print and Cursor Things away from the setup into the loop routine Edited May 5, 2020 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
No1sonuk Posted May 6, 2020 Posted May 6, 2020 (edited) Looks like you need some code to add spaces to clear the remaining digits. So, if you have it fixed at the high digit (a 4-digit number is printed like this): 01234 <- Cursor position xxxx_ (_ means a blank space) You just need to add spaces after the numbers. If it's fixed at the low digit, like this: 01234 <- Cursor position _xxxx You'd need to add 1 space on the front if it's lower than 10000, 2 spaces if it's lower than 1000 and so on. An alternative to BOTH of these is to just blank the 5 spaces before you send the number. Edited May 6, 2020 by No1sonuk
raptor909 Posted May 6, 2020 Author Posted May 6, 2020 Now it's ok. YEAH!! Thank you very very very much. Now it's fine. Looks like you need some code to add spaces to clear the remaining digits. So, if you have it fixed at the high digit (a 4-digit number is printed like this): 01234 <- Cursor position xxxx_ (_ means a blank space) You just need to add spaces after the numbers. If it's fixed at the low digit, like this: 01234 <- Cursor position _xxxx You'd need to add 1 space on the front if it's lower than 10000, 2 spaces if it's lower than 1000 and so on. An alternative to BOTH of these is to just blank the 5 spaces before you send the number. A-10C | A-10C II | F/A-18C | F16C | AV-8B | FW-190 A-8 | MB339 | A-4E | CA [sIGPIC][/sIGPIC] https://simitaliagames.com/dcs/
Recommended Posts