Results 1 to 2 of 2
  1. #1
    150+ Forum Groupie
    Join Date
    Aug 2008
    Location
    Dallas, Texas
    Posts
    192
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Script for 2 encoders and 6 seven seg displays

    I built a COM1 radio with 5 digit displays and a dual concentric encoder and it was working fine but recently I changed to 6 digit displays. I couldn't find an example sioc script using 2 encoders. I tried to modify my file so the decimals would increase/decrease properly rather than in increments of .003, .006,.009,.012 etc. but I just made matters worse. Can someone point me to an example file using 2 rotary encoders or tell me whats wrong with my file.

    Jerry

    /=====================================================================
    // * COM1
    //=====================================================================

    Var 6000 // Standby Frequency 2D High Digits
    {
    CALL V6012 // Send value to Simulator
    }

    Var 6001 // Standby Frequency 2D Low Digits
    {
    CALL V6012 // Send value to Simulator
    }

    Var 6002, Link IOCARD_DISPLAY, Device 3, Digit 64, Numbers 6 // Active Radio Frequency

    Var 6003, Link IOCARD_DISPLAY, Device 3, Digit 70, Numbers 3 // Standby Frequency Low Digits

    Var 6004, Link IOCARD_DISPLAY, Device 3, Digit 73, Numbers 2 // Standby Frequency High Digits

    Var 6005, Link IOCARD_DISPLAY, Device 3, Digit 75, Numbers 1 // Standby Frequency 1 Digit

    Var 6006, Value 0

    Var 6007, Link FSUIPC_OUT, Offset $311A, Length 2 // COM1 Standby Frequency
    {
    V6004 = V6000 // Send high digits to display
    V6003 = V6001 // Send low digits to display
    V6005 = 1
    }

    Var 6008, Link FSUIPC_OUT, Offset $034E, Length 2 // COM1 Active Frequency
    {
    L0 = FROMBCD V6008 // change to binary
    V6002 = L0 + 100000 // and display the 1 in front
    }

    Var 6009, Link IOCARD_SW, Device 3, Input 110, Type P // SWAP Active/Standby
    {
    L0 = V6000 * 100 // Value of 2 high digits
    L0 = L0 + V6001 // + value of low digits
    L1 = FROMBCD V6008 // Change the current frequency to Decimal
    V6008 = TOBCD L0 // and send the frequency to Standby
    L0 = L1 / 100 // Get the 2 High Digits
    V6000 = TRUNC L0 // Se los paso a la variable
    L2 = V6000 * 100
    V6001 = L1 - L2 // Paso los 2 digitos bajos
    }

    Var 6010, Link IOCARD_ENCODER, Device 3, Input 94, Aceleration 1, Type 2 // High Digits
    {
    V6000 = ROTATE 18 ,36 ,V6010 // Increase/Decrease considering limites 18-36
    }

    Var 6011, Link IOCARD_ENCODER, Device 3, Input 96, Aceleration 1, Type 2 // Low Digits
    {
    IF V6011 > 0 // If the frequency increases
    {
    IF V6001 = 975 // If it is the high limit
    {
    V6001 = 0 // Change to 0
    }
    ELSE // If it is not the high limit
    {
    L0 = V6001 + 3 // Sumo 3 pero ahora reviso...
    L1 = L0 / 100 // Saco unidades
    L1 = TRUNC L1
    L1 = L1 * 100
    L1 = L0 - L1
    IF L1 = 3 // Si las unidades terminan en 3
    {
    L0 = L0 + 1 // Decremento en 1
    }
    IF L1 = 8 // Si las unidades terminan en 8
    {
    L0 = L0 - 1 // Decremento en 1
    }
    V6001 = L0 // Paso el valor final
    }
    }
    ELSE // Si es un decremento de Frecuencia
    {
    IF V6001 = 0 // Si ha llegado al limite
    {
    V6001 = 97 // Paso al valor alto
    }
    ELSE // Si no ha llegado al limite
    {
    L0 = V6001 - 3
    IF L0 = -1 // Miro si es -1 que corresponde a 0
    {
    V6001 = 0 // asigno entonces 0
    }
    ELSE // Prosigo con lextraccion de las unidades
    {
    L1 = L0 / 10 // Saco unidades
    L1 = TRUNC L1
    L1 = L1 * 10
    L1 = L0 - L1
    IF L1 = 4 // Si termina en 4 corresponde con 5
    {
    L0 = L0 + 1
    }
    IF L1 = 9 // Si termina en 9 corresponde con 0
    {
    L0 = L0 + 1
    }
    V6001 = L0 // Paso el valor a la variable
    }
    }
    }
    }

    Var 6012, Link SUBRUTINE // Manda valor a frecuencia standby
    {
    L0 = V6000 * 100 // Monta el n鷐ero
    L0 = L0 + V6001
    V6007 = TOBCD L0 // Pasamos a BCD y enviamos al simulador
    }

  2. #2
    150+ Forum Groupie
    Join Date
    Aug 2008
    Location
    Dallas, Texas
    Posts
    192
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Script for 2 encoders and 6 seven seg displays

    I think I finally got the decimals to work right but when I swap the frequencies its putting a 0 in front on the active instead of a 1. I tried adding a 0 but it didn't work.


    //=====================================================================
    // * COM1
    //=====================================================================

    Var 6000 // Standby Frequency 2D High Digits
    {
    CALL V6012 // Send value to Simulator
    }

    Var 6001 // Standby Frequency 2D Low Digits
    {
    CALL V6012 // Send value to Simulator
    }

    Var 6002, Link IOCARD_DISPLAY, Device 3, Digit 64, Numbers 6 // Active Radio Frequency

    Var 6003, Link IOCARD_DISPLAY, Device 3, Digit 70, Numbers 3 // Standby Frequency Low Digits

    Var 6004, Link IOCARD_DISPLAY, Device 3, Digit 73, Numbers 2 // Standby Frequency High Digits

    Var 6005, Link IOCARD_DISPLAY, Device 3, Digit 75, Numbers 1 // Standby Frequency 1 Digit

    Var 6006, Value 0

    Var 6007, Link FSUIPC_OUT, Offset $311A, Length 2 // com2 Standby Frequency
    {
    V6004 = V6000 // Send high digits to display
    V6003 = V6001 // Send low digits to display
    V6005 = 1
    }

    Var 6008, Link FSUIPC_OUT, Offset $034E, Length 2 // com2 Active Frequency
    {
    L0 = FROMBCD V6008 // change to binary
    V6002 = L0 + 10000 // and display the 1 in front
    }

    Var 6009, Link IOCARD_SW, Device 3, Input 110, Type P // SWAP Active/Standby
    {
    L0 = V6000 * 100 // Value of 2 high digits
    L0 = L0 + V6001 // + value of low digits
    L1 = FROMBCD V6008 // Change the current frequency to Decimal
    V6008 = TOBCD L0 // and send the frequency to Standby
    L0 = L1 / 100 // Get the 2 High Digits
    V6000 = TRUNC L0 // Se los paso a la variable
    L2 = V6000 * 100
    V6001 = L1 - L2 // Paso los 2 digitos bajos
    }

    Var 6010, Link IOCARD_ENCODER, Device 3, Input 94, Aceleration 1, Type 2 // High Digits
    {
    V6000 = ROTATE 18 ,36 ,V6010 // Increase/Decrease considering limites 18-36
    }

    Var 6011, Link IOCARD_ENCODER, Device 3, Input 96, Aceleration 1, Type 2 // Low Digits
    {
    IF V6011 > 0 // If the frequency increases
    {
    IF V6001 = 975 // If it is the high limit
    {
    V6001 = 0 // Change to 0
    }
    ELSE // If it is not the high limit
    {
    L0 = V6001 + 3 // Sumo 3 pero ahora reviso...
    L1 = L0 / 10 // Saco unidades
    L1 = TRUNC L1
    L1 = L1 * 10
    L1 = L0 - L1
    IF L1 = 3 // If the digits end in 3
    {
    L0 = L0 + 1 // Decremento en 1
    }
    IF L1 = 8 // If the digits end in 8
    {
    L0 = L0 - 1 // Decremento en 1
    }
    V6001 = L0 // Pass the final value
    }
    }
    ELSE // If the frequency decreases
    {
    IF V6001 = 0 // If it has reached the limit
    {
    V6001 = 975 // Paso al valor alto
    }
    ELSE // If it has not reached the limit
    {
    L0 = V6001 - 3
    IF L0 = -1 // Miro si es -1 que corresponde a 0
    {
    V6001 = 0 // assign 0
    }
    ELSE // Prosigo con lextraccion de las unidades
    {
    L1 = L0 / 10 // Saco unidades
    L1 = TRUNC L1
    L1 = L1 * 10
    L1 = L0 - L1
    IF L1 = 4 // If it terminates en 4 corresponds to 5
    {
    L0 = L0 + 1
    }
    IF L1 = 9 // If it terminates en 9 corresponds to 0
    {
    L0 = L0 + 1
    }
    V6001 = L0 // Pass the value to the variable
    }
    }
    }
    }

    Var 6012, Link SUBRUTINE // Send value to standby frequency
    {
    L0 = V6000 * 100 // Monta el n鷐ero
    L0 = L0 + V6001
    V6007 = TOBCD L0 // Pasamos a BCD y enviamos al simulador
    }

    var 6013, name ii_sw1_com1, link IOCARD_SW, Device 3, input 114
    {
    if &ii_sw1_com1 = 1
    {
    call &clr_com1
    &io_l1_com1 = 1
    }
    }

    var 6014, name ii_sw2_com1, link IOCARD_SW, Device 3, input 113
    {
    if &ii_sw2_com1 = 1
    {
    call &clr_com1
    &io_l2_com1 = 1
    }
    }

    var 6015, name ii_sw3_com1, link IOCARD_SW, Device 3, input 112
    {
    if &ii_sw3_com1 = 1
    {
    call &clr_com1
    &io_l3_com2 = 1
    }
    }

    var 6016, name ii_sw4_com1, link IOCARD_SW, Device 3, input 115
    {
    if &ii_sw4_com1 = 1
    {
    call &clr_com1
    &io_l4_com1 = 1
    }
    }

    var 6017, name ii_sw5_com1, link IOCARD_SW, Device 3, input 108
    {
    if &ii_sw5_com2 = 1
    {
    call &clr_com2
    &io_l5_com2 = 1
    }
    }


    var 6018, name ii_sw6_com1, link IOCARD_SW, Device 3, input 116
    {
    if &ii_sw6_com2 = 1
    {
    call &clr_com2
    &io_l6_com2 = 1
    }
    }

    var 6019, name io_off_com1, link IOCARD_SW, Device 3, input 111
    {
    if &io_off_com2 = 1
    {
    call &clr_com2
    }
    }


    var 6020, name io_l1_com1, link IOCARD_OUT, Device 3, output 79

    var 6021, name io_l2_com1, link IOCARD_OUT, Device 3, output 81

    var 6022, name io_l3_com1, link IOCARD_OUT, Device 3, output 85

    var 6023, name io_l4_com1, link IOCARD_OUT, Device 3, output 75

    var 6024, name io_l5_com1, link IOCARD_OUT, Device 3, output 77

    var 6025, name io_l6_com1, link IOCARD_OUT, Device 3, output 83


    var 6026, name clr_com1, link SUBRUTINE
    {
    &io_l1_com1 = 0
    &io_l2_com1 = 0
    &io_l3_com1 = 0
    &io_l4_com1 = 0
    &io_l5_com1 = 0
    &io_l6_com1 = 0
    }