Snake and Tetris-like games with Sense HAT on a Raspberry Pi 2 loaded with Windows 10

tl;dr – me n33dz the codez => check here on the SenseHatGames folder

The Sense HAT is a small and inexpensive board  for Raspberry Pi. It sits on top of it and offers a variety of sensors and (most importantly), a 8×8 RGB LED matrix and a 5-direction joystick. More specifically, it offers access to these sensors

  • Gyroscope
  • Accelerometer
  • Magnetometer
  • Temperature
  • Barometric pressure
  • Humidity

IMG_20160125_234729929_TOP.jpgSense HAT on top of a Raspberry Pi 2. You can clearly see the 8×8 RGB LED matrix whereas the joystick is on the bottom right of the HAT.

Absolutely worth mentioning, this board has also gone to space in the Astro Pi mission as part of a competition in the UK! I recently purchased one and, apart from the fun I had interacting with the sensors, I really liked the LED matrix and the joystick. So, I thought, why don’t I try and create a couple of games on it?

Read More »

Raspberry, Weather Shield, Azure IoT Hub, Streaming Analytics and more!

Intro

Recently I became the happy owner of a brand new Raspberry Pi 2. In case you don’t know about it, Raspberry is a pretty powerful computing device in a form factor of a credit card. You can install Windows 10 IoT Core on the Raspberry and code against it using the Universal Windows Platform (UWP_, aka write programs for this small device using C# and XAML. So, I embarked on a new self-education journey and, after some reading, I had to pick a pre-made hands-on sample and replicate it. I picked this one, since the only extra hardware it requires is a shield (Sparkfun Weather Shield) and some cables to connect it with the Raspberry. The sample instructions on hackster.io are pretty straight forward and the source code provided for the Weather Shield + UWP integration is pretty self-explanatory. Only modification I made was to add a timer to pull humidity and temperature from the shield at a fixed time interval.

12374739_10153447116073742_392889873121113510_o

12369049_10153441934143742_8606620306222203016_n

However, I wanted to take this project one step further. Connect the device to Azure IoT Hub, send data to it, pass the data via a simple Azure Stream Analytics job and store it to Azure Table Storage, expose it via a Web API web service and consume it from an ASP.NET MVC web application. Well, it’s not as difficult as it sounds! I’ll briefly describe the steps I used

Azure IoT Hub

The Azure IoT Hub (in preview, at the time of writing) is a service in which millions of devices can connect and exchange messages. The IoT Hub enables bidirectional communication to and from each device, can manage each device separately and provides a high level of security. To create a new IoT Hub, login into the new Azure management portal and create it. There is also a free tier to support app development, which you can use. If you do not have an active Azure subscription, you can easily create a trial account. Even though it requires a credit card, you will not be charged at all, provided you stay within your spending limits.

image

Read More »

Universal Helpers library for the Universal Windows Platform

It’s been some time since I posted something about my Universal Helpers library. The biggest news is that the library has been updated to support the Universal Windows Platform, allowing its usage on projects for Windows desktops, laptops, tablets, mobile devices and more! Apart from that, I’ve updated the library to include some additional behaviors and helpful classes. Let’s take a walkthrough. All this was made possible due to the release (open source!) of XAML Behaviors for UWP.

Behaviors

DragElementBehavior

Allows you to make a UIElement draggable, either by mouse or touch. It has options for

– allow the user to rotate, via multitouch

– allow the user to scale, via multitouch. User can select the maximum scale and the minimum scale.

– you can assign a container so that the draggable element can never leave the container’s bounds

– option whether the draggable element has inertia (i.e. will continue movement by decelerating when the user drags it and lets it go)

image

TapStoryboardBehavior

The TapStoryboardbehavior is useful for scenarios where we want to tap an element, start a storyboard and execute a method when the storyboard finishes running. It also has an option to specify whether the method is on the code-behind file or in the VM (i.e. in the DataContext of the page, for MVVM scenarios).

image

FeedbackBehavior

The FeedbackBehavior allows the user to implement a feedback functionality when an element is tapped and “pointer over”, specifically a scale animation on pointer over and an opacity change when tapped. This is used to notify the end user that she has indeed tapped the specified element.

SelectAllTextOnFocusBehavior

This simple behavior makes all text on a TextBox selected when the user taps on the TextBox.

Validation Behaviors

Read More »