Mar 03
AndyElectronics, Mac OS X, Objective-C/Apple Development, Programming/Computer, Projects ambient light, arm, atmel Sam7, ethernet, mac, make controller, objective-c, sensor, temt6000, udp

iPotti™ 1.2 bathroom status device
So, we have this issue at the office with our single-person bathrooms. We have one “m” bathroom and one “w” bathroom. We have 40+ people in the office. Many people who sit out-of-sight from the bathrooms often walk all the way across our office only to find out that someone else has beaten them to the potti.
To solve this problem, I took a Make Controller from MakingThings.com, wired a couple of Vishay TEMT6000 ambient light sensors (photo transistors) to it, then wrote a Mac desktop app to sit in the status bar to show everyone the status of the pottis. I call it, “iPotti™” and it works awesome!
More
VN:R_U [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +20 (from 20 votes)
Oct 15
AndyiOS/iPhone/iPad, Objective-C/Apple Development, Programming/Computer cocoa, code, ipad, iphone, mac, objective-c, programming, software
Until I find a home for my little snippets of code, here is where they will go.
While building an iOS (iPhone) application, I needed a quick little method in Objective-c that would take strings of color codes from data provided by web developer peeps and convert those string values into UIColor objects. For instance, sometimes we’d get “#ff7401″ from the data for our app. Sometimes it might be formatted like, “0xff7401″ or even just, “ff7401″. I simply created a category on NSString to make is super-simple.
NSString+meltutils.h
// UIColor+meltutils.h
// Created by Andy Frey on 10/15/10.
#import <Foundation/Foundation.h>
@interface NSString (meltutils)
- (UIColor *)toUIColor;
@end
NSString+meltutils.m
#import "NSString+meltutils.h"
@implementation NSString (meltutils)
- (UIColor *)toUIColor {
unsigned int c;
if ([self characterAtIndex:0] == '#') {
[[NSScanner scannerWithString:[self substringFromIndex:1]] scanHexInt:&c];
} else {
[[NSScanner scannerWithString:self] scanHexInt:&c];
}
return [UIColor colorWithRed:((c & 0xff0000) >> 16)/255.0 green:((c & 0xff00) >> 8)/255.0 blue:(c & 0xff)/255.0 alpha:1.0];
}
@end
So, to use this, all you have to do is import the header file and send a message to your string that contains the color code:
#import "NSString+meltutils.h"
...
UIColor *c = [@"#ff840a" toUIColor];
...
Hope that helps someone out a little!
VN:R_U [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]