More EyeTV related scripting.

Ok, so I spend way too much time with my laptop in my…well, my lap.

I’ve become a bit dissatisfied with the remote control that comes with EyeTV. But it has some strange lag at times, and things like changing the aspect ratio is under a web of menus.

So, I figured out how to do a litany of things via applescript, which I run through an ssh connection.

Now, for your enjoyment, here’s some scripts (as called in SSH, if you’re going to copy them into an applescript script, take out the osascript -e ‘ and the trailing ‘)

Full Screen:
osascript -e ‘tell application “EyeTV” to enter full screen’
osascript -e ‘tell application “EyeTV” to exit full screen’

Channel Changing:
Since I’ve still got the DTV box sitting between the EyeTV and my cable, the remote control is a way better way to change the channel, since this basically doubles the applescript lag.
osascript -e ‘tell application “EyeTV” to channel_change channel number 60’
osascript -e ‘tell application “EyeTV” to channel_up’
osascript -e ‘tell application “EyeTV” to channel_down’

Play/Pause:
osascript -e ‘tell application “EyeTV” to pause’
osascript -e ‘tell application “EyeTV” to play’

Aspect Ratio:
Even via applescript changing the Aspect Ratio isn’t straight forward. There isn’t a direct command for it, so what I’ve been doing is instead telling the computer to pretend it just got the short cut key for the various aspect ratios.
osascript -e ‘tell application “System Events” to keystroke “1” using {command down, option down}’
osascript -e ‘tell application “System Events” to keystroke “2” using {command down, option down}’
osascript -e ‘tell application “System Events” to keystroke “3” using {command down, option down}’

ZephIR & EyeTV

Comcast recently switched the majority of their analog cable over to digital, forcing me to get a little digital converter box to sit between the cable and my EyeTV. It also killed my ability to change channel thru EyeTV (I have the first gen of the 250+, which doesn’t have built in QCAM) so I bought a ZephIR.

It works pretty well, but when quickly flipping through channels, it just doesn’t keep up. Often I’d land on a channel (say 42) but since I’d been using just the up/down buttons, it would stop somewhere between (like 55).

So I wrote a little perl script to fix the problem.

In order for it to work you have to make sure that the components are named DIFFERENTLY in EyeTV and ZephIR. (Severing the connection between them.)

Here’s the code:

#!/usr/bin/perl

# Declare the subroutines
sub trim($);
sub currentChannel();
sub blast($);
sub blastUp();
sub blastDown();

# Declare channel variable
my $curChan;

$curChan = currentChannel();

while(1) {
my $chanNow = currentChannel();
if(!($curChan == $chanNow))
{
$diff = $chanNow-$curChan;
if($diff==1) { blastUp(); }
elsif($diff==-1) { blastDown(); }
else {
blast($chanNow);
}
$curChan = $chanNow;
}
}

sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}

sub currentChannel()
{
$result = `osascript -e ‘tell application “EyeTV” to get current channel’`;
return trim($result);
}

sub blast($)
{
my $in = shift;
my $command = “tell application \”ZephIR\” \n”;
foreach (split(//, $in)) {
$command .= “fire zephir command \”$_\” of component \”ComcastDTA_\”\n”;
}
$command .= “fire zephir command \”enter\” of component \”ComcastDTA_\”\n”;
$command .= “end tell\n”;
system(“osascript -e ‘$command'”);
}

sub blastUp()
{
system(“osascript -e ‘tell application \”ZephIR\” to fire zephir command \”Channel_Up\” of component \”ComcastDTA_\”‘”);
}

sub blastDown()
{
system(“osascript -e ‘tell application \”ZephIR\” to fire zephir command \”Channel_Down\” of component \”ComcastDTA_\”‘”);
}

Cardiolumen

Using a heart rate monitor, an arduino, a servo motor, some gears and a dimmer switch, cardiolumen present the user’s heart rate back to him, creating a sort of meditative loop.

Authenticity Visual Responses

So far I’ve only posted 1/6 of the visual responses for Zara’s class. Initially it was because I was debating whether or not I wanted to post them on my blog, then it was just because I was just not doing them. I’m still not sure I want these on the blog, but since I’m doing them all at once, what the hell!

Authentic Brand

Adafruit Industries

Adafruit Industries is the epitome of an authentic brand to me. Why? I’m not sure. But I feel a strong emotional connection to it as a brand, and really feel like the values it embodies are ones that should be upheld within the DIY community.

Authentic Portland Architecture

The Bridges of Portland
What could be more authentic to Portland than its iconic bridges?

Authentic Experience

Third Class Superhero - Charles Yu

Ok, so this book is actually pretty sub par, and by no means is it an experience, but it had this really cool excerpt about authentic experiences, so I thought I’d include that.

“We choose a package deal with Authentic ExperiencesTM.
According to the brochure, there are five kinds of Experience: Urban, Rural, Semirural, Ethnic, and Ethnic with Danger. Standard Endangerment is Mild or Implied, but those in the know understand they may inquire discreetly about Actual Hazard – e.g., I’ve heard there might be something more? wispered into the ear of a client services representative (along with a slip of paper, folded and pressed into the palm, on which has been written a four- or even low five-figure sum) – for which damage waiver/general release forms will have to be signed and notarized…”

“‘When does the Authenticity start?’ my wife says. ‘I want to have some Experiences.'”

Authentic Artist

No Pic

I really can’t think of anyone who embodies the idea of an authentic artist. Really, I think anyone who is putting work out there with artistic intent fits. (And no, I don’t think they have to handle all stages of production to qualify.)

Authentic Designed Product

gEarings

Is it wrong to mark my own product as an “authentic designed product?” I mean, come on, Shawna thinks it authentic, and I’m not about to disagree with her!

Tweetolumen

After 5.5 hours of setup at Maker Faire 2009 tangolumen was non-functional.

Either I screwed something up in the setup or something broke in shipping (or both… or option C [to be named later]) but whatever the cause, I didn’t bring the tools with me I need to really debug it, nor did I really have ample time (or the heart) to rip it back up and fix it.

Now there are two things you can really do in a situation like this. You can just accept that it’s broken and prepare yourself for a weekend of saying “Well…this is my project, here is what it is supposed to do…but it’s broken” or you can hack together something new. I went to the hardware store and picked up enough parts to hack together with the laser cut pieces I brought to control Tang

Creating a NIB-free Cocoa Touch application in XCode

Do you program Cocoa Touch apps? Do you hate that all of the project templates expect you to be using interface builder? Me too! Here’s how to get rid off all IB dependencies in your app!

Why would you want to do this?
Because programatically creating interfaces is considerably easier to deal with. (In my opinion anyway.)

How do you do it?
I’m glad you asked. It’s a little bit of a hassle, BUT it’s worth it.

So here we go.

1) Create a new project in XCode using the “Window Based Application” template (Title it whatever the heck you want. For the sake of this tutorial I’m calling it “NoNib”)

2) Looking at all the contents of your new app you should see:
CoreGraphics.framework
Foundation.framework
Info.plist
main.m
MainWindow.xib
NoNib.app
NoNib_Prefix.pch
NoNibAppDelegate.h
NoNibAppDelegate.m
UIKit.framework

Go ahead and delete MainWindow.xib (the NIB) and send it to the trash. You don’t need it.

3) Open Info.plist
Select the line with key “Main nib file base name” and delete it

4) Open main.m
Find the line “int retVal = UIApplicationMain(argc, argv, nil, nil);” and replace the second line with the name of your AppDelegate as a string (example “int retVal = UIApplicationMain(argc, argv, nil, @”NoNibAppDelegate”);”)

5) Open your AppDelegate.h file and remove the line “@property (nonatomic, retain) IBOutlet UIWindow *window;”

6) Open your AppDelegate.m file
Remove the line “@synthesize window;”
Then, within – (void)applicationDidFinishLaunching:(UIApplication *)application before the line that says “[window makeKeyAndVisible];” add this line “window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];”

7) Build and Go
If it doesn’t build without error, you most likely missed something in the above steps. Otherwise it should launch in the simulator as a completely empty app with a black background. CONGRATULATIONS! You can now start building Views and View Controllers without any of those icky interface builder remnants dragging you down.