    treadle_sequence[position] = UNUSED_SEQ; // new last row is "unused"
 }
 
-void program_treadle_sequence(void) {
+enum events  program_treadle_sequence(void) {
+   // program the treadle sequence, and return the button push that caused us to stop
    int sequence_pos_on_top = 0;
    int sequence_pos = 0, treadle_num = 0;
    bool show_title = true;
    bool row_select = false;  // are we selecting the whole row by having the cursor on the far left?
+   bool did_something = false;
    enum events event;
    H_LED(H_ENC_GREEN);
    V_LED(V_ENC_RED);

      lcd.setCursor(row_select ? 0 : treadle_num + 3,
                    sequence_pos - sequence_pos_on_top + (show_title ? 1 : 0));
      if (row_select) {
         lcd.noCursor();
         lcd.blink(); }
      else {
         lcd.noBlink();
         lcd.cursor(); }
      do {
         event = check_event(); }
      while (event == eNone);

// The current implementation assumes all files are padded to the fixed maximum size.
// All stored files will break if NUM_SHAFTS, NUM_TREADLES, or MAX_SEQUENCE is changed!

//    other global variables

LiquidCrystalFast lcd (LCD_RS, LCD_RW, LCD_ENB, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
Encoder H_ENC (H_ENC_A, H_ENC_B);
