Repository: ChiefPilot/F3BarGauge Branch: master Commit: ce502aa73f77 Files: 17 Total size: 63.9 KB Directory structure: gitextract_ddzacrtk/ ├── F3BarGaugeDemo/ │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── F3BarGauge.h │ ├── F3BarGauge.m │ ├── F3BarGaugeDemo-Info.plist │ ├── F3BarGaugeDemo-Prefix.pch │ ├── ViewController.h │ ├── ViewController.m │ ├── en.lproj/ │ │ ├── InfoPlist.strings │ │ └── ViewController.xib │ └── main.m ├── F3BarGaugeDemo.xcodeproj/ │ ├── project.pbxproj │ ├── project.xcworkspace/ │ │ └── contents.xcworkspacedata │ └── xcuserdata/ │ └── bradbenson.xcuserdatad/ │ ├── xcdebugger/ │ │ └── Breakpoints.xcbkptlist │ └── xcschemes/ │ ├── F3BarGaugeDemo.xcscheme │ └── xcschememanagement.plist └── README.markdown ================================================ FILE CONTENTS ================================================ ================================================ FILE: F3BarGaugeDemo/AppDelegate.h ================================================ // // AppDelegate.h // F3BarGaugeDemo // // Created by Brad Benson on 12/13/11. // Copyright (c) 2011 __MyCompanyName__. All rights reserved. // #import @class ViewController; @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) ViewController *viewController; @end ================================================ FILE: F3BarGaugeDemo/AppDelegate.m ================================================ // // AppDelegate.m // F3BarGaugeDemo // // Created by Brad Benson on 12/13/11. // Copyright (c) 2011 __MyCompanyName__. All rights reserved. // #import "AppDelegate.h" #import "ViewController.h" @implementation AppDelegate @synthesize window = _window; @synthesize viewController = _viewController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; // Override point for customization after application launch. self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; } - (void)applicationWillResignActive:(UIApplication *)application { /* Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. */ } - (void)applicationDidEnterBackground:(UIApplication *)application { /* Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. */ } - (void)applicationWillEnterForeground:(UIApplication *)application { /* Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. */ } - (void)applicationDidBecomeActive:(UIApplication *)application { /* Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. */ } - (void)applicationWillTerminate:(UIApplication *)application { /* Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. */ } @end ================================================ FILE: F3BarGaugeDemo/F3BarGauge.h ================================================ // // F3BarGauge.h // // Copyright (c) 2011-2014 by Brad Benson // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following // conditions are met: // 1. Redistributions of source code must retain the above copyright // notice this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in // the documentation and/or other materials provided with the // distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY // OF SUCH DAMAGE. // //---> Pick up required headers <----------------------------------------- #import //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------| F3BarGauge class definition |--------------------- //------------------------------------------------------------------------ //------------------------------------------------------------------------ @interface F3BarGauge : UIView @property (readwrite, nonatomic) float value; @property (readwrite, nonatomic) float warnThreshold; @property (readwrite, nonatomic) float dangerThreshold; @property (readwrite, nonatomic) float maxLimit; @property (readwrite, nonatomic) float minLimit; @property (readwrite, nonatomic) int numBars; @property (readonly, nonatomic) float peakValue; @property (readwrite, nonatomic) BOOL holdPeak; @property (readwrite, nonatomic) BOOL litEffect; @property (readwrite, nonatomic) BOOL reverse; @property (readwrite, strong) UIColor *outerBorderColor; @property (readwrite, strong) UIColor *innerBorderColor; @property (readwrite, strong) UIColor *backgroundColor; @property (readwrite, strong) UIColor *normalBarColor; @property (readwrite, strong) UIColor *warningBarColor; @property (readwrite, strong) UIColor *dangerBarColor; -(void) resetPeak; @end ================================================ FILE: F3BarGaugeDemo/F3BarGauge.m ================================================ // // F3BarGauge.m // // Copyright (c) 2011-2014 by Brad Benson // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following // conditions are met: // 1. Redistributions of source code must retain the above copyright // notice this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in // the documentation and/or other materials provided with the // distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY // OF SUCH DAMAGE. // //===[ Required headers ]================================================ // Our stuff #import "F3BarGauge.h" //===[ Local definitions/constants/etc ]================================= static const int BAR_NOT_USED = -1; // Used to indicate that bar/level/peak does not exist //----------------------------------------------------------------------- //----------------------------------------------------------------------- //---------------| F3BarGauge class implementation |------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- //===[ Extention for private-ish stuff ]================================= @interface F3BarGauge() { float _peakValue; // Peak value seen since reset int _iOnIdx, // Point at which segments are on _iOffIdx, // Point at which segments are off _iPeakBarIdx, // Index of peak value segment _iWarningBarIdx, // Index of first warning segment _iDangerBarIdx; // Index of first danger segment } @end @implementation F3BarGauge //===[ Published Methods ]=============================================== //----------------------------------------------------------------------- // Method: initWithFrame: // Designated initializer // -(instancetype) initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if(self) { // Assign default values [self setDefaults]; } return self; } //----------------------------------------------------------------------- // Method: initWithCoder: // Initializes the instance when brought from nib, etc. // -(instancetype) initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if(self) { // Assign default values [self setDefaults]; } return self; } //----------------------------------------------------------------------- // Method: resetPeak // Resets peak value. // -(void) resetPeak { // Reset the value and redraw _peakValue = -INFINITY; _iPeakBarIdx = BAR_NOT_USED; [self setNeedsDisplay]; } //----------------------------------------------------------------------- // Method: value setter // -(void) setValue:(float)a_value { bool fRedraw = false; // Save value _value = a_value; // Point at which bars start lighting up int iOnIdx = (_value >= _minLimit) ? 0 : _numBars; if( iOnIdx != _iOnIdx ) { // Changed - save it _iOnIdx = iOnIdx; fRedraw = true; } // Point at which bars are no longer lit int iOffIdx = ((_value - _minLimit) / (_maxLimit - _minLimit)) * _numBars; if( iOffIdx != _iOffIdx ) { // Changed - save it _iOffIdx = iOffIdx; fRedraw = true; } // Are we doing peak? if( _holdPeak && a_value > _peakValue ) { // Yes, save the peak bar index _peakValue = a_value; _iPeakBarIdx = MIN(_iOffIdx, _numBars - 1); } // Redraw the display? if( fRedraw ) { // Do it [self setNeedsDisplay]; } } //----------------------------------------------------------------------- // Method: setNumBars: // This method sets the number of bars in the display // - (void) setNumBars:(int)a_iNumBars { // Reset peak value to force it to be updated w/new bar index _peakValue = -INFINITY; // Save it, then update the thresholds _numBars = a_iNumBars; self.value = _value; self.warnThreshold = _warnThreshold; self.dangerThreshold = _dangerThreshold; } //----------------------------------------------------------------------- // Method: setWarnThreshold: // Sets the level for which bars should be of the warning color // (dft: yellow) // - (void) setWarnThreshold:(float)a_flWarnThreshold { // Save it and recompute values _warnThreshold = a_flWarnThreshold; _iWarningBarIdx = ( !isnan(a_flWarnThreshold) && a_flWarnThreshold > 0.0f ) ? (int)( _warnThreshold * (float)_numBars ) : BAR_NOT_USED; } //----------------------------------------------------------------------- // Method: setDangerThreshold: // Sets the level for which bars should be of the warning color // (dft: red). // - (void) setDangerThreshold:(float)a_flDangerThreshold { // Save it and recompute values _dangerThreshold = a_flDangerThreshold; _iDangerBarIdx = ( !isnan(a_flDangerThreshold) && a_flDangerThreshold > 0.0f ) ? (int)( _dangerThreshold * (float)_numBars ) : BAR_NOT_USED; } //===[ Unpublished Methods ]============================================= //----------------------------------------------------------------------- // Method: setDefaults // Configure default settings for instance // -(void) setDefaults { // Set view background to clear self.backgroundColor = [UIColor clearColor]; // Configure limits _maxLimit = 1.0f; _minLimit = 0.0f; _value = 0.0f; // Set defaults for bar display _holdPeak = NO; _numBars = 10; _iOffIdx = 0; _iOnIdx = 0; _iPeakBarIdx = BAR_NOT_USED; _litEffect = YES; _reverse = NO; self.warnThreshold = 0.60f; self.dangerThreshold = 0.80f; // Set default colors _backgroundColor = [UIColor blackColor]; _outerBorderColor = [UIColor grayColor]; _innerBorderColor = [UIColor blackColor]; _normalBarColor = [UIColor greenColor]; _warningBarColor = [UIColor yellowColor]; _dangerBarColor = [UIColor redColor]; // Misc. self.clearsContextBeforeDrawing = NO; self.opaque = NO; } //----------------------------------------------------------------------- // Method: drawRect: // Draw the gauge // -(void) drawRect:(CGRect)rect { CGContextRef ctx; // Graphics context CGRect rectBounds, // Bounding rectangle adjusted for multiple of bar size rectBar; // Rectangle for individual light bar size_t iBarSize; // Size (width or height) of each LED bar // How is the bar oriented? rectBounds = self.bounds; BOOL fIsVertical = (rectBounds.size.height >= rectBounds.size.width); if(fIsVertical) { // Adjust height to be an exact multiple of bar iBarSize = rectBounds.size.height / _numBars; rectBounds.size.height = iBarSize * _numBars; } else { // Adjust width to be an exact multiple iBarSize = rectBounds.size.width / _numBars; rectBounds.size.width = iBarSize * _numBars; } // Compute size of bar rectBar.size.width = (fIsVertical) ? rectBounds.size.width - 2 : iBarSize; rectBar.size.height = (fIsVertical) ? iBarSize : rectBounds.size.height - 2; // Get stuff needed for drawing ctx = UIGraphicsGetCurrentContext(); CGContextClearRect(ctx, self.bounds); // Fill background CGContextSetFillColorWithColor(ctx, _backgroundColor.CGColor); CGContextFillRect(ctx, rectBounds); // Draw LED bars CGContextSetStrokeColorWithColor(ctx, _innerBorderColor.CGColor); CGContextSetLineWidth(ctx, 1.0); for( int iX = 0; iX < _numBars; ++iX ) { // Determine position for this bar if(_reverse) { // Top-to-bottom or right-to-left rectBar.origin.x = (fIsVertical) ? rectBounds.origin.x + 1 : (CGRectGetMaxX(rectBounds) - (iX+1) * iBarSize); rectBar.origin.y = (fIsVertical) ? (CGRectGetMinY(rectBounds) + iX * iBarSize) : rectBounds.origin.y + 1; } else { // Bottom-to-top or right-to-left rectBar.origin.x = (fIsVertical) ? rectBounds.origin.x + 1 : (CGRectGetMinX(rectBounds) + iX * iBarSize); rectBar.origin.y = (fIsVertical) ? (CGRectGetMaxY(rectBounds) - (iX + 1) * iBarSize) : rectBounds.origin.y + 1; } // Draw top and bottom borders for bar CGContextAddRect(ctx, rectBar); CGContextStrokePath(ctx); // Determine color of bar UIColor *clrFill = _normalBarColor; if( _iDangerBarIdx >= 0 && iX >= _iDangerBarIdx ) { clrFill = _dangerBarColor; } else if( _iWarningBarIdx >= 0 && iX >= _iWarningBarIdx ) { clrFill = _warningBarColor; } // Determine if bar should be lit BOOL fLit = ((iX >= _iOnIdx && iX < _iOffIdx) || iX == _iPeakBarIdx); // Fill the interior of the bar CGContextSaveGState(ctx); CGRect rectFill = CGRectInset(rectBar, 1.0, 1.0); CGPathRef clipPath = CGPathCreateWithRect(rectFill, NULL); CGContextAddPath(ctx, clipPath); CGContextClip(ctx); [self drawBar:ctx withRect:rectFill andColor:clrFill lit:fLit]; CGContextRestoreGState(ctx); CGPathRelease(clipPath); } // Draw border around the control CGContextSetStrokeColorWithColor(ctx, _outerBorderColor.CGColor); CGContextSetLineWidth(ctx, 2.0); CGContextAddRect(ctx, CGRectInset(rectBounds, 1, 1)); CGContextStrokePath(ctx); } //----------------------------------------------------------------------- // Method: drawBar:::: // This method draws a bar // - (void) drawBar:(CGContextRef)a_ctx withRect:(CGRect)a_rect andColor:(UIColor *)a_clr lit:(BOOL) a_fLit { // Is the bar lit? if(a_fLit) { // Are we doing radial gradient fills? if(_litEffect) { // Yes, set up to draw the bar as a radial gradient static size_t nu_locations = 2; static CGFloat locations[] = { 0.0, 0.5 }; CGFloat aComponents[8]; CGColorRef clr = a_clr.CGColor; // Set up color components from passed UIColor object if (CGColorGetNumberOfComponents(clr) == 4) { // Extract the components // // Note that iOS 5.0 provides a nicer way to do this i.e. // [a_clr getRed:&aComponents[0] // green:&aComponents[1] // blue:&aComponents[2] // alpha:&aComponents[3] ]; memcpy(aComponents, CGColorGetComponents(clr), 4*sizeof(CGFloat)); // Calculate dark color of gradient aComponents[4] = aComponents[0] - ((aComponents[0] > 0.3) ? 0.3 : 0.0); aComponents[5] = aComponents[1] - ((aComponents[1] > 0.3) ? 0.3 : 0.0); aComponents[6] = aComponents[2] - ((aComponents[2] > 0.3) ? 0.3 : 0.0); aComponents[7] = aComponents[3]; } // Calculate radius needed CGFloat width = CGRectGetWidth(a_rect); CGFloat height = CGRectGetHeight(a_rect); CGFloat radius = sqrt( width * width + height * height ); // Draw the gradient inside the provided rectangle CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB(); CGGradientRef myGradient = CGGradientCreateWithColorComponents (myColorspace, aComponents, locations, nu_locations); CGPoint myStartPoint = { CGRectGetMidX(a_rect), CGRectGetMidY(a_rect) }; CGContextDrawRadialGradient(a_ctx, myGradient, myStartPoint, 0.0, myStartPoint, radius, 0); CGColorSpaceRelease(myColorspace); CGGradientRelease(myGradient); } else { // No, solid fill CGContextSetFillColorWithColor(a_ctx, a_clr.CGColor); CGContextFillRect(a_ctx, a_rect); } } else { // No, draw the bar as background color overlayed with a mostly // ... transparent version of the passed color CGColorRef fillClr = CGColorCreateCopyWithAlpha(a_clr.CGColor, 0.2f); CGContextSetFillColorWithColor(a_ctx, _backgroundColor.CGColor); CGContextFillRect(a_ctx, a_rect); CGContextSetFillColorWithColor(a_ctx, fillClr); CGContextFillRect(a_ctx, a_rect); CGColorRelease(fillClr); } } @end ================================================ FILE: F3BarGaugeDemo/F3BarGaugeDemo-Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFiles CFBundleIdentifier com.flightiii.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion 6.0 CFBundleName ${PRODUCT_NAME} CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1.0 LSRequiresIPhoneOS UIRequiredDeviceCapabilities armv7 UIStatusBarStyle UIStatusBarStyleLightContent UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight ================================================ FILE: F3BarGaugeDemo/F3BarGaugeDemo-Prefix.pch ================================================ // // Prefix header for all source files of the 'F3BarGaugeDemo' target in the 'F3BarGaugeDemo' project // #import #ifndef __IPHONE_4_0 #warning "This project uses features only available in iOS SDK 4.0 and later." #endif #ifdef __OBJC__ #import #import #endif ================================================ FILE: F3BarGaugeDemo/ViewController.h ================================================ // // ViewController.h // F3BarGaugeDemo // // Created by Brad Benson on 12/13/11. // Copyright (c) 2011 __MyCompanyName__. All rights reserved. // #import #import "F3BarGauge.h" @interface ViewController : UIViewController @end ================================================ FILE: F3BarGaugeDemo/ViewController.m ================================================ // // ViewController.m // F3BarGaugeDemo // // Created by Brad Benson on 12/13/11. // Copyright (c) 2011 __MyCompanyName__. All rights reserved. // #import "ViewController.h" @interface ViewController () @property (strong, nonatomic) IBOutlet F3BarGauge *horizontalBar; @property (strong, nonatomic) IBOutlet F3BarGauge *reversedBar; @property (strong, nonatomic) IBOutlet F3BarGauge *verticalBar; @property (strong, nonatomic) IBOutlet F3BarGauge *lcdBar; @property (strong, nonatomic) IBOutlet F3BarGauge *peakHoldBar; @property (strong, nonatomic) IBOutlet F3BarGauge *customThresholdBar; @property (strong, nonatomic) IBOutlet F3BarGauge *customRangeBar; @property (strong, nonatomic) IBOutlet UISlider *valueSlider; @property (strong, nonatomic) IBOutlet UILabel *valueLabel; - (IBAction)didChangeValue:(id)sender; - (IBAction)didReset:(id)sender; @end @implementation ViewController #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; _reversedBar.reverse = YES; _customThresholdBar.numBars = 15; _customThresholdBar.warnThreshold = 0.45; _customThresholdBar.dangerThreshold = 0.90; _customThresholdBar.normalBarColor = [UIColor blueColor]; _customThresholdBar.warningBarColor = [UIColor cyanColor]; _customThresholdBar.dangerBarColor = [UIColor magentaColor]; _customThresholdBar.outerBorderColor = [UIColor clearColor]; _customThresholdBar.innerBorderColor = [UIColor clearColor]; _customRangeBar.numBars = 20; _customRangeBar.minLimit = 0.40; _customRangeBar.maxLimit = 0.60; _peakHoldBar.numBars = 10; _peakHoldBar.holdPeak = YES; _lcdBar.numBars = 20; _lcdBar.litEffect = NO; UIColor *clrBar = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1.0]; _lcdBar.normalBarColor = clrBar; _lcdBar.warningBarColor = clrBar; _lcdBar.dangerBarColor = clrBar; _lcdBar.backgroundColor = [UIColor clearColor]; _lcdBar.outerBorderColor = [UIColor clearColor]; _lcdBar.innerBorderColor = [UIColor clearColor]; } - (IBAction)didChangeValue:(id)sender { // Update the text label _valueLabel.text = [NSString stringWithFormat:@"%0.02f", _valueSlider.value]; // Update the bar gauges _horizontalBar.value = _valueSlider.value; _reversedBar.value = _valueSlider.value; _lcdBar.value = _valueSlider.value; _verticalBar.value = _valueSlider.value; _peakHoldBar.value = _valueSlider.value; _customThresholdBar.value = _valueSlider.value; _customRangeBar.value = _valueSlider.value; } - (IBAction)didReset:(id)sender { [_peakHoldBar resetPeak]; } @end ================================================ FILE: F3BarGaugeDemo/en.lproj/InfoPlist.strings ================================================ /* Localized versions of Info.plist keys */ ================================================ FILE: F3BarGaugeDemo/en.lproj/ViewController.xib ================================================ ================================================ FILE: F3BarGaugeDemo/main.m ================================================ // // main.m // F3BarGaugeDemo // // Created by Brad Benson on 12/13/11. // Copyright (c) 2011 __MyCompanyName__. All rights reserved. // #import #import "AppDelegate.h" int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } ================================================ FILE: F3BarGaugeDemo.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ C68DA36E1497B71B00437005 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C68DA36D1497B71B00437005 /* UIKit.framework */; }; C68DA3701497B71B00437005 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C68DA36F1497B71B00437005 /* Foundation.framework */; }; C68DA3721497B71B00437005 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C68DA3711497B71B00437005 /* CoreGraphics.framework */; }; C68DA3781497B71B00437005 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C68DA3761497B71B00437005 /* InfoPlist.strings */; }; C68DA37A1497B71B00437005 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C68DA3791497B71B00437005 /* main.m */; }; C68DA37E1497B71B00437005 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C68DA37D1497B71B00437005 /* AppDelegate.m */; }; C68DA3811497B71B00437005 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C68DA3801497B71B00437005 /* ViewController.m */; }; C68DA3841497B71B00437005 /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C68DA3821497B71B00437005 /* ViewController.xib */; }; C68DA3911497B79000437005 /* F3BarGauge.m in Sources */ = {isa = PBXBuildFile; fileRef = C68DA3901497B79000437005 /* F3BarGauge.m */; }; C6E5F05A188F04B0006D1593 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6E5F059188F04B0006D1593 /* Default-568h@2x.png */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ C68DA3691497B71B00437005 /* F3BarGaugeDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = F3BarGaugeDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; C68DA36D1497B71B00437005 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; C68DA36F1497B71B00437005 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; C68DA3711497B71B00437005 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; C68DA3751497B71B00437005 /* F3BarGaugeDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "F3BarGaugeDemo-Info.plist"; sourceTree = ""; }; C68DA3771497B71B00437005 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; C68DA3791497B71B00437005 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; C68DA37B1497B71B00437005 /* F3BarGaugeDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "F3BarGaugeDemo-Prefix.pch"; sourceTree = ""; }; C68DA37C1497B71B00437005 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; C68DA37D1497B71B00437005 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; C68DA37F1497B71B00437005 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; C68DA3801497B71B00437005 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; C68DA3831497B71B00437005 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController.xib; sourceTree = ""; }; C68DA38F1497B79000437005 /* F3BarGauge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = F3BarGauge.h; sourceTree = ""; }; C68DA3901497B79000437005 /* F3BarGauge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = F3BarGauge.m; sourceTree = ""; }; C6E5F059188F04B0006D1593 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ C68DA3661497B71B00437005 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( C68DA36E1497B71B00437005 /* UIKit.framework in Frameworks */, C68DA3701497B71B00437005 /* Foundation.framework in Frameworks */, C68DA3721497B71B00437005 /* CoreGraphics.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ C68DA35E1497B71B00437005 = { isa = PBXGroup; children = ( C6E5F059188F04B0006D1593 /* Default-568h@2x.png */, C68DA38A1497B73D00437005 /* BarGauge */, C68DA3731497B71B00437005 /* F3BarGaugeDemo */, C68DA36C1497B71B00437005 /* Frameworks */, C68DA36A1497B71B00437005 /* Products */, ); sourceTree = ""; }; C68DA36A1497B71B00437005 /* Products */ = { isa = PBXGroup; children = ( C68DA3691497B71B00437005 /* F3BarGaugeDemo.app */, ); name = Products; sourceTree = ""; }; C68DA36C1497B71B00437005 /* Frameworks */ = { isa = PBXGroup; children = ( C68DA36D1497B71B00437005 /* UIKit.framework */, C68DA36F1497B71B00437005 /* Foundation.framework */, C68DA3711497B71B00437005 /* CoreGraphics.framework */, ); name = Frameworks; sourceTree = ""; }; C68DA3731497B71B00437005 /* F3BarGaugeDemo */ = { isa = PBXGroup; children = ( C68DA37C1497B71B00437005 /* AppDelegate.h */, C68DA37D1497B71B00437005 /* AppDelegate.m */, C68DA37F1497B71B00437005 /* ViewController.h */, C68DA3801497B71B00437005 /* ViewController.m */, C68DA3821497B71B00437005 /* ViewController.xib */, C68DA3741497B71B00437005 /* Supporting Files */, ); path = F3BarGaugeDemo; sourceTree = ""; }; C68DA3741497B71B00437005 /* Supporting Files */ = { isa = PBXGroup; children = ( C68DA3751497B71B00437005 /* F3BarGaugeDemo-Info.plist */, C68DA3761497B71B00437005 /* InfoPlist.strings */, C68DA3791497B71B00437005 /* main.m */, C68DA37B1497B71B00437005 /* F3BarGaugeDemo-Prefix.pch */, ); name = "Supporting Files"; sourceTree = ""; }; C68DA38A1497B73D00437005 /* BarGauge */ = { isa = PBXGroup; children = ( C68DA38F1497B79000437005 /* F3BarGauge.h */, C68DA3901497B79000437005 /* F3BarGauge.m */, ); name = BarGauge; path = F3BarGaugeDemo; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ C68DA3681497B71B00437005 /* F3BarGaugeDemo */ = { isa = PBXNativeTarget; buildConfigurationList = C68DA3871497B71B00437005 /* Build configuration list for PBXNativeTarget "F3BarGaugeDemo" */; buildPhases = ( C68DA3651497B71B00437005 /* Sources */, C68DA3661497B71B00437005 /* Frameworks */, C68DA3671497B71B00437005 /* Resources */, ); buildRules = ( ); dependencies = ( ); name = F3BarGaugeDemo; productName = F3BarGaugeDemo; productReference = C68DA3691497B71B00437005 /* F3BarGaugeDemo.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ C68DA3601497B71B00437005 /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 0420; }; buildConfigurationList = C68DA3631497B71B00437005 /* Build configuration list for PBXProject "F3BarGaugeDemo" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); mainGroup = C68DA35E1497B71B00437005; productRefGroup = C68DA36A1497B71B00437005 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( C68DA3681497B71B00437005 /* F3BarGaugeDemo */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ C68DA3671497B71B00437005 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( C68DA3781497B71B00437005 /* InfoPlist.strings in Resources */, C68DA3841497B71B00437005 /* ViewController.xib in Resources */, C6E5F05A188F04B0006D1593 /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ C68DA3651497B71B00437005 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( C68DA37A1497B71B00437005 /* main.m in Sources */, C68DA37E1497B71B00437005 /* AppDelegate.m in Sources */, C68DA3811497B71B00437005 /* ViewController.m in Sources */, C68DA3911497B79000437005 /* F3BarGauge.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ C68DA3761497B71B00437005 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( C68DA3771497B71B00437005 /* en */, ); name = InfoPlist.strings; sourceTree = ""; }; C68DA3821497B71B00437005 /* ViewController.xib */ = { isa = PBXVariantGroup; children = ( C68DA3831497B71B00437005 /* en */, ); name = ViewController.xib; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ C68DA3851497B71B00437005 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.0; SDKROOT = iphoneos; }; name = Debug; }; C68DA3861497B71B00437005 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; name = Release; }; C68DA3881497B71B00437005 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "F3BarGaugeDemo/F3BarGaugeDemo-Prefix.pch"; INFOPLIST_FILE = "F3BarGaugeDemo/F3BarGaugeDemo-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; name = Debug; }; C68DA3891497B71B00437005 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "F3BarGaugeDemo/F3BarGaugeDemo-Prefix.pch"; INFOPLIST_FILE = "F3BarGaugeDemo/F3BarGaugeDemo-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ C68DA3631497B71B00437005 /* Build configuration list for PBXProject "F3BarGaugeDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( C68DA3851497B71B00437005 /* Debug */, C68DA3861497B71B00437005 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; C68DA3871497B71B00437005 /* Build configuration list for PBXNativeTarget "F3BarGaugeDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( C68DA3881497B71B00437005 /* Debug */, C68DA3891497B71B00437005 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = C68DA3601497B71B00437005 /* Project object */; } ================================================ FILE: F3BarGaugeDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: F3BarGaugeDemo.xcodeproj/xcuserdata/bradbenson.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist ================================================ ================================================ FILE: F3BarGaugeDemo.xcodeproj/xcuserdata/bradbenson.xcuserdatad/xcschemes/F3BarGaugeDemo.xcscheme ================================================ ================================================ FILE: F3BarGaugeDemo.xcodeproj/xcuserdata/bradbenson.xcuserdatad/xcschemes/xcschememanagement.plist ================================================ SchemeUserState F3BarGaugeDemo.xcscheme orderHint 0 SuppressBuildableAutocreation C68DA3681497B71B00437005 primary ================================================ FILE: README.markdown ================================================ F3BarGauge ========== Welcome! -------- This demo contains the LED bar gauge control for iOS. It has been tested on iOS 6.x and 7.x on iTouch, iPhone, and iPad devices. ![Screenshot](https://raw.github.com/ChiefPilot/F3BarGauge/master/F3BarGauge.png "Screenshot of Component Demo App") If you find this control of use (or find bugs), I'd love to hear from you! Drop a note to brad@flightiii.com with questions, comments, or dissenting opinions. Background ---------- This control is intended to replicate/simulate the level indicator on an audio mixing board. These indicators are usually segmented/stacked LEDs, with several colors to indicate thresholds. This control replicates that look, using Quartz drawing primitives, and auto-adjusts to horizontal or vertical orientation. Additionally, the colors, number of bars, peak hold, and other items are easily customized. Usage ----- Adding this control to your XCode project is straightforward : 1. Add the F3BarGauge.h and F3BarGauge.m files to your project 2. Add a new blank subview to the nib, sized and positioned to match what the bar gauge should look like. 3. In the properties inspector for this subview, change the class to "F3BarGauge" 4. Add an outlet to represent the bar gauge 5. Update your code to set the value property as appropriate. For more information have a look at the demo code, which has multiple examples including a version that customizes the with an LCD-style appearance. License ------- Copyright (c) 2011-2014 by Brad Benson All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.