Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brightness not working with monocolor #9

Open
joapuiib opened this issue Mar 17, 2021 · 8 comments
Open

Brightness not working with monocolor #9

joapuiib opened this issue Mar 17, 2021 · 8 comments

Comments

@joapuiib
Copy link

I'm trying to set the brightness of the monocolor option, but it doesn't seem to be working.

I'm using the following command:

ite8291r3-ctl monocolor --brightness 50 --name blue
ite8291r3-ctl query --brightness
10

I added a print(args) line on handle_monocolor_args function and it gives me the following output, so I guess this is not the problem.

Namespace(brightness=50, device=None, func=<function main.<locals>.handle_monocolor_args at 0x7f36220a1040>, name='blue', rgb=None)

I also tried to set the color first and then, call the brightness option, but it doesn't work either.

ite8291r3-ctl monocolor --name blue
ite8291r3-ctl brightness 50
ite8291r3-ctl query --brightness
10

I noticed that the brightness applied is the last effect brightness used.

ite8291r3-ctl effect rainbow -b 40
ite8291r3-ctl monocolor blue # Here --brightness option doesn't work
ite8291r3-ctl query --brightness
40
ite8291r3-ctl effect rainbow -b 10
ite8291r3-ctl monocolor blue # Here --brightness option doesn't work
ite8291r3-ctl query --brightness
10

Also, the brightness option doesn't work for effects:

ite8291r3-ctl effect rainbow -b 20
ite8291r3-ctl query --brightness
20
ite8291r3-ctl brightness 50
ite8291r3-ctl query --brightness
20

My guess it that ite8291r3.set_brightness() doesn't work as expected (or I don't understand it).

@joapuiib
Copy link
Author

joapuiib commented Mar 17, 2021

I modified set_brightness() from:

self.__send_ctrl(commands.SET_BRIGHTNESS, 0x02, brightness)

to (copied from aucc):

self.__send_ctrl(commands.SET_EFFECT, 0x02, 0x33, 0x00, brightness)

It works now when using the monocolor -b option, but not the brightness standalone option.
It has to be applied before to the set_color():

ite8291r3-ctl monocolor --name red -b 50 # this works now
ite8291r3-ctl query -b
50
ite8291r3-ctl monocolor --name red -b 30 # this works now
ite8291r3-ctl query -b
30
ite8291r3-ctl brightness 20 # This doesn't work
ite8291r3-ctl query -b # It returns the correct brightness but it's not applied to the keyboard yet
20
ite8291r3-ctl monocolor --name red # Now is applied with brightness 20

@pobrn
Copy link
Owner

pobrn commented Mar 17, 2021

Can you post the output of ite8291r3-ctl query --devices? Interestingly, the commands that don't work for you, work for me perfectly.

$ ite8291r3-ctl monocolor --brightness 50 --name yellow
$ ite8291r3-ctl query --brightness
50
$ ite8291r3-ctl monocolor --brightness 25 --name blue
$ ite8291r3-ctl query --brightness
25
$ ite8291r3-ctl monocolor --brightness 10 --name red
$ ite8291r3-ctl query --brightness
10

These work as expected. Please correct me if I misunderstood what you're trying to do.

@pobrn
Copy link
Owner

pobrn commented Mar 17, 2021

Could you also apply this patch to the current master, and try the commands that didn't work, then send the output?

diff --git a/ite8291r3_ctl/ite8291r3.py b/ite8291r3_ctl/ite8291r3.py
index 4512d47..513e2df 100644
--- a/ite8291r3_ctl/ite8291r3.py
+++ b/ite8291r3_ctl/ite8291r3.py
@@ -144,14 +144,14 @@ class ite8291r3:
                self.channel = channel
 
        def __send_data(self, payload):
-               #print(f"sending data ({len(payload)} bytes) {payload} to device")
+               print(f"sending data ({len(payload)} bytes) {payload} to device")
                return self.channel.write(payload)
 
        def __send_ctrl(self, *payload):
                if len(payload) < 8:
                        payload += (0, ) * (8 - len(payload))
 
-               #print(f"sending ctrl {payload} to device")
+               print(f"sending ctrl {payload} to device")
 
                # https://github.com/libusb/hidapi/blob/533dd9229a846d6ab00c4dced1cbddf66b576258/libusb/hid.c#L1180
                self.channel.ctrl_transfer(

@joapuiib
Copy link
Author

It looks like that it is working in your example.

This is the result of query --devices:

$ ite8291r3_ctl query --devices
048d:ce00 bus 1 addr 3 rev 0.03 product 'ITE Device(8291)' manufacturer 'ITE Tech. Inc.'

The result of the same commands you executed:

$ ite8291r3_ctl monocolor --brightness 50 --name yellow
sending ctrl (9, 2, 50, 0, 0, 0, 0, 0) to device
sending ctrl (136, 0, 0, 0, 0, 0, 0, 0) to device
sending ctrl (8, 2, 51, 0, 36, 0, 0, 0) to device
sending ctrl (22, 0, 0, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 1, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 2, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 3, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 4, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 5, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
$ ite8291r3_ctl query --brightness
sending ctrl (136, 0, 0, 0, 0, 0, 0, 0) to device
36
$ ite8291r3_ctl monocolor --brightness 25 --name blue
sending ctrl (9, 2, 25, 0, 0, 0, 0, 0) to device
sending ctrl (136, 0, 0, 0, 0, 0, 0, 0) to device
sending ctrl (8, 2, 51, 0, 36, 0, 0, 0) to device
sending ctrl (22, 0, 0, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') to device
sending ctrl (22, 0, 1, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') to device
sending ctrl (22, 0, 2, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') to device
sending ctrl (22, 0, 3, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') to device
sending ctrl (22, 0, 4, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') to device
sending ctrl (22, 0, 5, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') to device
$ ite8291r3_ctl query --brightness
sending ctrl (136, 0, 0, 0, 0, 0, 0, 0) to device
36
ite8291r3_ctl monocolor --brightness 10 --name red
sending ctrl (9, 2, 10, 0, 0, 0, 0, 0) to device
sending ctrl (136, 0, 0, 0, 0, 0, 0, 0) to device
sending ctrl (8, 2, 51, 0, 36, 0, 0, 0) to device
sending ctrl (22, 0, 0, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 1, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 2, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 3, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 4, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 5, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
$ ite8291r3_ctl query --brightness
sending ctrl (136, 0, 0, 0, 0, 0, 0, 0) to device
36

Brightness doesn't change in my computer.

@pobrn
Copy link
Owner

pobrn commented Mar 18, 2021

Please run the following with the prints still in the code:

ite8291r3_ctl monocolor -b 50 --name yellow
ite8291r3_ctl brightness 40 && ite8291r3_ctl query --brightness
ite8291r3_ctl brightness 30 && sleep 1 && ite8291r3_ctl query --brightness
ite8291r3_ctl query --fw-version

@joapuiib
Copy link
Author

$ ite8291r3_ctl monocolor -b 50 --name yellow
sending ctrl (9, 2, 50, 0, 0, 0, 0, 0) to device
sending ctrl (136, 0, 0, 0, 0, 0, 0, 0) to device
sending ctrl (8, 2, 51, 0, 36, 0, 0, 0) to device
sending ctrl (22, 0, 0, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 1, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 2, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 3, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 4, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
sending ctrl (22, 0, 5, 0, 0, 0, 0, 0) to device
sending data (65 bytes) bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00wwwwwwwwwwwwwwwwwwwww\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00') to device
$ ite8291r3_ctl brightness 40 && ite8291r3_ctl query --brightness
sending ctrl (9, 2, 40, 0, 0, 0, 0, 0) to device
sending ctrl (136, 0, 0, 0, 0, 0, 0, 0) to device
36
$ ite8291r3_ctl brightness 30 && sleep 1 && ite8291r3_ctl query --brightness
sending ctrl (9, 2, 30, 0, 0, 0, 0, 0) to device
sending ctrl (136, 0, 0, 0, 0, 0, 0, 0) to device
36
$ ite8291r3_ctl query --fw-version
sending ctrl (128, 0, 0, 0, 0, 0, 0, 0) to device
18.3.0.1

@pobrn
Copy link
Owner

pobrn commented May 7, 2021

It seems the firmware version is different from what I have. It possibly doesn't support setting only the brightness.

@pobrn
Copy link
Owner

pobrn commented May 8, 2021

Could you please try the current master and see if it works? If it doesn't, please attach the output when called with the --debug option, e.g.

ite8291r3-ctl --debug monocolor -b 50 --name white

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants