In a previous post, Vlaya and I showed how the flash frequency can lead to many nice effects.

## A question of angles

After a long reflection, we realized that for many reasons the best way to describe the flashes is not by their frequency, but instead by the absolute angular position of the Phyllo when each flash occurs.

Therefore, each image description will contain the colors frames and a pre-computed absolute angle (which may be procedurally computed or included in a stored animation).

These absolute angular positions are not to be confused with the relative angular rotation of the motor between two consecutive flashes. This is also relevant, as in most cases we want a flash to occur with a constant (relative) angular spacing between two flashes.

However it is not satisfactory to describe the flashes by their angular spacing, as even a small numerical imprecision in the relative angle will lead to an increasing angular drift down the line. This is critical for animations shared between several Phyllos where we might need to light patterns in a specific direction for a long period, making angular precision paramount.

## Two critical examples

Let’s start by looking at two important flashing effects. Covering these actually leads us directly to covering all the cases:

### Vertically aging petals

In the previous post about Phyllo effects, we evoked the case where the petals simply age in a vertical line. We want to be able to have a stream of petals aging in the same direction.

By construction of the Phyllo, the matching angular spacing between two flashes is the golden angle, which is as irrational as they come.

The angle being irrational, there will necessarily be some numerical imprecision. But it is actually enough to use a good rational approximation: over the short time it takes for a petal to age from top to bottom, the horizontal drift will be unnoticeable.

### Non-rotating spirals

In the case of the non-rotating spirals, the absolute angle can be expressed as a simple fraction ( k times the ratio of two Fibonacci numbers for the kth absolute angle).

This allows us to compute the absolute angles without any imprecision (by storing the numerator and the denominator of the fraction), which is good because in this case an angular drift would soon become noticeable (the supposed non-rotating spiral would visibly start to rotate).

### And in the other cases ?

To cover the two previous situations, it turns out to be enough to be able to flash at rational absolute angles. It is also sufficient for the case of rotating spirals – simply choose a *different* rational angle and the apparent speed will be non-zero.

## What next ?

All we need now is a way to actually generate a flash given a rational absolute angle. The important thing is not to avoid all imprecision in the timing of the flash, which is impossible, but rather that this imprecision only result in a punctual error and *not* an error that increases over time.

We’ve already found a way to do this thanks to the versatility of STM32 Timers, and we’ll explain it in an upcoming article.

Stay tuned 🙂