-- Lua Code Fragment -- © 2015 www.theCUBEstudio.com -- color codes and usage for Mach4 screen LED --color = scr.GetProperty('led10','Color') --wx.wxMessageBox (color) -- NOTE: color numbers are exponents -- NOTE: color names red/green for LEDs is a state change that follows the On/Off state -- NOTE: Parameter named 'Value' in an LED is the On/Off switch -- usage example below -- Observation: The exponent value (color number) for Red/green and Yellow colors have equal delta ---------------- therefor could be used to create a 'stoplight' effect by calculating the color value ---------------- the exponent values are 0,1,and 2, so by using a default, the control value can be booleani -- USAGE: color numbers can be imput expressly in the function -or- --------- intuitive variables can be pre-defined - see example below -or- --------- color number can be calculated and then used by either method -- SYNTAX: scr.SetProperty('NameOfScreenControl','NameOfParameter','NewStringValue'); -- ****************** creating and loading Variables for each Color ********** --******************* (these are the actual correct values ****************** red = "0"; amber = "2"; blue = "4"; green = "8"; nocolor = tostring(2^4); -- string value saved is "16" purple = tostring(2^6); -- string value saved is "32" white = 64; -- example using numeric value - musyt be converted to string in the screen call yellow = 128; -- odd duck: green_red = "9"; -- ************************ Variables for ON and OFF ledON = "1"; --example of storing the variable as a string ledOFF = 0; --can also be stored as a number -- see examples below for the proper syntax for each method -- ************************* -- example usage by string variable scr.SetProperty('led10', 'Color', blue); scr.SetProperty('led10', 'Value', '1'); -- note that a string value can be created 'on the fly' scr.SetProperty('led10', 'Value', '0'); -- if numeric formula is pre-coverter to a string, just use the variable name scr.SetProperty('led10', 'Color', purple); scr.SetProperty('led10', 'Value', ledON); scr.SetProperty('led10', 'Value', tostring(ledOFF)); -- if the Color variable contains a number, it must be converted to a string in the function call scr.SetProperty('led10', 'Color', tostring(white)); scr.SetProperty('led10', 'Value', '1'); scr.SetProperty('led10', 'Value', '0'); --************************* Example using exponents local i = 0; for i = 0,7,1 do --- color string value can be calculated and coverted on the fly scr.SetProperty('led10', 'Color', tostring(2^i)); scr.SetProperty('led10', 'Value', '1'); scr.SetProperty('led10', 'Value', '0'); end --************************* stoplight example ******************** StopLightColor = ""; UserInput = 0; -- ********************************* set up a function to change the light function ChangeStopLight() -- wx.wxMessageBox (tostring(UserInput)); if (UserInput > 1) then StopLightColor = tostring(128); elseif (UserInput == 1) then StopLightColor = tostring(8); else StopLightColor = tostring(0); end scr.SetProperty('led10', 'Color', StopLightColor); scr.SetProperty('led10', 'Value', '1'); end -- ****************************** simulate user input for i = 0,2,1 do -- wx.wxMessageBox (tostring(i)); scr.SetProperty('led10', 'Value','0'); UserInput = i; ChangeStopLight() end