Awesome HSV RGB IKEA lamp
When my girlfriend gave me her birthday present, i was overwhelmed. The drawing was perfect, I loved the motive, details and shadows. And it came that she had her own birthday! This was the moment i decided not to buy one of her wishlist’s entrys (yes i keep track) but build something by my own too (let’s just stick to buying things okay?). I thought about painting a picture too but decided against it. I just didn’t want to reveal my inner artist and make her jealous.
Since im a student of it and electronics, i chose to build something wired. It had to be cool but also instructive for me i though. I always planned on building a “proper” RedGreenBlue LED Lamp which could fade between colors. But i never found the time nor the motivation to do something símilar in my freetime. The first attempts on my Arduino Board were pretty basic. The colors were fading, yes, but randomly which means (in RGB color space) pretty white changes to a white reddish to bright white reddish to a bright white reddish with a touch of green or blue. This wasn’t that exciting at all. I “went” to the mikrocontroller.net community and asked about color spaces. My idea was to make a distinction between color and brightness and avoid same colors with just different portions of white. I found that the hsv (hue saturation value) color space met my needs. It allowed me to use a simple potentiometer for choosing the color (hue) and a further one for the brightness, while the saturation remains constant (no white parts please
)
I started coding (checkout github) the code for an atmega8 controller and tested it on a breadboard first. I found and bought a perfect fitting aluminium globe at IKEA which could hold both the led and the electronic circuit. Then I began with the final board layout in Eagle and ordered the other parts at reichelt: Three Potentiometers (two logarithmic ones), three nmos transistors, resistors, capacitors, push buttons, toggle and finally the power supply (5V2A).


I attached the parts to the new board and tested it with Georg who provided an oscillocope and even a 3D printer. I designed and printed two plastic parts for the globe to hold the led and the board.
Also I changed the original design from a standing lamp to a laying one. I though it would look nicer and lighten a wall much better. Also the potentiometers and buttons were better accessible (It’s not a bug it’s a feature).

Everything looked fine but a random flashing which disturbed me. One user from the forum gave me hint that there could be something wrong with my code since he had the same problem in the past. So glad this guy read the post -> no flickering anymore!


During the project i learned a lot about the whole progress of implementing a vision. I really started with a vague idea and then made use of a great toolchain (3d printing, uC development, board layout in eagle, testing testing and testing with oscilloscope)… Also i must say that there were a lot of coincidences like a broken diode and a wrongly connected mosfet which i eventually hadn’t noticed in other places… Maybe you (Kenzie) remember that i was happy about the one day on skype? Yeah, i figured the board was actually working … so this was my last week; for you! be happy!
Looking forward to party in fading colors!
Reference:
https://github.com/kreuzUndQwertz/hsv2rgb (code and board layouts as well as the openscad 3d designs)
http://www.mikrocontroller.net/topic/262143#postform (thread on rgb space and flashing issue)
Anchor Point vs. Position (CALayer)
Yesterday i was trying to do some animation which included rotation along the x axis. For this i needed to figure out how to set the anchor point of my layer without moving it in the superlayers coordinate system. But when i setted a different anchor Point the layer moved.
I didn’t know why and some internet resources did not help me at all.
I noticed that both setting the position or the anchor point would move the layer. But setting the one does not affect the other. Some pages on the web explained this bahvior with examples. Now i will give you an example too but no instrutions or advices for how to work with it in concrete cases. This post tries to explain the concept in general.
The anchor point is an attribute of every layer. Its coordinates describe a realtive position in your layer. Every point from 0.0/0.0 to 1.0/1.0 describes a point withing the bounds of the layer. Every negative pair like -1.0/-1.0 is placed once the height to the top and once the width to the left oustide the layers bounds. For instance 0.5/0.5 is the center of a layers bounds. Make sure you understand that this point is independent from the layers or superlayers actual dimension (in pixels or whatever). 0.5/0.5 always is the center independent from if its a layer of size 500×500 or 500×150.
Position on the other hand is expressed in actual layer dimensions but referrs to the superlayer not the layer itself! Position in short says “Position the layer in a way that the anchor point of the layer matches the position in my superlayer”.
Example: You have created a view (50×50) and added it to the center of your superview (150×150) using setCenter…
The anchor point of every layer is always set to 0.5/0.5 at creation time and therefor points to the center of the layer. Now when you added your view and placed it to the center, the position attribute of the layer makes shure that the layer is centered in respect to your anchor point (currently 0.5/0.5).
Since the anchor point is the center of the sublayer, the position attribute must be the center of the super layer so that the layers center is the superlayers center. As stated above, the position attribute now says “the layer is positioned in a way that the relative point 0.5/0.5 (anchor point) is at the super views center by setting the position to 75×75 sublayer.
Now imagine you change the anchor point so that not the layers center is centered in the superlayer but the upperleft corner. All you need to do is setting the anchor point to 0.0/0.0 which represents the realtive position for the upper left corner.

Solution: UIScrollview that doesn’t interfere with content touches
Hi there, i’m currently working on a drawing-application which uses a scrollview to navigate threw the content. With the normal UIScrollview you will definitely run into problems!
The problem is that UIScrollView will only deliver taps but no movement gestures to it’s content.
1) So i was looking for a solution to pan and zoom with 2 fingers and interact with the content-view with one finger.
2) Also it should be possible to have a period of time in which the 1 finger touch event can be canceled by the two finger events. This is useful since people tend to start with one finger followed by the second one a little later.
3)Also it should be possible to touch the screen with a second finger without canceling the content interaction!
The idea was to filter all the touch-events, but since UIScrollView uses gesture recognizers (namely UIScrollViewPanGestureRecognizer which inherits from UIPanGestureRecognizer) you can’t filter these touches since there aren’t any but the first touchesBegan…
To solve these problems i did the following:
- Set setCanCancelContentTouches:NO when you detect a 1 touch event in touchesBegan: works but you still have the problem with 2).
- Solution: Use a timer to set setCanCancelContentTouches:NO after a period like 0.1 seconds or so
- Problem: In the first moments the gesture recognizer will interfere with your touch movements and use them instead
- Solution: Reconfigure all pangesture recognizers to only accept 2 touch events
- Problem: In the first moments the gesture recognizer will interfere with your touch movements and use them instead
- Solution: Use a timer to set setCanCancelContentTouches:NO after a period like 0.1 seconds or so
-
#import “JWTwoFingerScrollView.h”
-
@implementation JWTwoFingerScrollView
-
#pragma mark -
-
#pragma mark Event Passing
-
- (id)initWithCoder:(NSCoder *)coder {
-
self = [super initWithCoder:coder];
-
if (self) {
-
for (UIGestureRecognizer* r in self.gestureRecognizers) {
-
NSLog(@“%@”,[r class]);
-
if ([r isKindOfClass:[UIPanGestureRecognizer class]]) {
-
[((UIPanGestureRecognizer*)r) setMaximumNumberOfTouches:2];
-
[((UIPanGestureRecognizer*)r) setMinimumNumberOfTouches:2];
-
}
-
}
-
}
-
return self;
-
}
-
-(void)firstTouchTimerFired:(NSTimer*)timer {
-
[self setCanCancelContentTouches:NO];
-
}
-
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
-
[self setCanCancelContentTouches:YES];
-
touchesBeganTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(firstTouchTimerFired:) userInfo:nil repeats:NO];
-
[touchesBeganTimer retain];
-
[touchFilter touchesBegan:touches withEvent:event];
-
}
-
}
-
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
-
[touchFilter touchesMoved:touches withEvent:event];
-
}
-
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
-
[touchFilter touchesEnded:touches withEvent:event];
-
}
-
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
-
[touchFilter touchesCancelled:touches withEvent:event];
-
}
-
@end
It really took me ages to get this running, there were plenty other solutions which all didnt meet my needs. Some used a timer but delayed the first touch event, others allowed only one touch event but interrupted as soon as there was a two finger touch event. Some threads on stackoverflow might be interesting for you, since it also helped me to get this solution working!
http://stackoverflow.com/questions/787212/scrolling-with-two-fingers-with-a-uiscrollview
if you want, download the files!
iScrape 0.4 drags and drops images, ignores blacklisted folders
Finally there is iScrape 0.4 with many more bugs and some new features. Please report me if you find any bugs or have any other suggestions. Some settings in preference pane are disabled since they aren´t implemented completely.





