Roger01 Posted October 29, 2017 Posted October 29, 2017 Hi, I was makking a 7-segment for the Master Caution. But, I have only found the Master Caution LED and the 7-segment twinkle: How can I do, to run a code then Master Caution is active? (not the LED but the Master Caution itself). I want to showing the Master Caution all the time among other things. Any idea? Thanks!:thumbup:
LynxDK Posted October 29, 2017 Posted October 29, 2017 May i ask why you want to make a Segment for that? The original is a engraved piece of plastic with matt film ontop of it, with light behind it. So you would be able to make this using 1-2 LED's behind a simular setup. Take a look at this: http://lynx.dk/pictures/forum/annunciator_prototype_1.JPG http://lynx.dk/pictures/forum/annunciator_prototype_2.JPG Regards. LynxDK [sIGPIC][/sIGPIC] Instagram
Roger01 Posted October 29, 2017 Author Posted October 29, 2017 This is not my question, I want to do some things like a text with a 7-segment when the Master Caution is on, if possible.
FSFIan Posted October 29, 2017 Posted October 29, 2017 If I understand correctly, you want to show a steady text while the master caution light is blinking and nothing when it is shut off. There is nothing like that in the DCS cockpit, so you'll have to write some code that decides when you want to turn your message on and off. DCS-BIOS gives you two pieces of information you can work with: the state of the master caution light and the state of the master caution button. void onMasterCautionChange(unsigned int newValue) { // newValue is 0 if the master caution light is off, 1 if it is on } DcsBios::IntegerBuffer masterCautionBuffer(0x1012, 0x0800, 11, onMasterCautionChange); void onUfcMasterCautionChange(unsigned int newValue) { // newValue is 0 if the reset button is not pressed, 1 if it is pressed } DcsBios::IntegerBuffer ufcMasterCautionBuffer(0x10f2, 0x0008, 3, onUfcMasterCautionChange); With that information, you'd have to code some kind of time-out, i.e. turn the master caution message on when the master caution light illuminates, but only turn it off after it has either been off for some amount of time or the reset button has been pressed. To see those code snippets, you have to use "Advanced" view in the control reference. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
Roger01 Posted October 29, 2017 Author Posted October 29, 2017 Ian;3278662']If I understand correctly' date=' you want to show a steady text while the master caution light is blinking and nothing when it is shut off..[/quote'] Yes that's it! Thanks a lot for your explanation. I do this, this week. :book:
Roger01 Posted October 29, 2017 Author Posted October 29, 2017 It works! Thanks for your help! It's not a clear code, but it's better than nothing. #define DCSBIOS_IRQ_SERIAL #include <DcsBios.h> #include <LedControl.h> unsigned long previousMillis = 0; unsigned long currentMillis = millis(); // Arduino Pin 5 to DIN, 7 to Clk, 6 to LOAD, no.of devices is 1 LedControl lc=LedControl(5,7,6,1); void setup() { DcsBios::setup(); // Initialize the MAX7219 device lc.shutdown(0,false); // Enable display lc.setIntensity(0,5); // Set brightness level (0 is min, 15 is max) lc.clearDisplay(0); // Clear display register } DcsBios::Switch2Pos eppApuGenPwr("EPP_APU_GEN_PWR", 10); void onMasterCautionChange(unsigned int newValue) { if (newValue==1) { previousMillis = currentMillis; } } DcsBios::IntegerBuffer masterCautionBuffer(0x1012, 0x0800, 11, onMasterCautionChange); void loop() { currentMillis = millis(); if (currentMillis - previousMillis < 400) { lc.setRow(0,7,B01110110); lc.setRow(0,6,B01110111); lc.setRow(0,5,B01011011); lc.setRow(0,4,B00001111); lc.setRow(0,3,B01001111); lc.setRow(0,2,B00000101); lc.setRow(0,1,B10000000); lc.setRow(0,0,B01001110); } else { lc.setRow(0,7,B01011011); lc.setRow(0,6,B00111011); lc.setRow(0,5,B11011011); lc.setRow(0,4,B00000000); lc.setRow(0,3,B01111110); lc.setRow(0,2,B01010111); lc.setRow(0,1,B00000000); lc.setRow(0,0,B00000000); } DcsBios::loop(); }
Recommended Posts