Categories
Academia Programming

Randomness – C# mini tutorial

Note: This was some teaching material I used on the degree and professional courses to explain a little about using randomness- why and how -in your applications. The courses were based around C#, but are easily adapted to many other languages, including Java and Javascript. Just ask for a translation! Because they were slides used as part of an in-class tutorial, some parts may raise questions as much as answer them…
Note 2: A Visual Studio project is available with some starting code, and some questions (in the form of comments) for you to try to answer, available here: rand.zip

Randomness

  • What is randomness?
  • Where can we use it in our programs?
  • How can we acquire random values?
  • How can we make some values more likely than others (weighting/non-uniform distribution)?
Categories
Javascript Web technologies

Clouds – animation example

Here’s a demonstrator I coded up for one of our web development classes, to illustrate some animation techniques.

Give it a try, put some clouds in your browser to while away your tea break.
Note how the clouds towards the top of the screen are larger, fewer in number, and faster moving than at the bottom of the screen, roughly simulating the wider field of view nearer the horizon. There’s a CSS gradient to try to sell the illusion too. This distribution is controlled by feeding output from the pseudorandom number generator into a function, giving a skewed distribution where larger numbers are more common than smaller numbers.
Controls are at the foot of the page. They are faded in and out using the CSS transition property, whilst the cloud animations are done using the velocity.js library. I hand-drew the clouds (PNG format, for the variable transparency needed for compositing). I apologise in advance for some of the iffier ones.

Categories
Electronics Programming

Boring Deadly Urgent Machine (Game) :: Part 1 :: The Spec

Some machines I like because of their sleek, minimalist exteriors, modernist or even brutalist megaliths of silicon, or brass.
But I love me some blinkenlights. If it’s got switches galore, laden with quadrant faders and vernier dials, festooned with vu meters, pulsing with neon lamps or LEDs, I’m going to pay that some serious attention. Throw in some industrial interconnects, be they ubiquitous BNCs, or some exotic mixed signal sockets, anything heavy duty, very very high frequency, lots of pins or fibre optic, fastened with clips, twist-locks, clamps or thumb screws….ahem.

Categories
Javascript Programming Web technologies

Why isn't SVG more widely used?

I was first introduced to Scalable Vector Graphics (SVG) through Inkscape, the excellent free vector graphics drawing application. It’s available for Windows, Linux and OS X, so please give it a try. You can get it as a portable app, runnable on a Windows machine from a USB memory stick, incredibly handy to have when working on other people’s machines (so if you’ve never visited PortableApps.com, maybe now’s the time!).

Categories
Microcontrollers Programming

Atollic TrueStudio and STM32Cube

TL;DR version of getting Atollic TrueStudio and STM32Cube working
I have an ST Nucleo-F411RE development board that I’d like to use for a project. It’s using a microcontroller from the same STM32 family as I’ve tried out before, but packaged onto a board with Arduino (Uno)-pattern headers, as well as the full pin breakout. I’m not sure how useful that is for my project yet, but I wanted to give it a test drive.
Most platforms have multiple development options.
The Arduino biosphere has various hardware targets, but with a common IDE. But the Arduino boards are all based on microcontrollers from Atmel (now part of Microchip, the company that also makes PIC microcontrollers). So you aren’t limited to the Arduino IDE, and if you’d like to, you can use all sorts of development toolchains and IDEs.