Single button controlling two ATtiny85s

I've spent most of the day trying to work this out and can't find exactly the information i'm after and i can't figure it out myself so hoping someone can give me a hand.

I'm using two ATtiny85s currently which are part of a larger circuit. tiny #1 is a strange noise maker, tiny #2 is controlling a relay which switches in/out tiny #1 into a larger guitar effect. It's all working well but i started thinking that it would be cool if the footswitch connected to tiny #2 which bypasses/unbypasses could also change the 'mode' of tiny #1 which is making the noise. So that the footswitch would bypass/unbypass tiny #2 with a short press (as it does currently), but select between two modes in tiny #1 when there's a long press.

So i need to change the code for tiny #2 so that it toggles on button release rather than press, and it also needs to ignore long presses so that it won't bypass tiny #1 when you're trying to change the mode.

Then i need to have tiny #1 read the same footswitch as tiny #2 and change between two different pieces of code (noise makers) only when it detects a long press. So i guess tiny #1 only deals with short presses and tiny #2 only deals with long presses.

This is an attempt at the code for tiny #2 largely based on an arduinogetstarted tutorial.

#include <ezButton.h>
int buttonPin = 3;
int relayPin = 0;
const int SHORT_PRESS_TIME = 1000; // 1000 milliseconds
const int LONG_PRESS_TIME  = 1000; // 1000 milliseconds

ezButton button(buttonPin);  // create ezButton object that attach to buttonPin;

int relayState = LOW;
unsigned long pressedTime  = 0;
unsigned long releasedTime = 0;
bool isPressing = false;
bool isLongDetected = false;

void setup() {
  button.setDebounceTime(50); // set debounce time to 50 milliseconds
  pinMode (buttonPin, INPUT_PULLUP);
  pinMode (relayPin, OUTPUT);
  digitalWrite (relayPin, relayState);
}

void loop() {
  button.loop(); // MUST call the loop() function first


  if (button.isPressed()) {
    pressedTime = millis();
    isPressing = true;
    isLongDetected = false;
  }

  if (button.isReleased()) {
    isPressing = false;
    releasedTime = millis();

    long pressDuration = releasedTime - pressedTime;

    if ( pressDuration < SHORT_PRESS_TIME ) {
      relayState = !relayState;
      digitalWrite (relayPin, relayState);


    }

    if (isPressing == true && isLongDetected == false) {
      long pressDuration = millis() - pressedTime;

      if ( pressDuration > LONG_PRESS_TIME ) {

        isLongDetected = true;
      }
    }
  }

I'm not sure that's the best way to go about it but that's where i'm at.
I'm really stumped on how to use long presses only to toggle between modes on tiny #1. I thought about using the same approach here but i can't think how to select between two different bits of code.

Sorry for the info-dump! Any help would be greatly appreciated

Patrick

I feel like i may be getting closer here but still not working correctly. This is just for the part that needs to detect only the long presses and switch between two pieces of code. I'm just using LEDs to try and see if it's working. LED 2 does flash after 3 seconds but LED 1 lights straight away and only turns off when LED 2 has flashed. Then when i press the button again LED 2 flashes straight away then stops when LED 1 turns on. Something is amiss

boolean mode1 = true;

const int BUTTON_PIN = 3; // the number of the pushbutton pin
const int LONG_PRESS_TIME  = 3000; // 1000 milliseconds
int LED1 = 0;
int LED2 = 1;
int LED1State;


// Variables will change:
int lastState = LOW;  // the previous state from the input pin
int currentState;     // the current reading from the input pin
unsigned long pressedTime  = 0;
bool isPressing = false;
bool isLongDetected = false;

void setup() {

  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode (LED1, OUTPUT);
  digitalWrite (LED1, LOW);
  pinMode (LED2, OUTPUT);
  digitalWrite (LED2, LOW);
}

void loop() {
  // read the state of the switch/button:
  currentState = digitalRead(BUTTON_PIN);

  if (lastState == HIGH && currentState == LOW) {       // button is pressed
    pressedTime = millis();
    isPressing = true;
    isLongDetected = false;
  } else if (lastState == LOW && currentState == HIGH) { // button is released
    isPressing = false;
  }

  if (isPressing == true && isLongDetected == false) {
    long pressDuration = millis() - pressedTime;

    if ( pressDuration > LONG_PRESS_TIME ) {
      mode1 = !mode1;
      isLongDetected = true;
    }
    if (mode1) {
      LED1State = !LED1State;
      digitalWrite (LED1, LED1State);
    }
    else {
      digitalWrite (LED2, HIGH);
      delay (100);
      digitalWrite (LED2, LOW);
      delay (100);
      digitalWrite (LED2, HIGH);
      delay (100);
      digitalWrite (LED2, LOW);
    }
  }
  lastState = currentState;
}