This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Javascript, use value of the main knx object and display a icon
#1
Greetings.

Im have a bit wise encoded knx objects (lots).  I would like to bitmask part out and animate a icon via the remaining part but have become stuck at the point of selecting the icons attached. 

Is it possible to select what icon is displayed (from a normal animated icon), eg if "faults" value = 0 show one icon 1 to 5 show a diffecent icon, >5 show another?  Or an I going down a dead end here and just create/calculate numeric ranges in the icon animation.

Baised from the "Group Address value in SVG icon" example
$(function(){
  $('.faultIcon').each(function(i, el) {
    var $el = $(el), addr = $el.data('object'); // or 'status-object'

    grp.listen(addr, function(obj) {
     var faults  =   obj.value & 3F000000;
     faults = faults >> 24;
     ?????????? 
    });

  });
});



Robert.
Reply
#2
You can use "Additional icons" to assign specific value to an icon. I suggest using virtual objects to display fault status values instead of Custom JS.
Reply
#3
I made a script spawn the hundereds of virtual group addresses in the end.

I guess the question is can custom JS "intercept" the knx value and process it before the browser selects what icon to display from the Aditional icons list?
Reply
#4
Another approach is to use image element, attach object listeners in Custom JS and change img src depending on the value.
Reply
#5
(31.10.2019, 14:24)admin Wrote: Another approach is to use image element, attach object listeners in Custom JS and change img src depending on the value.
Is that using a .lp file and creating a canvas to display the icon?  I started digging into that aproach and it started to get a little complex even with the image url paths hard coded :-)  I may have another look at that though as I didnt know about the object listener aproch I was also trying to make a custom basic client server via url parmiters data link happen...
Reply
#6
You don't need .lp files for that. Go to Scripting > Tools > Edit custom JavaScript. Here's an example of changing image based on value: https://forum.logicmachine.net/showthrea...1#pid14121
Reply


Forum Jump: