Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 17    Views: 85

Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
10/25/12 08:59 AM (13 years ago)

What I did today

Today I created code that made a single button turn the ios light on and off. That is all.
 
MacApple
Apple Fan
Profile
Posts: 4675
Reg: Oct 25, 2010
USA
61,150
like
10/25/12 09:06 AM (13 years ago)
Nicely done. Good stuff.
 
tb
buzztouch Evangelist
Profile
Posts: 2050
Reg: Nov 03, 2011
Oxford
32,300
like
10/25/12 09:15 AM (13 years ago)
Do you mean the flash on the rear of the iPhone 4, 4S, 5 or iPod Touch 5th Gen? Because if so, well done! It really is a good seller that type of app.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/25/12 09:16 AM (13 years ago)
yup. I think I might start a buzztouch blog two actually "what I did today" & "What I should have done today"
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/25/12 09:34 AM (13 years ago)
I'd be interested in seeing that code if you want to share! Can you make the light blink at specified intervals? Somebody earlier was looking for an app they could use to tune things with various RPMs. Mark
 
tb
buzztouch Evangelist
Profile
Posts: 2050
Reg: Nov 03, 2011
Oxford
32,300
like
10/25/12 09:34 AM (13 years ago)
@Kittsy Are you a good coder or something!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/25/12 09:39 AM (13 years ago)
@ annandale no, no coding experience at all. If I wanna do something I google it, stack overflow normally have to mix about three tutorials to get what I want. @gonorthwest , christ nothing so complicated. all the code does is literally is press button light comes on press same button again light goes off.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/25/12 09:43 AM (13 years ago)
Getting your software to interact with your hardware is no small feat! Now just figure out how to alternate the on/off, and you're in business! Mark
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/25/12 09:46 AM (13 years ago)
Add to .h @property (nonatomic) int flashlightState; Add to .m Add #import <AVFoundation/AVFoundation.h> to your .h @synthesize flashlightState; under view did load add flashlightState = 0; Add to the button method AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; // If torch supported, add button to toggle flashlight on/off if ([device hasTorch] == YES) {insert your code to create button here, button should then call self perform [self flashlightStateControl] -(void) flashlightStateControl { if (flashlightState == 1) { [self torchOff]; flashlightState = 0; } else { [self torchOn]; flashlightState = 1; } } -(void)torchOn{ AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; [device lockForConfiguration:nil]; [device setTorchMode: AVCaptureTorchModeOn]; [device unlockForConfiguration]; } -(void)torchOff{ AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; [device lockForConfiguration:nil]; [device setTorchMode: AVCaptureTorchModeOff]; [device unlockForConfiguration];
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/25/12 09:47 AM (13 years ago)
oh can do that it was a pain -(void) flashlightStateControl { if (flashlightState == 1) { [self torchOff]; flashlightState = 0; } else { [self torchOn]; flashlightState = 1; } }
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/25/12 09:49 AM (13 years ago)
writing a little code for GoNorthWest. must be getting better dude cos I've used your post and guides for all kinds. Nice to give a liitle back
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/25/12 10:00 AM (13 years ago)
Thanks, @kittsy! We all have our niches to fill here...not being able to code (and not really having the time to sit down and learn) is why I'm at buzztouch in the first place! The cool thing is that I'm actually able to understand some of what you wrote thanks to @David's plugin tutorial! Mark
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/25/12 10:01 AM (13 years ago)
why do people do this too me now I'm trying to think of a way to make it blink. I reckon in english use the above code turn on turn off press button > start pattern code (void)pattern code{ [self turnOn] [self performSelector:@selector(turnOff) withObject:nil afterDelay:0.2]; [self performSelector:@selector(turnOn) withObject:nil afterDelay:0.2]; etc }
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/25/12 10:03 AM (13 years ago)
I've become addicted, I wouldn't say I understand fully what the code does. But by downloading example projects from github and such I'm learning how it all pieces together.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/25/12 10:14 AM (13 years ago)
Love it! I think you're on the way to a cool Strobe Light plugin! You could provide a selector for the frequency, and then it would fire the light at that frequency, which could be used to check RPMs of various objects! Cool stuff!
 
SheriDee
Code is Art
Profile
Posts: 1094
Reg: Sep 23, 2011
location unknow...
22,840
like
10/25/12 10:28 AM (13 years ago)
@Andrew....dude you are sharing some amazing stuff the last few days! Thank you!
 
tb
buzztouch Evangelist
Profile
Posts: 2050
Reg: Nov 03, 2011
Oxford
32,300
like
10/25/12 12:42 PM (13 years ago)
That could really become useful. This could really become useful for many people. You should make a plugin with this feature and make some money out of it. It would be great to have. I'd be happy to pay.
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
10/27/12 12:49 AM (13 years ago)
Amazing info Kittsy and would like to see both of your blogs live soon...
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.