Home AMX User Forum NetLinx Studio

Bargraph update from a variable.

Ok, so this is likely a very simple question, but I can't readily find the answer. I am controlling a Denon receiver and would like to populate a bar graph with volume feedback. I was originally using the Amx module for that receiver, however, it seemed to choke from time to time and took way long to load on boot. I'm now controlling it natively though code. I've gotten so far as using a data event to pull the feedback and put it in a CHAR sbuffer. Where I'm struggling is with sending the info to the bar graph so it will display that on the panel. Also, the feedback jumps between 2-3 characters as it moves in half steps. Ie, 50 (for 50%), and 505 (for 50.5%). Ideally I could update it with each step, but if I only update on 2 digit feedback (each full step or two button presses) that is fine too. Thanks!

Comments

  • viningvining Posts: 4,368
    This is what I've have in my com module:
    CASE AVR_CMD_MV:
               {
               STACK_VAR INTEGER nVol;
               
               if(find_string(iRX_Buff,'MAX ',1))  
                {//only held here for now.  use if there's a need for it and reason to increase levels above 16.
                REMOVE_STRING(iRX_Buff,'MAX ',1);
                
                nVol = atoi(iRX_Buff);
                if(nVol > 100)
                 {
                 sAVRm.sZM.nMaxVol = nVol / 10;
                 }
                else
                 {
                 sAVRm.sZM.nMaxVol = nVol;
                 }
                fnSend_Main_LVL(AVR_LVL_MAXVOL,sAVRm.sZM.nMaxVol);
                nMatchFound = 1;
                }
               else 
                {
                nVol = atoi(iRX_Buff);
                if(nVol > 100)
                 {
                 sAVRm.sZM.nMVol = nVol / 10;
                 }
                else
                 {
                 sAVRm.sZM.nMVol = nVol;
                 }
                fnSend_Main_LVL(AVR_LVL_MV,sAVRm.sZM.nMVol);
                nMatchFound = 1;
                }
               }
    
    In this module I just send levels back to the main, no strings or commands so in my Avr.axi which receives the levels sent by the com module I basically just do this for volume FB:
    fnAVR_DoSend_LVL(iUI_Indx,iLVL_Chnl,iLVL_Value,iAVR_Indx);
    
    Which updates any UIs on the same instance of the module. My variables are integers so they automatically round off the value since I don't need decimal precision and the master will automatically decide if it needs to send the level when you receive 85.5 and then 86, 86 will be sent on 85.5 and not again on 86 since the masters knows it already just sent 86 and won't send it again. I send what I get and don't worry about sending every increment.
  • alexsquaredalexsquared Posts: 166
    Thank you Vining for the comprehensive response. I only wish it made sense to my feeble mind :) I understand now about the round off and no need to track feedback to the decimal level (especially within a bargraph). do you know of a simplistic command that would send the variable text to the bargraph in a way that the bargraph would understand it? The denon FB seems to report back in a percentage of volume, not in a db level, so there's no need to do any math functions either, just send the value (ie 56) to the bargraph level.
  • a_riot42a_riot42 Posts: 1,624
    If you want to update the bargraph, simply do a send_level to it. There is no need to send variable text to a bargraph unless you want it to display text along with the bargraph level.

    send_level dvUI, 1, 50

    Paul
  • alexsquaredalexsquared Posts: 166
    a_riot42 wrote: »
    If you want to update the bargraph, simply do a send_level to it. There is no need to send variable text to a bargraph unless you want it to display text along with the bargraph level.

    send_level dvUI, 1, 50

    Paul

    Thank you Paul for the input. I'm trying to send this level to the UI

    SEND_LEVEL dvDenon4308CITp,1,sPARSE1

    and I get the below error.

    ERROR: C10504: [<expr2> of SEND_LEVEL <ref><expr1><expr2>] is not compatible with a [DOUBLE] value

    as an FYI, sParse1 should be in an integer state based on my ATOI command.

  • viningvining Posts: 4,368
    sParse1 must be a double so you could change that to an integer or type_cast(sParse1) in your send_level.
Sign In or Register to comment.