1st impressions of the SimPie

CAM00604[Update: I originally wrote this at just gone midnight and probably shouldn’t have pushed publish but should have waited until this morning after a quick read but I didn’t so didn’t realise that I didn’t actually say what the SimPie is :) The SimPie is a handheld device that plugs directly onto the Raspberry Pi’s GPIO connector & has a buzzer, RGB led (can be really really bright, after looking at the lit led for a few seconds and looking away you get the residual image in your eyes for about 10 minutes :) and 3 buttons]

A couple of weeks ago @cyntech ran a twitter “guess what this is?” competition http://goo.gl/7EjcGE to win one of their new product and I was one of the winners and it arrived in this afternoons post.

At first glance it looks remarkably like the controller for a hospital bed. In fact if it had a microphone and was a beige/grey colour it would be a perfect match for the controllers they use on the hospital beds in the three hospitals in Brooklyn that I have sampled over the years. Now there’s an idea, A Raspberry Pi controlled adjustable bed. I’m sure a lot of people would pay top dollar for that :)

Tearing open the plastic bag that the SimPie comes in you’ll find the SimPie itself, a sheet of button stickers & a slightly smaller than A5 size insert card with all the information you’ll need to get started, however, I have a couple of niggles with the instruction card especially when combined with the demos on the simpie.co.uk website but more about that in the niggles & whinges section below.

For my initial testing and messing around and because people are obviously going to compare the SimPie to the Pibrella although while they both have button/buttons, led/leds & a buzzer they are really for two different but overlapping demographics I decided to try a few of the programs that I have written over the last few days for the Pibrella with the SimPie.

The first thing I tried was my silly attempts to get music or a reasonable facsimile there of.

 

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>
#include <time.h>

#include <wiringpi.h>
#include <softtone.h>

#include "notes.h"

#define PIN 4
const int starwars[] =
{
    A2x,8, A2x,8, P,16, F3,8, F3,8, P,16, D3x,16, P,16, D3,16, P,16, C3,16, P,16, A3x,8,
    A3x,8, P,16, F3,8, P,16, D3x,16, P,16, D3,16, P,16, C3,16, P,16, A3x,8, A3x,8, P,16,
    F3,8, P,16, D3x,16, P,16, D3,16, P,16, D3x,16, P,16, C3,8, C3,8,
    MUSIC_END
};
const int furelise[] =
{
    e4, 8, d4x, 8, e4, 8, d4x, 8, e4, 8, b3, 8, d4, 8, c4, 8, a3,8, p, 8,
    c3, 8, e3, 8, a3, 8,  b3, 4, p, 8, e3, 8, g3x, 8, b3, 8, c4, 4, p, 8, e3, 8,
    e3, 8, d4x, 8, e4, 8, d4x, 8, e4, 8, b3, 8, d4, 8, c4, 8, a3, 8, p, 8, c3, 8,
    e3, 8, a3, 8, b3, 4, p, 8, e3, 8, c4, 8, b3, 8, a3, 4,
    MUSIC_END
};
const int HeyJude[] = {
    G2,8, E2,8, P,16, E2,16, E2,16, G2,16, A2,16, D2,8, P,16, D2,16, E2,16, F2,8,
    C3,8, C3,16, C3,16, H2,16, G2,16, A2,16, G2,16, F2,16, E2,8, P,16, G2,16,
    A2,16, A2,8, A2,16, D3,16, C3,16, H2,16, H2,16, C3,16, A2,16, G2,8, P,16,
    C2,16, D2,16, E2,16, A2,16, A2,16, G2,8,
    MUSIC_END
};

static void _delay_loop_1(int32_t count) {
    asm volatile("__delay_%=: subs %[count], %[count], #1; bne __delay_%=\n"
        : : [count]"r"(count) : "cc");
}

void PlayMusic( const int* pMusicNotes,uint8_t tempo)
{
        int duration;
        int note;
        int i;
        uint32_t delay = tempo * 1000000;

        while( *pMusicNotes )
        {
                note = *pMusicNotes;
                pMusicNotes++;
                duration = *pMusicNotes;
                pMusicNotes++;
printf("note:%d, dur:%d \n ",note, duration);

                if( p == note )
                {
                        softToneWrite (PIN, 0);
                }
                else
                {
                        softToneWrite (PIN, note);
                }
                for(i=0;i<32-duration;i++)
                {
                        nanosleep((struct timespec[]){{0, delay}}, NULL);
                }
        }
        softToneWrite (PIN,0);
}



int main ()
{
  wiringPiSetupGpio () ;
  softToneCreate (PIN) ;

  for (;;) {
        printf("***playing furelise***\n");
       PlayMusic( furelise, 20 );
       delay(1000);
        printf("***playing starwars***\n");
       PlayMusic( starwars, 17 );
       delay(1000);
        printf("***jude***\n");
       PlayMusic( HeyJude, 35 );
       delay(1000);
  }
}

Which sounds like

YouTube Preview Image

when run. Not great but not bad all things considered. It doesn’t sound quite as good as when played on the Pibrella but that’s probably because I haven’t yet done the same tweaking I did for the Pibrella version to get it to sound it’s best. I basically just edited the pin number the buzzer is on in an early version of my port of http://aquaticus.info/pwm-examples

The other program I tried on the SimPie was my attempt to make a morse key. As the SimPie has more than 1 button I thought for this version i’d make it an iambic dual paddle type morse key. So I use the red button for the dots & the green button for the dashes. This time on the whole it works better than the version I wrote for the Pibrella although it does have some quirks & logic/timing problems but for a quick hack while being distracted by requests for chicken soup, tea, toast & ice cream by sick people every 10 minutes i’m reasonably happy with it.

 

import time, sys
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)

red = 12
green = 16

GPIO.setup(11,GPIO.IN, pull_up_down=GPIO.PUD_UP) # RED Switch
GPIO.setup(15,GPIO.IN, pull_up_down=GPIO.PUD_UP) # GREEN Switch

GPIO.setup(7,GPIO.OUT) #SOUNDER

GPIO.setup(red, GPIO.OUT) # RGB LED / R
GPIO.setup(green, GPIO.OUT)  # RGB LED / G

morse_decode = {
         '.-':           'A',
         '-...':         'B',
         '-.-.':         'C',
         '-..':          'D',
         '.':            'E',
         '..-.':         'F',
         '--.':          'G',
         '....':         'H',
         '..':           'I',
         '.---':         'J',
         '-.-':          'K',
         '.-..':         'L',
         '--':           'M',
         '-.':           'N',
         '---':          'O',
         '.--.':         'P',
         '--.-':         'Q',
         '.-.':          'R',
         '...':          'S',
         '-':            'T',
         '..-':          'U',
         '...-':         'V',
         '.--':          'W',
         '-..-':         'X',
         '-.--':         'Y',
         '--..':         'Z',
         '-----':        '0',
         '.----':        '1',
         '..---':        '2',
         '...--':        '3',
         '....-':        '4',
         '.....':        '5',
         '-....':        '6',
         '--...':        '7',
         '---..':        '8',
         '----.':        '9',
         '--..--':       ',',
         '.-.-.-':       '.',
         '..--..':       '?',
         '-.-.-.':       ';',
         '---...':       ':',
         '.----.':       "'",
         '-....-':       '-',
         '-..-.':        '/',
         '-.--.-':       '(',
         '-.--.-':       ')',
         '..--.-':       '_'
}

delay = .08

character=""
try:

  start=time.time()
  finish=0
  key_flag=0
  space_flag=1
  while True:

    if (GPIO.input(11) == False):
      if key_flag==0:
        character+="."
        key_flag=1
        space_flag=0
      GPIO.output(7, True) # Buzzer On
      GPIO.output(12, True) # RGB - RED (ON)
      time.sleep(delay)
      start=time.time()
    elif (GPIO.input(11) == True):
      key_flag=0
      GPIO.output(12, False) # RGB - RED (OFF)
      GPIO.output(7, False) # Buzzer Off

    if (GPIO.input(15) == False):
      if key_flag==0:
        character+="-"
        key_flag=1
        space_flag=0
      GPIO.output(7, True) # Buzzer On
      GPIO.output(16, True) # RGB - GREEN (ON)
      time.sleep(delay*3)
      start=time.time()

    elif (GPIO.input(15) == True):
      key_flag=0
      GPIO.output(16, False) # RGB - GREEN
      GPIO.output(7, False) # Buzzer Off

    if (GPIO.input(11) == True and GPIO.input(15) == True):
      if space_flag==0:
        finish=time.time()
        if finish-start > delay*6:
          print morse_decode[character],
          sys.stdout.flush()
          character=""
          space_flag=1
          start=time.time()

    time.sleep(delay)


except KeyboardInterrupt:
 pass

print character
GPIO.cleanup()
YouTube Preview Image

Although i’ve only had the SimPie for about 10 hours I think it’s really pretty good, is really easy to use & has a lot of possibilities AND it has the added bonus that it looks pretty :) I like pretty. However, I do have a few complaints but they are minor ones that can be fixed with a bit of editing on the website and a slight in a later revision and they aren’t show stopper niggles.

1. The GPIO connector could do with a little dab of nail varnish or tippex or paint or some sort of marking to show which way it plugs onto the raspberry Pi’s GPIO header. I looked quite hard and i could see any markings and if you think about it there is probably only one way you could plug it in that makes sense because of the cable but a visual indicator wouldn’t go amiss.

2. The pin numbering scheme on the insert card & in the one in the demos on the website are different. OK it doesn’t take much effort to look up how to convert one numbering/naming scheme to another but come on guys choose one scheme and stick to it. Don’t use one then swap to another more often than you change your underwear :) Consistency is king.

3. My final niggle is the cable. Personally I think it’s too short but i’m sure i’m in a minority but probably a significant minority. Can you have a minority that is significant? Yeah you can :) So what i’d like to see on a future revision is a connector on the SimPie itself and a selection of cable lengths with headers on both ends.

So all in all I like the SimPie and think it’ll be a useful addon for many people and is well worth it’s price (£19.95). I do have some ideas on a SimPie+ but only if Cyntech want to hear them.

Share

2 Comments

Add a Comment
  1. I still don’t know what the SimPie is.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

russelldavis.org © 2014 Frontier Theme