Skip to content
Browse files

working on matrix stuff

  • Loading branch information...
1 parent c7044a7 commit 0ebad2f93a98a14427dd204a7ba16a178852f930 @HalfdanJ committed
View
2 ViljensTriumf/Plugins/BlackMagic.h
@@ -9,6 +9,8 @@
#import "MavController.h"
+#define NUM_SELECTORS 3
+
class DeckLinkController;
@interface BlackMagic : ofPlugin {
BlackMagicController * blackMagicController;
View
39 ViljensTriumf/Plugins/BlackMagic.mm
@@ -25,6 +25,10 @@ -(void)initPlugin{
// [self addPropF:@"blur"];
[self addPropB:@"deinterlace"];
+ for(int i=0;i<NUM_SELECTORS;i++){
+ [[self addPropF:[NSString stringWithFormat:@"matrix%iSelector",i]] setMinValue:1 maxValue:16];
+ }
+
blackMagicController = [[BlackMagicController alloc] init];
[blackMagicController initDecklink];
@@ -113,6 +117,41 @@ -(void)initPlugin{
//
+-(void)awakeFromNib{
+ [super awakeFromNib];
+
+ int x = 100; //possition x
+ int y = 100; //possition y
+
+ int width = 130;
+ int height = 40;
+
+ for(int i=0;i<NUM_SELECTORS;i++){
+ NSTextField * selectorLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(0,y, width,30)];
+ [self.view addSubview: selectorLabel];
+ selectorLabel.stringValue = [NSString stringWithFormat:@"%i",i];
+ selectorLabel.drawsBackground = NO;
+ [selectorLabel setBezeled:NO];
+ [selectorLabel setEditable:NO];
+
+
+ for(int u=0;u<16;u++){
+ NSButton *myButton = [[[NSButton alloc] initWithFrame:NSMakeRect(u*43+80, y, 52, height)] autorelease];
+ [self.view addSubview: myButton];
+ [myButton setTitle: [NSString stringWithFormat:@"#%i",u+1]];
+ [myButton setButtonType:NSMomentaryLightButton]; //Set what type button You want
+ [myButton setBezelStyle:NSRoundedBezelStyle]; //Set what style You want
+ }
+
+ y += height;
+ }
+}
+
+//
+//----------------
+//
+
+
-(void)setup{
glewInit();
View
4 ViljensTriumf/Plugins/MavController.h
@@ -11,10 +11,12 @@
@interface MavController : NSObject
{
ofSerial serial;
-
+ bool connected;
char incommingBytes[100];
int incommingBytesIndex;
+
+ NSMutableArray * outputs;
}
-(void) update;
View
46 ViljensTriumf/Plugins/MavController.mm
@@ -14,31 +14,41 @@ - (id)init
{
self = [super init];
if (self) {
- serial.setup("/dev/tty.usbserial-FT5CHURVA", 9600);
-
+ connected= serial.setup("/dev/tty.usbserial-FT5CHURVA", 9600);
+
}
return self;
}
-(void) update {
- while(serial.available()){
- incommingBytes[incommingBytesIndex++] = serial.readByte();
- if(incommingBytes[incommingBytesIndex-1] == '\n'){
- incommingBytesIndex = 0;
- NSLog(@"Got msg");
- int cmp = strcmp(incommingBytes, "RECONFIG");
- NSLog(@"%i",cmp);
- if(cmp > 0){
- NSLog(@"Reconfig");
+ if(connected ){
+ while(serial.available()){
+ incommingBytes[incommingBytesIndex++] = serial.readByte();
+ if(incommingBytes[incommingBytesIndex-1] == '\n'){
+ incommingBytesIndex = 0;
+ NSString * incommingStr = [NSString stringWithUTF8String:incommingBytes];
+ NSLog(@"Got msg: %@",incommingStr);
+
+ if([incommingStr rangeOfString:@"RECONFIG"].location != NSNotFound){
+ NSLog(@"Reconfig");
+
+ serial.writeByte('v');
+ serial.writeByte('1');
+ serial.writeByte('%');
+ } else {
+ NSError *error = NULL;
+ NSRegularExpression *regex = [NSRegularExpression
+ regularExpressionWithPattern:@"OUT+%i+%i IN+%i+%i VID"
+ options:NSRegularExpressionCaseInsensitive
+ error:&error];
+ [regex enumerateMatchesInString:incommingStr options:0 range:NSMakeRange(0, [incommingStr length]) usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop){
+ // your code to handle matches here
+ NSLog(@"Match %@",match);
+ }];
+ }
- serial.writeByte('v');
- serial.writeByte('1');
- serial.writeByte('%');
- } else {
- NSLog(@"%s",incommingBytes);
+ memset(incommingBytes,0,sizeof(incommingBytes));
}
-
- memset(incommingBytes,0,sizeof(incommingBytes));
}
}
}

0 comments on commit 0ebad2f

Please sign in to comment.
Something went wrong with that request. Please try again.