eeTools / SimulIDE-dev

SimulIDE Circuit Simulator.
https://simulide.com
GNU Affero General Public License v3.0
80 stars 20 forks source link

Numeric value written in the code with KY040 #3

Closed ThomasLeMezo closed 6 months ago

ThomasLeMezo commented 6 months ago

https://github.com/Arcachofo/SimulIDE-dev/blob/f8a3f4ec82bacd54a4febdecfa7985d716f33028/src/components/micro/ky040.cpp#L153 In the case where the number of ticks is not 20, it might give wrong results? we should have

m_dial->maximum()/m_steps - 1

instead of 19?

Arcachofo commented 6 months ago

I don't think so. 20 dial steps is the size of one encoder cycle, when it is < 10 output is low otherwise output is high. Note that m_dial->maximum() = steps*20

ThomasLeMezo commented 6 months ago

Ok, I see, you're right. You also set the maximum value of the dial inside the setSteps function.

By the way, it would be interesting to be able to connect the encoder to a motor.

Arcachofo commented 6 months ago

By the way, it would be interesting to be able to connect the encoder to a motor.

Yes, that was planned, indeed I had the idea that it was already done. Done at d69d2802c4dabea70ec83e968f7c633a0ea49e21 It works by linking a motor to an encoder: Right-click in the motor and choose "Link to Component", then click in the encoder. To finish linking click in any empty place.