lesthegrngo Posted August 15, 2024 Posted August 15, 2024 All, due to the way that I have my sim rig set using the HUD view, there is no way to check the position of the speed brakes (this is the A10C) as HUD view disables the view of the rest of the plane - you can't just view left or right to look at the wings. As a result, there are only two positions where I know where the speedbrakes are, fully open or fully closed. So, even though I know it is not realistic, I wanted to make a position indicator, either using a physical gauge like the flap indicator, or either an OLED percentage indicator or virtual gauge, however a quick look at DCS Bios didn't show speedbrake position (at least in the version I have installed) Looking at the A-10C.json file I see the following entry "EXT_SPEED_BRAKE_LEFT": { "category": "External Aircraft Model", "control_type": "metadata", "description": "Left Speed Brake", "identifier": "EXT_SPEED_BRAKE_LEFT", "inputs": [ ], "outputs": [ { "address": 4944, "description": "Left Speed Brake", "mask": 65535, "max_value": 65535, "shift_by": 0, "suffix": "", "type": "integer" Then I compare it to the entry for the left engine fan speed "L_ENG_FAN": { "category": "Engine Instruments", "control_type": "analog_gauge", "description": "Left Engine Fan Speed", "identifier": "L_ENG_FAN", "inputs": [ ], "outputs": [ { "address": 4258, "description": "gauge position", "mask": 65535, "max_value": 65535, "shift_by": 0, "suffix": "", "type": "integer" I was thinking that if I was to change "control type": from "metadata" to "analog gauge" and "description": from "left Speed Brake" to "Gauge position" in the Left SpeedBrake callout like this below I could use it to export to an OLED, LCD or gauge "EXT_SPEED_BRAKE_LEFT": { "category": "External Aircraft Model", "control_type": "analog gauge", "description": "Left Speed Brake", "identifier": "EXT_SPEED_BRAKE_LEFT", "inputs": [ ], "outputs": [ { "address": 4944, "description": "gauge position", "mask": 65535, "max_value": 65535, "shift_by": 0, "suffix": "", "type": "integer" I wrote the following sketch for use with a 1.3" i2C OLED #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 onleftspeedbrakeChange(unsigned int newValue) { unsigned int mappedValue = newValue / 655; 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(mappedValue); display.display(); } DcsBios::IntegerBuffer leftspeedbrakeBuffer(0x1350, 0xffff, 0, onleftspeedbrakeChange); I'm happy to report it works, basically displaying the speed brake position as between 0 (closed) and 100 fully open. There are a couple of things I am going to work to fix. The first is that on power up the screen is covered in noise, which only clears when you move the speed brake switch, so I have to get some kind of clear display function in there. The second issue is that the numbers are left justified, whereas I want it to be right justified so it looks more correct Cheers Les 1
Vinc_Vega Posted August 15, 2024 Posted August 15, 2024 (edited) Hi Les, To clear the screen from noise at startup, you should add a display.display(); command at the end of the Setup() routine. For the Adafruit Library, the easiest way to align text to the right is to print spaces in front of your numbers. If the numbers are less than 100 add one space, if lower than 10 add two spaces. Regards, Vinc Edited August 15, 2024 by Vinc_Vega spell checking Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
lesthegrngo Posted August 15, 2024 Author Posted August 15, 2024 Thanks Vinc, let me give that a go Cheers Les
lesthegrngo Posted August 15, 2024 Author Posted August 15, 2024 The display.display(); cured the noise the extra spaces just moved the numbers to the right a bit, but nothing more. It's irritating but not an issue, I'll just live with it. It looks like SH1106 is not a very sophisticated library for this type of thing. I'll try writing a sketch for SSD1306 to see if that works better Cheers Les
Vinc_Vega Posted August 15, 2024 Posted August 15, 2024 (edited) Hi Les, It's because the letters (and space) have not the same width. Using a fixed width font should do the right alignment. Alternatively you could program a kind of progress bar for that indication. https://steemit.com/utopian-io/@lapilipinas/arduino-blog-no-12-how-to-make-a-progress-bar-using-oled-display-and-rotary-encoder Regards, Vinc Edited August 15, 2024 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
Recommended Posts