New Marquee 'Widget' for your Tool Bag

Discussion in 'C-Bus Wiser 1 Controller' started by bmerrick, Mar 17, 2013.

  1. bmerrick

    bmerrick

    Joined:
    Jun 13, 2007
    Messages:
    437
    Likes Received:
    35
    Location:
    Sydney
    Hi All,

    Been trying to get this out for a little while.:rolleyes: Using the SystemIO String widget in a way that turns it into a moving Marquee display.

    Probably most useful for announcing a state change such as going into 'Away from Home' mode, notifying an alarm is currently active, telling you the Alarm is armed or annunciating 'confirmed' state changes of buttons you might hit on your iPhone etc. It can also display several monitors like temp etc within one widget which is good if you are getting close to your widget limit.

    Please be aware that the default code updates once a second, and at this rate only displays 60 characters a minute. You can make it do more than that if you want or need to, but be aware of the additional load on your Wiser.

    Below I have listed the Marquee Engine module and then a few sample modules that populate the marquee with information of various types. I have also included below that a simple procedure to get the System Time module going first for those who are just starting out.

    Code:
    Module - 'Marquee Engine'
      once (Second <> timechec) then // Runs the code just once a second
      begin
        marqstart := 'Updating - Please Wait.....................';// These first three lines can go into initialisation section
        marqdivider :='_'; // fill in character
        marqviewlen := 17; // 17 is one line, 30 is 2 lines maxlength
        marqstringlen := length (marqstring);
        if marqstringlen = 0 then
          begin
          SetLength(marqstart, marqviewlen+6 );
          marqstring := marqstart;
          marqstringlen := length (marqstring); 
          end;
        if marqstringlen < marqviewlen then
          begin
          Append(marqstring, marqdivider);
          marqstringlen := marqstringlen + length (marqdivider);
          end;
        copy(marquee, marqstring, 1, marqviewlen); 
        SetStringSystemIO("Marquee Display", marquee);
        copy(newmarqstring, marqstring, 2, marqstringlen -1);
        marqstring := newmarqstring;
        timechec := Second;
      end;
      
    Module - 'Marquee Group Watch'
     once (Second = 55) then
      begin
      if GetCBusLevel("Local Network", "Lighting", "KitchenDL") = 100% then
        begin
        Append(marqstring, 'Info:KitchenLightOn');
        Append(marqstring, '..');
        end;
      if GetCBusLevel("Local Network", "Lighting", "DiningRoomDL1") = 100% then
        begin
        Append(marqstring, 'Info:DiningRoomLightOn');
        Append(marqstring, '..');
        end;
      if GetCBusLevel("Local Network", "Lighting", "LoungeDL1") = 100% then
        begin
        Append(marqstring, 'Info:LoungeLightOn');
        Append(marqstring, '..');
        end;
      if GetCBusLevel("Local Network", "Enable", "House Unoccupied") = 100% then
        begin
        Append(marqstring, 'Info:Away From Home Mode Enabled');
        Append(marqstring, '..');
        end;
      end;
      
    
    Module - 'Marquee Alarms'
    DisableModule("Marquee Alarms");
    once (Second = 35) then
      begin
        if GetBoolIBSystemIO("Security Alarm Sounding") = TRUE then Append(marqstring, 'ALERT:Alarm Sounding..');
        if GetBoolIBSystemIO("Security All Zones Secure") = TRUE then
           begin
              alarmstate := 'Info:All Zones Secure..';
              if ConditionStaysTrue(GetBoolIBSystemIO("Security All Zones Secure") = TRUE, 60) then alarmstate := '';
              Append(marqstring, alarmstate);
              alarmstate := '';
           end ;
        if GetBoolIBSystemIO("Security Arm Ready") = TRUE then
           begin
              alarmstate := 'Info:Ready to Arm..';
              if ConditionStaysTrue(GetBoolIBSystemIO("Security Arm Ready") = TRUE, 60) then alarmstate := '';
              Append(marqstring, alarmstate);
              alarmstate := '';
           end ;  
        if GetBoolIBSystemIO("Security Arm Failed") = TRUE then Append(marqstring, 'ALERT:Arming Failed..');
        if GetBoolIBSystemIO("Security Armed State") = TRUE then Append(marqstring, 'Info:Alarm Armed..');
        if GetBoolIBSystemIO("Security Fire Alarm Sounding") = TRUE then Append(marqstring, 'ALERT:Fire Alarm Sounding..');
        if GetBoolIBSystemIO("Security Mains Failure") = TRUE then Append(marqstring, 'ALERT:Mains Failure..');
        if GetBoolIBSystemIO("Security Low Battery") = TRUE then Append(marqstring, 'Info:Battery Low..'); 
      end;
    
    
    Module - 'Marquee Temps'
    DisableModule("Marquee Temps");
    once (Second = 10) then
      begin
        r_temp4 := GetUnitParameter(254, 150, ptTemperature);
        Format(s_temp4, r_temp4:2:1);
        Append(s_temp4, 'C');
        Otemp :='Out-';
        Append(Otemp, s_temp4);
        r_temp5 := GetUnitParameter(254, 151, ptTemperature);
        Format(s_temp5, r_temp5:2:1);
        Append(s_temp5, 'C');
        Itemp :='In-';    
        Append(Itemp, s_temp5);
        Append(marqstring, 'Temps ');
        Append(marqstring, Otemp);
        Append(marqstring, '..');
        Append(marqstring, Itemp);
        Append(marqstring, '..');
      end;
    
    
    Module - 'Marquee System Time'
    DisableModule("Marquee System Time");
    once (Second = 01) then // Runs the code once a minute
    begin
      TimeToString(time, s_time);
      Append(marqstring, 'SystemTime:');
      Append(marqstring, s_time);
      Append(marqstring, '..');
    end;
    
    In Global Variables you will need:
    s_time : string;
    r_temp4 : real;
    s_temp4 : string;
    r_temp5 : real;
    s_temp5 : string;
    Itemp : string;
    Otemp : string;
    templine : string;
    alarmstate : string;
    
    marqstring : array[0..254] of char;
    newmarqstring :array[0..254] of char;
    marqstart : string;
    marquee : string;
    marqtext : string;
    marqsub1 : string;
    marqdivider :string;
    timechec : integer;
    marqviewlen : integer;
    marqpos : integer;
    marqlen : integer;
    marqstringlen : integer;


    Easy Instructions for System Time Marquee
    This simple marquee will display System time on your iPhone, Android, iPad in a marquee.

    In PICED - 'Edit Logic'
    Create a new Module called 'Marquee Engine' or whatever.

    in it put:
    Code:
      once (Second <> timechec) then // Runs the code just once a second
      begin
        marqstart := 'Updating - Please Wait.....................';// These first three lines can go into initialisation section
        marqdivider :='_'; // fill in character
        marqviewlen := 17; // 17 is one line, 30 is 2 lines maxlength
        marqstringlen := length (marqstring);
        if marqstringlen = 0 then
          begin
          SetLength(marqstart, marqviewlen+6 );
          marqstring := marqstart;
          marqstringlen := length (marqstring); 
          end;
        if marqstringlen < marqviewlen then
          begin
          Append(marqstring, marqdivider);
          marqstringlen := marqstringlen + length (marqdivider);
          end;
        copy(marquee, marqstring, 1, marqviewlen); 
        SetStringSystemIO("Marquee Display", marquee);
        copy(newmarqstring, marqstring, 2, marqstringlen -1);
        marqstring := newmarqstring;
        timechec := Second;
      end;
    
    Create a new Module called 'Marquee System Time' or whatever.

    in it put:
    Code:
    once (Second = 01) then // Runs the code once a minute
      begin
        TimeToString(time, s_time);
        Append(marqstring, 'SystemTime:');
        Append(marqstring, s_time);
        Append(marqstring, '..');
      end;
    
    In 'Global Variables' you will need:
    Code:
    s_time : string;
    r_temp4 : real;
    s_temp4 : string;
    r_temp5 : real;
    s_temp5 : string;
    Itemp : string;
    Otemp : string;
    templine : string;
    alarmstate : string;
    
    
    marqstring : array[0..254] of char;
    newmarqstring :array[0..254] of char;
    marqstart : string;
    marquee : string;
    marqtext : string;
    marqsub1 : string;
    marqdivider :string;
    timechec : integer;
    marqviewlen : integer;
    marqpos : integer;
    marqlen : integer;
    marqstringlen : integer;
    Logic should save and compile OK.

    Next, under 'Edit System IO'
    Add a System Variable - 'Marquee Display' set as a string variable

    Next, under 'Widget Manager'
    Create a new widget - Logic with widget type as 'User System IO String', probably best in a 'Tools' function group etc Location wherever.

    Choose the System IO Variable 'Marquee Display' and make the label 'System Info'

    If no errors, upload to your Wiser and you should be all OK to see the marquee. The code is not tested extensively and so is in no way 'bug free' and so please feel free to PM me any issues you have, or your 'cleaner code' suggestions and I will update it.

    Would also appreciate your return post of any additional module ideas you have/create/come up with to use the marquee.

    Enjoy,

    Brad
     

    Attached Files:

    Last edited by a moderator: Mar 17, 2013
    bmerrick, Mar 17, 2013
    #1
  2. bmerrick

    Mr Mark

    Joined:
    Jan 27, 2006
    Messages:
    323
    Likes Received:
    5
    Location:
    FNQ
    Not a fan of FaceBook, but in this instance miss the 'like' button...
     
    Mr Mark, Mar 17, 2013
    #2
  3. bmerrick

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    +1 'LIKE'

    Cheers..
     
    Roosta, Mar 17, 2013
    #3
  4. bmerrick

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    +1

    Well done. Thanks for sharing your work.
     
    Darren, Mar 29, 2013
    #4
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.