Reply
Logi Browser
paskalicky
Posts: 7
Registered: ‎01-12-2010
0

G110 Cycle Colors Mac OSX

I just purchased a G110 for my Macbook. I've searched the G keyboard forum and KB and cant find an answer to my question. Hoping if I post here someone will be able to answer. Is there a way to make the keyboard backlights continually cycle through all the colors?? I am using the latest Logitech software on Mac OSX 10.6.2 - Thankx

Logi Apprentice
Davs
Posts: 126
Registered: ‎10-05-2009
0

Re: G110 Cycle Colors Mac OSX

is lua supported in osx?

Logi Browser
paskalicky
Posts: 7
Registered: ‎01-12-2010
0

Re: G110 Cycle Colors Mac OSX

Thanks for the reply. Yep Lua for Macs. Would be GREAT if you had a script I could import! :robothappy:

Logi Apprentice
Davs
Posts: 126
Registered: ‎10-05-2009

Re: G110 Cycle Colors Mac OSX

One of a few gems Ken has posted on this board. I didn't even know about the existence of the HSL colour system before this post http://forums.logitech.com/t5/G-Series-Keyboards/G13-Playing-around-with-LUA-backlighting/m-p/407722...

Logi Browser
paskalicky
Posts: 7
Registered: ‎01-12-2010
0

Re: G110 Cycle Colors Mac OSX

Awesome link! I am going to give this a try. I know absolutely nothing about Lua scripting but what the hell.  Warning total newbie question ahead … Reading through some of the "color code" I am noticing RBG. I have a G110 with Red, Magenta, Blue. Do I need to change the values. M = Magenta or P = Purple? I am sure you just rolling on the floor by now, but don't you feel bad for me? HaHa Thank you a bunch for helping me out - Peace

Logi Apprentice
Davs
Posts: 126
Registered: ‎10-05-2009
0

Re: G110 Cycle Colors Mac OSX

[ Edited ]

Oh that's right, I completely forgot that the 110 only supports blue and red... Well, when you use the SetBacklightColor(r,g,b) function, does it just ignore the green value and only display a combination of the red and blue? If so, you shouldn't need to change that HSL script. 

 

But magenta should correspond to SetBacklightColor(255,0,255), and purple should correspond to SetBacklightColor(60,0,255). The only colour model that the Lua will directly accept is the additive colour model (the idea is that every colour can be produced using red green and blue in different intensities i.e. (0,0,255) should produce blue, while (0,255,255) should produce an intense, even mixture of green and blue light which is cyan. 

 

Edit: In retrospect, I think my fade script set to loop would probably suit you better than the HSL hue cycling script. I'll modify it for you later if I have time. 

Logi Browser
paskalicky
Posts: 7
Registered: ‎01-12-2010
0

Re: G110 Cycle Colors Mac OSX

Davs - I found a few moments to explore some Lua scripting via the script editor. For sure I am puzzled now. Basically I have copy and pasted the scripts found here, inserting them after 

function OnEvent(event, arg)

OutputLogMessage("event = %s, arg = %s\n", event, arg);

I can get any of them to run. The only success Ive had are very simple code like - SetBacklightColor(255, 0, 255);

Sleep(1900)

I have made sure to save the scripts after editing.

Spent some time at Lua web site and have examined the scripting API for Logitech. I am sure I must be missing some basic fundamentals or because of blue/red limitation of the G110 the scripts will not function?? For sure I can not produce green (255, 255, 255 ) is Magenta on my keyboard. Still working on finding a color cycle for my G110. Grasping :smileyhappy: …  Any suggestions? Thankx

Logi Apprentice
Davs
Posts: 126
Registered: ‎10-05-2009
0

Re: G110 Cycle Colors Mac OSX

So you say SetBacklightColor(255,255,255) results in magenta? Can you try a few other values, like:

 

255,0,0

0,255,0

0,0,255

 

It seems that SetBacklightColor() just uses red and blue values, ignoring green, but if it's not too much trouble could you check?

 

Also, post exactly what you have in your script editor so I can see what the problem is. 

Logi Browser
paskalicky
Posts: 7
Registered: ‎01-12-2010
0

Re: G110 Cycle Colors Mac OSX

[ Edited ]

255, 0, 0 = red

0,255,0 = off <-- no lights

0,0,255 = blue

 

 

function OnEvent(event, arg)
end
M1red=130; M1green=250; M1blue=190; --these are desired final colors
r=0; g=0; b=0;
SetBacklightColor(r, g, b); --turn LCD off before fading in colors
iMax=10; --this is the number of iterations. desired colors must be divisible by this number.
i=0;
while (i < iMax) do 
       Sleep(30); 
       r = r + M1red / iMax;
     g = g + M1green / iMax;
b = b + M1blue / iMax;
SetBacklightColor(r, g, b);
i = i + 1; --i'm not sure what the +1 operator is in Lua
end

 

function OnEvent(event, arg)

end

M1red=130; M1green=250; M1blue=190; --these are desired final colors

r=0; g=0; b=0;

SetBacklightColor(r, g, b); --turn LCD off before fading in colors

 

iMax=10; --this is the number of iterations. desired colors must be divisible by this number.

i=0;

while (i < iMax) do 

      Sleep(30); 

      r = r + M1red / iMax;

     g = g + M1green / iMax;

b = b + M1blue / iMax;

SetBacklightColor(r, g, b);

 

i = i + 1; --i'm not sure what the +1 operator is in Lua

end

 

Results in Magenta keys, but no color cycle?

Thankx Again

 

Logi Apprentice
Davs
Posts: 126
Registered: ‎10-05-2009
0

Re: G110 Cycle Colors Mac OSX

[ Edited ]

You're supposed to overwrite everything in the script editor with posted script (don't put it into OnEvent() if the posted script already has it).

 

Anyway, I optimized my script for you. I could have implemented event polling to improve responsiveness, but that probably won't be necessary in your case. You can put whatever two values between 0 and 255 you want into FadeInBacklightColor(x, x); play around with it and find out which combinations you prefer.

 

 

function OnEvent(event, arg)
	OutputLogMessage("event = %s, arg = %s\n", event, arg)
    if event == "PROFILE_ACTIVATED" then 
        while not IsModifierPressed("alt") do
            if alternate then
                FadeInBacklightColor(255, 0) --fade in Red
            else
                FadeInBacklightColor(0, 255) --fade in Blue
            end
            alternate = not alternate
        end
    end
end

function FadeInBacklightColor(DesiredRed, DesiredBlue)
    for i = 1, iMax do
            Sleep(50) 
            r = r - LastRed / iMax
            b = b - LastBlue / iMax
            r = r + DesiredRed / iMax
            b = b + DesiredBlue / iMax
            SetBacklightColor(r, 0, b)
    end
    LastRed, LastBlue = r, b
end

alternate = false
r, b, LastRed, LastBlue = 0, 0, 0, 0
iMax=15 --this is the number of iterations. desired colors must be divisible by this number.

 Note: press left alt to stop the color cycling.