pouët.net

Go to bottom

Frozen Nebula

--------------------------------------------------------------------------------
  Frozen Nebula
  Lovebyte 2024
  Mecrisp

  Matthias Koch
  m-atthias@users.sf.net
  http://mecrisp.sourceforge.net/
--------------------------------------------------------------------------------

First light of telescope, running in 256 bytes on a RISC-V microcontroller,
using two DAC channels for vector graphics on an analog oscilloscope.

Frozen Nebula is designed for GD32VF103 microcontrollers and
draws vector graphics on an analog oscilloscope in XY mode
connected to

   GND and the two DAC channels on pins
   PA4 (vertical) and
   PA5 (horizontal).

--------------------------------------------------------------------------------
  Design ideas:
--------------------------------------------------------------------------------

The patterns are drawn using an iterated function system using five rules
which are generated with pseudo random numbers, using fixed probabilities.

The idea behind IFS is:

Transform the current coordinates given a rotation and a translation
which is given by six parameters a to f as in

x' = a*x + b*y  + e
y' = c*x + d*y  + f

One rule alone would result in a dot, a line, a spiral or a circle.
But having multiple rules, and applying these in random order with
different probabilities results in very nice graphics.

You probably know famous IFS shapes like the Barnsley Fern!


At the beginning, Frozen Nebula starts with two rules sets, both cleared.
One is used for curent drawing, the other is the destination rule set to reach.

For updating the current rule set after a selected amount of pixels being drawn,
parameters of both rule sets are compared and the sign function (-1, 0, 1) of
the difference between current and destination is added to current.
This results in a smooth animation and "flowing" of the IFS drawing.

Once in a while, one of the parameters in the destination rule set is selected
and updated using the xorshift pseudo random number generator.

Internally, the parameters are stored as signed fixpoint numbers with 15
fractional bits in order to fit multiplication with sign into 32 bit registers.

--------------------------------------------------------------------------------
  How to run:
--------------------------------------------------------------------------------

If you have connected your

Longan Nano board to
             a USB-serial cable with 3.3V logic levels

3V3 or 5V -- VCC (measure the voltage present here)
R0        -- TXD
T0        -- RXD
GND       -- GND

you can flash it if you first

* Press and hold BOOT0 button
* Press and release Reset button
* Release BOOT0 button

and then execute

stm32loader -e -w -v -p /dev/ttyUSB0 frozen-nebula.bin

on your host machine.

Press and release Reset button to start demo.

--------------------------------------------------------------------------------
Go to top