Setting a Min/Max to a C-Bus Group

Discussion in 'C-Bus Serial Protocols' started by Matt, Dec 16, 2012.

  1. Matt

    Matt

    Joined:
    Aug 3, 2004
    Messages:
    26
    Likes Received:
    2
    Location:
    Cairns North Queensland
    Hi is There away to set a group address to have a maximum value of 160 (63%) in the logic,
    I am trying to integrate a axium multi zone amp in to my c-bus system and it requires hex values for the volume (00 to A0 ) 0 to 160 bass and treble (F4 - 0C) -12 to 12

    I have got most of it figured out using IntToHexString but using a regular group address gives me a value from (00 to FF)

    Is there a way to do this at all as i would like to control the volume bass treble etc from DLT's as well as the wiser.

    The code i have so far
    {constants}

    {Commands}
    LF = #$0A;
    MuteCommand = #$30#$32;
    SourceCommand = #$30#$33;
    VolumeCommand = #$30#$34;
    BassCommand = #$30#$35;
    TrebleCommand = #$30#$36;

    {Zones}
    Z1Amp = #$30#$31;
    Z1Pre = #$34#$31;
    Z2Amp = #$30#$32;
    Z2Pre = #$34#$32;
    Z3Amp = #$30#$33;
    Z3Pre = #$34#$33;
    Z4Amp = #$30#$34;
    Z4Pre = #$34#$34;


    {Data}

    {Source's}
    CD = #$30#$30;
    Tape = #$30#$31;
    Tuner = #$30#$32;
    Aux = #$30#$33;
    Utility = #$30#$34;
    Sat = #$30#$35;
    DVD = #$30#$36;
    Video = #$30#$37;
    {Mute}
    Mute = #$30#$30;
    UnMute = #$30#$31;
    ToggleMute = #$30#$32;

    {Zone 1 Controls}
    Z1AmpOn = #$30#$31#$30#$31#$30#$31#$0A;
    Z1AmpOff = #$30#$31#$30#$31#$30#$30#$0A;
    Z1AmpVolume = #$30#$34#$30#$31;
    Z1AmpBass = #$30#$35#$30#$31;
    Z1AmpTreble = #$30#$36#$30#$31;
    Z1PreOn = #$30#$31#$34#$31#$30#$31#$0A;
    Z1PreOff = #$30#$31#$34#$31#$30#$30#$0A;
    Z1PreVolume = #$30#$34#$34#$31;
    Z1PreBass = #$30#$35#$34#$31;
    Z1PreTreble = #$30#$36#$34#$31;

    {Variables}

    {VariablesVolume}
    Zone1VolumeHex : String;
    OutString : String;
    RequiredVolumeZone1 : Integer;
    CurrentVolumeZone1: integer;

    {Module Code}

    RequiredVolumeZone1 := GetLightingLevel("Zone1AmpVolume"); {get the level}
    OutString := Z1AmpVolume; {set the first part of the command string}
    IntToHexString(RequiredVolumeZone1,0,Zone1VolumeHex); {set the variable part of the command & convert cbus level to hex value }
    Append(OutString,Zone1VolumeHex); {add the strings together}
    Append(OutString,LF); {add a line feed }


    if ( RequiredVolumeZone1 <> CurrentVolumeZone1) then
    begin
    WriteSerial(1,OutString);
    CurrentVolumeZone1 := RequiredVolumeZone1;
    end;
     
    Matt, Dec 16, 2012
    #1
  2. Matt

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Just scale the value.

    Vol := ga * 160 div 255;
     
    Ashley, Dec 16, 2012
    #2
  3. Matt

    Matt

    Joined:
    Aug 3, 2004
    Messages:
    26
    Likes Received:
    2
    Location:
    Cairns North Queensland
    Got it Working...

    Thanks for the fast reply
     
    Matt, Dec 16, 2012
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.