本文整理汇总了Python中neopixel.GRB属性的典型用法代码示例。如果您正苦于以下问题:Python neopixel.GRB属性的具体用法?Python neopixel.GRB怎么用?Python neopixel.GRB使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类neopixel
的用法示例。
在下文中一共展示了neopixel.GRB属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wheel
# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import GRB [as 别名]
def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if pos < 0 or pos > 255:
r = g = b = 0
elif pos < 85:
r = int(pos * 3)
g = int(255 - pos * 3)
b = 0
elif pos < 170:
pos -= 85
r = int(255 - pos * 3)
g = 0
b = int(pos * 3)
else:
pos -= 170
r = 0
g = int(pos * 3)
b = int(255 - pos * 3)
return (r, g, b) if ORDER in (neopixel.RGB, neopixel.GRB) else (r, g, b, 0)
示例2: __init__
# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import GRB [as 别名]
def __init__(self):
super().__init__()
i2c = board.I2C()
if i2c is not None:
self._accelerometer = adafruit_lsm6ds.LSM6DS33(i2c)
# NeoPixels
self._neopixels = neopixel.NeoPixel(
board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB
)
self._buttons = GamePad(
digitalio.DigitalInOut(board.BUTTON_A),
digitalio.DigitalInOut(board.BUTTON_B),
)
示例3: __init__
# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import GRB [as 别名]
def __init__(self):
self.PORT = board.D18
self.NUM = 15
self.NUMBASE = 5
self.pixels = neopixel.NeoPixel(self.PORT, self.NUM)
self.cols = [
(255, 0, 0),
(255, 63, 0),
(255, 120, 0),
(0, 255, 0),
(0, 255, 255),
(0, 0, 255),
(255, 0, 255)
]
self.col_neutral = (80, 80, 30)
self.NUMCOLS = len(self.cols)
self.mode = 1
self.ORDER = neopixel.GRB
self.num_pixels = self.NUM
self.pixels.fill(self.col_neutral)
self.drinkcolor = (0,0,0)
self.thr = threading.Thread(target=self.mode3, args=())
self.thr.start()
示例4: __init__
# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import GRB [as 别名]
def __init__(self):
self.PORT = board.D18
self.NUM = 15
self.NUMBASE = 5
self.pixels = neopixel.NeoPixel(self.PORT, self.NUM)
self.cols = [
(255, 0, 0),
(255, 63, 0),
(255, 120, 0),
(0, 255, 0),
(0, 255, 255),
(0, 0, 255),
(255, 0, 255)
]
self.col_neutral = (80, 80, 30)
self.NUMCOLS = len(self.cols)
self.mode = 1
self.ORDER = neopixel.GRB
self.num_pixels = self.NUM
self.pixels.fill(self.col_neutral)
self.drinkcolor = (0,0,0)
示例5: wheel
# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import GRB [as 别名]
def wheel(self, pos):
if pos < 0 or pos > 255:
r = g = b = 0
elif pos < 85:
r = int(pos * 3)
g = int(255 - pos * 3)
b = 0
elif pos < 170:
pos -= 85
r = int(255 - pos * 3)
g = 0
b = int(pos * 3)
else:
pos -= 170
r = 0
g = int(pos * 3)
b = int(255 - pos * 3)
return (r, g, b) if ORDER == neopixel.RGB or ORDER == neopixel.GRB else (r, g, b, 0)
示例6: __init__
# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import GRB [as 别名]
def __init__(self):
super().__init__()
i2c = None
if i2c is None:
try:
i2c = board.I2C()
except RuntimeError:
self._accelerometer = None
if i2c is not None:
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
try:
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(
i2c, address=0x19, int1=int1
)
except ValueError:
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)
# NeoPixels
self._neopixels = neopixel.NeoPixel(
board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB
)
self._buttons = GamePadShift(
digitalio.DigitalInOut(board.BUTTON_CLOCK),
digitalio.DigitalInOut(board.BUTTON_OUT),
digitalio.DigitalInOut(board.BUTTON_LATCH),
)
self._light_sensor = analogio.AnalogIn(board.A7)
示例7: __init__
# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import GRB [as 别名]
def __init__(self):
super().__init__()
i2c = board.I2C()
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
try:
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(
i2c, address=0x19, int1=int1
)
except ValueError:
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)
# NeoPixels
self._neopixels = neopixel.NeoPixel(
board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB
)
self._buttons = GamePadShift(
digitalio.DigitalInOut(board.BUTTON_CLOCK),
digitalio.DigitalInOut(board.BUTTON_OUT),
digitalio.DigitalInOut(board.BUTTON_LATCH),
)
self._pygamer_joystick_x = analogio.AnalogIn(board.JOYSTICK_X)
self._pygamer_joystick_y = analogio.AnalogIn(board.JOYSTICK_Y)
self._light_sensor = analogio.AnalogIn(board.A7)
示例8: __init__
# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import GRB [as 别名]
def __init__(self):
super().__init__()
# NeoPixels
self._neopixels = neopixel.NeoPixel(
board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB
)
self._light_sensor = analogio.AnalogIn(board.LIGHT)