Selaa lähdekoodia

Extended Readme, slight modifications

Thomas Buck 8 vuotta sitten
vanhempi
commit
6e555618d7
3 muutettua tiedostoa jossa 26 lisäystä ja 13 poistoa
  1. 16
    11
      CaseLights/AppDelegate.m
  2. 1
    1
      CaseLights/Info.plist
  3. 9
    1
      README.md

+ 16
- 11
CaseLights/AppDelegate.m Näytä tiedosto

47
 #define RAM_COLOR_MIN 0
47
 #define RAM_COLOR_MIN 0
48
 #define RAM_COLOR_MAX 120
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
 @interface AppDelegate ()
54
 @interface AppDelegate ()
51
 
55
 
52
 @property (strong) NSStatusItem *statusItem;
56
 @property (strong) NSStatusItem *statusItem;
480
     }
484
     }
481
     
485
     
482
     // Schedule next invocation for this animation...
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
     // ...and also execute it right now
489
     // ...and also execute it right now
486
     [animation fire];
490
     [animation fire];
635
     }
639
     }
636
     
640
     
637
     unsigned char *data = [screen bitmapData];
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
     [self setLightsR:(red / max) G:(green / max) B:(blue / max)];
653
     [self setLightsR:(red / max) G:(green / max) B:(blue / max)];
649
 }
654
 }
650
 
655
 

+ 1
- 1
CaseLights/Info.plist Näytä tiedosto

21
 	<key>CFBundleSignature</key>
21
 	<key>CFBundleSignature</key>
22
 	<string>????</string>
22
 	<string>????</string>
23
 	<key>CFBundleVersion</key>
23
 	<key>CFBundleVersion</key>
24
-	<string>142</string>
24
+	<string>153</string>
25
 	<key>LSApplicationCategoryType</key>
25
 	<key>LSApplicationCategoryType</key>
26
 	<string>public.app-category.utilities</string>
26
 	<string>public.app-category.utilities</string>
27
 	<key>LSMinimumSystemVersion</key>
27
 	<key>LSMinimumSystemVersion</key>

+ 9
- 1
README.md Näytä tiedosto

8
 
8
 
9
 [![fritzing Schematic](https://i.imgur.com/jWLW22F.png)](https://i.imgur.com/sXAADUs.png)
9
 [![fritzing Schematic](https://i.imgur.com/jWLW22F.png)](https://i.imgur.com/sXAADUs.png)
10
 
10
 
11
+My finished setup is made with a cheap Arduino Pro Mini clone from China and a [dead simple RS232-TTL converter](http://picprojects.org.uk/projects/simpleSIO/ssio.htm) connected to its serial port. You may need to change `Serial` to `Serial1` in the Sketch if you’re trying to do this with an Arduino Leonardo, as I did at first.
12
+
13
+Uncomment the `#define DEBUG` at the beginning of the Sketch to enable very verbose debug messages sent on the serial port. This is not recommended for use with the CaseLights App.
14
+
11
 ## Mac OS X App
15
 ## Mac OS X App
12
 
16
 
13
 The CaseLights XCode project includes the JSystemInfoKit project from the submodule in this repository. Just run `xcodebuild` on the command line or open the project in XCode and click `Run` to start the App.
17
 The CaseLights XCode project includes the JSystemInfoKit project from the submodule in this repository. Just run `xcodebuild` on the command line or open the project in XCode and click `Run` to start the App.
14
 
18
 
15
-![Screenshot](https://i.imgur.com/N7j7BJV.png)
19
+![Screenshot](https://i.imgur.com/K7HuJPK.png)
20
+
21
+CaseLights is only visible in the system menu bar. You can enable or disable the fourth channel (used for UV lighting in my case), set the RGB LEDs to static colors or simple animations, and select different visualizations for the RGB LEDs like CPU, GPU and RAM usage or hardware temperatures. The minimum and maximum values for these modes are hardcoded, but can be modified easily.
22
+
23
+You can also select one of the displays connected to the Host machine. The CaseLights App will then create a Screenshot of this display 10-times per second and calculate the average color to display it on the RGB LEDs.
16
 
24
 
17
 ## Working with Git Submodules
25
 ## Working with Git Submodules
18
 
26
 

Loading…
Peruuta
Tallenna