launchpad-screen.cpp 883 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <iostream>
  2. #include "LaunchpadScreen.h"
  3. struct DrawScreen : public midi::LaunchpadScreen
  4. {
  5. virtual void keyPressed(unsigned char x, unsigned char y);
  6. void all(unsigned short a, unsigned short b)
  7. {
  8. setColorAll(midi::LaunchpadColor(a, b));
  9. }
  10. };
  11. midi::Launchpad l;
  12. DrawScreen s[8];
  13. void DrawScreen::keyPressed(unsigned char x, unsigned char y)
  14. {
  15. // std::cout << "(" << (int)x << ", " << (int)y << ")" << std::endl;
  16. if(y == 8) {
  17. std::cout << "switch to screen #" << (int)x << std::endl;
  18. disable();
  19. s[x].enable();
  20. } else {
  21. setColor(x, y, midi::LaunchpadColor(3 - getColor(x, y).red, 3 - getColor(x, y).green));
  22. }
  23. }
  24. int main()
  25. {
  26. for(int i=0; i<8; i++) {
  27. s[i].setLaunchpad(l);
  28. s[i].all(i % 4, (int)((float)i/4));
  29. }
  30. s[4].enable();
  31. std::cin.ignore();
  32. return 0;
  33. }