| 
					
				 | 
			
			
				@@ -0,0 +1,56 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#include <iostream> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#include <cstdlib> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#include "RtMidi.h" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#include "MidiMessage.h" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#include "Launchpad.h" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// Platform-dependent sleep routines. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#if defined(__WINDOWS_MM__) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  #include <windows.h> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds )  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#else // Unix variants 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  #include <unistd.h> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+#endif 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+struct DrawScreen : public LaunchpadScreen 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    virtual void keyPressed(unsigned char x, unsigned char y); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    void all(unsigned short a, unsigned short b) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        setColorAll(LaunchpadColor(a, b)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+Launchpad l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+DrawScreen s[8]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+void DrawScreen::keyPressed(unsigned char x, unsigned char y) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // std::cout << "(" << (int)x << ", " << (int)y << ")" << std::endl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(y == 8) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        std::cout << "switch to screen #" << (int)x << std::endl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        disable(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        s[x].enable(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        setColor(x, y, LaunchpadColor(3 - getColor(x, y).red, 3 - getColor(x, y).green)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+int main() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for(int i=0; i<8; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        s[i].setLaunchpad(l); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        s[i].all(i % 4, (int)((float)i/4)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    s[4].enable(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    while(true)  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SLEEP(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |