Arduino

Bluetooth communication between Arduino and Windows 8.1

Introduction Recently, after being inspired by this video of Arduino Bluetooth communication with Windows Phone 8 by Marcos Pereira, I got myself some new devices to play with: Arduino Uno R3 in a starter kit (link) JY-MCU Bluetooth module (link) and a few extra cables The thing is: I don’t have a Windows Phone 8 yet and the Windows Phone 7.8 APIs do not support this kind of Bluetooth communication. But: I have a Surface RT and with Windows 8.1 the RFCOMM API can be used to establish a serial link to the Arduino. Arduino and Visual Studio It happens that my developing skills are quite limited to C# and when I had to develop some Kinect software with Processing in early 2012, I almost freaked out. Arduino code is written in C++  and the standard Arduino IDE is derived from the Processing IDE. Fortunately there’s the Visual Studio extension…

C#

A Custom (Async) MessageBox for WPF and Windows Phone

The System.Windows.MessageBox provided by .NET is limited to a very small set of MessageBoxButtons (Yes/No/OK/Cancel) which do not allow for custom Button texts. The System.Windows.Forms.MessageBox also blocks the UI thread, which can be an annoying disadvantage as well. The MessageBox on Windows Phone has the same disadvantages. Custom buttons in a MessageBoxe simplify the decision for the user, because they can describe the results of the action: However you need to do this with a custom control, so for WPF as well as Windows Phone I designed a simple method for asynchronously showing a MessageBox with custom buttons. (The WPF implementation based on this control by Evan Wondrasek) So let’s bring some sample code.In WPF you can use multiple custom buttons: And on Windows Phone you’re limited to 2 buttons: To use CustomMessageBox, you need to get TCD.Controls from NuGet: And on Windows Phone 7.x you also need async support,…

C#

In-App Donations for Windows 8 Apps

Recently I wanted to offer my customers the opportunity to donate some money. No extra features, just a clean donation option. In-app purchases seemed to be the best option. The idea is to have a list of products which have a price and contain “donate” in their product ID (Fig. 1). In the app the list of products can be retrieved and shown when a donate button is tapped. If donations have been given can be checked by enumerating the existing licenses and looking for the “donate” term (Fig. 2). Reasonably simple right? Well the principle is simple, but in-app purchases are a bit tricky to develop, debug and get through certification. (It took me 7 submissions to get it right..) Those are the things that can result in certification failure: no internet connection -> exception store does not respond properly -> exception error message looks to much like a…

Root

DIY laser-shooting range

This is probably the first post on (hopefully) a series of ‘offtopic’ posts covering cool things I’ve done and consider worth sharing. It’s about a side project we did more than two years ago, while working on multitouch tables and IR technology. At first we incorporated a 780 nm infrared laser into a plastic MP5 soft-air toy gun. The laser perfectly fit into the barrel (Fig. 1a). Two 1.5 V batteries were placed inside the hold (Fig. 1b) and wired with a 25 V/470 µF, a switch and the laser (Fig. 2). The idea behind using a capacitor is to prevent continuous firing of the laser, most importantly as a security measure. The assembled MP5 laser gun can then be used to fire light bursts of a few milliseconds. To track the infrared light spots on a projection surface, we used a modified Hercules Classic Silver webcam. It’s a very cheap model (only 320×240 pixels) but it features a M12 lens with integrated IR filter which…

Hardware

2 months Surface RT – some thoughts from scientists perspective

There are countless reviews on the Surface RT already, but I consider myself some kind of non-average user, so I’d like to share my experience too. To understand my argument on the device, you should know: Who I am I am a undergraduate Biology student from Germany with some experience in WPF/Multitouch/Kinect/Windows Phone/Windows 8 development using C#. Most software I write is just for personal use, but I published some of my work (WP7, Win8) as well. Since the launch of the first public beta, I‘ve been using and developing for the Windows 8 platform, so I have a reasonable understanding of what’s going on. The Surface RT is my very first tablet computer. I’ve considered to get other devices (HP ElitePad, Samsung – ARM as well as x86), but decided that the Surface RT was the best fit. Everyday tasks Just like my HTC Mozart, I use the Surface…

C#

Localizing Enums (in a ComboBox)

Enums have many useful applications and are often used in CoboBoxes to let the user select things. In the code behind the enum values are often defined using more or less cryptic text, because neither spaces, special characters, or leading numbers can be used in enum values (for good reasons!). Therefor it is necessary to change the text to something more understandable (language-localized in some cases). One way to achieve this is to create the ComboBox items manually, but it’s much more comfortable to fill the ComboBox items directly with the enum values, because you can get/set the SelectedItem without converting it back and forth from/to the enum value. You can’t override the .ToString() method of the Enum type, so we have to come up with another solution. Just like any other control, the ComboBox uses a Template to create its items. We will replace the default template with one…

C#

Keyboard Dismissing ComboBox

In the last few days I came across a design issue with the touch keyboard on Windows 8. The keyboard dismissal logic (documented here) defines a list of controls which do not cause the keyboard to dismiss when they get focused. The purpose is to prevent the keyboard from opening and closing all the time when the user fills out a form and is likely to switch between keyboard-editable controls such as TextBox and other controls like AppBar, Checkbox, RadioButtons the ComboBox and some more. While that works fine with the other controls, ComboBox expands when interacted with and might get covered by the touch keyboard. And unfortunately you can’t change that behavior, or manually dismiss a deployed touch keyboard. (The user is in complete control over the keyboard.) While on the MSDN forums it was suggested to alter the layout such that the ComboBox is less likely to collide with the…

Bio

03 Der Needleman-Wunsch-Algorithmus

Einführung in die Bioinformatik Vorbereiten der Software Grundlagen der objektorientierten Programmierung Einfaches Codebeispiel – manipulieren eines strings Referenzieren einzelner Zeichen in einem string Generieren einer zufälligen Aminosäure-Sequenz Scoring von Alignments Prüfen auf Identität Bewerten von Mutationen – Substitution Matrix Bewerten eines Alignments Der Needleman-Wunsch-Algorithmus Die F-Matrix (abstrakt) Auswählen des Alignments (abstrakt) F-Matrix (Code) Auswählen des Alignments (Code) Die F-Matrix (abstrakt) Der Needleman-Wunsch-Algorithmus geht bei der Berechnung des idealen Alignements in zwei Schritten vor, um exponentiell skalierende Rechenzeit zu vermeiden. Zunächst wird die sogenannte F-Matrix berechnet, aus welcher anschließend das ideale Alignment zusammengesetzt wird. Zur Veranschaulichung alignen wir die Sequenzen GACFC und GCFHC. Jedes Feld in der Matrix (jede Zelle der Tabelle) beinhaltet einen Score. Diese Punktzahl ist jene, die auf dem Weg zur Berechnung des Feldes gesammelt wurde. Zur Berechnung einer Zelle sind immer die Felder links oben, oben und links notwendig: Unter den drei Feldern wird jenes gewählt, durch…

Bio

02 Scoring von Alignments

Einführung in die Bioinformatik Vorbereiten der Software Grundlagen der objektorientierten Programmierung Einfaches Codebeispiel – manipulieren eines strings Referenzieren einzelner Zeichen in einem string Generieren einer zufälligen Aminosäure-Sequenz Scoring von Alignments Prüfen auf Identität Bewerten von Mutationen – Substitution Matrix Bewerten eines Alignments Der Needleman-Wunsch-Algorithmus Die F-Matrix (abstrakt) Auswählen des Alignments (abstrakt) F-Matrix (Code) Auswählen des Alignments (Code) — coming soon Prüfen auf Identität Die einfachste Art, zwei Sequenzen miteinander zu vergleichen ist, zu prüfen, ob sie identisch sind. Dazu müssen jeweils die 0. Position der ersten Sequenz mit der 0. Position der zweiten, die 1. der ersten mit der 1. der zweiten und so weiter vergleichen werden: Der folgende Code macht genau das gleiche, verwendet dabei jedoch statt einer for-Schleife eine while-Schleife: Das Ergebnis einer solchen Prüfung kann offensichtlich nur zwei Werte annehmen: true oder false. Sowohl Mutationen, als auch Rasterverschiebungen führen bei dieser Methode zu einem ‘false‘: APFELSAFT APPELSAFT…

Bio

01 Einführung in die Bioinformatik

Gerade Biologen/Biotechnologen ohne Vorkenntnisse aus der Informatik, haben oft Probleme beim Verständnis grundlegender Verfahren der Bioinformatik. In einer kleinen Serie von Tutorials, werde ich versuchen, dieser Zielgruppe den Einstieg zu erleichtern. Die Codebeispiele folgen der Syntax der Programmiersprache C#, die abstrakten Verfahren können aber auf andere objektorientierte Programmiersprachen übertragen werden. (z.B. Java, C++, VisualBasic…) Die Theorie zu lesen ist zwar schön und gut, doch am Besten verstehen, was vor sich geht kann man, indem man es selbst macht. Ich empfehle jedem, die Codebeispiele nachzubauen, bzw. in echt nachzuvollziehen! Keine Sorge, du musst nicht alles selbst machen. Im folgenden findest du zunächst eine Anleitung, wie du dir die notwendige Software installierst. Anschließend kannst du ein bereits vorbereitetes Projekt herunterladen. Einführung in die Bioinformatik Vorbereiten der Software Grundlagen der objektorientierten Programmierung Einfaches Codebeispiel – manipulieren eines strings Referenzieren einzelner Zeichen in einem string Generieren einer zufälligen Aminosäure-Sequenz Scoring von Alignments Prüfen auf…