Commits

Gordon McGregor committed 25d192f

added external status LED

Comments (0)

Files changed (4)

 
 const int TOGGLE = 1;
 const int IMMEDIATE = 0;
-
+const int LED_OFFSET = 2;
 const int MAX_BANKS = 2;
 const int MAX_SWITCHES = 4;
 const int MAX_STATES = 2;
 
 enum {OFF, INFO, DEBUG, TRACE} debug_levels;
 
-const int DEBUG_LEVEL = OFF;
+const int DEBUG_LEVEL = INFO;
 
 int previous_index, current_bank;
 
   memset(&banks, 0, sizeof(banks_t));
   setup_default_bank();
   
+  for (int i = LED_OFFSET; i < LED_OFFSET + MAX_SWITCHES + 1; i++) {
+    pinMode(i, OUTPUT); 
+  }
   debug("Debug MIDI alive",0, INFO);
   
 }
     }
   
   previous_index = index; // update the index variables at the end, so we can know which was changed through the processing stages
+  display_banks_status();
   } // end previos != index loop
   
   delay(100);// cheap debounce - probably needs to change
+
+
 
 // Flash an LED attached to the pin at the given delay
 void flash_led(int pin, int time_delay){
 void fast_flash(int pin) {
   flash_led(pin, 50);
 }
-  
+
+
+void display_banks_status() {
+
+  digitalWrite(LED_OFFSET, (current_bank == 0)?LOW: HIGH);
+  debug("LED bank", current_bank, INFO);
+
+  for (int s = 0 ; s < MAX_SWITCHES; s++) {
+    if(banks.bank[current_bank].switches[s].state == STATE0) {
+      digitalWrite(s + LED_OFFSET+1, LOW);
+      debug("LED LOW", s+LED_OFFSET+1, INFO);
+    }
+    else {
+      digitalWrite(s + LED_OFFSET + 1, HIGH);
+      debug("LED HIGH", s+LED_OFFSET+1, INFO);
+    }      
+  }
+}
+
 
-int switch_levels[10] = {561, 459, 384, 261, 159, 641, 510, 416, 277, 167};
+int switch_levels[10] = {561, 459, 384, 261, 163, 641, 510, 416, 277, 169};
 
 
 int find_closest_level_index(int sample) {