Page 1 of 3 123 LastLast
Results 1 to 10 of 27
  1. #1
    25+ Posting Member
    Join Date
    Oct 2015
    Location
    United Kingdom
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Jim's radio stack - dual rotary encoder amendment?

    Hello peeps

    Before I invest in the dual rotary from leo, I was wondering how complicated it would be to incorporate this into the sterling code Jim has created for his radio stack build? I've spent a few hours searching through this forum and not quite found what I'm after to answer this. I did find a code for the dual in "Re: 7 segment led displays and my radio" which is posted in this forum. However this is used with the 7 seg displays (obviously) and not the LCD in Jim's code. Would it be difficult to amend for the lcd? (I don't really know how they work, not having one).

    Secondly, I have a 20 x 4 ldc, (I'm impressed I soldered it without killing it tbh) which affords me the luxury of doubling up displays compared to the 16x2 on Jim's schematic and code. What would yo think about the following format for the display?

    Line 1 - Com.1
    Line 2 - Freq # Standby Freq #
    Line 3 - Com.2
    Line 4 - Freq# Standby freq #

    I could then keep the red push switch, instead of using it to switch between units in the radio frequencies I could use it to toggle Com.1 &2, Nav 1 &2 etc.
    Would this be worth the hassle of recoding? I must state that I'm new to coding, happy to do some grafting and trial and error, but if it's a complete recode, I'm probably out of my depth.

    I look forward to your suggestions.

    Best wishes
    D

  2. #2
    150+ Forum Groupie


    BushPilotWannabe's Avatar
    Join Date
    Jan 2014
    Location
    Alberta, Canada
    Posts
    176
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Jim's radio stack - dual rotary encoder amendment?

    I Think that branching out like this will make Jim very happy. Wish that I could follow his lead and poke around in the PC.

    How about this:
    Line 1 - permanent "COM!" (COM1) <--> (COM1 Standby)
    Line 2 - permanent "NAV1" (NAV1) <--> (NAV1 Standby)
    Line 3 - permanent "NAV2" (NAV2) <--> (NAV2 Standby)
    Line 4 - remaining functions switched as before but squeezed onto one line.

    in void EQUALS() - " if (com1 != com1old && digitalRead(12) == LOW) " prevents updating the LCD unless the rotary switch is tuned to COM1. Amend the code to allow an update to COM1 whenever new numbers come down from LINK2FS.

    Dual rotary encoders are usually two separate encoders in one package. Create a "Quadrature quad2(next two empty pins);" for the second encoder. Search the forum for posts on how to do this.
    The lines in void ROTARYS()
    " if (digitalRead(10)==0 ) {
    Serial.println("A01");
    }
    else Serial.println("A03");
    } "
    can be changed so that quad1 (inner knob) generates "A03" and quad2 (outer knob) generates "A01". Tuning COM1 does not affect the display but will remain necessary to connect the rotary encoders to the serial bus.

    A button is required to kick the "SWAP" command up to FSX. You could use a pushbutton to "step" through the radio selections but adds one more distraction during a period of high activity. Not so much with you kids but when you start using "you kids", simplify.

    If lack of pins is a factor see the third post at http://www.mycockpit.org/forums/show...740&highlight= . Another post for 5 position magneto switches http://svglobe.com/arduino/a_switch.htm explains the concept much better, the circuit uses a different method to eliminate contact bounce. Both work but don't add elements from one into the other without testing. The first article mentions using pushbuttons to replace the rotary switch for evaluation. The rotary switch is a string of pushbuttons and only one pushbutton can be pressed at a time. Most rotary switches break one contact before completing a circuit with the next which is akin to releasing a pushbutton. I guess pushbuttons could replace the rotary switch. Eight (including autopilot) 12x12 mm tactile switches with square caps and labels under clear covers would work very well.

    Do one small part at a time. At times there can be a steep learning curve. Watch the punctuation, especially ; { } and both single and double = signs. Do not hesitate to use the cheaper Arduino Nano and a breadboard to test problems as you go, but most important, organize your backups and modified sketches. There will be a lot of them.

    Help is always out there, especially if you are specific in your request.


    Hugh
    ---CYXD ----- TWR --- GND ------ Closed
    ILS-- NDB -- 119.1 -- 121.9 ---- 11/2013

  3. #3
    25+ Posting Member
    Join Date
    Oct 2015
    Location
    United Kingdom
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Jim's radio stack - dual rotary encoder amendment?

    Hugh, thank you for your time in replying extensively. I like the LCD display you suggest and will try to have a look at sorting this.
    Thank you for your hep with the dual rotary too, I will buy one I think and have a play. Your explanation of thinking of it as 2 separate entities makes more sense to me than all the look ups I did today.

    I like your workflow of doing 1 step at a time, I think I'm too impatient sometimes. I've not made back ups before, just change things and save over, which is destructive. I'll do this from now on.

    Thanks too for not providing an absolute answer, I like being given a direction, and then left to work things out, which I find one learns from.

    I'll order the dual tonight me thinks, that and a usb interface for my diy throttle with sliding potentiometers. (well, if I ain't got at least 2 things going on then life's just boring!).

    Thanks again Hugh
    Damo

  4. #4
    10+ Posting Member
    Join Date
    Jan 2013
    Location
    UK
    Posts
    18
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Jim's radio stack - dual rotary encoder amendment?

    Damo, I have just finished my FSX Radio Stack which incorporates the COM/NAV radios, autopilot, transponder, etc.
    It uses a Leo Bodnar dual rotary encoder and a 16 x 2 LCD display (as well as a number of 7-segment displays, buttons, etc.).

    The thread for the project is here... http://www.mycockpit.org/forums/showthread.php?t=29966

    although I used a library for the LCD, I have written my own code for the encoders, 7-segment displays, buttons, et-al.
    The above thread includes arduino code extracts (however some of this has changed in the final version), which are heavily commented and as such may be of help.

    I hope to update the thread with a video showing the radio stack in action in the very near future and I will also post the final code.

    Dave

  5. Thanks iwik thanked for this post
  6. #5
    500+ This must be a daytime job



    Join Date
    Jan 2007
    Location
    NEW ZEALAND
    Posts
    867
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Jim's radio stack - dual rotary encoder amendment?

    Dave,
    I had a look at your build thread. Very well done and a lot of work. I have not seen something done so comprehensively.
    When you finish if you would post your code it would help a lot of people who struggle with code.
    Your panel is so complete for a GA pilot.
    Keep up the good work.
    Regards
    Les

  7. #6
    10+ Posting Member
    Join Date
    Jan 2013
    Location
    UK
    Posts
    18
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Jim's radio stack - dual rotary encoder amendment?

    Les,

    many thanks for your comments. My project now also includes DME and ADF functionality which uses the LCD to display ADF frequency or DME distance/speed and controls the OBS/HDG bugs on the relevant Nav dials.

    FYI - I have just posted my implementation (with the latest code, which is heavily commented) for five rotary encoders (one Leo Bodnar dual and three cheapo chinese rotary encoders) on this thread... http://www.mycockpit.org/forums/showthread.php?t=29730

    Dave

  8. #7
    25+ Posting Member
    Join Date
    Oct 2015
    Location
    United Kingdom
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Jim's radio stack - dual rotary encoder amendment?

    Hi Dave

    Yes, I had seen your post and great work when researching yesterday. Thanks for posting it and for directing towards it. I haven't looked at your final code yet, but well done, great annotations and workflow.
    I eventually found this on the forum, http://www.mycockpit.org/forums/showthread.php?t=27048 from Fess_ter (thanks fess_ter!), which I thought, as a newbie, would be easier for me to understand!

  9. #8
    25+ Posting Member
    Join Date
    Oct 2015
    Location
    United Kingdom
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Jim's radio stack - dual rotary encoder amendment?

    Right, your help please. I'm in a real pickle. I have used Jim's code in his rotary encoders demo from the fsx for experts. I tried to add LCD support to this sketch but kept getting errors. So I then copied the encoder code into the Multi_Radio sketch.
    Now rotaries aren't outputting into link2fs in monitor card 1, and therefore not in fsx.
    Jim's Rotary code uses different wording in the code to tha tin the radio one. Such as doutPin vs KoutPin, Kstringoldstate vs stringoldstate. Multi Radio has "Void Inputs" and the encoders has "Void Keys". Perhaps this is where mismatches happen. When I try to fiddle I get INPUTS errors (not specified) and all kinds of jazz.

    Edit:
    Ok, I'm at work, which means I have time to do no work, unlike at home where there is a 6 month old to take off of a manic mum.
    So, I've decided to use my brain, and, bit by bit, add code from the radio project sketch to the rotary sketch. Add a line, Verify, add a line, verify, etc, change this and that, add 'K's to pinxxxx you know.

    Sadly, actually bringing the arduino to work will probably give me away, so I can't check it works via upload until this evening, if baby and wife allow.

    So here is my amended code, I'll let you know if it works, although I have little hope in my expertise, even if it's copying and pasting!

    Code:
    
    /* 
        This code is in the public domain
        For use with "Link2fs_Multi"
        Jimspage.co.nz
        My thanks to the Guys that gave me snippets of code. 
        
        This sets the Arduino Mega card for 3 rotary encoders and "keys" input except pin 13.
        Attach a switch to any pin from pin 8 upwards (except 13) and program that pin in "Multi"
        Everything to do with "Keys"  starts with a "K" in this code.
        Everything to do with rotary encoders starts with a "R" in this code.
        The Quadrature2 library is available from my site Jimspage.co.nz. (Special thanks to Bill Holland)
        It's here ,, http://www.jimspage.co.nz/encoders2.htm (Near the bottom of the page)
        Rotary encoder 1 is on pins 2 and 3
        Rotary encoder 2 is on pins 4 and 5
        Rotary encoder 3 is on pins 6 and 7
        The "push" switch on each one is connected to a "Keys" input pin and just seen as a switch.
        
        To change this to suit a Uno,, do the following ,,,,
        Line 29 ,, change "70"  to "20"
        Line 117 ,, change "70"  to  "20"
        That will make all the pins from pin 8 upwards on a Uno, as "Keys" input pins. (Except pin 13)
    
    
    */
    #include "math.h"
    #include "Quadrature.h"
    #include 
    #include 
    
    
    Quadrature quad1(8,9);
    Quadrature quad2(10,11);
    LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
    
    
    int CodeIn;// used on all serial reads
    int KpinNo; 
    int Koutpin;
    int active; // the mode thats active
    int activeold;
    int mark; // shows where the cursor is in the likes of ADF etc
    Servo flapsServo;
    
    
    String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate, APsp, APspold, stringnewstate,stringoldstate, com1, com1old, com1sb, com1sbold,com2, com2old, com2sb,com2sbold, airsp, airspold, altit, altitold;
    String nav1, nav1old, nav1sb, nav1sbold, nav2, nav2old, nav2sb, nav2sbold;
    String adf, adfold, xpdr, xpdrold, dme1, dme1old, dme2, dme2old, pitot, pitotold;
    String gearSimple;
    char blank = 255;
    
    
    int R;// a variable
    int Rold;// the old reading
    int Rdif;// the difference since last loop
    int R2;// a second test variable
    int R3;// a second test variable
    int Rold2;// a second loop old reading
    int Rdif2; // the second test difference
    int Rold3;// a second loop old reading
    int Rdif3; // the second test difference
    
    
    // make some custom arrows for the LCD:
    byte leftArrow[8] = { // This makes a <-- on lcd
      0b00000,
      0b00100,
      0b01000,
      0b11111,
      0b01000,
      0b00100,
      0b00000,
      0b00000
    };
    
    
    byte rightArrow[8] = { //make a --> on lcd
    
    
      0b00000,
      0b00100,
      0b00010,
      0b11111,
      0b00010,
      0b00100,
      0b00000,
      0b00000
    };
    
    
    void setup() 
    {
      lcd.begin(20, 4); // set up the LCD's number of columns and rows: 
      Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
        for (int KoutPin = 12; KoutPin < 70; KoutPin++)// Get all the pins ready for "Keys"  
      {
        pinMode(KoutPin, INPUT);
        digitalWrite(KoutPin, HIGH);  
      }
      for (int PinNo = 54; PinNo <= 69; PinNo++)// Get all the OUTPUT pins from analog
      {
     pinMode(KpinNo, OUTPUT);
    }
    
    
    lcd.createChar(0, leftArrow); // create a new character
    lcd.createChar(1, rightArrow);
     
    mark = 12;
    lcd.clear();
    flapsServo.attach(13);
    Serial.begin(115200);   
    }
    
    
    void loop() {
      {LCDMODE();}  // Sets up the LCD for the mode it's in (From the rotary switch)
      
      {KEYS();} //Check the "keys" section
      {ENCODER();} //Check the Rotary Encoders
      if (Serial.available()) {// Check if serial data has arrived from PC
        CodeIn = getChar();
        if (CodeIn == '=') {EQUALS();} // The first identifier is "="
        if (CodeIn == '<') {LESSTHAN();}// The first identifier is "<"
        if (CodeIn == '?') {QUESTION();}// The first identifier is "?"
        if (CodeIn == '/') {SLASH();}// The first identifier is "/" (Annunciators)
      }
    
    
    }
    
    
    char getChar()// Get a character from the serial buffer
    {
      while(Serial.available() == 0);// wait for data
      return((char)Serial.read());// Thanks Doug
    }
    
    
    void LCDMODE(){
    if (active != activeold)
        activeold = active;
      if (digitalRead(14)==0 and active != 14) { // Sets up the LCD when switching to Com1)
        lcd.setCursor(0, 0);
        delay (11);
        lcd.print(com1); 
        lcd.setCursor(8, 0);
        lcd.write(byte(0)); // this is the left arrow
        lcd.setCursor(9, 0);  // this is the right arrow
        lcd.write((byte) 1);
         lcd.setCursor(12, 0);
        delay (11);
        lcd.print(com1sb); 
    
    
       
        lcd.setCursor(0, 2);
        delay (11);
        lcd.print("Comm 1      Standby"); 
        active = 14;
    
    
        if (digitalRead(16)==0 and active != 16) {  // Sets up the LCD when switching to Nav1)
       lcd.setCursor(0, 0);
        delay (11);
        lcd.print(nav1); 
        lcd.setCursor(8, 0);
        lcd.write(byte(0)); // this is the left arrow
        lcd.setCursor(9, 0);  // this is the right arrow
        lcd.write((byte) 1);
         lcd.setCursor(12, 0);
        delay (11);
        lcd.print(nav1sb); 
    
    
       
        lcd.setCursor(0, 2);
        delay (11);
        lcd.print("Nav 1       Standby"); 
        active = 16;
      }
      if (digitalRead(17)==0 and active != 17) {  // Sets up the LCD when switching to Nav2)
        lcd.setCursor(0, 0);
        delay (11);
        lcd.print(nav2); 
        lcd.setCursor(8, 0);
        lcd.write(byte(0)); // this is the left arrow
        lcd.setCursor(9, 0);  // this is the right arrow
        lcd.write((byte) 1);
         lcd.setCursor(12, 0);
        delay (11);
        lcd.print(nav2sb); 
    
    
       
        lcd.setCursor(0, 2);
        delay (11);
        lcd.print("Nav 2       Standby"); 
        active = 17;
      }    
      if (digitalRead(18)==0 and active != 18) {  // Sets up the LCD when switching to ADF)
        lcd.setCursor(0, 0);
        delay (11);
        
        lcd.print("ADF      ");  
        lcd.setCursor(9, 0);
        delay (11);
        lcd.print(adf); 
        lcd.print("  ");
        lcd.setCursor(0, 1);
        lcd.print("                ");
        lcd.setCursor(0, 2);
        lcd.print("                   "); 
        
        if (mark == 9 ){mark = 10;}
        lcd.setCursor(mark, 1);
        lcd.print("-");
        active = 18;             
      }    
      if (digitalRead(19)==0 and active != 19) {  // Sets up the LCD when switching to DME)
        lcd.setCursor(0, 0);
        delay (11);
        lcd.print(dme1); 
        lcd.setCursor(0, 9);
        lcd.print(dme2);
        lcd.setCursor(0, 2);
        delay (11);
        lcd.print("DME 1        DME2  ");  
        
        
        active = 19;
      }        
      if (digitalRead(20)==0 and active != 20) {  // Sets up the LCD when switching to XPDR)
        lcd.setCursor(0, 0);
        delay (11);
        lcd.print("XPonder  ");  
        lcd.setCursor(9, 0);
        delay (11);
        lcd.print(xpdr); 
        lcd.print("    ");
        lcd.setCursor(0, 1);
        lcd.print("                ");
        lcd.setCursor(mark, 1);
        lcd.print("-");
        lcd.setCursor(0, 2);
        delay (11);
        lcd.print("                  ");
        active = 20;                   
       }
      }
    
    
    if (digitalRead(15)==0 and active != 15) {  // Sets up the LCD when switching to Com2)
        lcd.setCursor(0, 0);
        delay (11);
        lcd.print(com2); 
        lcd.setCursor(8, 0);
        lcd.write(byte(0)); // this is the left arrow
        lcd.setCursor(9, 0);  // this is the right arrow
        lcd.write((byte) 1);
         lcd.setCursor(12, 0);
        delay (11);
        lcd.print(com2sb); 
    
    
       
        lcd.setCursor(0, 2);
        delay (11);
        lcd.print("Comm 2      Standby"); 
        active = 15;
      }
      
    }// end of LCDmode
      
    void EQUALS(){      // The first identifier was "="
           delay (11);
           CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
        case 'A'://Found the reading "Com1"
            com1 = "";
            com1 += getChar();
            com1 += getChar();
            com1 += getChar();
            com1 += getChar();
            com1 += getChar();
            com1 += getChar();
            com1 += getChar();
            if (com1 != com1old && digitalRead(14) == LOW) {
              delay (11);
              lcd.setCursor(9, 0);
              delay (11);
              lcd.print(com1);
              com1old = com1;
              }
             break;
          case 'B': // Found the reading "Com1 s/b" 
            com1sb = "";
            com1sb += getChar();
            com1sb += getChar();
            com1sb += getChar();
            com1sb += getChar();
            com1sb += getChar();
            com1sb += getChar();
            com1sb += getChar();
            if (com1sb != com1sbold && digitalRead(14) == LOW ){
              delay (11);
              lcd.setCursor(9, 1);
              delay (11);
              lcd.print(com1sb);
              com1sbold = com1sb;
              }        
             break;
           case  'C': //  Found the reading "Com2"
            com2 = "";
            com2 += getChar();
            com2 += getChar();
            com2 += getChar();
            com2 += getChar();
            com2 += getChar();
            com2 += getChar();
            com2 += getChar();
            if (com2 != com2old && digitalRead(15) == LOW) {
              lcd.setCursor(9, 0);
              delay (11);
              lcd.print(com2);
              com2old = com2;
              }
             break;
           case  'D': //  Found the reading "Com2 s/b"
            com2sb = "";
            com2sb += getChar();
            com2sb += getChar();
            com2sb += getChar();
            com2sb += getChar();
            com2sb += getChar();
            com2sb += getChar();
            com2sb += getChar();
            if (com2sb != com2sbold && digitalRead(15) == LOW) {
              lcd.setCursor(9, 1);
              delay (11);
              lcd.print(com2sb);
              com2sbold = com2sb;
              }
             break;          
           case  'E': //  Found the reading "Nav1"
            delay (11);
            nav1 = "";
            nav1 += getChar();
            nav1 += getChar();
            nav1 += getChar();
            nav1 += getChar();
            nav1 += getChar();
            nav1 += getChar();
            nav1 += (" "); //pads it up to 8 caracters
            if (nav1 != nav1old && digitalRead(16) == LOW) {
              lcd.setCursor(9, 0);
              delay (11);
              lcd.print(nav1);
              nav1old = nav1;
              }
             break;
           case  'F': //  Found the reading "Nav1 s/b"
            nav1sb = "";
            nav1sb += getChar();
            nav1sb += getChar();
            nav1sb += getChar();
            nav1sb += getChar();
            nav1sb += getChar();
            nav1sb += getChar();
            nav1sb += (" "); //pads it up to 8 caracters
            if (nav1sb != nav1sbold && digitalRead(16) == LOW) {
              lcd.setCursor(9, 1);
              delay (11);
              lcd.print(nav1sb);
              nav1sbold = nav1sb;
              }              
             break;
           case  'G': //  Found the reading "Nav2"
            delay (11);
            nav2 = "";
            nav2 += getChar();
            nav2 += getChar();
            nav2 += getChar();
            nav2 += getChar();
            nav2 += getChar();
            nav2 += getChar();
            nav2 += (" "); //pads it up to 8 caracters
            if (nav2 != nav2old && digitalRead(17) == LOW) {
              lcd.setCursor(9, 0);
              delay (11);
              lcd.print(nav2);
              nav2old = nav2;
              }
             break;
           case  'H': //  Found the reading "Nav2 s/b"
            nav2sb = "";
            nav2sb += getChar();
            nav2sb += getChar();
            nav2sb += getChar();
            nav2sb += getChar();
            nav2sb += getChar();
            nav2sb += getChar();
            nav2sb += (" "); //pads it up to 8 caracters
            if (nav2sb != nav2sbold && digitalRead(17) == LOW) {
              lcd.setCursor(9, 1);
              delay (11);
              lcd.print(nav2sb);
              nav2sbold = nav2sb;
              }              
             break;
           case  'I': //  Found the reading "ADF"
            adf = "";
            adf += getChar();
            adf += getChar();
            adf += getChar();
            adf += getChar();
            adf += getChar();
            adf += getChar();
            adf += (" "); //pads it up to 8 caracters
            if (adf != adfold && digitalRead(18) == LOW) {
              lcd.setCursor(9, 0);
              delay (11);
              lcd.print(adf);
              adfold = adf;
              }
             break;   
           case  'J': //  Found the reading "XPDR"
            delay (11);
            xpdr = "";
            xpdr += getChar();
            xpdr += getChar();
            xpdr += getChar();
            xpdr += getChar();
            xpdr += ("    "); //pads it up to 8 caracters
            if (xpdr != xpdrold && digitalRead(20) == LOW) {
              lcd.setCursor(9, 0);
              delay (11);
              lcd.print(xpdr);
              xpdrold = xpdr;
              }               
             break;
           case  'K': //  Found the reading "DME1"
            delay (11);
            dme1 = "";
            dme1 += getChar();
            dme1 += getChar();
            dme1 += getChar();
            dme1 += getChar();
            dme1 += getChar();
            dme1 += ("   "); //pads it up to 8 caracters
            if (dme1 != dme1old && digitalRead(19) == LOW) {
              lcd.setCursor(9, 0);
              delay (11);
              lcd.print(dme1);
              dme1old = dme1;
              }
             break;          
           case  'L': //  Found the reading "DME2"
            delay (11);
            dme2 = "";
            dme2 += getChar();
            dme2 += getChar();
            dme2 += getChar();
            dme2 += getChar();
            dme2 += getChar();
            dme2 += ("   "); //pads it up to 8 caracters
            if (dme2 != dme2old && digitalRead(19) == LOW) {
              lcd.setCursor(9, 1);
              delay (11);
              lcd.print(dme2);
              dme2old = dme2;
            }
            break;
          }               
        }
    
    
    
    
    void LESSTHAN(){    // The first identifier was "<"
    CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
        case 'A'://Found the second identifier
           //Do something
        break;
         
        case 'B':
           //Do something
        break;
         
        case 'C':
           //Do something
        break;
           
             //etc etc etc
         }
    }
    
    
    void QUESTION(){    // The first identifier was "?"
    CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
        case 'A'://Found the second identifier
           //Do something
        break;
         
        case 'B':
           //Do something
        break;
         
        case 'C':
           //Do something
        break;
           
             //etc etc etc
         }
    }
    void SLASH(){    // The first identifier was "/" (Annunciator)
      //Do something
    }
    void KEYS() 
    {
      Kstringnewstate = "";
      for (int KpinNo = 12; KpinNo < 70; KpinNo++){
        KpinStateSTR = String(digitalRead(KpinNo)); 
        KoldpinStateSTR = "";
        KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 12));
        if (KpinStateSTR != KoldpinStateSTR) {// yes it's different
          if (KpinNo == 11 and KpinStateSTR == "0") { //Change-over button is pressed
            if (active == 14) Serial.println("A06");//com1
            if (active == 15) Serial.println("A12");//com2
            if (active == 16) Serial.println("A18");//nav1
            if (active == 17) Serial.println("A24"); //nav2
            if ( active == 18){ //adf
              mark = (mark + 1);
              if (mark == 13){ 
                mark = 14;
              }// sort out for piont in ADF
              active = 1;
              if (mark > 14)mark = 10;
            }
            if  (active == 20){ //xponder
              mark = (mark + 1);
              if (mark == 13){ 
                mark = 9;
              }// sort out for length Xponder
              active = 1;
              if (mark > 12)mark = 12;
            }
          }// end of pin sortout
            if (KpinNo == 21 && KpinStateSTR == "0"){Serial.println ("C01");} // Gear UP 
            if (KpinNo == 21 && KpinStateSTR == "1"){Serial.println ("C02");} // Gear DOWN 
        Kstringnewstate += KpinStateSTR;
      }
      Kstringoldstate = Kstringnewstate;
    }
    }
    void ENCODER(){
    R =(quad1.position()/2); //The /2 is to suit the encoder(See my website)
      if (R != Rold) { // checks to see if it different
        (Rdif = (R-Rold));// finds out the difference
       if (Rdif == 1) Serial.println ("A01");//Com1 Mhz down
       if (Rdif == -1) Serial.println ("A02"); //Com1 Mhz up
       Rold = R; // overwrites the old reading with the new one.
      } 
      R2 =(quad2.position());
      if (R2 != Rold2) {
        (Rdif2 = (R2-Rold2));
        if (Rdif2 == 1) Serial.println ("A03"); // Com1 Khz down
        if (Rdif2 == -1) Serial.println ("A04");//Com1 Khz up
        Rold2 = R2;
      
     
      
      }}


    Last edited by Damo78; 11-12-2015 at 04:08 PM. Reason: missed out some #include codes

  10. #9
    150+ Forum Groupie


    BushPilotWannabe's Avatar
    Join Date
    Jan 2014
    Location
    Alberta, Canada
    Posts
    176
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Jim's radio stack - dual rotary encoder amendment?

    No problem Damo78. Is this your radio stack sketch? http://www.jimspage.co.nz/Multi_Radio.htm ? If you want we can take this to personal messages and post how we got the results.


    Hugh
    ---CYXD ----- TWR --- GND ------ Closed
    ILS-- NDB -- 119.1 -- 121.9 ---- 11/2013

  11. #10
    25+ Posting Member
    Join Date
    Oct 2015
    Location
    United Kingdom
    Posts
    34
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Jim's radio stack - dual rotary encoder amendment?

    Thats very kind Hugh, yes that's it. I may well take you up on that.

    I've amended my code as I had missed out #include Quad and Servo.

    I've got home, amended and uploaded the code, and... low and behold, it's all working...sort of. I'm proper chuffed.

    For some reason the lcd display is being naughty, and popping the (com1) on the 1st line even though the code states top line position 12. So I'll have a play tonight (baby is asleep, another miracle). Strange, as before it links ti link the arrows are in the correct place, looks like the com1 and s/b inputs/readings are squiring it up.

    I'll update asa the wife has gone to bed.

    Happy days
    D

Page 1 of 3 123 LastLast