|
@@ -47,6 +47,10 @@
|
47
|
47
|
#define RAM_COLOR_MIN 0
|
48
|
48
|
#define RAM_COLOR_MAX 120
|
49
|
49
|
|
|
50
|
+// You can play around with these values (skipped pixels, display timer delay) to change CPU usage in display mode
|
|
51
|
+#define AVERAGE_COLOR_PERFORMANCE_INC 10
|
|
52
|
+#define DISPLAY_DELAY 0.1
|
|
53
|
+
|
50
|
54
|
@interface AppDelegate ()
|
51
|
55
|
|
52
|
56
|
@property (strong) NSStatusItem *statusItem;
|
|
@@ -480,7 +484,7 @@
|
480
|
484
|
}
|
481
|
485
|
|
482
|
486
|
// Schedule next invocation for this animation...
|
483
|
|
- animation = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(visualizeDisplay:) userInfo:[NSNumber numberWithInteger:[sender tag]] repeats:YES];
|
|
487
|
+ animation = [NSTimer scheduledTimerWithTimeInterval:DISPLAY_DELAY target:self selector:@selector(visualizeDisplay:) userInfo:[NSNumber numberWithInteger:[sender tag]] repeats:YES];
|
484
|
488
|
|
485
|
489
|
// ...and also execute it right now
|
486
|
490
|
[animation fire];
|
|
@@ -635,16 +639,17 @@
|
635
|
639
|
}
|
636
|
640
|
|
637
|
641
|
unsigned char *data = [screen bitmapData];
|
638
|
|
- unsigned long long width = [screen pixelsWide];
|
639
|
|
- unsigned long long height = [screen pixelsHigh];
|
640
|
|
- unsigned long long max = width * height;
|
641
|
|
- unsigned long long red = 0, green = 0, blue = 0;
|
642
|
|
- for (unsigned long long i = 0; i < max; i++) {
|
643
|
|
- red += data[(spp * i) + redC];
|
644
|
|
- green += data[(spp * i) + greenC];
|
645
|
|
- blue += data[(spp * i) + blueC];
|
646
|
|
- }
|
647
|
|
-
|
|
642
|
+ unsigned long width = [screen pixelsWide];
|
|
643
|
+ unsigned long height = [screen pixelsHigh];
|
|
644
|
+ unsigned long max = width * height;
|
|
645
|
+ unsigned long red = 0, green = 0, blue = 0;
|
|
646
|
+ for (unsigned long i = 0; i < max; i += AVERAGE_COLOR_PERFORMANCE_INC) {
|
|
647
|
+ unsigned long off = spp * i;
|
|
648
|
+ red += data[off + redC];
|
|
649
|
+ green += data[off + greenC];
|
|
650
|
+ blue += data[off + blueC];
|
|
651
|
+ }
|
|
652
|
+ max /= AVERAGE_COLOR_PERFORMANCE_INC;
|
648
|
653
|
[self setLightsR:(red / max) G:(green / max) B:(blue / max)];
|
649
|
654
|
}
|
650
|
655
|
|