Permalink
Browse files

Final product

  • Loading branch information...
1 parent 0458f9f commit 937ed33cdd4b0bc95d44a0b21a4c0424b61a87d4 @HalfdanJ committed Mar 26, 2012
View
@@ -2,7 +2,14 @@
#include "SPI.h"
#include "ArduinoLinkDefines.h"
-int clientId = 8;
+//------------------------------------
+//------------------------------------
+
+int clientId = 11;
+
+//------------------------------------
+//------------------------------------
+
int dataPin = 3;
int clockPin = 2;
@@ -38,6 +38,7 @@
@property (retain) IBOutlet NSTextView *logView;
@property (readwrite, retain) NSMutableArray * clientStates;
@property (assign) IBOutlet NSButton *testPatternButton;
+@property (assign) IBOutlet NSButton *testLedButton;
-(IBAction)sendTestValue:(id)sender;
- (void)logError:(NSString *)msg;
@@ -14,6 +14,7 @@
@implementation AppDelegate
@synthesize testPatternButton;
+@synthesize testLedButton;
@synthesize window, logView, clientStates;
@@ -196,7 +197,7 @@ - (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data
fromAddress:(NSData *)address
withFilterContext:(id)filterContext
{
- if(![testPatternButton state]){
+ if(![testPatternButton state] && ![testLedButton state]){
NSString * string = [NSString stringWithCString:((const char*)[data bytes]) encoding:NSUTF8StringEncoding];
if([string length] > 6 && [[string substringToIndex:7] isEqualToString:@"Art-Net"]){
if(!artnetReceived){
@@ -120,6 +120,7 @@ typedef struct {
@property (readwrite) float test;
@property (readwrite) NSRecursiveLock * lock;
@property (assign) IBOutlet NSButton *TestPatternButton;
+@property (assign) IBOutlet NSButton *testLedButton;
@property (readwrite) BOOL pixelsUpdated;
- (NSString *) openSerialPort: (NSString *)serialPortFile baud: (speed_t)baudRate;
@@ -13,6 +13,7 @@
@implementation XbeeController
@synthesize TestPatternButton;
+@synthesize testLedButton;
//@synthesize port;
@synthesize updateRate, test, lock, pixelsUpdated;
@@ -70,13 +71,13 @@ -(int) offsetStripPixel:(int)pixel{
-(int) stripForPixel:(int)pixel{
if(pixel < 38)
- return 0;
- if(pixel < 76)
return 1;
+ if(pixel < 76)
+ return 0;
if(pixel < 102)
- return 2;
- if(pixel < 128)
return 3;
+ if(pixel < 128)
+ return 2;
return 4;
}
@@ -557,7 +558,26 @@ -(void)serialUpdateThread:(NSThread *)parentThread{
demoMode = 0;
while(TRUE) {
//Test data
- if([TestPatternButton state]){
+ if([testLedButton state]){
+
+
+ for(int i=0;i<NUM_CLIENTS;i++){
+ for(int u=0;u<NUM_PIXELS;u++){
+
+ float r = (sin(-[startTime timeIntervalSinceNow]*1 + [self stripForPixel:u]) + 1)/2.0;
+ float g = (sin(-[startTime timeIntervalSinceNow]*1+3.14*2/3.0+ [self stripForPixel:u]) + 1)/2.0;
+ float b = (sin(-[startTime timeIntervalSinceNow]*1+3.14*2/3.0+3.14/3.0+ [self stripForPixel:u]) + 1)/2.0;
+
+ clients[i].pixels[u].r = r;
+ clients[i].pixels[u].g = g;
+ clients[i].pixels[u].b = b;
+
+ }
+ }
+ pixelsUpdated = YES;
+
+ }
+ else if([TestPatternButton state]){
if(demoMode == 0){
demoR -= [demoTime timeIntervalSinceNow]*0.2;
Oops, something went wrong.

0 comments on commit 937ed33

Please sign in to comment.