All Downloads are FREE. Search and download functionalities are using the official Maven repository.

data.nodescript.lighteffects.NeoControlEWS_groups_mode15_tvSingleLED.nodescript Maven / Gradle / Ivy

## Script only for NeoControl EWS!
## This script defines a group of LEDs 
## Mode: TV effect for 1 LED
##
## Hardware: Neocontrol with NeoControl EWS firmware
## Software:
##
## history: 2020-05-08 V.Dierkes, first version
##          2020-05-18 V.Dierkes, version to publish
##
## how to use:
## A) configure
##    Not needed
## B) load and run this script
##    what will happen?
##    1. the led group will be configured with the given parameters
## C) have fun
##    Switching on/off the SPORT will control the group of light elements accordingly
##

##require(vid="13", pid="129")

##application(text:de="NeoEWS: Konfiguration einer Lichtgruppe für Modus 15 - TV-Simulation Einzel-RGB(W)-LED", text:en="NeoEWS: Configuration of a light group for mode 11 - TV simulation Single RGB(W)-LED")
##instruction(text:de="Für diese TV-Simulation wird (nur) eine RGB- bzw. RGBW-LED benötigt. Dazu wird zusätzlich zum Gruppeneffekt ein Lightport mit einer dynamischen Farbe konfiguriert. Mit der Zuordnungstabelle wird dieser Lightport sichtbar geschaltet. Darüber wird auch automatisch erkannt ob dieser Lightport auf Strang A oder B erscheint. Dies ist notwendig um die LED im richtigen Modus (RGB oder RGBW) zu betreiben. Damit die richtigen Farben verwendet werden, muss die Farbreihenfolge des Strangs richtig eingestellt sein (siehe CV 1199 und 1200).")
##instruction(text:en="For this TV simulation (only) a single RGB resp. RGBW LED is needed. To achieve this one lightport and one dynamic color is needed additionally to the group effect. By using the allocation table this lightport is made visible. And also with the allocation table the group effect detects automatically if the TV simulation is connected to stripe A or B and therfore the LED can be used in the correct mode (RGB or RGBW). It needs to be ensured that the sequence of colors of the corresponding stripe is correct (see CV 1199 and 1200).")
##
##input($my_group:switch, text:de="Nummer der Lichtgruppe (Achtung: Nur 0-15!)", text:en="Number of the group (Caution: 0-15 only!)", default=0)
##input($start_led:light, text:de="Zu verwendender Lightport", text:en="Lightport to be used", default=0)
##input($dyn_color:int, text:de="Farbnummer der dynamischen Farbe (Bereich: 32-51)", text:en="color number of dynamic color (32-51 only)", default=32)
##input($led_tabval1:int, text:de="Position der RGB(W)-LED", text:en="Position of RGB(W)-LED", default=0)

## -------------- 1. Select Target

#if((${vid} == 13) && (${pid} == 129))
  ## Only for Neo_EWS

## -------------- 2. Define default values
  #set($group_mode = 15)
  #set($group_option = 0)
  #set($speed_min = 0)
  #set($speed_sec = 0)
  #set($speed_hun = 0)
  #set($group_on = 1)
  #set($group_off = 0)
  #set($Integer = 0)
  #set($cv_base_lights    = 81)
  #set($cv_base_accessory = $cv_base_lights + ( 5 * ${node_light_count}) )
## Fix size of 20 instead of ${node_accessory_count} for accessory CV area
  #set($cv_base_colors    = $cv_base_accessory + ( 10 * 20) )
  #set($cv_base_groups    = $cv_base_colors + ( 3 * 32 ) )
  #set($cv_base_mapping   = $cv_base_groups + ( 6 * 16 ) )
  #set($cv_base_config    = $cv_base_mapping + ( 1 * 256 ) )
  #set($cv_base_acc_cfg   = $cv_base_config + ( 6 ) )

  #set($version_major = 0)
  #set($version_sub   = 0)
  #set($version_run   = 0)
  #set($version_string="${node_firmware_version}")
  #set($version_array = $version_string.split("\."))
  #if($version_array.size() == 3) 
    #set($version_major = $Integer.parseInt($version_array[0]))
    #set($version_sub   = $Integer.parseInt($version_array[1]))
    #set($version_run   = $Integer.parseInt($version_array[2]))
  #end

## -------------- 3. execute part of the script

  #if( ($dyn_color >= 32) && ($dyn_color <=51) )

    #if( ($my_group>=0) && ($my_group<=15) )
    
      #if( ($led_tabval1 >= 0) && ($led_tabval1 <= 255) )
      
        #if( ($start_led >= 0) && ($start_led <= ${node_light_count}) )
      
          #if(10000*$version_major+100*$version_sub+$version_run >= 20400)
            ## do it only in case the parameters are in the allowed range
          
            ## do some naming stuff
            set switch $my_group name="Group${my_group}_TV-SingleRGBW_LP${start_led}"
            #set($i = $start_led)
            set light $i name="Group${my_group}_TV-SingleRGBW_Lightport"

            ## Set mode

            ## Set on/off value
            #set($group_onoff = (16 * $group_on) + $group_off)

            ## calculate speed_faktor
            #set($speed_factor = 0)
            #set($speed_time = (6000*$speed_min) + (100*$speed_sec) + $speed_hun)

            #if($speed_time > 65500)
              #set($speed_factor=251)
            #elseif($speed_time > 33000)
              #set($speed_factor=($speed_time - 33000) / 3000 + 240)
            #elseif($speed_time > 6000)
              #set($speed_factor=($speed_time - 7000) / 1000 + 216)
            #elseif($speed_time > 3000)
              #set($speed_factor = ($speed_time - 3500) / 500 + 210)
            #elseif($speed_time > 1000)
              #set($speed_factor=$speed_time / 100 + 179)
            #elseif($speed_time > 100)
              #set($speed_factor=($speed_time - 110) / 10 + 100)
            #elseif($speed_time > 0)
              #set($speed_factor=$speed_time - 1)
            #end
          
          ## --------------- 4. Write the data to the node

            #set($cv_base = $cv_base_groups + (6 * $my_group))
            #set($cv_addr = $cv_base)

            ## Configure the light group
            set CV ${cv_addr} ${group_mode}
            #set($cv_addr = $cv_addr + 1)
            set CV ${cv_addr} ${start_led}
            #set($cv_addr = $cv_addr + 1)
            ## last_led is not used, put a default value
            set CV ${cv_addr} 0
            #set($cv_addr = $cv_addr + 1)
            set CV ${cv_addr} ${speed_factor}
            #set($cv_addr = $cv_addr + 1)
            set CV ${cv_addr} ${group_onoff}
            #set($cv_addr = $cv_addr + 1)
            set CV ${cv_addr} ${group_option}

            ## Configure the light port with the dynamic color, full brightness and no dimming (even dimming is not used)
            #set($cv_addr = $cv_base_lights + (5 * ${start_led}) )
            set CV ${cv_addr}  $dyn_color
            ## #set($cv_addr = $cv_addr + 1)
            ## set CV ${cv_addr}   0 ## Off value
            ## #set($cv_addr = $cv_addr + 1)
            ## set CV ${cv_addr} 255 ## On value
            ## #set($cv_addr = $cv_addr + 1)
            ## set CV ${cv_addr} 255 ## Dimm off
            ## #set($cv_addr = $cv_addr + 1)
            ## set CV ${cv_addr} 255 ## Dimm on
            ## #set($cv_addr = $cv_addr + 1)
            
            config port ptype=light ValueOff=0 ValueOn=255 DimmOff=255 DimmOn=255 number=$start_led

            ## Stripe position
            #set($cv_base = $cv_base_mapping)
            #set($cv_addr = $cv_base + $led_tabval1)
            set CV ${cv_addr} ${start_led}
          
          #else
            #if ($user_lang == "de")
              $exceptionThrower.throwUserDefined("Die Firmware der NeoEWS ist zu alt, Update auf mindestens 2.4.0 n?tig.")
            #else
              $exceptionThrower.throwUserDefined("The firmware of the NeoEWS is too old, please update to 2.4.0 or newer.")
            #end
          #end

        #else
          #if ($user_lang == "de")
            $exceptionThrower.throwUserDefined("Der gew?hlte Lightport ist au?erhalb des erlaubten Bereichs (0-${node_light_count}): $start_led")
          #else
            $exceptionThrower.throwUserDefined("The choosen light port is out of allowed range (0-${node_light_count}): $start_led")
          #end
        #end

      #else
        #if ($user_lang == "de")
          $exceptionThrower.throwUserDefined("Die gew?hlte Stripe Position ist au?erhalb des erlaubten Bereichs (0-255): $led_tabval1")
        #else
          $exceptionThrower.throwUserDefined("The choosen stripe position is out of allowed range (0-255): $led_tabval1")
        #end
      #end

    #else
      #if ($user_lang == "de")
        $exceptionThrower.throwUserDefined("Die gew?hlte Gruppe ist au?erhalb des erlaubten Bereichs (0-15): $my_group")
      #else
        $exceptionThrower.throwUserDefined("The choosen group is out of allowed range (0-15): $my_group")
      #end
    #end
    
  #else
    #if ($user_lang == "de")
      $exceptionThrower.throwUserDefined("Die gew?hlte dynamische Farbe ist au?erhalb des erlaubten Bereichs (32-51): $dyn_color")
    #else
      $exceptionThrower.throwUserDefined("The choosen dynamic color is out of allowed range (32-51): $dyn_color")
    #end
  #end
#end
#######################################




© 2015 - 2024 Weber Informatics LLC | Privacy Policy