Jump to content

wiggles5289

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by wiggles5289

  1. 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(); } }
  2. Where should one begin for a ground school experience? I have learned the Viper from the inside out but when it comes to knowing lingo or even how to navigate the skies I have no idea where to start. Any suggestions for tutorials?
  3. Working on making Left AUX Panel gauge replacement for the F16C. What is the current driver I should use for the FIP?
  4. Its more of a work in progress atm with Matchstick. I reached out to a few people on the DCS FP discord. I will update this thread as I figure stuff out.
  5. @JohnnyChicago It worked! I just modified that code to IRQ instead of Default serial and it worked smoothly. Just need to tweak the fonts and position of text to use the full display. //F-16 DED for DCS BIOS using 256x64 ER-OLED032-1G from BuyDisplay.com #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #include <Arduino.h> #include <U8g2lib.h> #ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif #ifdef U8X8_HAVE_HW_I2C #include <Wire.h> #endif U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 5, /* dc=*/ 3, /* reset=*/ 4); char* line1; char* line2; char* line3; char* line4; char* line5; void onDedLine1Change(char* newValue) { line1 = newValue; } DcsBios::StringBuffer<25> dedLine1Buffer(0x44fc, onDedLine1Change); void onDedLine2Change(char* newValue) { line2 = newValue; } DcsBios::StringBuffer<25> dedLine2Buffer(0x4516, onDedLine2Change); void onDedLine3Change(char* newValue) { line3 = newValue; } DcsBios::StringBuffer<25> dedLine3Buffer(0x4530, onDedLine3Change); void onDedLine4Change(char* newValue) { line4 = newValue; } DcsBios::StringBuffer<25> dedLine4Buffer(0x454a, onDedLine4Change); void onDedLine5Change(char* newValue) { line5 = (newValue); } DcsBios::StringBuffer<25> dedLine5Buffer(0x4564, onDedLine5Change); void setup() { DcsBios::setup(); u8g2.begin(); u8g2.clearBuffer(); u8g2.setFont(u8g2_font_t0_12_tf); } void loop() { u8g2.firstPage(); do { u8g2.drawStr(0, 10, line1); u8g2.drawStr(0, 20, line2); u8g2.drawStr(0, 30, line3); u8g2.drawStr(0, 40, line4); u8g2.drawStr(0, 50, line5); } while ( u8g2.nextPage() ); u8g2.updateDisplay(); DcsBios::loop(); }
  6. Contribute to the GitHub if you want to help develop an open source DED: https://github.com/wiggles5289/Orange-Viper-Simulations/blob/main/F16/DED.ino TLDR; Here's working code thanks to the help from @fusionand @JohnnyChicago //F-16 DED for DCS BIOS using 256x64 ER-OLED032-1G from BuyDisplay.com //Final code by JohnnyChicago,a whole lotta font cred to Fusion's wife, and Wiggles5289 on the DCS Forums //Updated for DCS 2.7 on 06SEP2022 #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #include <Arduino.h> #include <U8g2lib.h> #include <U8glib.h> #ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif #ifdef U8X8_HAVE_HW_I2C #include <Wire.h> #endif U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); char* line1; char* line2; char* line3; char* line4; char* line5; const u8g_fntpgm_uint8_t DEDfont16px[1148] U8G_FONT_SECTION("DEDfont16px") = "_\0\3\3\4\4\4\5\5\10\16\0\376\12\376\12\377\1\212\3\1\4_ \5\0\10\61!\14\224\32" "q$\207\212H,\222\0\42\10\66y\61DL\2#\22\227\31q\224$\222\213\222D$\221\134\224$" "\22\0$\20\326\371\260\204\62\212\210\252\225$\241\11E\0%\24\270\10q\206\22\231D\22\232Hu\31" "E\324$\302\11\0&\21\227\31qf\22\221D\66\223JL\22\221h\42'\6\62{\61\14(\15\264" "\372\260$\42\211H\67\221L\0)\15\264\372\60d\42\231H\27\221D\4*\20\310\10\61~\60\205h" "s\300\214\24:<\20+\12V\71\261\204\42\223P\4,\10C\373\60,\24\0-\6\26Y\61\14." "\6#\33\61\14/\16\246\11\61\325\204\62\241L(\23\12\1\60\16\226\32q(\42JS\245B\222P" "\0\61\11\225\31\361D\207\230>\62\14\226\31q(\42\222P\246\243\1\63\17\226\31q(\42\222P\64" "%\221$\24\0\64\20\227\31q\244*\42\211H\242$\71J%\0\65\15\226\31\61\16A\305\252P&" "!\1\66\15\226\31\261fj\25\21'\11\5\0\67\15\226\31\61\214\62\241L(\23\252\1\70\20\226\31" "q(\42REB\221\224H\22\12\0\71\15\226\31q(\42N\222\232\332\10\0:\10s\33\61\354 " "\3;\12\223\373\60\354 \13\5\0<\11\226\31\61e\272\352\0=\7\66I\61\314\6>\11\226\31\61" "\244\272\351\10\77\16\226\31q(\42\222LQ\16\23\212\0@\17\230\30q,B&\213\204\42!\331\1" "\7A\14\226\31\261d\24\21\323a\304$B\14\226\31\61*\42\246\213\210\351\2C\15\226\31q(\42" "FM$\11\5\0D\14\226\31\61H\22%\276HH\0E\14\226\31\61\16A\305\212P\321\0F\14" "\226\31\61\16A\305\212P#\0G\14\226\31q(\42F\225\22IRH\13\226\31\61D\234\16#N" "\2I\11\224\32\61(\42}!J\13\226\31\61\365H\42I(\0K\15\226\31\61D,ZH\22\235" "H\2L\11\226\31\61\204\372\321\0M\20\227\31\61d\264J%B\211P\42\64\66\1N\15\227\31\61" "d\264\222\205b\252\261\11O\13\226\31q(\42~\222P\0P\14\226\31\61*\42\246\213P#\0Q" "\14\266\371p(\42~\222\20\245\2R\14\226\31\61*\42\246\213&&\1S\14\226\31q(\42\252V" "\222\204\2T\11\226\31\61LB\375\4U\12\226\31\61D\374IB\1V\13\226\31\61D\374$\241\211" "\0W\21\227\31\61d\134\42\224\10%\242I\42\222H\0X\17\226\31\61D$\211$&\224E\224\230" "\4Y\14\226\31\61D\234$\64\241&\0Z\12\226\31\61\214j:\12\15[\11\304\352\60L\372'\2" "\134\27\230\30\61d\22ID%\42\71L\42*\21\221D&\221ID\0]\11\304\352\60H\372'\3" "^\11\66\231\261d\24\221\0_\7\30\350\60\16\1`\10\64\232\61F\62\1a\16\267\31\361\242\263\312" "\35\303\245\66\215\1b\14\226\31\61\204\302\212\210\247\13\0c\14v\31q(\42\242&\11\5\0d\12" "\226\31\61UN<I\12e\14v\31q(\42\322a(\245\0f\14\226\31\261(B\65\213P\33\0" "g\14\246\351pN<I\212\302\13\0h\13\226\31\61\204\302\212\210O\2i\13\246\31\261\204r\10Q" "O\6j\12\325\351\360\224i\372\315\2k\15\226\31\61\204J,\22\222D\211$l\11\226\31\61\210\372" "\311\0m\21w\31\61,\222\10%B\211P\42\224\10M\0n\11v\31\61*\42>\11o\11Cm" "qR$)\0p\14\246\351\60*\42\236.BE\0q\12\246\351pN<I\212\32r\13v\31\61" "D\24\233P#\0s\12v\31q\216R\252\360\2t\13\226\31q\204\62\213PW\2u\11v\31\61" "D|\222\24v\13v\31\61D<Ih\42\0w\21w\31\61d\224\10%B\211P\42\232$\22\0" "x\15v\31\61D$\11MF\21\221\4y\24\247\350pD\22\221D$\21ID\22\221\210*\24\321" "\0z\11v\31\61\214\62\35\15{\14\265\371\360D\62%E\65E\1|\7\302\353\60>\14}\15\265" "\372\60\204\62E%\65%\31\0~\12\70xqf\23\311l\2\0\0\0\4\377\377\0"; void onDedLine1Change(char* newValue) { line1 = newValue; } DcsBios::StringBuffer<29> dedLine1Buffer(0x450a, onDedLine1Change); void onDedLine2Change(char* newValue) { line2 = newValue; } DcsBios::StringBuffer<29> dedLine2Buffer(0x4528, onDedLine2Change); void onDedLine3Change(char* newValue) { line3 = newValue; } DcsBios::StringBuffer<29> dedLine3Buffer(0x4546, onDedLine3Change); void onDedLine4Change(char* newValue) { line4 = newValue; } DcsBios::StringBuffer<29> dedLine4Buffer(0x4564, onDedLine4Change); void onDedLine5Change(char* newValue) { line5 = newValue; } DcsBios::StringBuffer<29> dedLine5Buffer(0x4582, onDedLine5Change); void setup() { DcsBios::setup(); u8g2.begin(); u8g2.clearBuffer(); u8g2.setFont(DEDfont16px); } void loop() { u8g2.firstPage(); do { u8g2.drawStr(30, 12.8, line1); u8g2.drawStr(30, 25.6, line2); u8g2.drawStr(30, 38.4, line3); u8g2.drawStr(30, 51.2, line4); u8g2.drawStr(30, 64, line5); } while ( u8g2.nextPage() ); u8g2.updateDisplay(); DcsBios::loop(); } We still need someone to contribute a better working font that supports the inverted character colors using the U8G2 Library. We are so close to having a fully working DED! I have been struggling to get DCS BIOS and the u8g2 library to work. Any time I put a drawStr.() line in a void onDisplayChange or whatever it is, it doesn't draw anything but in a corner it looks like its showing the first line of the DED in one character spot with insane tearing from high FPS. Display works fine and is configured correctly when using the Hello World examples from the u8g2 library. A sample of my code is below: /* Tell DCS-BIOS to use a serial connection and use the default Arduino Serial library. This will work on the vast majority of Arduino-compatible boards, but you can get corrupted data if you have too many or too slow outputs (e.g. when you have multiple character displays), because the receive buffer can fill up if the sketch spends too much time updating them. If you can, use the IRQ Serial connection instead. */ #define DCSBIOS_DEFAULT_SERIAL #include "DcsBios.h" #include <Arduino.h> #include <U8g2lib.h> #ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif #ifdef U8X8_HAVE_HW_I2C #include <Wire.h> #endif U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h void onDedLine1Change(char* newValue) { u8g2.clearBuffer(); // clear the internal memory u8g2.setFont(u8g2_font_ncenB12_tr); // choose a suitable font u8g2.drawStr(2,12,newValue); // write something to the internal memory u8g2.sendBuffer(); // transfer internal memory to the display } DcsBios::StringBuffer<25> dedLine1Buffer(0x44fc, onDedLine1Change); void onDedLine2Change(char* newValue) { u8g2.clearBuffer(); // clear the internal memory u8g2.setFont(u8g2_font_ncenB12_tr); // choose a suitable font u8g2.drawStr(2,25,newValue); // write something to the internal memory u8g2.sendBuffer(); // transfer internal memory to the display } DcsBios::StringBuffer<25> dedLine2Buffer(0x4516, onDedLine2Change); void onDedLine3Change(char* newValue) { u8g2.clearBuffer(); // clear the internal memory u8g2.setFont(u8g2_font_ncenB12_tr); // choose a suitable font u8g2.drawStr(2,38,newValue); // write something to the internal memory u8g2.sendBuffer(); // transfer internal memory to the display } DcsBios::StringBuffer<25> dedLine3Buffer(0x4530, onDedLine3Change); void onDedLine4Change(char* newValue) { u8g2.clearBuffer(); // clear the internal memory u8g2.setFont(u8g2_font_ncenB12_tr); // choose a suitable font u8g2.drawStr(2,51,newValue); // write something to the internal memory u8g2.sendBuffer(); // transfer internal memory to the display } DcsBios::StringBuffer<25> dedLine4Buffer(0x454a, onDedLine4Change); void onDedLine5Change(char* newValue) { u8g2.clearBuffer(); // clear the internal memory u8g2.setFont(u8g2_font_ncenB12_tr); // choose a suitable font u8g2.drawStr(2,64,newValue); // write something to the internal memory u8g2.sendBuffer(); // transfer internal memory to the display } DcsBios::StringBuffer<25> dedLine5Buffer(0x4564, onDedLine5Change); void setup() { DcsBios::setup(); u8g2.begin(); } void loop() { DcsBios::loop(); }
×
×
  • Create New...