Using Gammon's LED Flasher library with a state machine?

I've been looking at Nick Gammon's LED_Flasher library, located on this page: http://gammon.com.au/blink

And I can't see if there's a way to make his "Flashing Sketch" work in a state machine. It seems that you can only set the parameters for the rate of flashing once per LED, and then turn the LED on or off. What I'd like to do is have two or three patterns of flashing per LED, and then switch to each set of patterns, depending on the state.

Is this possible, or do I need to look for another method?

If you don't call update() the led won't flash...

Thank you for that. I was clearly up too late and should’ve gone to bed!

I’ve got the LED Flasher demo code merged with the switchCase example. There’s something I don’t get about how this library works…there doesn’t seem to be any way to turn off the LEDs and then turn them back on. In the code below, case 0 causes all the LEDs to blink by updating them; case 1 shuts them off. However, when you switch from case 0 to case 1, some of the LEDs may stay lit, so I would like them to be off in case 1. The section of case 1 that’s commented out doesn’t work; instead, I added the digitalWrite commands for each LED to make sure they’re off. When the code goes back to case 0 then the LEDs blink as expected.

// Merges LED Flasher with Switch Case demo, using a 5K pot

// Example of flashing multiple LEDs at different rates without delays
// Author: Nick Gammon
// Date: 23 December 2012

#include <LedFlasher.h>

const int sensorMin = 0;      // sensor minimum, discovered through experiment
const int sensorMax = 800;    // sensor maximum, discovered through experiment

// set up some LEDs
LedFlasher floodLight (8, 200, 300);
LedFlasher shuttleBayDoors (9, 300, 600);
LedFlasher impulseEngine (10, 900, 100);
LedFlasher strobe (11, 500, 1000);
LedFlasher navigation (12, 1000, 2000);
LedFlasher torpedoes (3, 250, 500);

void setup() 
  {      
  floodLight.begin ();
  shuttleBayDoors.begin ();
  impulseEngine.begin ();
  strobe.begin ();
  navigation.begin ();
  torpedoes.begin ();
  
 // initialize serial communication:
  Serial.begin(9600); 
  }  // end of setup

void loop() {
   // read the sensor:
  int sensorReading = analogRead(A0);
  // map the sensor range to a range of four options:
  int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
  
  switch (range) {
  case 0:    // pot turned all the way off
    Serial.println("case 0");
  
  // update lights
  floodLight.update ();
  shuttleBayDoors.update ();
  impulseEngine.update ();
  strobe.update ();
  navigation.update ();
  torpedoes.update ();
     break;
  case 1:    // pot turned about 1/4 way
    Serial.println("case 1");
//  floodLight.off ();
//  shuttleBayDoors.off ();
//  impulseEngine.off ();
//  strobe.off ();
//  navigation.off ();
//  torpedoes.off ();    
  digitalWrite(8, LOW);    
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
  digitalWrite(12, LOW);
  digitalWrite(3, LOW);
    
    break;
  case 2:    // pot turned about 1/2 of the way
    Serial.println("case 2");
    break;
  case 3:    // pot turned about 3/4 of the way
    Serial.println("case 3");
    break;     
  
  // do other useful stuff here ...

     } 
  }  // end of loop

Set the digital output to the state that you need as you enter the next state, as you have done.

Or just add a method to the library to do the same thing (like reset() or something). This could allow you to reset timers as well..

UPDATE: I just check the library header file and the object has everything you need...

    void begin ();
    void update ();
    void on ();
    void off ();
    bool isOn () const;

Thanks Marco, I appreciate the effort even though it's not your library.