The right tool joypad for the job

The RetroPie project is great! You can turn your Raspberry Pi into a NES/SNES Mini clone in no time and you don’t need to stop there as adding additional systems such as Atari 2600, Master System, MegaDrive, C64, PlayStation 1 etc happen almost automagically thanks to some clever install scripts. Playing these classic consoles with software emulation provides near perfect picture and sound but using a modern controller such as the Xbox 360 controller was ruining my experience and just felt wrong. I thought to myself could this be improved and decided to pay a visit to my original boxed up game consoles which have been happily yellowing (as it turns out) in my loft and gathered up a bunch of my favourite joysticks and joypads.

I then set about reverse engineering each one. All the controllers used here are originals and unmodified (‘warts and all’ – or should I say long thick cables that act as trip hazards, all part of the charm!) the propriety connectors were obtained by sourcing and cutting up extension cables as these are still being made and are readily available. This also ensures these classic joypads will still be usable on their original systems, keeping my childhood intact! Once one was completed I shared the code on my github, if interested please check them out https://github.com/jfrmilner/Arduino-USBRetroGamingControllers

With this experience, I designed a circuit board and selector system so they could all be connected and used on one system. The board acts as a shield for an Arduino Micro that expands the available pins allowing all the controllers to be connected. This works by using a series of Shift-in Registers, Shift-out Registers and some Multiplexers. The Shift-in’s handle the simple switch based controllers like the C64 joystick, the Shift-out’s control the Multiplexers (one nibble per IC) and some LEDs on the selector, and the Multiplexers connect the controllers that require direct access to the Arduino’s digital pins. The latter is required to meet the response times of ICs in the controllers which are usually Shift Register(s) or Multiplexer(s) (yes more of them). The Arduino presents itself as two joypads with native plug-and-play support for Microsoft Windows 7+ and Linux/RetroPie. The selector is simply a ring of LEDs with a potentiometer in the centre, using the knob will move the lit LED to the desired controller pictured in that position, a simple system with an unexpected bonus of being a little retro in its appearance.

The case was sourced from eBay and was chosen because of the small size and removable front panel, a handy feature providing the flexibility for future revisions. Using the graphics editor software Inkscape I created a design for the front panel and positioning of the multitude of game ports. This was imported into jscut.org and milled out on my trusty Shapeoko 2 CNC. A nice feature of RetroPie is that it has some handy shortcuts for things like Loading, Saving and Exiting games which greatly improve usability for casual users. To make these shortcuts available I added some LED Arcade buttons with custom labels which connect to an SX1509 (this simplifies LED effects and Interrupt offloading) and another Arduino 32u4 based board this time presenting as a keyboard. The overall look feels like a blending of the early Atari consoles and Arcade machine.

In efforts to keep this writeup short I’ve deliberately kept the details at a fairly high level but if anyone would like me to expand on an area then please leave a comment, same goes if you have any suggestions. I’m pleased with how this collection of hacks has turned out and most importantly I’ve had fun learning what makes all these controllers tick. As for the console, this will live in the break out room at work, coffee and a few rounds of Bomberman with the guys, ah bliss!

jfrmilner


Improve your retro gaming emulation experience by using the systems original controller

This post provides instructions so you can bring back to life your old controller with native plug-and-play support for Microsoft Windows 7+ and Linux/RetroPie using an ATmega32u4 based Arduino.

File 12-07-2016, 18 38 47
File 12-07-2016, 18 39 06

Ever since Arduino’s started to appear with the ATmega32u4 chip which allows the creation of USB devices I’ve wanted to create adapters to reuse my old game controllers on modern hardware. Unfortunately the official libraries didn’t support joystick/gamepads only keyboard and mouse. Thankfully Matthew Heironimus started a project to address this exact situation with his Arduino Joystick Library http://mheironimus.blogspot.co.uk/2015/11/arduino-joystick-library.html.

Using Matthew’s library and the following sketch https://github.com/jfrmilner/Arduino-USBRetroGamingControllers/blob/master/SegaMasterSystem_GamePad_USB/SegaMasterSystem_GamePad_USB.ino you can easily create an adapter for your controller following these steps

1. Get a suitable connector. For this project you’ll need to search (eBay/Aliexpress) for a SNES Controller Extension. Cut into the cable and expose the wires, this is the one I used
Controller_SNES_Extension
2. Find the pinout for your controller. PINOUTS.RU is a good source, for example here is the one for the SNES Controller http://pinoutsguide.com/Game/snescontroller_pinout.shtml. Use a multimeters continuity test to quickly map the pins to wires.
3. Wire the connector to the Arduino. I’ve included the pin information in the Arduino sketch, so for example SNES proprietary connector Pin1 goes to Arduino +5v.
4. Install Matthew’s library from https://github.com/MHeironimus/ArduinoJoystickLibrary. See https://www.arduino.cc/en/Guide/Libraries for more information.
5. Upload the Arduino Sketch and then connect your controller.
6. Test. Windows’s users should be able to see the controller appear as a gamepad which will be named after your Arduino board, for example.
Controller_DeviceAndPrinters
Windows provides a helpful test program on the properties page of the controller
Controller_DeviceAndPrinters_Properties
7. Play. For SNES Emulation I recommend Snes9x http://www.snes9x.com/.

Thanks for reading and be sure to check out my other controller conversions.

Kind Regards, jfrmilner


Improve your retro gaming emulation experience by using the systems original controller.

This post provides instructions so you can bring back to life your old controller with native plug-and-play support for Microsoft Windows 7+ and Linux/RetroPie using an ATmega32u4 based Arduino.
File 10-07-2016, 13 49 04
File 10-07-2016, 13 49 23
Ever since Arduino’s started to appear with the ATmega32u4 chip which allows the creation of USB devices I’ve wanted to create adapters to reuse my old game controllers on modern hardware. Unfortunately the official libraries didn’t support joystick/gamepads only keyboard and mouse. Thankfully Matthew Heironimus started a project to address this exact situation with his Arduino Joystick Library http://mheironimus.blogspot.co.uk/2015/11/arduino-joystick-library.html.

Using Matthew’s library and the following sketch https://github.com/jfrmilner/Arduino-USBRetroGamingControllers/blob/master/SegaMegaDrive_GamePad_USB/SegaMegaDrive_GamePad_USB.ino you can easily create an adapter for your controller following these steps

1. Get a suitable connector. For this project you’ll need to search (eBay/Aliexpress) for a DE9 or DB9 Male Breakout board, this is the one I used
DB9
2. Find the pinout for your controller. PINOUTS.RU is a good source, for example here is the one for the MegaDrive Controller http://pinouts.ru/Game/genesiscontroller_pinout.shtml
3. Wire the connector to the Arduino. I’ve included the pin information in the Arduino sketch, so for example DE9 Pin1 goes to Arduino Pin 1 (Up).
4. Install Matthew’s library from https://github.com/MHeironimus/ArduinoJoystickLibrary. See https://www.arduino.cc/en/Guide/Libraries for more information.
5. Upload the Arduino Sketch and then connect your controller.
6. Test. Windows’s users should be able to see the controller appear as a gamepad which will be named after your Arduino board, for example.
Controller_DeviceAndPrinters
Windows provides a helpful test program on the properties page of the controller
Controller_DeviceAndPrinters_Properties
7. Play. For MegaDrive emulation I recommend the Fusion Emulator for Sega Systems (google fusion364)

Thanks for reading and be sure to check out my other controller conversions.

Kind Regards, jfrmilner


Improve your retro gaming emulation experience by using the systems original controller

This post provides instructions so you can bring back to life your old controller with native plug-and-play support for Microsoft Windows 7+ and Linux/RetroPie using an ATmega32u4 based Arduino.
File 13-07-2016, 20 55 21
File 13-07-2016, 20 56 07
Ever since Arduino’s started to appear with the ATmega32u4 chip which allows the creation of USB devices I’ve wanted to create adapters to reuse my old game controllers on modern hardware. Unfortunately the official libraries didn’t support joystick/gamepads only keyboard and mouse. Thankfully Matthew Heironimus started a project to address this exact situation with his Arduino Joystick Library http://mheironimus.blogspot.co.uk/2015/11/arduino-joystick-library.html.

Using Matthew’s library and the following sketch https://github.com/jfrmilner/Arduino-USBRetroGamingControllers/blob/master/SegaMasterSystem_GamePad_USB/SegaMasterSystem_GamePad_USB.ino you can easily create an adapter for your controller following these steps

1. Get a suitable connector. For this project you’ll need to search (eBay/Aliexpress) for a DE9 or DB9 Male Breakout board, this is the one I used
DB9
2. Find the pinout for your controller. PINOUTS.RU is a good source, for example here is the one for SMS Control Pad http://pinouts.ru/Game/sega_ms_joy_pinout.shtml
3. Wire the connector to the Arduino. I’ve included the pin information in the Arduino sketch, so for example DE9 Pin1 goes to Arduino Pin 2 (CONTROL_PAD_UP).
4. Install Matthew’s library from https://github.com/MHeironimus/ArduinoJoystickLibrary. See https://www.arduino.cc/en/Guide/Libraries for more information.
5. Upload the Arduino Sketch and then connect your controller.
6. Test. Windows’s users should be able to see the controller appear as a gamepad which will be named after your Arduino board, for example.
Controller_DeviceAndPrinters
Windows provides a helpful test program on the properties page of the controller
Controller_DeviceAndPrinters_Properties
7. Play. For SMS emulation I recommend the Fusion Emulator for Sega Systems (google fusion364)

Thanks for reading and be sure to check out my other controller conversions.

Kind Regards, jfrmilner


Improve your retro gaming emulation experience by using the systems original controller
This post provides instructions so you can bring back to life your old controller with native plug-and-play support for Microsoft Windows 7+ and Linux/RetroPie using an ATmega32u4 based Arduino.

Controller_C64-02
Controller_C64-01

Ever since Arduino’s started to appear with the ATmega32u4 chip which allows the creation of USB devices I’ve wanted to create adapters to reuse my old game controllers on modern hardware. Unfortunately the official libraries didn’t support joystick/gamepads only keyboard and mouse. Thankfully Matthew Heironimus started a project to address this exact situation with his Arduino Joystick Library http://mheironimus.blogspot.co.uk/2015/11/arduino-joystick-library.html.

Using Matthew’s library and the following sketch https://github.com/jfrmilner/Arduino-USBRetroGamingControllers/blob/master/ClassicJoyStick_USB/ClassicJoyStick_USB.ino you can easily create an adapter for your controller following these steps

1. Get a suitable connector. For this project you’ll need to search (eBay/Aliexpress) for a DE9 or DB9 Male Breakout board, this is the one I used
DB9
2. Find the pinout for your controller. PINOUTS.RU is a good source, for example here is the one for C64 Control Port http://old.pinouts.ru/Inputs/ControlPortC64_pinout.shtml
3. Wire the connector to the Arduino. I’ve included the pin information in the Arduino sketch, so for example DE9 Pin1 goes to Arduino Pin 2 (JOY_UP).
4. Install Matthew’s library from https://github.com/MHeironimus/ArduinoJoystickLibrary. See https://www.arduino.cc/en/Guide/Libraries for more information.
5. Upload the Arduino Sketch and then connect your controller.
6. Test. Windows’s users should be able to see the controller appear as a gamepad which will be named after your Arduino board, for example.
Controller_DeviceAndPrinters
Windows provides a helpful test program on the properties page of the controller
Controller_DeviceAndPrinters_Properties

7. Play. For C64 emulation I’ve had great success with VICE http://vice-emu.sourceforge.net/ on both Windows and Linux (RetroPie)

Thanks for reading and be sure to check out my other controller conversions – https://github.com/jfrmilner/Arduino-USBRetroGamingControllers

Kind Regards, jfrmilner


A pastebin is a type of web application where users can store plain text. There are many implementations and versions of pastebin found around the web, this Script is designed to with Stikked https://github.com/claudehohl/Stikked (mainly because that’s what we’re using at work). All the Linux systems I administer have the following alias for Curl

alias pastebin='curl -k -d text="`cat -`" -d name="`whoami`@`hostname -f`" https://paste.work.net/api/create 2>/dev/null'

This allows me to quickly pipe the results of a command to pastebin where I can then send the link via Instant Message/Twitter for example. I really like this functionality and wanted to have the same ability when I’m working at my Windows PowerShell prompt. The end result is an Advanced Function that wraps Invoke-WebRequest (similar in concept to cURL). This function allowed me to add additional parameters for options available in the API http://paste.scratchbook.ch/api, with my favourite being “Language” which provides the option to syntax highlight code.

Here is a quick video demo of the function in action

Below is the v1.0 code and here is a link to the code on my GitHub page which will contain the latest version https://github.com/jfrmilner/PowerShell-Out-PasteBin/blob/master/Out-PasteBin.ps1

function Out-PasteBin {
	<#
	.SYNOPSIS
	A PowerShell function to output to a Stikked PasteBin. 
		It fully supports being used in the current pipeline or simply cat'ing a text file. 
		The URL for the Paste is copied to the Clipboard for ease of access.
	Its recommended that this function be added to your PowerShell Profile to guarantee availability
	PowerShell Profiles - http://technet.microsoft.com/en-us/library/bb613488(v=VS.85).aspx 
	.PARAMETER <inputPipeline>
	Inbound object that will be converted to String for uploading to Stikked PasteBin
	.PARAMETER <Language>
	Code Language. Default = "text"
	.PARAMETER <username>
	Username. Default = current Windows logged in Username.
	.PARAMETER <Private>
	None private Pastes will be publicly listed and will appear on recent lists etc. Default = True (Private)
	.PARAMETER <expireMinutes>
	Paste liftime in Minutes. Default = 30.
	.EXAMPLE
	Get-VM | Out-PasteBin
	.EXAMPLE
	Get-ChildItem | Out-PasteBin -expireMinutes 120
	.EXAMPLE
	cat Out-PasteBin.ps1 | Out-PasteBin -language PowerShell
	.NOTES
		Author: jfrmilner/John Milner
		Blog  : https://jfrmilner.wordpress.com 
		File Name: Out-PostBin.ps1
		Requires: Powershell V2
		Legal: This script is provided "AS IS" with no warranties or guarantees, and confers no rights. You may use, modify, reproduce, and distribute this script file in any way provided that you agree to give the original author credit.
		Version: v1.0 - 2015/06/18
	#>
    param(
	   	[parameter(ValueFromPipeline=$true, ValueFromRemainingArguments=$true)]
	    $inputPipeline
		,
		[ValidateSet("html5", "css", "javascript", "php", "python", "ruby", "lua", "bash", "erlang", `
		"go", "c", "cpp", "diff", "latex", "sql", "xml", "text", "0", "4cs", "6502acme", "6502kickass",`
		"6502tasm", "68000devpac", "abap", "actionscript", "actionscript3", "ada", "algol68", "apache",` 
		"applescript", "apt_sources", "asm", "asp", "autoconf", "autohotkey", "autoit", "avisynth", "awk",` 
		"bascomavr", "basic4gl", "bf", "bibtex", "blitzbasic", "bnf", "boo", "c_loadrunner", "c_mac", `
		"caddcl", "cadlisp", "cfdg", "cfm", "chaiscript", "cil", "clojure", "cmake", "cobol", "coffeescript",`
		"csharp", "cuesheet", "d", "dcs", "delphi", "div", "dos", "dot", "e", "ecmascript", "eiffel", "email", `
		"epc", "euphoria", "f1", "falcon", "fo", "fortran", "freebasic", "fsharp", "gambas", "gdb", "genero", `
		"genie", "gettext", "glsl", "gml", "gnuplot", "groovy", "gwbasic", "haskell", "hicest", "hq9plus", `
		"html4strict", "icon", "idl", "ini", "inno", "intercal", "io", "j", "java", "java5", "jquery", "klonec", `
		"klonecpp", "lb", "lisp", "llvm", "locobasic", "logtalk", "lolcode", "lotusformulas", "lotusscript", `
		"lscript", "lsl2", "m68k", "magiksf", "make", "mapbasic", "matlab", "mirc", "mmix", "modula2", "modula3",`
		"mpasm", "mxml", "mysql", "newlisp", "nsis", "oberon2", "objc", "objeck", "ocaml", "oobas", "oracle11", `
		"oracle8", "oxygene", "oz", "pascal", "pcre", "per", "perl", "perl6", "pf", "pic16", "pike", "pixelbender", `
		"pli", "plsql", "postgresql", "povray", "powerbuilder", "powershell", "proftpd", "progress", "prolog", `
		"properties", "providex", "purebasic", "q", "qbasic", "rails", "rebol", "reg", "robots", "rpmspec", `
		"rsplus", "sas", "scala", "scheme", "scilab", "sdlbasic", "smalltalk", "smarty", "systemverilog", "tcl",`
		"teraterm", "thinbasic", "tsql", "typoscript", "unicon", "uscript", "vala", "vb", "vbnet", "verilog", "vhdl",`
		"vim", "visualfoxpro", "visualprolog", "whitespace", "whois", "winbatch", "xbasic", "xorg_conf", "xpp", `
		"yaml", "z80", "zxbasic")]
		[string]$language = "text"
		,
		[string]$username = [Environment]::UserName
		,
		[bool]$private = $true
		,
		[int]$expireMinutes = 30
	    )
	begin {
		Add-Type -AssemblyName System.Web
		Add-Type -AssemblyName System.Windows.Forms
		[array]$text=@()
	}
    process {
		$text += $inputPipeline
	}
	end {
		#Create Paste string from input
		$string = [System.Web.HttpUtility]::UrlEncode($($text | Format-Table -AutoSize | Out-String))
		$Global:PSContent = @() 
		$Global:PSContent += "private=$([int]$private)&"
		$Global:PSContent += "lang=$($language)&"
		$Global:PSContent += "name=$($username)&"
		$Global:PSContent += "expire=$($expireMinutes)&"
		$Global:PSContent += "title=pipeline&"
		$Global:PSContent += "text=$($string)"
		try
		 {
			#Upload to Stikked PasteBin. Change the Uri to your hosted Stikked PasteBin.
			Invoke-WebRequest -Uri 'http://paste.scratchbook.ch/api/create' -Method Post -Body $PSContent -OutVariable response | Out-Null
			
			#Copy Stikked URL response to Clipboard
			Write-Host $('[copied to clipboard] Postbin URL: {0}' -f $response.Content) -ForegroundColor Green -BackgroundColor Blue
			[System.Windows.Forms.Clipboard]::SetText( $response.Content, 'UnicodeText' )
		 }
		catch [system.exception]
		 {
		  	"caught a system exception"
		 }
	}
}

Note for WordPress code copy
If you double click anywhere on the code, the entire code view is replaced with a pre-selected view from which users can copy with a simple Ctrl+C. Clicking anywhere else returns the view to the original state.

To make this function useful it really should be available for all your PowerShell sessions so I recommended that you add it to your PowerShell Profile, see the following link for details – http://technet.microsoft.com/en-us/library/bb613488(v=VS.85).aspx

Regard,

jfrmilner


The WordPress.com stats helper monkeys prepared a 2014 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 47,000 times in 2014. If it were a concert at Sydney Opera House, it would take about 17 sold-out performances for that many people to see it.

Click here to see the complete report.


In this post I detail how I created a simple ScreenSaver prevention AutoHotKey Script which can be toggled on or off with a simple key press.

What is AutoHotkey?
AutoHotkey (AHK) is a free, open-source macro-creation and automation software for Windows that allows users to automate repetitive tasks. It is driven by a scripting language that was initially aimed at providing keyboard shortcuts, otherwise known as hotkeys, that over time evolved into a full-fledged scripting language.

The Problem
Due to an Internal IT policy we have a screen saver GPO set with a 10 minute timer, now ordinarily this is fine but it can be a real pain when delivering PowerPoint presentations so I created a ahkscript to move the mouse one pixel to the right and then back again every minute which tricks the computer into thinking there is an active user. This allows for a light touch workaround to the problem which can be enabled or disabled by pressing Ctrl+5. I’ve even added a Tray Tip so its easy to tell if this is running or not, for example:

ScreenSaverPreventionEnabled

;autoexecute section
preventScreenSaverVar := false ; Boolean for Screen-saver prevention label (subroutine). True = running/enabled.
SetTimer, preventScreenSaver, 60000 ; Screen-saver launch prevention label (subroutine), checks every 1 minute


^5::
global preventScreenSaverVar := !preventScreenSaverVar
if (global preventScreenSaverVar) {
TrayTip, Screen Saver Prevention, Enabled, 2, 17
}
else { TrayTip, Screen Saver Prevention, Disabled, 2, 17 
}
return

;ScreenSaver launch prevention subroutine
preventScreenSaver:
if (global preventScreenSaverVar) {
    MouseMove, 1, 0, 1, R  ;Move the mouse one pixel to the right
    MouseMove, -1, 0, 1, R ;Move the mouse back one pixel
}
return

I’ll put a mirror of this code on my GitHub. If there are any updates code wise you’ll find it there.

Thanks for reading,

jfrmilner

Quote  —  Posted: 22/12/2014 in PowerShell
Tags:


In this project I detail how I created an Internet light controlled Christmas tree. Last year I heard about a great project by ioBridge Labs named CheerLights but unfortunately at the time this was late December and it was simply too late for me to join in, well not this year! The idea of CheerLights is a simple one: connect a strip of RGB LEDs to an Internet connected Microcontroller and have it query the CheerLight servers for the current colour, now the real magic here is that anyone can synchronously change the colour of every CheerLights setup by sending a Tweet with Hashtag #CheerLights, for example

Here’s a quick video from ioBridge about CheerLights including a demo

If you’d like a go yourself please choose from the following supported Colours:

Red
Green
Blue
Cyan
White
Warmwhite / Oldlace
Purple
Magenta
Yellow
Orange
Pink

You can see what the latest colour is right now by visiting www.cheerlights.com or https://thingspeak.com/channels/1417, getting the app android/iPhone and there is even a Google Chrome plugin but at the time of writing this is missing some of the new colours.

The Build

As with all projects of this nature, they can be customised to your own personnel preferences so I’ll not tell you what you should get but instead what I used for this build and I’ll try and highlight some pointers. I’ve got a few Arduino MCUs now, in fact I’m beginning to wonder if I’ve inadvertently become a collector as it seems I’ve just about one of each type, so from my stock I decided on a combination of Arduino Uno and Arduino WiFi Shield. The only real requirement here is that you use an MCU that you are comfortable with, if you have the same hardware (or similar – replacing the WiFi Shield with the Ethernet Shield would require minimal code changes) then you can simply upload my Sketch and away you go.
To control the LEDs I decided to use the FastLED Animation Library. This is quite a mature project and the library makes for some simple and easily readable code. FastLED supports popular LEDs including Neopixel, WS2801, WS2811, WS2812B, LPD8806, TM1809, and more so plenty of options. I went with a string of 25 WS2801 from raspimart.co.uk.

WS2801

 

You’ll also need a Christmas Tree, I picked up a desktop sized one from eBay – http://www.ebay.co.uk/itm/381033205884

ChristmasTree

 

Power

Be sure to get a power supply that can output at the correct voltage and has sufficient ampere to run the lights. Looking at the spec of my lights I know I needed a 5volts 2A (60mA*25=1500mA) AC Adaptor. I used a single AC Adaptor to power both the Arduinos and the LEDs with a splitter.

Tip: Don’t use the VIN on the Arduino to power more than 1A as this is the maximum tolerance of the forwarding diode, instead use a splitter.

The Code

Sketch flow
Boot up and connect to WiFi (halt on no connection) and run the Startup Routine (clears LEDs Black-White-Black)
Set current colours to black.
Start loop – { Check for current colour via ThingSpeak API
If it’s the same as the last check then wait and check again, if we’ve checked a couple of times without change then play either the Sparkle* or Twinkle* effect.
If the colour is different; then transition from the original colour to the new colour via the RGB colour wheel (see below image) using the shortest path, for example Red>Green would transition via Orange and Yellow or Blue>Red would transition via Magenta-Pink.
}

RGBColourWheel

 

*The Sparkle effect increases the brightness of a single LED and runs that back and forth over the strip.
*The Twinkle effect creates a FastLED Colour pallet of the current colour with black stripes which is then looped over the LED strip.

FastLED
I’m using the FastLED library which made coding these transitions and effects extremely simple.. The FastLED library has a lot to offer, one of my favourites is its ability to allow for compact colour palettes which use very little of my precious Arduino RAM, here’s a sample of the help section which explains this feature:

Normally, in computer graphics, the palette (or “color lookup table”) has 256 entries, each containing a specific 24-bit RGB color. You can then index into the color palette using a simple 8-bit (one byte) value. A 256-entry color palette takes up 768 bytes of RAM, which on Arduino is quite possibly “too many” bytes. FastLED does offer traditional 256-element palettes, for setups that can afford the 768-byte cost in RAM. However, FastLED also offers a compact alternative. FastLED offers palettes that store 16 distinct entries, but can be accessed AS IF they actually have 256 entries; this is accomplished by interpolating between the 16 explicit entries to create fifteen intermediate palette entries between each pair.

If you’re interested in lighting effects then I suggest you take a look at the Wiki

You can pick up a copy my code from GitHub – https://github.com/jfrmilner/Arduino-CheerLights

Here’s a quick demo of it in action

Thanks for reading and good luck with setting up your tree

Merry Christmas!

jfrmilner


I’ve been using IFTTT for a while now and its really changing the way I use online services. Just recently they added Channels for NewsBlur and Boxcar which allows for some really interesting Recipes, such as if there is a new blog post (NewsBlur) then let you know via a Push notification to your mobile device (Boxcar). This works great for the majority of my feeds but there are some that are just to busy and need to be filtered on certain keywords or RegEx matches before sending me Push notifications, as this is not currently possible (hoping it will one day) I set out to do it myself..

Thankfully NewsBlur provide a simple web based API which can be easily access with PowerShell.

First we must login to the API


$postParams = @{username='jfrmilner';password='new$blur'}
Invoke-WebRequest -Uri 'https://www.newsblur.com/api/login' -Method Post -Body $postParams -SessionVariable newsblur

In the above lines we pass the credentials to the NewsBlur endpoint and store the session in a variable $newsblur.


$stories = @()
foreach ($i in 1..20) {
$postParams = @{page="$i";read_filter="unread"}
$newsContent = Invoke-WebRequest -Uri 'https://www.newsblur.com/reader/feed/4340960' -Method Get -WebSession $newsblur -Body $postParams
$stories += $newsContent.Content | ConvertFrom-Json
}

In the above lines we create an array to store our stories and then collect 20 pages of results from NewsBlur that are unread. The ability to get only unread messages is one of the main reasons I collect the feeds from NewsBlur rather than directly from the sites RSS feed.

The above feed is actually for HotUKDeals. HotUKDeals allow you to customise your own RSS feeds which is nice so for this example I setup one for Gaming deals in the UK – http://www.hotukdeals.com/rss/jfrmilner. You will also notice the feed uses a numeric ID, you can obtain this with a GET /reader/feeds call but for quick ad-hoc use the NewsBlur web portal, click your feed and you will see the number in the address bar, for example:

NewsBlurWebPortalIDLookup


$myWatchList = $stories.stories | ? { $_.story_title -match "Humble|Uncharted 3" }

In the above line I use a simple RegEx to filter for stories that mention Humble or Uncharted 3.

NewsBlurResults1

In the above screenshot we can confirm this is working as expected; now I just need to Push this information to my phone.

Now we will just loop the results to the Send-BoxcarPush function I created my previous post.

foreach ($story in $myWatchList) {
Send-BoxcarPush -notificationTitle $story.story_title -notificationLongMessage $story.story_permalink -notificationSound cash
}

And to the notification sound of cash (the cash I’ll be saving) my phone lights up

NewsBlurResults2

#POST /reader/mark_feed_as_read
$postParams = @{feed_id=4340960}
$newsContent = Invoke-WebRequest -Uri 'https://www.newsblur.com/reader/mark_feed_as_read' -Method POST -WebSession $newsblur -Body $postParams

In the above lines we mark the feed as read to prevent getting duplicate notifications.

#POST /api/logout
#Logout the currently logged in user.
Invoke-WebRequest -Uri 'https://www.newsblur.com/api/logout' -Method POST -WebSession $newsblur

And finally we logout in the above lines.

Now all you need to do is sent this up as a scheduled task in Windows to run as frequently as you need.

As always thank you for reading and if you found this post useful please share and/or leave a comment.

Regards, jfrmilner