mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	simplify code of effect fade.py
Former-commit-id: 3c7c633e764d14c9e11c6e145289894954695c65
This commit is contained in:
		| @@ -1,8 +1,5 @@ | ||||
| import hyperion, time | ||||
|  | ||||
| def setColor(rgb): | ||||
| 	hyperion.setColor( bytearray( hyperion.ledCount * rgb)) | ||||
|  | ||||
| # Get the parameters | ||||
| fadeTime   = float(hyperion.args.get('fade-time', 5.0)) | ||||
| colorStart = hyperion.args.get('color-start', (255,174,11)) | ||||
| @@ -15,20 +12,16 @@ color_step = ( | ||||
| ) | ||||
|  | ||||
| # fade color | ||||
| calcChannel = lambda i: min(max(int(colorStart[i] + color_step[i]*step),0),255) | ||||
| for step in range(256): | ||||
| 	if hyperion.abort(): | ||||
| 		break | ||||
|  | ||||
| 	setColor( ( | ||||
| 		int( min(max(0, colorStart[0] + color_step[0]*step), 255) ), | ||||
| 		int( min(max(0, colorStart[1] + color_step[1]*step), 255) ), | ||||
| 		int( min(max(0, colorStart[2] + color_step[2]*step), 255) ) | ||||
| 	) ) | ||||
|  | ||||
| 	hyperion.setColor( calcChannel(0),calcChannel(1),calcChannel(2) ) | ||||
| 	time.sleep( fadeTime / 256 ) | ||||
|  | ||||
| # maintain color until effect end | ||||
| setColor(colorEnd) | ||||
| hyperion.setColor(colorEnd[0],colorEnd[1],colorEnd[2]) | ||||
| while not hyperion.abort(): | ||||
| 	time.sleep(1) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user