 static Joystick joystick(JOYSTICK_SW, JOYSTICK_X, JOYSTICK_Y);
 static Pano pano(horiz_motor, vert_motor, camera, HORIZ_EN, VERT_EN);
 
+// these variables are modified by the menu
+volatile int focal, horiz, vert, shutter, pre_shutter, running, orientation, aspect, shots, motors_enable;
+volatile int stop_running = false;
+
+void button_click(){
+    stop_running = true;
+}
+
 const int rows = 6;
 
 void setup() {

}

void loop() {
    int event = joystick.read();
    if (event && !running){
        handleEvent(event);
        Serial.println(focal);
        if (running){   // pano was just started via Menu
            display.clearDisplay();
            display.setCursor(0,0);
            display.print(F("Start "));
            display.display();
            pano.setFocalLength(focal);
            pano.setFOV(horiz, vert);
            pano.setShutter(shutter, pre_shutter);
            pano.start();
        }
    }
    if (running){ // pano is in process
        display.clearDisplay();
        display.setCursor(0,0);
        display.println(F("running\n"));

        display.print(F("vert = "));
        display.println(pano.vert_position);
        display.display();

        running = pano.next();
        if (stop_running || !running){
            detachInterrupt(digitalPinToInterrupt(JOYSTICK_SW));
            running = false;
            menu.sync();

            pano.end();

            display.println((stop_running) ? F("canceled") : F("finished"));
            display.display();
            delay(1000);

            menu.open();
            handleEvent(EVENT_NONE);
        }
