Python LimitlessLED via RF

Check-in [4631f6c93e]
Login

Check-in [4631f6c93e]

Overview
Comment:Corrected color computation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4631f6c93e45ee32b651a5dd861c6fdb360ad7ff0bd626b4940929a8cef9149b
User & Date: rkeene on 2020-04-28 16:39:53
Other Links: manifest | tags
Context
2020-04-28
16:58
Ensure on/off are delivered check-in: 1b6d5a2023 user: rkeene tags: trunk
16:39
Corrected color computation check-in: 4631f6c93e user: rkeene tags: trunk
16:31
Added ignores check-in: 4e8659777a user: rkeene tags: trunk
Changes

Modified __init__.py from [1d38bdb4f5] to [d36207e003].

1
2
3
4
5
6
7
8
9
10
11
12
#! /usr/bin/env python3

import random
import time
import math

class remote:
	_remote_type_alias_map = {
		'fut089': 'rgb+cct'
	}
	_remote_type_parameters_map = {
		'rgbw': {




<







1
2
3
4

5
6
7
8
9
10
11
#! /usr/bin/env python3

import random
import time


class remote:
	_remote_type_alias_map = {
		'fut089': 'rgb+cct'
	}
	_remote_type_parameters_map = {
		'rgbw': {
436
437
438
439
440
441
442



443
444
445


446
447



448

449
450
451
452
453
454
455
		return h

	def _rgb_to_color(self, rgb):
		r = (rgb >> 16) & 0xff
		g = (rgb >>  8) & 0xff
		b =  rgb        & 0xff




		if r == g and g == b:
			return (r * -1) - 1



		h = self._rgb_to_hue(r, g, b)




		color = ((h / 360.0) * 255.0) + 26


		color = int(color + 0.5)

		self._debug("RGB = \x1b[38;2;%i;%i;%im%06x\x1b[0m; Hue = %s; Color = %i" % (r, g, b, rgb, str(h * 360), color))

		return color








>
>
>



>
>


>
>
>

>







435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
		return h

	def _rgb_to_color(self, rgb):
		r = (rgb >> 16) & 0xff
		g = (rgb >>  8) & 0xff
		b =  rgb        & 0xff

		# If the value is really a shade of white
		# encode the brightness as a negative value
		# where 0 is -1, 1 is -2, etc
		if r == g and g == b:
			return (r * -1) - 1

		# Compute the hue of the RGB value (ignore
		# luminance and saturation)
		h = self._rgb_to_hue(r, g, b)

		# Convert the hue into a LimitlessLED value
		# which is really just the position along the
		# color strip, offset
		color = ((h / 360.0) * 255.0) + 26
		color = color % 256

		color = int(color + 0.5)

		self._debug("RGB = \x1b[38;2;%i;%i;%im%06x\x1b[0m; Hue = %s; Color = %i" % (r, g, b, rgb, str(h * 360), color))

		return color