tttapa / MIDI_controller

This is a library for creating a MIDI controller using an Arduino or Teensy board.
GNU General Public License v3.0
404 stars 69 forks source link

Rotary encoder sends four signals instead of one. #76

Closed santta closed 5 years ago

santta commented 5 years ago

Description of the problem or question

Rotary encoder sends four signals instead of one. I tried to correct for different versions of the values ​​rotaryencoder.hpp (normal_encoder) and speedmultiplay (in the sketch). But the encoder still sends 4 signals at one turn. How can I fix this problem?

Steps to reproduce the problem

RotaryEncoder.hpp

Hardware

Mega2560

Software versions:

MIDI Controller library: 3.1.0 Arduino IDE: 1.8.4 Windows10 screen

Settings in the IDE

Full code

#define USE_ROTARY_ENCODER
#include <MIDI_Controller.h>

const int speedMultiply = 1;     // No change in speed of the encoder (number of steps is multiplied by 1)

// Create a new instance of the class 'RotaryEncoder', called 'enc', on pin 2 and 3, controller number 0x14, on channel1,
// no change in speed (speed is multiplied by 1), it's used as a jog wheel, and the sign mode is set to two's complement.

//Энкодер
RotaryEncoder encoder(8, 9, 0x14, 9, speedMultiply, NORMAL_ENCODER, TWOS_COMPLEMENT);

//Кнопка
Digital button0(A1, 0x12, 3, 127);

//Кнопка энк
Digital button1(A15, 0x13, 2, 127);

//Мультики
AnalogMultiplex multiplexer1(A0, { 2, 3, 4, 5 } );

//Кнопки мультика 1
Digital button2[] = {
  {multiplexer1.pin(2), 0x19, 10},
  {multiplexer1.pin(1), 0x18, 8},
};

void setup() {}

void loop() {
  // Refresh the encoder (check whether the position has changed since last time, if so, send the difference over MIDI)
  MIDI_Controller.refresh();
}

Steps taken to try to diagnose or solve the problem

? Tried the MIDI debug mode, used a MIDI monitor, ... ?

The goal of your project and aditional information

default

tttapa commented 5 years ago

Then you have a very strange encoder. Did you try using NORMAL_ENCODER * 4?

santta commented 5 years ago

Yes, I tried this value, but nothing has changed. There may be a problem in the encoder itself, I will try to connect another one.

santta commented 5 years ago

I installed another encoder (100% good) - four signals are sent again.

tttapa commented 5 years ago

I have no idea, to be honest. I tested it on an Arduino Leonardo and a Teensy with a typical rotary encoder, and all seems fine. If you look at the code, you'll see that changing the number of pulses per step has to have some effect on how many messages are sent.

Does changing the value to 1 result in 16 messages?

Could you try just the Encoder library, without the MIDI_Controller library? Just print the encoder position to the serial monitor.

santta commented 5 years ago

I have now determined that the problem with the arduino IDE is on my PC. For some reason, the program does not work correctly.