lesthegrngo Posted November 25, 2022 Posted November 25, 2022 Hi all, just working the multiplexer sketch for the five OLED's I am using for the VHF radio panels, and I am a bit confused as to the way that Freq 2 and 3 are output. Freq 1 and 4, plus preset have integer strings as outputs, yet 2 and 3 has 'gauge position' shifting by 3 up to 255 as the outputs, yet the OLED should be displaying a number Sounds like I should be mapping the output to an integer, but somehow that doesn't feel right. It also has the frequency select encoder input, which reinforces that for me Can anyone explain what this should be doing? Les
No1sonuk Posted November 25, 2022 Posted November 25, 2022 I actually helped someone with the KA50 radio display the other day. In that case, freq 1 and 4 are strings, 2 and 3 are integers. Maybe this will help (it's for the KA50): char* WHF2freq1 = "00"; // Display digits are mixed string and integer so separate variables are easier int WHF2freq2 = 0; int WHF2freq3 = 0; char* WHF2freq4 = "00"; void WHFR2DisplayPrint(){ tcaselect(0); display.clearDisplay(); display.setCursor(10,10); display.print (*WHF2freq1); display.print (WHF2freq2); display.print ("."); display.print (WHF2freq3); display.print (*WHF2freq4); display.display(); } void onR800Freq1Change(char* newValue) { // Freq1 change - "10" "11" "12" "13" "14" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" *WHF2freq1= (newValue); WHFR2DisplayPrint(); } DcsBios::StringBuffer<2> r800Freq1StrBuffer(0x190e, onR800Freq1Change); void onR800Freq2Change(unsigned int newValue) { // Freq2 change WHF2freq2=(newValue); WHFR2DisplayPrint(); } DcsBios::IntegerBuffer r800Freq2Buffer(0x190c, 0x3c00, 10, onR800Freq2Change); void onR800Freq3Change(unsigned int newValue) { // Freq3 change WHF2freq3=(newValue); WHFR2DisplayPrint(); } DcsBios::IntegerBuffer r800Freq3Buffer(0x1910, 0x000f, 0, onR800Freq3Change); void onR800Freq4Change(char* newValue) { // Freq4 change - possible values: "00" "25" "50" "75" *WHF2freq4=(newValue); WHFR2DisplayPrint(); } DcsBios::StringBuffer<2> r800Freq4StrBuffer(0x1912, onR800Freq4Change); I assume yours is for the A-10? If that KA50 code doesn't help, I'll have a look at the A-10 code when I get home from work.
lesthegrngo Posted November 25, 2022 Author Posted November 25, 2022 (edited) Thanks, the sketch below worked for Freq2 although the result was unexpected - it displayed the letters IS #define DCSBIOS_DEFAULT_SERIAL #include <DcsBios.h> #include <Arduino.h> #include <U8g2lib.h> #include <Wire.h> U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R3, /* clock=*/SCL, /* data=*/SDA, /* reset=*/U8X8_PIN_NONE); // All Boards without Reset of the Display R3 refers to 270 deg text rotation void setup(void) { u8g2.begin(); DcsBios::setup(); } int WHF2freq2 = 0; void onVhfamFreq2Change(unsigned int newValue) { WHF2freq2 = (newValue); u8g2.clearBuffer(); u8g2.setFont(u8g2_font_logisoso38_tr); u8g2.drawStr(0, 80, WHF2freq2); // 0 left, 0 top bottom appx 100 u8g2.sendBuffer(); delay(1000); } DcsBios::IntegerBuffer vhfamFreq2Buffer(0x118e, 0x00f0, 4, onVhfamFreq2Change); void loop() { DcsBios::loop(); } However the same would not work for Freq3 bizarrely, couldn't get anything to display Les Edited November 25, 2022 by lesthegrngo
lesthegrngo Posted November 25, 2022 Author Posted November 25, 2022 I kept on with this, but it seems the u8g2 library is a bit fussy. Not sure why that should be, but it will do four of the five strings Probably some minor detail, but got me scratching my head Les
No1sonuk Posted November 25, 2022 Posted November 25, 2022 If this is for the A-10, why aren't you using the whole frequency string? I use this for my LCD radio display: void onVhfAmFrequencySChange(char* newValue) { lcd.setCursor(0,0); lcd.print("VHF AM: "); // Clear the line lcd.setCursor(8,0); lcd.print(newValue); } DcsBios::StringBuffer<7> vhfAmFrequencySBuffer(0x12de, onVhfAmFrequencySChange); That gives the whole frequency in one string, including the decimal point. It's available for all 3 radios, the ILS and the TACAN.
lesthegrngo Posted November 25, 2022 Author Posted November 25, 2022 (edited) On an LCD screen via a PCF8754 board it does display, but not on these 0.66" u8G2 OLEDs - which is what I have chosen unfortunately. There are some that use the Adafruit SSD1306 library instead of u8g2, I suspect they would be easier to work with Trouble is no-one ships them to Qatar u8g2 also needs 328 Nanos due to the library size, so not a wonderful choice Tomorrow I'll show pictures so you can see why I'm looking at individual digits, there are five oleds per panel Les Edited November 25, 2022 by lesthegrngo
No1sonuk Posted November 25, 2022 Posted November 25, 2022 OK... lcd.print(newValue[0]); Will send just character 0. Note the addition of "[0]" to the variable name. Change it to 1,2,3, etc. for the other characters.
lesthegrngo Posted November 26, 2022 Author Posted November 26, 2022 Thanks Here's a pic of the vhf panel with the multiplexed OLED array on its PCB below, with a test sketch (in this case the TISL sketc) to test the hardware. Each OLED will display the particular frequency, or at least that's the intention!
lesthegrngo Posted November 26, 2022 Author Posted November 26, 2022 I have a suspicion that the reason Freq3 doesn't display is that the output would be " .0 " or " 0. " and that is playing hob with the u8G2 displayString command. Maybe I need to be able to convert it to text Les
lesthegrngo Posted November 26, 2022 Author Posted November 26, 2022 All, I have the panel 90% working now, but (for the VHF AM panel at least) are Freq 2 and Freq 3 ever anything other than "4" and ".0"? I have the encoders wired for Freq 2 and 3, and no matter what preset you put in and what frequency knobs you twiddle, that's all they ever display, in which case reading the in game data is pointless - I may as well just print 4 and .0 Am I reading that right? Les
lesthegrngo Posted November 26, 2022 Author Posted November 26, 2022 (edited) Yeah, dry joint on Freq2 Encoder, so that now shows changes on the LCD display. However the OLED display stubbornly refuses to reflect the LCD numeral, it just gives out letters and also as you rotate the freq2 encoder it messes with the Freq1 OLED I'll try and get a vid up here you go Les Edited November 26, 2022 by lesthegrngo
No1sonuk Posted November 26, 2022 Posted November 26, 2022 Does it respond properly to the in-game controls?
lesthegrngo Posted November 26, 2022 Author Posted November 26, 2022 it's the same, looks like the way the OLED is interpreting the output data I'm puzzled as to why the Freq2 is dealt with differently to the other two Frequency values that change Les
No1sonuk Posted November 26, 2022 Posted November 26, 2022 Because the others are basically 2-character values. Freq2 is a single digit.
lesthegrngo Posted November 26, 2022 Author Posted November 26, 2022 (edited) Ok, with the help of VincVega and No1sonuk, who as ever were untiring in their inputs, I finally have it working. It's a bit late to do detail today, but will happily share anything with you all, but just to show here is a video of the (loosely assembled) VHF AM panel. I still have to finish some details on it but 95% of the work has been done Thanks once more to all that helped! Les Edited November 26, 2022 by lesthegrngo 1 1
Recommended Posts