Jump to content

Recommended Posts

Posted

try this, replace the A10 part like this

void onTacanChannelChange(char* newValue) {
  display.fillRect(0, 0, 128, 60, BLACK);  // Draws a blank rectangle to clear the previous text
  display.setTextColor(WHITE, BLACK);
  display.setCursor(14, 50);
  display.print(newValue);
  display.display();
}
DcsBios::StringBuffer<4> tacanChannelBuffer(0x1162, onTacanChannelChange);

 

with your code

 

#define DCSBIOS_DEFAULT_SERIAL
//#define DCSBIOS_IRQ_SERIAL

//#define DCSBIOS_RS485_SLAVE 51
//#define TXENABLE_PIN 2

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
#include "Fonts/FreeSans24pt7b.h"

#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);


#include <DcsBios.h>


void setup()

{
display.begin(SH1106_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
delay(1000);
  display.clearDisplay();   // clears the screen and buffer
  display.setFont(&FreeSans24pt7b);
  
 DcsBios::setup();
}

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

  void onTacanChannelChange(char* newValue) {
    display.fillRect(0, 0, 128, 60, BLACK);  // Draws a blank rectangle to clear the previous text
  display.setTextColor(WHITE, BLACK);
  display.setCursor(14, 50);
  display.print(newValue);
  display.display();
}
DcsBios::StringBuffer<4> tacanChannelBuffer(0x1162, onTacanChannelChange);

 

Posted

Thanks. I was playing with you code the other day as it is the only code I can find for the SH1106. The problem I have is where the snipet says ""your code here". I don't know anything about programming OLEDs. Cutting and pasting is as far as I can go.

By copying the "your code here" from yours with my BIOS snipets, it doesn't work. the screen shows "Fuel Flow" and instead of numbers, a "g" with 3 dots through the top of it.

 

 

Viper_Fuel_Flow_Test.ino

GD ViperWorks - YouTube

F-16CM Block 50 Replica Sim Pit Construction

Posted

The characters were all trying to print on the same part of the screen, plus you only need one instance of the screen clearing rectangle

 

try this

#define DCSBIOS_DEFAULT_SERIAL
//#define DCSBIOS_IRQ_SERIAL

//#define DCSBIOS_RS485_SLAVE 51
//#define TXENABLE_PIN 2

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
#include "Fonts/FreeSans24pt7b.h"

#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);


#include <DcsBios.h>


void setup()

{
display.begin(SH1106_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
delay(1000);
  display.clearDisplay();   // clears the screen and buffer
  display.setFont(&FreeSans24pt7b);
  
 DcsBios::setup();
}

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

void onFuelflowcounter100Change(unsigned int newValue) {
  display.fillRect(0, 0, 128, 60, BLACK);  // Draws a blank rectangle to clear the previous text
  display.setTextColor(WHITE, BLACK);
  display.setCursor(15, 50);
  display.print(newValue);
  display.display();
  }
  DcsBios::IntegerBuffer fuelflowcounter100Buffer(0x44e8, 0xffff, 0, onFuelflowcounter100Change);

void onFuelflowcounter1kChange(unsigned int newValue) {
  display.setTextColor(WHITE, BLACK);
  display.setCursor(30, 50);
  display.print(newValue);
  display.display(); 
  }
  DcsBios::IntegerBuffer fuelflowcounter1kBuffer(0x44e6, 0xffff, 0, onFuelflowcounter1kChange);

  void onFuelflowcounter10kChange(unsigned int newValue) {
  display.setTextColor(WHITE, BLACK);
  display.setCursor(45, 50);
  display.print(newValue);
  display.display();
    }
    DcsBios::IntegerBuffer fuelflowcounter10kBuffer(0x44e4, 0xffff, 0, onFuelflowcounter10kChange);

 

Posted

Thanks! Getting closer! I now get 4 digits on the display. "Fuel Flow" is no longer displayed as before.

The digits are too large though. they do not replicate the correct data from in DCS. For example in game 1200 PPH shows ~1680 PPH on the screen.

GD ViperWorks - YouTube

F-16CM Block 50 Replica Sim Pit Construction

Posted

so the numbers are not correct?

Try this, send a picture if you can

 

#define DCSBIOS_DEFAULT_SERIAL
//#define DCSBIOS_IRQ_SERIAL

//#define DCSBIOS_RS485_SLAVE 51
//#define TXENABLE_PIN 2

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
#include "Fonts/FreeSans24pt7b.h"

#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);


#include <DcsBios.h>


void setup()

{
display.begin(SH1106_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
delay(1000);
  display.clearDisplay();   // clears the screen and buffer
  display.setFont(&FreeSans24pt7b);
  
 DcsBios::setup();
}

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

void onFuelflowcounter100Change(unsigned int newValue) {
     display.fillRect(0, 0, 128, 60, BLACK);  // Draws a blank rectangle to clear the previous text
  display.setTextColor(WHITE, BLACK);
  display.setCursor(45, 50);
  display.print(newValue);
  display.display();
  }
  DcsBios::IntegerBuffer fuelflowcounter100Buffer(0x44e8, 0xffff, 0, onFuelflowcounter100Change);

void onFuelflowcounter1kChange(unsigned int newValue) {
    display.setTextColor(WHITE, BLACK);
  display.setCursor(30, 50);
  display.print(newValue);
  display.display(); 
  }
  DcsBios::IntegerBuffer fuelflowcounter1kBuffer(0x44e6, 0xffff, 0, onFuelflowcounter1kChange);

  void onFuelflowcounter10kChange(unsigned int newValue) {
  display.setTextColor(WHITE, BLACK);
  display.setCursor(15, 50);
  display.print(newValue);
  display.display();
    }
    DcsBios::IntegerBuffer fuelflowcounter10kBuffer(0x44e4, 0xffff, 0, onFuelflowcounter10kChange);

 

Posted

The section of each callout like this "display.setCursor(30, 50);" sets where the text is displayed, basically horizontal and vertical position, try playing with that to make all the text display

It may be that the numbers will need to be mapped

Les 

Posted

Thanks, Les for your valuable time. I am trying to recover a Jaheli Simulator FFI that is no longer communicating with DCS-BIOS. Even though I found a sketch that worked for a smaller screen, I would prefer to not redesign and remake my entire FFI housing. 

I can move the digits around the screen but they are still too big and incorrect data. If you have any more ideas, great! But if not, thanks for so much help. 

GD ViperWorks - YouTube

F-16CM Block 50 Replica Sim Pit Construction

Posted

try this with a smaller text

#define DCSBIOS_DEFAULT_SERIAL
//#define DCSBIOS_IRQ_SERIAL

//#define DCSBIOS_RS485_SLAVE 51
//#define TXENABLE_PIN 2

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
#include "Fonts/FreeSans18pt7b.h"

#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);


#include <DcsBios.h>


void setup()

{
display.begin(SH1106_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
delay(1000);
  display.clearDisplay();   // clears the screen and buffer
  display.setFont(&FreeSans24pt7b);
  
 DcsBios::setup();
}

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

void onFuelflowcounter100Change(unsigned int newValue) {
     display.fillRect(0, 0, 128, 60, BLACK);  // Draws a blank rectangle to clear the previous text
  display.setTextColor(WHITE, BLACK);
  display.setCursor(45, 50);
  display.print(newValue);
  display.display();
  }
  DcsBios::IntegerBuffer fuelflowcounter100Buffer(0x44e8, 0xffff, 0, onFuelflowcounter100Change);

void onFuelflowcounter1kChange(unsigned int newValue) {
    display.setTextColor(WHITE, BLACK);
  display.setCursor(30, 50);
  display.print(newValue);
  display.display(); 
  }
  DcsBios::IntegerBuffer fuelflowcounter1kBuffer(0x44e6, 0xffff, 0, onFuelflowcounter1kChange);

  void onFuelflowcounter10kChange(unsigned int newValue) {
  display.setTextColor(WHITE, BLACK);
  display.setCursor(15, 50);
  display.print(newValue);
  display.display();
    }
    DcsBios::IntegerBuffer fuelflowcounter10kBuffer(0x44e4, 0xffff, 0, onFuelflowcounter10kChange);

we can look at the mapping when we get the text size right

  • 2 months later...
Posted (edited)

The values for the flow counter are for use with gauges and not for a direct output. So it is not easy to convert them back to a real digital display. The results look much better in the scrolling digit style, like already done for several A-10 instruments. Furthermore, it doesn't matter what OLED driver is in use. Most of the sketches can be adapted to several libraries or drivers (like SSD1306 SPI to SH1106 I2C or so).

I quickly scripted within Middlefart's A-10 code to make it useable for the F-16 Fuel Flow Counter and SH1106 driven OLEDs. The sketch uses the (standard) characters.h file for the digits, to be installed within the same folder like the script.

It's not 100% perfect but may be a starting point for your Fuel Flow Counter.

Spoiler
// I2C -OLED display for the F-16 Fuel Flow Counter @ Display 128 * 64 by Vinc_Vega
// adapted from the A-10 Fuel Counter by Middlefart (Original code)

#define DCSBIOS_IRQ_SERIAL

// #define DCSBIOS_RS485_SLAVE 22
// #define TXENABLE_PIN 2

#include "DcsBios.h"

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

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1   //   QT-PY / XIAO
#define i2c_Address 0x3c //initialize with the I2C addr 0x3C Typically eBay OLED's

// Fuel Quantity - OLED-Display
  struct scrollDigit {
    int digit; //The digit that is displayed
    int y; // The vertical position of the digit
  };
  
  struct disp {
    Adafruit_SH1106G display;
    int width;
    int numberOfDigits;
    scrollDigit digits[5];
  };

// for I2C interface
  disp oled = {Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 24, 5, {{-1,0},{0,0},{0,0},{0,0},{0,0}}};

//*****************************************

void setup() {

  DcsBios::setup();

  delay(250); // wait for the OLED to power up
  oled.display.begin(i2c_Address, true); // Address 0x3C default
  // oled.display.setContrast (1); // uncomment to use the dim option for the display
  oled.display.display();
  
}

//*****************************************

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);
  }

  // comment the next line if using an engraved cover infront of the display
  printBezle(); // top layer of the display
  
  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;
    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+49, c24_1, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_2, 24, 32, 1); break;
      case 0: oled->display.drawBitmap(x, y-17, c24_9, 24, 32, 1); oled->display.drawBitmap(x, y+16, c24_0, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_1, 24, 32, 1); break;
      case 1: oled->display.drawBitmap(x, y+16, c24_1, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_2, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_3, 24, 32, 1); break;
      case 2: oled->display.drawBitmap(x, y+16, c24_2, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_3, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_4, 24, 32, 1); break;
      case 3: oled->display.drawBitmap(x, y+16, c24_3, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_4, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_5, 24, 32, 1); break;
      case 4: oled->display.drawBitmap(x, y+16, c24_4, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_5, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_6, 24, 32, 1); break;
      case 5: oled->display.drawBitmap(x, y+16, c24_5, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_6, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_7, 24, 32, 1); break;
      case 6: oled->display.drawBitmap(x, y+16, c24_6, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_7, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_8, 24, 32, 1); break;
      case 7: oled->display.drawBitmap(x, y+16, c24_7, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_8, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_9, 24, 32, 1); break;
      case 8: oled->display.drawBitmap(x, y+16, c24_8, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_9, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_0, 24, 32, 1); break;
      case 9: oled->display.drawBitmap(x, y+16, c24_9, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_0, 24, 32, 1); oled->display.drawBitmap(x, y+82, c24_1, 24, 32, 1); break;
      default: oled->display.drawBitmap(x, y-17, c24_9, 24, 32, 1); oled->display.drawBitmap(x, y+16, c24_0, 24, 32, 1); oled->display.drawBitmap(x, y+49, c24_1, 24, 32, 1); break;
    }

}

void onFuelflowcounter10kChange(unsigned int newValue)
  {
    unsigned int mappedValue = newValue / 6553;
    unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());
    
    if (mappedValue == 0)
    {
      oled.digits[0].digit = -1;
      oled.digits[0].y = 0;
    }
    else
    {
    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 fuelflowcounter10kBuffer(0x44e4, 0xffff, 0, onFuelflowcounter10kChange);
  DcsBios::IntegerBuffer fuelflowcounter1kBuffer(0x44e6, 0xffff, 0, onFuelflowcounter1kChange);
  DcsBios::IntegerBuffer fuelflowcounter100Buffer(0x44e8, 0xffff, 0, onFuelflowcounter100Change);

//  print the bezel for the Fuel Flow Counter
void printBezle()
  {
    oled.display.fillRect(0, 0, 50, 17, SH110X_BLACK); // top left
    oled.display.fillRect(50, 0, 25, 8, SH110X_BLACK); // top
    oled.display.fillRect(75, 0, 54, 17, SH110X_BLACK); // top right
    oled.display.fillRect(0, 47, 50, 17, SH110X_BLACK); // bottom left
    oled.display.fillRect(50, 54, 25, 10, SH110X_BLACK); // bottom
    oled.display.fillRect(75, 47, 54, 17, SH110X_BLACK);  // bottom right
    oled.display.setTextColor(SH110X_WHITE);
    oled.display.setTextSize(2);
    oled.display.setCursor(3, 0);
    oled.display.print("FUEL");
    oled.display.setCursor(78, 0);
    oled.display.print("FLOW");
    oled.display.setTextSize(1);
    oled.display.setCursor(54, 57);
    oled.display.print("PPH");
  }

//*************************************************

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

 

Regards, Vinc

characters.h

Edited by Vinc_Vega
  • Thanks 1

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

@Vinc_Vega that was perfect! If you had any idea how long I have been struggling with reactivating this display. Since the JaHeLi FFI-DED-Indexer combo went t/u, I have not been able to recover the FFI because I don't know enough code to make lcd's work. I can't thank you enough! Really! I'm very excited about this. Thank you!!!

  • Like 1

GD ViperWorks - YouTube

F-16CM Block 50 Replica Sim Pit Construction

Posted (edited)

If you like, you may post a picture or clip of the working display in your cockpit environment 😉

Regards, Vinc 

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted

Thanks, that's awesome 👍

I wish I was that far with my cockpit.  But there always is a next winter to work on it.

I'll try to improve graphics and performance of the sketch and will give you an update.

Regards, Vinc 

  • Like 1

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted (edited)

Thanks @Vinc_Vega

The final adjustment is the entire display lower and slightly left. Then it should be perfection. I like the bezel printing because provides illumination through the acrylic. If the scrolling digit is taller to fill the cutout that would be ideal too.

 

image.jpeg

Edited by Enabler

GD ViperWorks - YouTube

F-16CM Block 50 Replica Sim Pit Construction

Posted (edited)

Hi, I didn't know that your instrument uses an engraved bezel but assumed that such designs may exist 

For your case you only comment (use // infront of a code line) the line calling the printBezel() routine within the UpdateDisplay() function. It's also documented within the code in the UpdateDisplay() routine.

Than the black rectangles and the text will disappear.

 

Edit: can you tell me how many pixels we have to go down? I assume 5 pixels may do it.

 

Regards, Vinc

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted (edited)

Hi Enabler,

I did some modifications to the sketch, so you may adjust it to your needs.

The digits may be shifted vertically by a new constant "BL" (for bottom line). Horizontal shifting may be done by adjusting the variable "h_adj", where 0 alligns all left and 4 centers the output to the display. Furthermore, the black rectangular areas are swapped with white filled rects to illuminate your engravings. That backlights even may be adjusted to your instrument bezel. I think you'll make it, just read the comments from line 17 on.

Unfortunately I haven't found an easy way to reduce the fontsize, so the above "characters_n.h" file is still in use.

EDIT: update see below posting

Regards, Vinc

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Posted (edited)

Update of the adjustable sketch for the SH1106 I2C OLED, including shrinked numbers (by 2 pixels in width and height each).

Graphics file see below for download, let me know if the numbers should be smaller.

Spoiler
// I2C -OLED display for the F-16 Fuel Flow Counter @ Display 128 * 64 by Vinc_Vega
// adapted from the A-10 Fuel Counter by Middlefart (Original code)

#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
#include "digits_22x30.h"

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1   //   QT-PY / XIAO
#define i2c_Address 0x3c //initialize with the I2C addr 0x3C Typically eBay OLED's

// ***** do your adjustments to the illuminated areas on the below variables *****
const byte BL = 20; // baseline for the scrolling digits (17 to meet the center of a 64 pixel height display for a 30 px height digit)
const byte TH = 15; // height of the top left and right rectangular areas to illuminate an engraved bezle
const byte TW1 = 45; // width of the top left rectangle
const byte TW2 = 45; // width of the top right rectangle
const byte BH = 5;  // height of the bottom center illuminated area
const byte BW = 40; // width of the bottom center rectangle

// ***** adjustment to the scrolling digits *****
const byte v_dist = 35; // vertical distance between two scrolling digits (must be more than 30 !!!)
const byte h_adj = 6;  // horizontal distance adjustment (0 alligns the display to the left, 6 centers the third digit to the display)

// temporary values (only for backlight calculations)
const byte digit_w = 22;  // width of a digit 
const byte digit_h = 30;  // hieght of a digit

// Fuel Quantity - OLED-Display
  struct scrollDigit {
    int digit; //The digit that is displayed
    int y; // The vertical position of the digit
  };
  
  struct disp {
    Adafruit_SH1106G display;
    int width;
    int numberOfDigits;
    scrollDigit digits[3];
  };

// for I2C interface
  disp oled = {Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET), 22, 3, {{-1,0},{0,0},{0,0}}};

//*****************************************

void setup() {

  DcsBios::setup();

  delay(250); // wait for the OLED to power up
  oled.display.begin(i2c_Address, true); // Address 0x3C default
  // oled.display.setContrast (1); // uncomment to use the dim option for the display
  oled.display.display();
  
}

//*****************************************

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);
  }

  // print the right most two digits
  oled.display.drawBitmap((digit_w * 4) - digit_w + 4 + h_adj, BL, c22_0, digit_w, digit_h, 1);
  oled.display.drawBitmap((digit_w * 5) - digit_w + 5 + h_adj, BL, c22_0, digit_w, digit_h, 1);

    // draw backlights for engraved bezels
    oled.display.fillRect(0, 0, TW1, TH, SH110X_WHITE); // top left
    oled.display.fillRect(128 - TW2, 0, TW2, TH, SH110X_WHITE); // top right
    oled.display.fillRect(h_adj + (3* digit_w) - digit_w/2 - BW/2, 64 - BH, BW, BH, SH110X_WHITE); // bottom
  
  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 ) + h_adj;
    switch (digit)
    {
      case -1: oled->display.drawBitmap(x, y+BL, c22_Empty, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_1, 22, 30, 1); break;
      case 0: oled->display.drawBitmap(x, y+BL-v_dist, c22_9, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_0, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_1, 22, 30, 1); break;
      case 1: oled->display.drawBitmap(x, y+BL-v_dist, c22_0, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_1, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_2, 22, 30, 1); break;	  
      case 2: oled->display.drawBitmap(x, y+BL-v_dist, c22_1, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_2, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_3, 22, 30, 1); break;
      case 3: oled->display.drawBitmap(x, y+BL-v_dist, c22_2, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_3, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_4, 22, 30, 1); break;
      case 4: oled->display.drawBitmap(x, y+BL-v_dist, c22_3, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_4, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_5, 22, 30, 1); break;
      case 5: oled->display.drawBitmap(x, y+BL-v_dist, c22_4, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_5, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_6, 22, 30, 1); break;
      case 6: oled->display.drawBitmap(x, y+BL-v_dist, c22_5, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_6, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_7, 22, 30, 1); break;
      case 7: oled->display.drawBitmap(x, y+BL-v_dist, c22_6, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_7, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_8, 22, 30, 1); break;
      case 8: oled->display.drawBitmap(x, y+BL-v_dist, c22_7, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_8, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_9, 22, 30, 1); break;
      case 9: oled->display.drawBitmap(x, y+BL-v_dist, c22_8, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_9, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_0, 22, 30, 1); break;
      default: oled->display.drawBitmap(x, y+BL-v_dist, c22_9, 22, 30, 1); oled->display.drawBitmap(x, y+BL, c22_0, 22, 30, 1); oled->display.drawBitmap(x, y+v_dist+BL, c22_1, 22, 30, 1); break;
    }

}

void onFuelflowcounter10kChange(unsigned int newValue)
  {
    unsigned int mappedValue = newValue / 6553;
    unsigned int y = map(newValue, mappedValue * 6553, mappedValue * 6553 + 6553, 0, YPos());
    
    if (mappedValue == 0)
    {
      oled.digits[0].digit = -1;
      oled.digits[0].y = 0;
    }
    else
    {
    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 fuelflowcounter10kBuffer(0x44e4, 0xffff, 0, onFuelflowcounter10kChange);
  DcsBios::IntegerBuffer fuelflowcounter1kBuffer(0x44e6, 0xffff, 0, onFuelflowcounter1kChange);
  DcsBios::IntegerBuffer fuelflowcounter100Buffer(0x44e8, 0xffff, 0, onFuelflowcounter100Change);

//*************************************************

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

 

Regards, Vinc

digits_22x30.h

Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

  • Recently Browsing   0 members

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