Python LimitlessLED via RF

Check-in [8b48210ca6]
Login

Check-in [8b48210ca6]

Overview
Comment:Calculate a few things better
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8b48210ca63123b1d9329d319e7d06ed4a10ffd5570eb53fdf9b6bfbe4966d20
User & Date: rkeene on 2020-08-27 17:07:40
Other Links: manifest | tags
Context
2020-08-27
21:56
Support transitioning for brightness check-in: 6c4b5c6de5 user: rkeene tags: trunk
17:07
Calculate a few things better check-in: 8b48210ca6 user: rkeene tags: trunk
2020-05-17
21:17
limitlessled_rf v0.14 check-in: 2ea910c594 user: rkeene tags: 0.14, trunk
Changes

Modified limitlessled_rf/__init__.py from [f3be2e4306] to [79e827bccc].

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
				'speed_down': 0x0C,
				'change_color_mode': 0x0D,
				'zone_set_brightness': 0x0E,
				'zone_set_color':  0x0F
			}
		},
		'cct': {
			'retries':  10,
			'delay':    0.2,
			'channels': [4, 39, 74],
			'syncword': [0x55AA, 0x050A],
			'brightness_range': [0, 9],
			'temperature_output_range': [0, 9],
			'temperature_input_range':  [6500, 3000],
			'zones': [1, 2, 3, 4],
			'features': [







|
|







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
				'speed_down': 0x0C,
				'change_color_mode': 0x0D,
				'zone_set_brightness': 0x0E,
				'zone_set_color':  0x0F
			}
		},
		'cct': {
			'retries':  3,
			'delay':    0.11,
			'channels': [4, 39, 74],
			'syncword': [0x55AA, 0x050A],
			'brightness_range': [0, 9],
			'temperature_output_range': [0, 9],
			'temperature_input_range':  [6500, 3000],
			'zones': [1, 2, 3, 4],
			'features': [
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
				'brightness_up':    0x0C,
				'brightness_down':  0x04,
				'temperature_up':   0x0E,
				'temperature_down': 0x0F
			}
		},
		'lyh_cct': {
			'retries':  50,
			'delay':    0.2,
			'channels': [24],
			'syncword': [0x6F67, 0xA118],
			'message_length': 13,
			'format_config': {
				'crc_enabled': 0,
				'packet_length_encoded': 0,

				'auto_term_tx': 0
			},
			'brightness_range': [0, 9],
			'temperature_output_range': [0, 9],
			'temperature_input_range':  [6500, 3000],
			'zones': [1, 2, 3],
			'features': [







|







>







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
				'brightness_up':    0x0C,
				'brightness_down':  0x04,
				'temperature_up':   0x0E,
				'temperature_down': 0x0F
			}
		},
		'lyh_cct': {
			'retries':  70,
			'delay':    0.2,
			'channels': [24],
			'syncword': [0x6F67, 0xA118],
			'message_length': 13,
			'format_config': {
				'crc_enabled': 0,
				'packet_length_encoded': 0,
				'auto_ack': 1,
				'auto_term_tx': 0
			},
			'brightness_range': [0, 9],
			'temperature_output_range': [0, 9],
			'temperature_input_range':  [6500, 3000],
			'zones': [1, 2, 3],
			'features': [
551
552
553
554
555
556
557
558
559
560
561

562
563
564
565
566
567
568
569
				'zone': zone
			}

		message['brightness'] = brightness

		return self._send_button(message)

	def _step_value(self, target_value, target_range_min, target_range_max, button_prefix, zone):
		# Step all the way to the nearest extreme before moving it to
		# where it should be
		target_range = target_range_max - target_range_min + 1

		midpoint = (target_range / 2) + target_range_min

		# Move to the "initial" value where we force the value
		# to the extreme, then move it to its final value
		initial_steps = target_range
		if target_value < midpoint:
			initial_direction = 'down'
			final_direction = 'up'







|



>
|







552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
				'zone': zone
			}

		message['brightness'] = brightness

		return self._send_button(message)

	def _step_value(self, target_value, target_range_min, target_range_max, button_prefix, zone, midpoint = None):
		# Step all the way to the nearest extreme before moving it to
		# where it should be
		target_range = target_range_max - target_range_min + 1
		if midpoint is None:
			midpoint = (target_range / 2) + target_range_min

		# Move to the "initial" value where we force the value
		# to the extreme, then move it to its final value
		initial_steps = target_range
		if target_value < midpoint:
			initial_direction = 'down'
			final_direction = 'up'
604
605
606
607
608
609
610






611
612
613
614
615
616
617
618
		for step in range(final_steps):
			self._debug("[FINAL] Stepping {} {}".format(button_prefix, final_direction))
			self._send_button(step_command)

		return True

	def _step_brightness(self, brightness, brightness_min, brightness_max, zone = None):






		return self._step_value(brightness, brightness_min, brightness_max, 'brightness', zone)

	def _step_temperature(self, temperature, temperature_min, temperature_max, zone = None):
		return self._step_value(temperature, temperature_min, temperature_max, 'temperature', zone)

	def _max_brightness(self, zone = None):
		if zone is None:
			message = {'button': 'max'}







>
>
>
>
>
>
|







606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
		for step in range(final_steps):
			self._debug("[FINAL] Stepping {} {}".format(button_prefix, final_direction))
			self._send_button(step_command)

		return True

	def _step_brightness(self, brightness, brightness_min, brightness_max, zone = None):
		# For setting the brightness, set a change-overpoint at around
		# 75%, where below this value we will go to the dimmest and
		# step up and above this point it will go to the brightest
		# and step down.  This is to avoid getting bright then dimming
		# which is much more jarring than getting dim and brightening.
		brightness_changeover = ((brightness_max - brightness_min) * 0.75) + brightness_min;
		return self._step_value(brightness, brightness_min, brightness_max, 'brightness', zone, midpoint = brightness_changeover)

	def _step_temperature(self, temperature, temperature_min, temperature_max, zone = None):
		return self._step_value(temperature, temperature_min, temperature_max, 'temperature', zone)

	def _max_brightness(self, zone = None):
		if zone is None:
			message = {'button': 'max'}