Wednesday, October 17, 2012

iOS - Showing/Hiding MPMoviePlayerController Controls

This question seems to be all over stack overflow and iphone dev sdk forums with no real answer....So how does one show and hide the controls of the MPMoviePlayerController programmatically? Here you go...
 - (void)showControls  
   for(id views in [[player view] subviews]){  
     for(id subViews in [views subviews]){  
       for (id controlView in [subViews subviews]){  
         if ( [controlView isKindOfClass:NSClassFromString(@"MPInlineVideoOverlay")] ) {  
           [controlView setAlpha:1.0];  
           [controlView setHidden:NO];  
 - (void)hideControls  
   for(id views in [[player view] subviews]){  
     for(id subViews in [views subviews]){  
       for (id controlView in [subViews subviews]){  
         if ( [controlView isKindOfClass:NSClassFromString(@"MPInlineVideoOverlay")] ) {  
           [controlView setAlpha:0.0];  
           [controlView setHidden:YES];  

Thursday, January 27, 2011

The Predictor: College Football

The Predictor: College Football Edition brought to you by Dean's Sports.

With this application you can input statistics from the official college football website and the app will give you the predicted team scores, the favorite, and the total game points.

The formula used in this application has been in use for over a decade and has a fairly good track record.

Team Points 45%, Total Points 75%

Data from previous years is coming...

The screen shots are from the Orange Bowl on Jan 3, 2011. Virginia Tech vs. Stanford. The Predictor said Stanford would win by 12. The odds-makers set the line as Stanford a 3.5 point favorite. Good value in the line for Stanford. Stanford won 40-12. This was one of the biggest line differences (8.5) of all the bowl games. The Predictor also said there would be a total of 56 total points scored in the game. The odds-makers set the total at 59 points. 52 total points were scored in the game, under 59. Meaning The Predictor also predicted the total points better than the odds-makers.

The Predictor is for entertainment purposes only. We do not condone gambling.

Tuesday, December 21, 2010

Simple Weather Bash Script

This simple weather bash script was written with the intention of piping it to a text to speech program such as flite or festival. However, it can be used for any sort of text notification such as printing to the command line or emailing.


# Written by:
# Brandt Daniels
# December 2010


RAW=$(curl -s "$LAT&lon=$LON&TextType=1")
echo "$RAW" | sed 's/\(.*\)<\/b>\(.*\)
.*/\1\2/;s/.*<.*//g;/^$/d' | head -$1

Friday, October 15, 2010

x10 Rain8II sprinkler weather scripts for use with Heyu

I use Heyu-2.9.1 for X10 home automation running on a Sheevaplug. For irrigation, I purchased a Rain8II from WGL Designs some time ago. With the Rain8II you need an X10 ON, and OFF for each zone to control it, unlike the first Rain8 where you just needed to trigger the first zone and it would automatically go through it's watering cycle. The Rain8II is also 2-way X10. That means you can configure it to automatically send back a status message to confirm that is has received the command that an x10 device has sent it.

The Rain8II states in the manual that it can be controlled by an X10 Mini Timer schedule, which I've done. When you want to disable the schedule, due to rain for example, you simply slide the selector from 'Run' to 'Set Clock' and it disables the first 5 unit codes. In my case I am only using 5 sprinkler zones so this worked out perfect. If you want to disable all 8 zones on the Rain8II, you will need to change the house code on the Mini Timer to an unused house code.

I mostly use the CM11a and Heyu for my Rain8II timers. Only when my CM11a cable went bad, I used the Mini Timer until I replaced the cable. I simply created the proper macros and timers in the schedule file an uploaded them to the CM11a. Well since I have a LOT of x10 signals flying around my house, some of the x10 signals for the Rain8II were being missed. According to the Heyu man pages, the solution for this was to simply schedule it twice a minute apart. So I have two ON and two OFF timers for all five zones. This works great, but I still have to comment out the timers and re-upload the schedule file on unexpected rainy days I don't want to water, and remember to reverse that when I am ready to water according the regular schedule again. Also, since the Rain8II sends back confirmation messages to Heyu, I shouldn't need two entries per ON and OFF for each zone in the schedule file!

With Heyu-2.9.1, the module type RAIN8II was added, as well as the module option 'DEFER'. What DEFER does, is it makes Heyu wait until it receives back the Status message from the module before updating it's internal state tables. So now you can send the command 'heyu status backyard_grass' and it will give you a guaranteed result. I also recently learned that you can trigger heyu scripts in the x10.conf file with CM11a uploaded timers using the 'sndm' flag in your script. If you use Heyu, you should know what the transmission flags are.

All that being said, I wanted a way so that my sprinkler timers would work with only the CM11a in case my Sheevaplug is down for some reason. I also wanted to be able to supplement the CM11a timers with a little intelligence when the Sheevaplug and heyu were up and running, which they are most of the time.

The first goal here is to create a status checking script so that I can eliminate the two timer schedules per x10 signal per zone that I currently have uploaded to the CM11a. I only want one timer entry per signal!

The second goal is to create a rain checking script, so that sprinklers won't turn on if it is raining, or has rained in the last X number of days. It would be so cool if I could calculate evapo-transpiration in the script, but that is a pipe dream for now.

So far, I have a first draft of the weather script created and as of tonight it worked! (it is raining a bit at the moment).

I still need to create the status checking script. I will update this blog as I get to it.

I hope some of you shell scripting and heyu experts can offer corrections and advice!

It appears that pasting my code has messed it up a bit, need to figure that out...


alias driveway_grass I1 RAIN8II DEFER
alias walkway_grass I2 RAIN8II DEFER
alias front_planters I3 RAIN8II DEFER
alias backyard_grass I4 RAIN8II DEFER
alias sideyard_grass I5 RAIN8II DEFER

SCRIPT driveway_grass on sndm :: /usr/local/bin/; if [ "$?" ]; then heyu off driveway_grass; fi
SCRIPT walkway_grass on sndm :: /usr/local/bin/; if [ "$?" ]; then heyu off walkway_grass; fi
SCRIPT front_planters on sndm :: /usr/local/bin/; if [ "$?" ]; then heyu off front_planters; fi
SCRIPT backyard_grass on sndm :: /usr/local/bin/; if [ "$?" ]; then heyu off backyard_grass; fi
SCRIPT sideyard_grass on sndm :: /usr/local/bin/; if [ "$?" ]; then heyu off sideyard_grass; fi


macro driveway_grass_on 0 on driveway_grass
macro driveway_grass_off 0 off driveway_grass
macro walkway_grass_on 0 on walkway_grass
macro walkway_grass_off 0 off walkway_grass
macro front_planters_on 0 on front_planters
macro front_planters_off 0 off front_planters
macro backyard_grass_on 0 on backyard_grass
macro backyard_grass_off 0 off backyard_grass
macro sideyard_grass_on 0 on sideyard_grass
macro sideyard_grass_off 0 off sideyard_grass

timer 01/01-12/31 21:30 21:40 driveway_grass_on driveway_grass_off
timer 01/01-12/31 21:31 21:41 driveway_grass_on driveway_grass_off
timer 01/01-12/31 21:42 21:52 walkway_grass_on walkway_grass_off
timer 01/01-12/31 21:43 21:53 walkway_grass_on walkway_grass_off
timer 01/01-12/31 21:54 22:04 front_planters_on front_planters_off
timer 01/01-12/31 21:55 22:05 front_planters_on front_planters_off
timer 01/01-12/31 22:06 22:16 backyard_grass_on backyard_grass_off
timer 01/01-12/31 22:07 22:17 backyard_grass_on backyard_grass_off
timer 01/01-12/31 22:18 22:23 sideyard_grass_on sideyard_grass_off
timer 01/01-12/31 22:19 22:24 sideyard_grass_on sideyard_grass_off



# This script will check for rain and
# return a 0 if no rain, and a 1 if
# it is raining.

RAINPAD=2 # Day 0 is today.

# Get dates in various formats for use below.
DATE=`date +"%Y/%m/%d"`
CURPDT=`date +'%Y%m%d'`

# Available colums are:
# PDT,Max TemperatureF,Mean TemperatureF,Min TemperatureF,Max Dew PointF,MeanDew PointF,Min DewpointF,Max Humidity, Mean Humidity, Min Humidity, Max Sea Level PressureIn, Mean Sea Level PressureIn, Min Sea Level PressureIn, Max VisibilityMiles, Mean VisibilityMiles, Min VisibilityMiles, Max Wind SpeedMPH, Mean Wind SpeedMPH, Max Gust SpeedMPH,PrecipitationIn, CloudCover, Events
RESULT=`curl -s$STATIONID/$DATE/WeeklyHistory.html?format=1`

# Remove HTML
# Remove header line
# We only care about fields: PDT, Mean TemperatureF, PrecipitationIn, and Events
# Reverse output so today is first going back in time.
WEEKLY=`echo $RESULT | sed 's/
/\\n/g' | sed '/<.*>/d' | sed '/PDT/d' | cut -d, -f1,3,20,22 | sed -n '1!G;h;$p'`

# Remove decimal and convert RAINTHRESH to base10

echo "$WEEKLY" | while read RECORD
RECPDT=`echo $RECORD | cut -d, -f1 | sed 's/-//g'`
TEMP=`echo $RECORD | cut -d, -f2`
INCHES=`echo $RECORD | cut -d, -f3`
EVENT=`echo $RECORD | cut -d, -f4`
if [ "$DATEDIFF" = "0" ] && [ "$EVENT" = "Rain" ]; then exit 1; fi
if [ "$INCHES" = "T" ] && [ "$EVENT" != "Rain" ]; then INCHES="0"; else INCHES=$((10#$INCHES)); fi
if [ "$DATEDIFF" -le "$RAINPAD" ] && [ "$EVENT" = "Rain" ] && [ "$INCHES" -ge "$RAINTHRESH" ]; then
exit 1

Monday, September 27, 2010


Well I got a sheevaplug. I don't feel like writing now so I'll update this as I feel like it.

Reserved for sheevaplug

Monday, February 22, 2010

Linux Voice Recognition and Speech Home Automation

Here is a video I made for the Syno contest:

Please read more!!

I was able to successfully cross-compile and run Julius Voice Recognition Engine on my Synology DS209.

I am working on trying to compile Festival w/ MBROLA engine in place of Flite for better TTS voices. I am also looking at Cepstral and AT&T Natural Voices.

Another good program to look at would be DomotiGa + Gambas for linux HA.

Flite TTS on a Synology NAS

I was able to successfully cross compile a text-to-speech engine called Flite which is very lightweight to run on my DS209j. This means you can use HEYU or Misterhouse to output speech upon an event.

Here is my config file generated from running configure:

root@xubuntu-vm:/usr/local/flite-1.3-release# cat config/config
# -*- makefile -*-
# This file is automatically generated by configure.
# Do not hand edit.

TARGET_OS    = linux-gnu
TARGET_CPU   = powerpc
HOST_OS    = linux-gnu
HOST_CPU   = powerpc

CC       = /usr/local/powerpc-linux/bin/powerpc-linux-gcc
CFLAGS   = -I/usr/local/powerpc-linux/include -Wall

AR       = /usr/local/powerpc-linux/bin/powerpc-linux-ar
RANLIB   = /usr/local/powerpc-linux/bin/powerpc-linux-ranlib
INSTALL  = /usr/bin/install -c

M68KCC   = 




MMAPTYPE    = posix
STDIOTYPE   = stdio

FL_LANG  = usenglish
FL_VOX   = cmu_us_kal16
FL_LEX   = cmulex

prefix        = /usr/local
exec_prefix   = ${prefix}
EXEEXT       = 
INSTALLBINDIR = ${exec_prefix}/bin
INSTALLLIBDIR = ${exec_prefix}/lib
INSTALLINCDIR = ${prefix}/include/flite