Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions examples/black.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import time
import sys,os
import random

import sys, os
sys.path.append(os.path.realpath('.'))

from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)
Expand Down
3 changes: 1 addition & 2 deletions examples/color-change.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import time
import sys, os

sys.path.append(os.path.realpath('.'))

from openrgb import OpenRGB

seq = [
Expand Down
6 changes: 2 additions & 4 deletions examples/cpuload.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import time
import psutil
import sys,os

import sys, os
sys.path.append(os.path.realpath('.'))
from openrgb import OpenRGB

from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)


# find and clear
for device in client.devices():
device.set((0, 0, 0))


while True:
load = psutil.cpu_percent()
for device in client.devices():
Expand Down
5 changes: 2 additions & 3 deletions examples/get-modes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import time
import sys,os

import sys, os
sys.path.append(os.path.realpath('.'))

from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)
Expand Down
9 changes: 3 additions & 6 deletions examples/getting-started.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# Adding the library to our PYTHONPATH
import sys,os
import sys, os
sys.path.append(os.path.realpath('.'))

from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)

devices = {}
for i in range(client.controller_count()):
devices[i] = client.controller_data(device_id=i)
devices = list(client.devices())

print(devices)

for _, device in devices.items():
for device in devices:
print('{} has {} LED(s)'.format(device.name, len(device.leds)))
11 changes: 11 additions & 0 deletions examples/load-profiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys, os
sys.path.append(os.path.realpath('.'))

from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)

profiles = client.profiles()
print(profiles)

client.load_profile(profiles[0])
12 changes: 5 additions & 7 deletions examples/objects.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import sys
import os

import sys, os
sys.path.append(os.path.realpath('.'))


from openrgb import OpenRGB


client = OpenRGB('localhost', 6742)
devices = [d for d in client.devices()]
print(devices[4].modes[1].active())

devices = list(client.devices())

print(devices[0].modes[1].active())
5 changes: 3 additions & 2 deletions examples/ram.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import time
import sys
import os
import random

import sys, os
sys.path.append(os.path.realpath('.'))

from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)
Expand All @@ -15,6 +15,7 @@
for mode in device.modes:
if mode.name == "Direct":
mode.active()
break
device.set((0, 0, 0))
devices.append(device)

Expand Down
4 changes: 2 additions & 2 deletions examples/set-mode.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import time
import sys,os
import random

import sys, os
sys.path.append(os.path.realpath('.'))

from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)
Expand Down
6 changes: 3 additions & 3 deletions examples/single-led.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import time
import sys,os

import sys, os
sys.path.append(os.path.realpath('.'))

from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)

for device in client.devices():
print(device)
device.leds[0].set((255, 0, 255))
12 changes: 2 additions & 10 deletions examples/try-all-zones.py → examples/try-all-modes.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import time
import sys,os

import sys, os
sys.path.append(os.path.realpath('.'))
from openrgb import OpenRGB


seq = [
(214, 2, 112),
(0, 56, 168),
(155, 79, 150),
(0, 56, 168),
(214, 2, 112)
]
from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)

Expand Down
2 changes: 1 addition & 1 deletion examples/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys, os

sys.path.append(os.path.realpath('.'))

from openrgb import OpenRGB

client = OpenRGB('localhost', 6742)
Expand Down
6 changes: 2 additions & 4 deletions examples/zone-change.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import time
import sys,os

import sys, os
sys.path.append(os.path.realpath('.'))
from openrgb import OpenRGB

from openrgb import OpenRGB

seq = [
(214, 2, 112),
Expand Down
30 changes: 14 additions & 16 deletions openrgb/ORGBDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def active(self):
return
# We belong to an ORGBDevice, which belongs to the main OpenRGB class.
device = self.owner
con = device.owner
con.set_update_mode(self, device_id=device.id)
client = device.owner
client.set_update_mode(self, device_id=device.id)

# serialize this for the wire.
def __bytes__(self):
Expand Down Expand Up @@ -113,7 +113,7 @@ def __init__(self,

def set(self, colors, interpolate=False):
"""
This will set the LEDs belong to this zone to the color(s) in
This will set the LEDs belonging to this zone to the color(s) in
`colors`.

If provided with a single tuple, it will set all LEDs in the zone to
Expand All @@ -131,10 +131,10 @@ def set(self, colors, interpolate=False):
Interpolate has no effect if not given a list.
"""
device = self.owner
con = device.owner
client = device.owner
n_leds = self.leds_count
_set_batch(
lambda c, did: con.update_zone_leds(self.id, c, did),
lambda c, did: client.update_zone_leds(self.id, c, did),
device,
n_leds,
colors,
Expand All @@ -147,11 +147,11 @@ def __getitem__(self, item):

class ORGBLED(object):
"""
ORGBLED is a class that contains a reference to a Single LED.
This is constructed by ORGBDevice and shouldn't ever need to be created
`ORGBLED` is a class that contains a reference to a single LED.
This is constructed by `ORGBDevice` and shouldn't ever need to be created
manually.

It does however provide the LED Name, current value, and a reference to the
It does however provide the LED name, current value, and a reference to the
device that owns it.


Expand All @@ -172,17 +172,17 @@ def set(self, color):
as a tuple of RGB values.
"""
device = self.owner
con = device.owner
client = device.owner
self.value = color
con.update_single_led(self.id, color, device_id=device.id)
client.update_single_led(self.id, color, device_id=device.id)

def __getitem__(self, item):
return self.__dict__[item]


class ORGBDevice:
"""
ORGB is used to read device responses from the OpenRGB SDK server
`ORGBDevice` is used to read device responses from the OpenRGB SDK server.

:attribute id: Device ID.
:attribute type: Device Type.
Expand All @@ -196,7 +196,6 @@ class ORGBDevice:
:attribute zones: List of zones
:attribute leds: List of LEDs
:attribute colors: List of colors

"""

def __init__(self, data, device_id=0, owner=None):
Expand Down Expand Up @@ -300,7 +299,7 @@ def __init__(self, data, device_id=0, owner=None):

def set(self, colors, interpolate=False):
"""
This will set the LEDs belong to this device to the color(s) in
This will set the LEDs belonging to this device to the color(s) in
`colors`.

If provided with a single tuple, it will set all LEDs in the device to
Expand All @@ -316,11 +315,10 @@ def set(self, colors, interpolate=False):
range of values in `colors`

Interpolate has no effect if not given a list.

"""
con = self.owner
client = self.owner
n_leds = len(self.leds)
_set_batch(con.update_leds, self, n_leds, colors, interpolate)
_set_batch(client.update_leds, self, n_leds, colors, interpolate)

def __repr__(self):
return '{} - {}'.format(self.name, self.type)
Loading