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.

83 lines
1.9KB

  1. #include "DS.hpp"
  2. namespace rack_plugin_SubmarineFree {
  3. struct OG_106 : DS_Module {
  4. static const int deviceCount = 6;
  5. enum ParamIds {
  6. NUM_PARAMS
  7. };
  8. enum InputIds {
  9. INPUT_A_1,
  10. INPUT_A_2,
  11. INPUT_A_3,
  12. INPUT_A_4,
  13. INPUT_A_5,
  14. INPUT_A_6,
  15. INPUT_B_1,
  16. INPUT_B_2,
  17. INPUT_B_3,
  18. INPUT_B_4,
  19. INPUT_B_5,
  20. INPUT_B_6,
  21. NUM_INPUTS
  22. };
  23. enum OutputIds {
  24. OUTPUT_1,
  25. OUTPUT_2,
  26. OUTPUT_3,
  27. OUTPUT_4,
  28. OUTPUT_5,
  29. OUTPUT_6,
  30. NUM_OUTPUTS
  31. };
  32. enum LightIds {
  33. NUM_LIGHTS
  34. };
  35. OG_106() : DS_Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {}
  36. void step() override;
  37. };
  38. void OG_106::step() {
  39. int setCount = 0;
  40. for (int i = 0; i < deviceCount; i++) {
  41. if (inputs[INPUT_A_1 + i].active)
  42. if (inputs[INPUT_A_1 + i].value > midpoint())
  43. setCount++;
  44. if (inputs[INPUT_B_1 + i].active)
  45. if (inputs[INPUT_B_1 + i].value > midpoint())
  46. setCount++;
  47. if (outputs[OUTPUT_1 + i].active) {
  48. outputs[OUTPUT_1 + i].value = (setCount > 0)?voltage1:voltage0;
  49. setCount = 0;
  50. }
  51. }
  52. }
  53. struct OG106 : ModuleWidget {
  54. OG106(OG_106 *module) : ModuleWidget(module) {
  55. setPanel(SVG::load(assetPlugin(plugin, "res/OG-106.svg")));
  56. for (int i = 0; i < OG_106::deviceCount; i++) {
  57. int offset = 58 * i;
  58. addInput(Port::create<sub_port_blue>(Vec(4,19 + offset), Port::INPUT, module, OG_106::INPUT_A_1 + i));
  59. addInput(Port::create<sub_port_blue>(Vec(4,47 + offset), Port::INPUT, module, OG_106::INPUT_B_1 + i));
  60. addOutput(Port::create<sub_port_blue>(Vec(62,33 + offset), Port::OUTPUT, module, OG_106::OUTPUT_1 + i));
  61. }
  62. }
  63. void appendContextMenu(Menu *menu) override {
  64. ((DS_Module *)module)->appendContextMenu(menu);
  65. }
  66. };
  67. } // namespace rack_plugin_SubmarineFree
  68. using namespace rack_plugin_SubmarineFree;
  69. RACK_PLUGIN_MODEL_INIT(SubmarineFree, OG106) {
  70. Model *modelOG106 = Model::create<OG_106, OG106>("SubmarineFree", "OG-106", "OG-106 OR Gates", LOGIC_TAG, MULTIPLE_TAG);
  71. return modelOG106;
  72. }