You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
3.1KB

  1. // Copyright 2014 Olivier Gillet.
  2. //
  3. // Author: Olivier Gillet (ol.gillet@gmail.com)
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. // See http://creativecommons.org/licenses/MIT/ for more information.
  24. //
  25. // -----------------------------------------------------------------------------
  26. //
  27. // User interface
  28. #ifndef CLOUDS_UI_H_
  29. #define CLOUDS_UI_H_
  30. #include "stmlib/stmlib.h"
  31. #include "stmlib/ui/event_queue.h"
  32. #include "clouds/drivers/leds.h"
  33. #include "clouds/drivers/switches.h"
  34. namespace clouds {
  35. enum UiMode {
  36. UI_MODE_VU_METER,
  37. UI_MODE_BLEND_METER,
  38. UI_MODE_QUALITY,
  39. UI_MODE_BLENDING,
  40. UI_MODE_PLAYBACK_MODE,
  41. UI_MODE_LOAD,
  42. UI_MODE_SAVE,
  43. UI_MODE_PANIC,
  44. UI_MODE_CALIBRATION_1,
  45. UI_MODE_CALIBRATION_2,
  46. UI_MODE_SAVING,
  47. UI_MODE_SPLASH,
  48. UI_MODE_LAST
  49. };
  50. enum SwitchIndex {
  51. SWITCH_MODE,
  52. SWITCH_WRITE,
  53. SWITCH_FREEZE
  54. };
  55. enum FactoryTestingCommand {
  56. FACTORY_TESTING_READ_POT,
  57. FACTORY_TESTING_READ_CV,
  58. FACTORY_TESTING_READ_GATE,
  59. FACTORY_TESTING_SET_BYPASS,
  60. FACTORY_TESTING_CALIBRATE
  61. };
  62. class GranularProcessor;
  63. class CvScaler;
  64. class Meter;
  65. class Settings;
  66. class Ui {
  67. public:
  68. Ui() { }
  69. ~Ui() { }
  70. void Init(
  71. Settings* settings,
  72. CvScaler* cv_scaler,
  73. GranularProcessor* processor,
  74. Meter* meter);
  75. void Poll();
  76. void DoEvents();
  77. void FlushEvents();
  78. void Panic() {
  79. mode_ = UI_MODE_PANIC;
  80. }
  81. uint8_t HandleFactoryTestingRequest(uint8_t command);
  82. private:
  83. void OnSwitchPressed(const stmlib::Event& e);
  84. void OnSwitchReleased(const stmlib::Event& e);
  85. void OnSecretHandshake();
  86. void CalibrateC1();
  87. void CalibrateC3();
  88. void SaveState();
  89. void PaintLeds();
  90. void LoadSampleMemory();
  91. void SaveSampleMemory();
  92. stmlib::EventQueue<16> queue_;
  93. Settings* settings_;
  94. CvScaler* cv_scaler_;
  95. Leds leds_;
  96. Switches switches_;
  97. uint32_t press_time_[kNumSwitches];
  98. uint32_t long_press_time_[kNumSwitches];
  99. UiMode mode_;
  100. GranularProcessor* processor_;
  101. Meter* meter_;
  102. uint8_t load_save_location_;
  103. DISALLOW_COPY_AND_ASSIGN(Ui);
  104. };
  105. } // namespace clouds
  106. #endif // CLOUDS_UI_H_