Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tortuga22/Tortuga22-LED-Indicators
Static library and bundle for implementing simple LED indicator views.
https://github.com/tortuga22/Tortuga22-LED-Indicators
Last synced: 3 months ago
JSON representation
Static library and bundle for implementing simple LED indicator views.
- Host: GitHub
- URL: https://github.com/tortuga22/Tortuga22-LED-Indicators
- Owner: tortuga22
- License: other
- Created: 2009-12-06T23:15:14.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2009-12-09T21:57:01.000Z (about 15 years ago)
- Last Synced: 2023-03-10T21:57:45.126Z (almost 2 years ago)
- Language: Objective-C
- Homepage:
- Size: 2.6 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.TXT
- License: LICENSE.TXT
Awesome Lists containing this project
- awesome - Tortuga22-LED-Indicators - Static library and bundle for implementing simple LED indicator views. (etc)
- awesome - Tortuga22-LED-Indicators - Static library and bundle for implementing simple LED indicator views. (etc)
README
DETAILS
Tortuga LED Indicators is a library you can drop into a project and use to create simple LED-looking on/off indicators (like a power light or connectivity indicator).
That's it.
The library gives you three options for controlling the LEDs:
1. Manually switching them on-and-off.
2. Using NSNotificationCenter to link notifications to actions that turn the lights on and off
3. Using KVO to have the LED monitor some keypath on some other variable...so integrating this code into an existing application's views won't require heavy lifting. The views use prerendered PNGs and will include convenience methods that will automatically select the appropriately-sized raw images to use.
USING IT
To use this library in your project you need to do two things.
#1: Include it as a subproject.
Rather than give a tutorial I am going to link you here:
http://www.clintharris.net/2009/iphone-app-shared-libraries/
...which is an extremely helpful writeup as to how to do exactly that.
#2: Include TULEDs.bundle as a resource in your project. Be sure to have it listed under the "Copy Bundle Resources" build phase for any project output that is using this library. If you don't do this your project will lack the png LED images it needs to use this library.
CODE SAMPLES
I recommend reading the list of methods defined in "TULEDIndicatorView+Convenience.h".
Briefly: suppose we had a class TULEDInternetConnectionMonitor. When created it'd check if internet access was available; when access was available it'd set connectionAvailable to YES and otherwise it'd set it to NO. It's KVO compliant for @"connectionAvailable".
We want to use TULEDIndicatorView to show if the internet is available. Here's what it takes:
@interface TULEDViewController : UIViewController {
IBOutlet TULEDIndicatorView *connectionAvailableIndicator;
TULEDInternetConnectionMonitor *connectionMonitor;
}//
@property(nonatomic) TULEDIndicatorView *connectionAvailableIndicator;
@property(nonatomic) TULEDInternetConnectionMonitor *connectionMonitor;@end
@implementation TULEDViewController
-(void)viewDidLoad {
[super viewDidLoad];
self.connectionMonitor = [TULEDInternetConnectionMonitor defaultConnectionMonitor];
[self.connectionAvailableIndicator makeGreenWatchingKeyPath:@"connectionAvailableIndicator"
ofObject:self.connectionMonitor
inverting:NO];
}@end
...if you were creating the view programmatically you'd do this instead:
self.connectionAvailableIndicator = [TULEDIndicatorView greenLEDIndicatorWithFrame:frame
watchingKeyPath:@"connectionAvailable"
ofObject:self.connectionMonitor
inverting:NO];...if instead you had been saddled with a legacy class that had a "problemWithInternet" property you'd do this instead:
self.connectionAvailableIndicator = [TULEDIndicatorView greenLEDIndicatorWithFrame:frame
watchingKeyPath:@"connectionAvailable"
ofObject:self.connectionMonitor
inverting:YES];...as setting inverting==YES means that for purposes of KVO-driven updates the LED Indicator treats a YES @ the monitored keyPath as a NO and vice-versa; this lets you avoid having to extend or rewrite pre-existing code to get it to work correctly with the LED Indicator.
For manually-driven state changes you don't use invert; if you're wiring things up by hand wire them up right.
MORE INFO
The TULEDIndicatorViewsDemo has some simple example code showing how to use TULEDIndicatorViews in your project. Read the source to see how everything works, and run it in the simulator to see how the LEDs look.
FAQ:
Q1: Why is no image showing or the app crashing?
A1: Perhaps you forgot to include the TULEDs.bundle into your application? Or included it but forgot to have it copied into the application bundle?Q2: What colors have you?
A2: Amber, Blue, Green, Red, Ultraviolet (purple), Yellow, White.CREDITS:
The bundled LED images are by Stuart Brown ( http://rtbrown.com ), originally made available here: http://modernl.com/article/led-icons . Their inclusion is courtesy of his gracious generosity.