hello everyone, after a month of testing I managed to fix the UFC screens, but the only one I can't get to work is the screen where the radio frequency is indicated (central top)
I am attaching the sketch to understand what is wrong
#include <Adafruit_SSD1306.h>
#include <splash.h>
#define MUX_Address 0x70 // TCA9548A Encoders address
#define DCSBIOS_IRQ_SERIAL
#include "Wire.h"
#include <U8glib.h>
#include "DcsBios.h"
Adafruit_SSD1306 oled(6);
char* OpQue[5]; // Create Option Quing Global Array
char* Dval[5]; // Create Option Display Global Array
char* ScPad[3]; // Create Scratchpad Display Global Array
char tmp_string[8]; // Temp string to convert numeric values to string before print to OLED display
U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_FAST); // Fast I2C / TWI
// Initialize I2C buses using TCA9548A I2C Multiplexer
void tcaselect(uint8_t i2c_bus) {
if (i2c_bus > return;
Wire.beginTransmission(MUX_Address);
Wire.write(1 << i2c_bus);
Wire.endTransmission();
}
/* paste code snippets from the reference documentation here */
/*------------------------------------ scratchpad number display --------------------------------------------*/
void onUfcScratchpadNumberDisplayChange(char* newValue) {
/* your code here */
ScPad[2] = newValue; // Copy numbers into the scratchpad array at 3rd position in array
DisplayScrn(); // Call the Display Screen function
}
DcsBios::StringBuffer<8> ufcScratchpadNumberDisplayBuffer(0x7446, onUfcScratchpadNumberDisplayChange);
/*----------------------------------- scratchpad 1st string display -----------------------------------------*/
void onUfcScratchpadString1DisplayChange(char* newValue) {
/* your code here */
ScPad[0] = newValue; // Copy 1st chr into the scratchpad array at 1st position in array
DisplayScrn(); // Call the Display Screen function
}
DcsBios::StringBuffer<2> ufcScratchpadString1DisplayBuffer(0x744e, onUfcScratchpadString1DisplayChange);
/*----------------------------------- scratchpad 2nd string display -----------------------------------------*/
void onUfcScratchpadString2DisplayChange(char* newValue) {
/* your code here */
ScPad[1] = newValue; // Copy 2nd chr into scratchpad array at 2nd position in array
DisplayScrn(); // Call the Display Screen function
}
DcsBios::StringBuffer<2> ufcScratchpadString2DisplayBuffer(0x7450, onUfcScratchpadString2DisplayChange);
/*---------------------------- Option Screen Displays ------------------------------*/
void onUfcOptionDisplay1Change(char* newValue) {
/* your code here */
Dval[0] = newValue; // Copy the option screen 1 data into screen array
DisplayScrn(); // Call the Display Screen function. Only needed a single
// DisplayScrn() call as not all option screens will display
// something when changed but option screen 1 ALWAYS changes
}
DcsBios::StringBuffer<4> ufcOptionDisplay1Buffer(0x7432, onUfcOptionDisplay1Change);
/*---------------------------------------------------------------------------------*/
void onUfcOptionDisplay2Change(char* newValue) {
/* your code here */
Dval[1] = newValue; // Copy the option screen 2 data into screen array
}
DcsBios::StringBuffer<4> ufcOptionDisplay2Buffer(0x7436, onUfcOptionDisplay2Change);
/*--------------------------------------------------------------------------------*/
void onUfcOptionDisplay3Change(char* newValue) {
/* your code here */
Dval[2] = newValue; // Copy the option screen 3 data into screen array
}
DcsBios::StringBuffer<4> ufcOptionDisplay3Buffer(0x743a, onUfcOptionDisplay3Change);
/*-------------------------------------------------------------------------------*/
void onUfcOptionDisplay4Change(char* newValue) {
/* your code here */
Dval[3] = newValue; // Copy the option screen 4 data into screen array
}
DcsBios::StringBuffer<4> ufcOptionDisplay4Buffer(0x743e, onUfcOptionDisplay4Change);
/*-------------------------------------------------------------------------------*/
void onUfcOptionDisplay5Change(char* newValue) {
/* your code here */
Dval[4] = newValue; // Copy the option screen 5 data into screen array
}
DcsBios::StringBuffer<4> ufcOptionDisplay5Buffer(0x7442, onUfcOptionDisplay5Change);
/*--------------------------- Option Queing 1 -----------------------------------*/
void onUfcOptionCueing1Change(char* newValue) {
/* your code here */
OpQue[0] = newValue; // Copy option 1 select value to option que array
DisplayScrn(); // Call the Display Screen function
}
DcsBios::StringBuffer<1> ufcOptionCueing1Buffer(0x7428, onUfcOptionCueing1Change);
/*--------------------------- Option Queing 2 -----------------------------------*/
void onUfcOptionCueing2Change(char* newValue) {
/* your code here */
OpQue[1] = newValue; // Copy option 2 select value to option que array
DisplayScrn(); // Call the Display Screen function
}
DcsBios::StringBuffer<1> ufcOptionCueing2Buffer(0x742a, onUfcOptionCueing2Change);
/*--------------------------- Option Queing 3 -----------------------------------*/
void onUfcOptionCueing3Change(char* newValue) {
/* your code here */
OpQue[2] = newValue; // Copy option 3 select value to option que array
DisplayScrn(); // Call the Display Screen function
}
DcsBios::StringBuffer<1> ufcOptionCueing3Buffer(0x742c, onUfcOptionCueing3Change);
/*--------------------------- Option Queing 4 -----------------------------------*/
void onUfcOptionCueing4Change(char* newValue) {
/* your code here */
OpQue[3] = newValue; // Copy option 4 select value to option que array
DisplayScrn(); // Call the Display Screen function
}
DcsBios::StringBuffer<1> ufcOptionCueing4Buffer(0x742e, onUfcOptionCueing4Change);
/*--------------------------- Option Queing 5 -----------------------------------*/
void onUfcOptionCueing5Change(char* newValue) {
/* your code here */
OpQue[4] = newValue; // Copy option 5 select value to option que array
DisplayScrn(); // Call the Display Screen function
}
DcsBios::StringBuffer<1> ufcOptionCueing5Buffer(0x7430, onUfcOptionCueing5Change);
/*-------------------------------------------------------------------------------
The option queing changes are the " : " chr on the displays. The DisplayScrn()
function needs to be called for each queing change as you are updating a Oled
with data from 2 sources. You need to write the option queing value & the Display
value together, if you just write the option queing value then that is all that
will show on the Oled.
------------------------------ Setup Displays etc -----------------------------*/
void setup() { // Setup Starts
DisplayInit(); // Initialize the displays function for the first time
DcsBios::setup(); // Setup DCS specific functions
} // Setup ends
/*--------------------- Initialize the Displays Function ---------------------------------*/
void DisplayInit(){ // start of function
for (int i = 0; i < 8; i++) { // Start of for loop to option & scratchpad screens
// 0 is scratchpad 1-5 are option screens 6 and 7 is comm1 and comm2
tcaselect(i); // selects the multiplexer output for a screen starting
// at 0 indexing to next screen each time through loop
do { } while( u8g.nextPage() );
} // end of for loop
} // end of function
/* -------------------------- Main Program Loop From Here --------------------------------*/
void loop() { // Start Main Program Loop
DcsBios::loop(); // run DCS Bios
} // End Main Program Loop
/*---------------------------------------------------------------------------------------------*/
void DisplayScrn(void) { // start of main display function
for (int i = 0; i < 5; i++) { // Start of for loop to display option screens
tcaselect(i+1); // Select each connected Option display on the I2C buses
// " 0 " is scratchpad display hence " i+1 " to index onto the
// correct bus for each Option Display screen
u8g.firstPage();
do {
u8g.setFont(u8g_font_helvB18); // standard nice size font for displays
u8g.drawStr( 0,25,OpQue[i]); // Option selection value displayed
u8g.drawStr( 15,25,Dval[i]); // Option choices displayed
} while( u8g.nextPage() );
} // End of for loop to display option screens
} // end of main display function
u8g.begin();// Initialize displays
u8g.setFont(u8g_font_helvB18); // standard nice size font for displays