Jump to content

SSD1306 Oled FFI Indicator for F-16


wiggles5289

Recommended Posts

EDIT: Added working code for FFI. Needs help to make it multifunctional to support Altimeter and Fuel QTY in the future. https://github.com/wiggles5289/Orange-Viper-Simulations/blob/main/F16/FFI/

Anyone have working code for an FFI for the Viper? I have tried for months trying to work with displays and am about done with even trying. I have found a good FFI font and some code from the DEDuino repo on GitHub(the alpha under releases) but cant even get basic info to display because of my poor coding skills.

//Scrolling Indicator for F-16 FFI for DCS BIOS using generic 128x32 SSD1306 !!!WITH I2C!!! display(tested on 0.91" screen from Amazon)
//Final code by JohnnyChicago and slightly modified/tested by Wiggles5289 on the DCS Forums
//Can work for Altimeter/Fuel QTY
//WIP on GitHub
//Updated for DCS 2.7 on 13SEP2022
//Working on making the font higher definition for future OLEDs with higher pixel density to eliminate the ugly screen door effect
//COMMENT OUT SECTIONS YOU DO NOT NEED AND READ THE COMMENTS BEFORE USE!
//REQUIRED FOR COMPILING: Adafruit SSD1306, Adafruit GFX, and dcs-bios-arduino library
//Updates Found at: https://github.com/wiggles5289/Orange-Viper-Simulations/blob/main/F16/FFI


//#define DCSBIOS_FOR_STM32

#ifdef DCSBIOS_FOR_STM32 //This sets Default Serial for STM32, will not compile with IRQ without an error
#define DCSBIOS_DEFAULT_SERIAL
#ifndef DCSBIOS_FOR_STM32 //This sets IRQ Serial as the default option for Arduino Nano/Uno, its much faster than Default Serial
#define DCSBIOS_IRQ_SERIAL
#endif

#include "DcsBios.h"

//#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "characters.h"

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)

//Comment for barometric pressure
#define FUELFLOW

int updateInterval = 100; //the number of milliseconds between updates(17 for 60FPS, 41 for 24FPS, 100 for Default)

struct scrollDigit {
  int digit; //The digit that is displayed
  int y; // The vertical position of the digit
};

struct disp {
  Adafruit_SSD1306 display;
  int width;
  int numberOfDigits;
  scrollDigit digits[5];
};

#ifdef FUELFLOW
disp oled = {Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 24, 5, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}};
#else
disp oled = {Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 16, 4, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}};
#endif

void setup() {
  if (!oled.display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    for (;;); // Don't proceed, loop forever
  }

  DcsBios::setup();
}

void UpdateDisplay()
{
  oled.display.clearDisplay();
  for (int i = 0; i < oled.numberOfDigits; i++)
  {
    printScrollingDigit(oled.digits[i].digit, oled.width, oled.digits[i].y, i + 1, &oled);
  }
  //Clear the area below the the numbers if we are using the small font
  if (oled.width == 16)
  {
    oled.display.fillRect(0, 25, 67, 7, BLACK);
  }

  oled.display.display();
}

int YPos()
{
  return (oled.width + 9) * -1;
}

void printScrollingDigit(int digit, int width, int y, int pos, disp *oled)
{
  int x = (width * pos) - width + pos;
#ifdef FUELFLOW
  switch (digit)
  {
    case -1: oled->display.drawBitmap(x, y, c24_Empty, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_1, 24, 32, 1); break;
    case 1: oled->display.drawBitmap(x, y, c24_1, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_2, 24, 32, 1); break;
    case 2: oled->display.drawBitmap(x, y, c24_2, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_3, 24, 32, 1); break;
    case 3: oled->display.drawBitmap(x, y, c24_3, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_4, 24, 32, 1); break;
    case 4: oled->display.drawBitmap(x, y, c24_4, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_5, 24, 32, 1); break;
    case 5: oled->display.drawBitmap(x, y, c24_5, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_6, 24, 32, 1); break;
    case 6: oled->display.drawBitmap(x, y, c24_6, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_7, 24, 32, 1); break;
    case 7: oled->display.drawBitmap(x, y, c24_7, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_8, 24, 32, 1); break;
    case 8: oled->display.drawBitmap(x, y, c24_8, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_9, 24, 32, 1); break;
    case 9: oled->display.drawBitmap(x, y, c24_9, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_0, 24, 32, 1); break;
    default: oled->display.drawBitmap(x, y, c24_0, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_1, 24, 32, 1); break;
  }
#else
  switch (digit)
  {
    case -1: oled->display.drawBitmap(x, y, c16_Empty, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_1, 16, 24, 1); break;
    case 1: oled->display.drawBitmap(x, y, c16_1, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_2, 16, 24, 1); break;
    case 2: oled->display.drawBitmap(x, y, c16_2, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_3, 16, 24, 1); break;
    case 3: oled->display.drawBitmap(x, y, c16_3, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_4, 16, 24, 1); break;
    case 4: oled->display.drawBitmap(x, y, c16_4, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_5, 16, 24, 1); break;
    case 5: oled->display.drawBitmap(x, y, c16_5, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_6, 16, 24, 1); break;
    case 6: oled->display.drawBitmap(x, y, c16_6, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_7, 16, 24, 1); break;
    case 7: oled->display.drawBitmap(x, y, c16_7, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_8, 16, 24, 1); break;
    case 8: oled->display.drawBitmap(x, y, c16_8, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_9, 16, 24, 1); break;
    case 9: oled->display.drawBitmap(x, y, c16_9, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_0, 16, 24, 1); break;
    default: oled->display.drawBitmap(x, y, c16_0, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_1, 16, 24, 1); break;
  }
#endif
}

#ifdef FUELFLOW
void onFuelflowcounter10kChange(unsigned int newValue)
{
  if (newValue == 0)
  {
    oled.digits[0].digit = -1;
    oled.digits[0].y = 0;
  }
  else
  {
    unsigned int mappedValue = newValue / 6553;
    unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());

    oled.digits[0].digit = mappedValue;
    oled.digits[0].y = y;
  }
}

void onFuelflowcounter1kChange(unsigned int newValue)
{
  unsigned int mappedValue = newValue / 6553;
  unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());

  oled.digits[1].digit = mappedValue;
  oled.digits[1].y = y;
}

void onFuelflowcounter100Change(unsigned int newValue)
{
  unsigned int mappedValue = newValue / 6553;
  unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());

  oled.digits[2].digit = mappedValue;
  oled.digits[2].y = y;
}
DcsBios::IntegerBuffer fuelflowcounter100Buffer(0x44e8, 0xffff, 0, onFuelflowcounter100Change);
DcsBios::IntegerBuffer fuelflowcounter10kBuffer(0x44e4, 0xffff, 0, onFuelflowcounter10kChange);
DcsBios::IntegerBuffer fuelflowcounter1kBuffer(0x44e6, 0xffff, 0, onFuelflowcounter1kChange);

//#else

#endif

unsigned long time = 0;

void loop() {
  DcsBios::loop();

  time = millis();
  if (time % updateInterval == 0)
  {
    UpdateDisplay();
  }
}

 


Edited by wiggles5289
Link to comment
Share on other sites

Unfortunately I've never tried to figure out pulling data from, maybe DCS BIOS can help with that aspect and you just need to transmit to the arduino.
DEDunio's communication protocol is fairly straight forward to "hack" most of the heavy lifting is on the PC side

(I've done it to save precious MCU cycles on low end Arduinos)

Link to comment
Share on other sites

DCSBIOS has the Fuel Flow Counter 10K, 1K, and 100 places separately output to 16 bit values. I used a simple map() function to change it to 0-9 int and changed the ascii value correction functions to the non ascii output from DCSBIOS, but beyond that I couldn't reverse engineer your code to make it work with an arduino mega.

Link to comment
Share on other sites

  • 4 months later...

Can anyone share their code for this, I've got Nano connected to a SH1106 my code below only to show the 10k portion to prove, but not getting the required display.

 

 


/*DCS BIOS FFI FOR VIPER*/

#define DCSBIOS_IRQ_SERIAL
#include "DcsBios.h"
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>


U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

unsigned int flowtenk;
int tenko;
void onFuelflowcounter10kChange(unsigned int newValue) {
    
    flowtenk = (newValue);
    tenko = map(flowtenk, 0,65535,0,9);
}
DcsBios::IntegerBuffer fuelflowcounter10kBuffer(0x44d6, 0xffff, 0, onFuelflowcounter10kChange);

void setup(void) {

  DcsBios::setup();
  u8g2.begin();
  u8g2.clearBuffer();                    
  u8g2.setFont(u8g2_font_7x13_tf);
}

void loop(void) {
  u8g2.clearBuffer();                    
  u8g2.drawStr(35,10, "FUEL FLOW");
  u8g2.drawStr(35,45, tenko);
  u8g2.sendBuffer();                    // Transfer to display
  delay(1000);  
}


```20211115_105509.jpg


Edited by Detent666
Link to comment
Share on other sites

  • 2 months later...
  • 6 months later...
  • 5 weeks later...
  • 9 months later...
  • 2 weeks later...
On 6/30/2021 at 12:22 PM, wiggles5289 said:

EDIT: Added working code for FFI. Needs help to make it multifunctional to support Altimeter and Fuel QTY in the future. https://github.com/wiggles5289/Orange-Viper-Simulations/blob/main/F16/FFI/

Anyone have working code for an FFI for the Viper? I have tried for months trying to work with displays and am about done with even trying. I have found a good FFI font and some code from the DEDuino repo on GitHub(the alpha under releases) but cant even get basic info to display because of my poor coding skills.

//Scrolling Indicator for F-16 FFI for DCS BIOS using generic 128x32 SSD1306 !!!WITH I2C!!! display(tested on 0.91" screen from Amazon)
//Final code by JohnnyChicago and slightly modified/tested by Wiggles5289 on the DCS Forums
//Can work for Altimeter/Fuel QTY
//WIP on GitHub
//Updated for DCS 2.7 on 13SEP2022
//Working on making the font higher definition for future OLEDs with higher pixel density to eliminate the ugly screen door effect
//COMMENT OUT SECTIONS YOU DO NOT NEED AND READ THE COMMENTS BEFORE USE!
//REQUIRED FOR COMPILING: Adafruit SSD1306, Adafruit GFX, and dcs-bios-arduino library
//Updates Found at: https://github.com/wiggles5289/Orange-Viper-Simulations/blob/main/F16/FFI


//#define DCSBIOS_FOR_STM32

#ifdef DCSBIOS_FOR_STM32 //This sets Default Serial for STM32, will not compile with IRQ without an error
#define DCSBIOS_DEFAULT_SERIAL
#ifndef DCSBIOS_FOR_STM32 //This sets IRQ Serial as the default option for Arduino Nano/Uno, its much faster than Default Serial
#define DCSBIOS_IRQ_SERIAL
#endif

#include "DcsBios.h"

//#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "characters.h"

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)

//Comment for barometric pressure
#define FUELFLOW

int updateInterval = 100; //the number of milliseconds between updates(17 for 60FPS, 41 for 24FPS, 100 for Default)

struct scrollDigit {
  int digit; //The digit that is displayed
  int y; // The vertical position of the digit
};

struct disp {
  Adafruit_SSD1306 display;
  int width;
  int numberOfDigits;
  scrollDigit digits[5];
};

#ifdef FUELFLOW
disp oled = {Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 24, 5, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}};
#else
disp oled = {Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 16, 4, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}};
#endif

void setup() {
  if (!oled.display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    for (;;); // Don't proceed, loop forever
  }

  DcsBios::setup();
}

void UpdateDisplay()
{
  oled.display.clearDisplay();
  for (int i = 0; i < oled.numberOfDigits; i++)
  {
    printScrollingDigit(oled.digits[i].digit, oled.width, oled.digits[i].y, i + 1, &oled);
  }
  //Clear the area below the the numbers if we are using the small font
  if (oled.width == 16)
  {
    oled.display.fillRect(0, 25, 67, 7, BLACK);
  }

  oled.display.display();
}

int YPos()
{
  return (oled.width + 9) * -1;
}

void printScrollingDigit(int digit, int width, int y, int pos, disp *oled)
{
  int x = (width * pos) - width + pos;
#ifdef FUELFLOW
  switch (digit)
  {
    case -1: oled->display.drawBitmap(x, y, c24_Empty, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_1, 24, 32, 1); break;
    case 1: oled->display.drawBitmap(x, y, c24_1, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_2, 24, 32, 1); break;
    case 2: oled->display.drawBitmap(x, y, c24_2, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_3, 24, 32, 1); break;
    case 3: oled->display.drawBitmap(x, y, c24_3, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_4, 24, 32, 1); break;
    case 4: oled->display.drawBitmap(x, y, c24_4, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_5, 24, 32, 1); break;
    case 5: oled->display.drawBitmap(x, y, c24_5, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_6, 24, 32, 1); break;
    case 6: oled->display.drawBitmap(x, y, c24_6, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_7, 24, 32, 1); break;
    case 7: oled->display.drawBitmap(x, y, c24_7, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_8, 24, 32, 1); break;
    case 8: oled->display.drawBitmap(x, y, c24_8, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_9, 24, 32, 1); break;
    case 9: oled->display.drawBitmap(x, y, c24_9, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_0, 24, 32, 1); break;
    default: oled->display.drawBitmap(x, y, c24_0, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_1, 24, 32, 1); break;
  }
#else
  switch (digit)
  {
    case -1: oled->display.drawBitmap(x, y, c16_Empty, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_1, 16, 24, 1); break;
    case 1: oled->display.drawBitmap(x, y, c16_1, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_2, 16, 24, 1); break;
    case 2: oled->display.drawBitmap(x, y, c16_2, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_3, 16, 24, 1); break;
    case 3: oled->display.drawBitmap(x, y, c16_3, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_4, 16, 24, 1); break;
    case 4: oled->display.drawBitmap(x, y, c16_4, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_5, 16, 24, 1); break;
    case 5: oled->display.drawBitmap(x, y, c16_5, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_6, 16, 24, 1); break;
    case 6: oled->display.drawBitmap(x, y, c16_6, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_7, 16, 24, 1); break;
    case 7: oled->display.drawBitmap(x, y, c16_7, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_8, 16, 24, 1); break;
    case 8: oled->display.drawBitmap(x, y, c16_8, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_9, 16, 24, 1); break;
    case 9: oled->display.drawBitmap(x, y, c16_9, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_0, 16, 24, 1); break;
    default: oled->display.drawBitmap(x, y, c16_0, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_1, 16, 24, 1); break;
  }
#endif
}

#ifdef FUELFLOW
void onFuelflowcounter10kChange(unsigned int newValue)
{
  if (newValue == 0)
  {
    oled.digits[0].digit = -1;
    oled.digits[0].y = 0;
  }
  else
  {
    unsigned int mappedValue = newValue / 6553;
    unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());

    oled.digits[0].digit = mappedValue;
    oled.digits[0].y = y;
  }
}

void onFuelflowcounter1kChange(unsigned int newValue)
{
  unsigned int mappedValue = newValue / 6553;
  unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());

  oled.digits[1].digit = mappedValue;
  oled.digits[1].y = y;
}

void onFuelflowcounter100Change(unsigned int newValue)
{
  unsigned int mappedValue = newValue / 6553;
  unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());

  oled.digits[2].digit = mappedValue;
  oled.digits[2].y = y;
}
DcsBios::IntegerBuffer fuelflowcounter100Buffer(0x44e8, 0xffff, 0, onFuelflowcounter100Change);
DcsBios::IntegerBuffer fuelflowcounter10kBuffer(0x44e4, 0xffff, 0, onFuelflowcounter10kChange);
DcsBios::IntegerBuffer fuelflowcounter1kBuffer(0x44e6, 0xffff, 0, onFuelflowcounter1kChange);

//#else

#endif

unsigned long time = 0;

void loop() {
  DcsBios::loop();

  time = millis();
  if (time % updateInterval == 0)
  {
    UpdateDisplay();
  }
}

 

 

This code is working for me. Even though I'm trying to get a SH1106 to do this, on the SD1306 it works. IS there a way to center the top line of the display to the middle of the screen though?

GD ViperWorks - YouTube

F-16CM Block 50 Replica Sim Pit Construction

Link to comment
Share on other sites

  • 2 months later...
On 6/30/2021 at 6:22 PM, wiggles5289 said:

EDIT: Added working code for FFI. Needs help to make it multifunctional to support Altimeter and Fuel QTY in the future. https://github.com/wiggles5289/Orange-Viper-Simulations/blob/main/F16/FFI/

Anyone have working code for an FFI for the Viper? I have tried for months trying to work with displays and am about done with even trying. I have found a good FFI font and some code from the DEDuino repo on GitHub(the alpha under releases) but cant even get basic info to display because of my poor coding skills.

//Scrolling Indicator for F-16 FFI for DCS BIOS using generic 128x32 SSD1306 !!!WITH I2C!!! display(tested on 0.91" screen from Amazon)
//Final code by JohnnyChicago and slightly modified/tested by Wiggles5289 on the DCS Forums
//Can work for Altimeter/Fuel QTY
//WIP on GitHub
//Updated for DCS 2.7 on 13SEP2022
//Working on making the font higher definition for future OLEDs with higher pixel density to eliminate the ugly screen door effect
//COMMENT OUT SECTIONS YOU DO NOT NEED AND READ THE COMMENTS BEFORE USE!
//REQUIRED FOR COMPILING: Adafruit SSD1306, Adafruit GFX, and dcs-bios-arduino library
//Updates Found at: https://github.com/wiggles5289/Orange-Viper-Simulations/blob/main/F16/FFI


//#define DCSBIOS_FOR_STM32

#ifdef DCSBIOS_FOR_STM32 //This sets Default Serial for STM32, will not compile with IRQ without an error
#define DCSBIOS_DEFAULT_SERIAL
#ifndef DCSBIOS_FOR_STM32 //This sets IRQ Serial as the default option for Arduino Nano/Uno, its much faster than Default Serial
#define DCSBIOS_IRQ_SERIAL
#endif

#include "DcsBios.h"

//#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "characters.h"

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)

//Comment for barometric pressure
#define FUELFLOW

int updateInterval = 100; //the number of milliseconds between updates(17 for 60FPS, 41 for 24FPS, 100 for Default)

struct scrollDigit {
  int digit; //The digit that is displayed
  int y; // The vertical position of the digit
};

struct disp {
  Adafruit_SSD1306 display;
  int width;
  int numberOfDigits;
  scrollDigit digits[5];
};

#ifdef FUELFLOW
disp oled = {Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 24, 5, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}};
#else
disp oled = {Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 16, 4, {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}};
#endif

void setup() {
  if (!oled.display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    for (;;); // Don't proceed, loop forever
  }

  DcsBios::setup();
}

void UpdateDisplay()
{
  oled.display.clearDisplay();
  for (int i = 0; i < oled.numberOfDigits; i++)
  {
    printScrollingDigit(oled.digits[i].digit, oled.width, oled.digits[i].y, i + 1, &oled);
  }
  //Clear the area below the the numbers if we are using the small font
  if (oled.width == 16)
  {
    oled.display.fillRect(0, 25, 67, 7, BLACK);
  }

  oled.display.display();
}

int YPos()
{
  return (oled.width + 9) * -1;
}

void printScrollingDigit(int digit, int width, int y, int pos, disp *oled)
{
  int x = (width * pos) - width + pos;
#ifdef FUELFLOW
  switch (digit)
  {
    case -1: oled->display.drawBitmap(x, y, c24_Empty, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_1, 24, 32, 1); break;
    case 1: oled->display.drawBitmap(x, y, c24_1, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_2, 24, 32, 1); break;
    case 2: oled->display.drawBitmap(x, y, c24_2, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_3, 24, 32, 1); break;
    case 3: oled->display.drawBitmap(x, y, c24_3, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_4, 24, 32, 1); break;
    case 4: oled->display.drawBitmap(x, y, c24_4, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_5, 24, 32, 1); break;
    case 5: oled->display.drawBitmap(x, y, c24_5, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_6, 24, 32, 1); break;
    case 6: oled->display.drawBitmap(x, y, c24_6, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_7, 24, 32, 1); break;
    case 7: oled->display.drawBitmap(x, y, c24_7, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_8, 24, 32, 1); break;
    case 8: oled->display.drawBitmap(x, y, c24_8, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_9, 24, 32, 1); break;
    case 9: oled->display.drawBitmap(x, y, c24_9, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_0, 24, 32, 1); break;
    default: oled->display.drawBitmap(x, y, c24_0, 24, 32, 1); oled->display.drawBitmap(x, y + 33, c24_1, 24, 32, 1); break;
  }
#else
  switch (digit)
  {
    case -1: oled->display.drawBitmap(x, y, c16_Empty, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_1, 16, 24, 1); break;
    case 1: oled->display.drawBitmap(x, y, c16_1, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_2, 16, 24, 1); break;
    case 2: oled->display.drawBitmap(x, y, c16_2, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_3, 16, 24, 1); break;
    case 3: oled->display.drawBitmap(x, y, c16_3, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_4, 16, 24, 1); break;
    case 4: oled->display.drawBitmap(x, y, c16_4, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_5, 16, 24, 1); break;
    case 5: oled->display.drawBitmap(x, y, c16_5, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_6, 16, 24, 1); break;
    case 6: oled->display.drawBitmap(x, y, c16_6, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_7, 16, 24, 1); break;
    case 7: oled->display.drawBitmap(x, y, c16_7, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_8, 16, 24, 1); break;
    case 8: oled->display.drawBitmap(x, y, c16_8, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_9, 16, 24, 1); break;
    case 9: oled->display.drawBitmap(x, y, c16_9, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_0, 16, 24, 1); break;
    default: oled->display.drawBitmap(x, y, c16_0, 16, 24, 1); oled->display.drawBitmap(x, y + 25, c16_1, 16, 24, 1); break;
  }
#endif
}

#ifdef FUELFLOW
void onFuelflowcounter10kChange(unsigned int newValue)
{
  if (newValue == 0)
  {
    oled.digits[0].digit = -1;
    oled.digits[0].y = 0;
  }
  else
  {
    unsigned int mappedValue = newValue / 6553;
    unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());

    oled.digits[0].digit = mappedValue;
    oled.digits[0].y = y;
  }
}

void onFuelflowcounter1kChange(unsigned int newValue)
{
  unsigned int mappedValue = newValue / 6553;
  unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());

  oled.digits[1].digit = mappedValue;
  oled.digits[1].y = y;
}

void onFuelflowcounter100Change(unsigned int newValue)
{
  unsigned int mappedValue = newValue / 6553;
  unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());

  oled.digits[2].digit = mappedValue;
  oled.digits[2].y = y;
}
DcsBios::IntegerBuffer fuelflowcounter100Buffer(0x44e8, 0xffff, 0, onFuelflowcounter100Change);
DcsBios::IntegerBuffer fuelflowcounter10kBuffer(0x44e4, 0xffff, 0, onFuelflowcounter10kChange);
DcsBios::IntegerBuffer fuelflowcounter1kBuffer(0x44e6, 0xffff, 0, onFuelflowcounter1kChange);

//#else

#endif

unsigned long time = 0;

void loop() {
  DcsBios::loop();

  time = millis();
  if (time % updateInterval == 0)
  {
    UpdateDisplay();
  }
}

 

 

HI i downloaded this code used it but its not FUEL FLOW INDICATOR but FUEL QUANTITY somebody know what to do? code is downloaded from link above.

Link to comment
Share on other sites

On 9/30/2023 at 8:45 PM, Vinc_Vega said:

HI i tried your code, it shows fuel flow and pph but instead of FFI it still shows fuel quantity

 

 

IMG_0442.jpg?ex=651ebc9e&is=651d6b1e&hm=IMG_0443.jpg?ex=651ebc9e&is=651d6b1e&hm=

 

Why don't you look here and replace the display driver to the original SSD1306 one?

Regards, Vinc

 

Link to comment
Share on other sites

3 hours ago, BeBe said:

HI i tried your code, it shows fuel flow and pph but instead of FFI it still shows fuel quantity

Hi BeBe,

No, it displays the Fuel Flow Couter values of the F-16. Have a second look at the clip posted here:

According to the control reference the addresses for the flow counter are 0x44e8, 0x44e4 and 0x44e6. That of the fuel totalizer display are 0x44f2, 0x44ee and 0x44f0.

We already had an issue with the A-10 and Bf-109 in the past, that some addresses had changed. So maybe you have to update your DcsBios files?

 

Regards, Vinc


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Well, I found out the problem I don't know why but the addresses you used didn't work for me so I had to use these codes:  0x44de, 0x44da, and 0x44dc  now it's finally working. Thank you very much without you mentioning the address I wouldn't have find out the problems 🙂

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...