add logging
This commit is contained in:
		
							parent
							
								
									e337625791
								
							
						
					
					
						commit
						6110039314
					
				
					 2 changed files with 14 additions and 6 deletions
				
			
		|  | @ -2,5 +2,7 @@ | ||||||
|   "leds": 450, |   "leds": 450, | ||||||
|   "brightness": 200, |   "brightness": 200, | ||||||
|   "gpio": 18, |   "gpio": 18, | ||||||
|   "type": "grb" |   "type": "grb", | ||||||
|  |   "fade_ticks": 25, | ||||||
|  |   "sleep_time": 100 | ||||||
| } | } | ||||||
							
								
								
									
										16
									
								
								lights.js
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								lights.js
									
										
									
									
									
								
							|  | @ -3,7 +3,7 @@ import * as fs from 'fs' | ||||||
| 
 | 
 | ||||||
| const cfg = JSON.parse(fs.readFileSync('./config.json')); | const cfg = JSON.parse(fs.readFileSync('./config.json')); | ||||||
| 
 | 
 | ||||||
| const fade_ticks = cfg.fade_ticks || 10; | const fade_ticks = cfg.fade_ticks || 20; | ||||||
| var pixels = new Uint32Array(cfg.leds); | var pixels = new Uint32Array(cfg.leds); | ||||||
| var pixel_cache = new Uint32Array(cfg.leds); | var pixel_cache = new Uint32Array(cfg.leds); | ||||||
| var next_pattern = new Uint32Array(cfg.leds); | var next_pattern = new Uint32Array(cfg.leds); | ||||||
|  | @ -32,6 +32,7 @@ export function set_pattern(pat) { | ||||||
| 
 | 
 | ||||||
| function tick_pattern() { | function tick_pattern() { | ||||||
|   // do the parsing stuff here
 |   // do the parsing stuff here
 | ||||||
|  |   console.log("TICKING PATTERN") | ||||||
| 
 | 
 | ||||||
|   for (let i = 0; i < cfg.leds; i++) { |   for (let i = 0; i < cfg.leds; i++) { | ||||||
|     var r = Math.floor(Math.random() * 100) |     var r = Math.floor(Math.random() * 100) | ||||||
|  | @ -53,7 +54,7 @@ export function tick() { | ||||||
|     tick_pattern(); |     tick_pattern(); | ||||||
|   } |   } | ||||||
|   ws281x.render(pixels); |   ws281x.render(pixels); | ||||||
|   ws281x.sleep(500); |   ws281x.sleep(cfg.sleep_time || 500); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function fade(index) { | function fade(index) { | ||||||
|  | @ -67,9 +68,14 @@ function fade(index) { | ||||||
|   var interval_g = diff_g / fade_ticks; |   var interval_g = diff_g / fade_ticks; | ||||||
|   var interval_b = diff_b / fade_ticks; |   var interval_b = diff_b / fade_ticks; | ||||||
| 
 | 
 | ||||||
|   if (Math.abs(final.r - current.r) < interval_r && |   console.log(`original: ${original.r} ${original.g} ${original.b}` + | ||||||
|     Math.abs(final.g - current.g) < interval_g && |     `current:  ${current.r} ${current.g} ${current.b}` + | ||||||
|     Math.abs(final.b - current.b) < interval_b |     `final:  ${final.r} ${final.g} ${final.b}` + | ||||||
|  |     `interval:  ${interval_r} ${interval_g} ${interval_b}`) | ||||||
|  | 
 | ||||||
|  |   if (final.r - current.r < interval_r && | ||||||
|  |     final.g - current.g < interval_g && | ||||||
|  |     final.b - current.b < interval_b | ||||||
|   ) { |   ) { | ||||||
|     pixels[index] = next_pattern[index]; |     pixels[index] = next_pattern[index]; | ||||||
|     pixel_cache[index] = next_pattern[index]; |     pixel_cache[index] = next_pattern[index]; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue