Skip to content

Commit

Permalink
Merge pull request #657 from ohmtech-rdi/erbui-encoder-leading-a-or-b
Browse files Browse the repository at this point in the history
Add leading type option to encoder
  • Loading branch information
ohmtech-rdi authored Jan 29, 2024
2 parents 9208c63 + 076972a commit 98cdb21
Showing 11 changed files with 191 additions and 31 deletions.
8 changes: 8 additions & 0 deletions build-system/erbui/generators/front_pcb/DiyManual.erbui
Original file line number Diff line number Diff line change
@@ -76,48 +76,56 @@ manufacturer DiyManual {
style rogan.1s, rogan, 1s, small, skirt, d_shaft
parts bourns.pec11rn.manual, rogan.1s
arg simulator_class "erb::BournsPec11R <erb::Rogan1S, false>"
arg leading_type "erb::EncoderLeadingType::A"
}

control Encoder {
style rogan.1s.black, rogan, 1s, black, small, skirt, d_shaft
parts bourns.pec11rn.manual, rogan.1s.black
arg simulator_class "erb::BournsPec11R <erb::Rogan1SBlack, false>"
arg leading_type "erb::EncoderLeadingType::A"
}

control Encoder {
style rogan.2s.black, rogan, 2s, black, medium, skirt, d_shaft
parts bourns.pec11rn.manual, rogan.2s.black
arg simulator_class "erb::BournsPec11R <erb::Rogan2SBlack, false>"
arg leading_type "erb::EncoderLeadingType::A"
}

control Encoder {
style rogan.3s, rogan, 3s, large, skirt, d_shaft
parts bourns.pec11rn.manual, rogan.3s
arg simulator_class "erb::BournsPec11R <erb::Rogan3S, false>"
arg leading_type "erb::EncoderLeadingType::A"
}

control EncoderButton {
style rogan.1s, rogan, 1s, small, skirt, d_shaft
parts bourns.pec11rs.manual, rogan.1s
arg simulator_class "erb::BournsPec11R <erb::Rogan1S, true>"
arg leading_type "erb::EncoderLeadingType::A"
}

control EncoderButton {
style rogan.1s.black, rogan, 1s, black, small, skirt, d_shaft
parts bourns.pec11rs.manual, rogan.1s.black
arg simulator_class "erb::BournsPec11R <erb::Rogan1SBlack, true>"
arg leading_type "erb::EncoderLeadingType::A"
}

control EncoderButton {
style rogan.2s.black, rogan, 2s, black, medium, skirt, d_shaft
parts bourns.pec11rs.manual, rogan.2s.black
arg simulator_class "erb::BournsPec11R <erb::Rogan2SBlack, true>"
arg leading_type "erb::EncoderLeadingType::A"
}

control EncoderButton {
style rogan.3s, rogan, 3s, large, skirt, d_shaft
parts bourns.pec11rs.manual, rogan.3s
arg simulator_class "erb::BournsPec11R <erb::Rogan3S, true>"
arg leading_type "erb::EncoderLeadingType::A"
}

control Led {
8 changes: 8 additions & 0 deletions build-system/erbui/generators/front_pcb/DiyWire.erbui
Original file line number Diff line number Diff line change
@@ -68,48 +68,56 @@ manufacturer DiyWire {
style rogan.1s, rogan, 1s, small, skirt, d_shaft
parts bourns.pec11rn.wire, rogan.1s
arg simulator_class "erb::BournsPec11R <erb::Rogan1S, false>"
arg leading_type "erb::EncoderLeadingType::A"
}

control Encoder {
style rogan.1s.black, rogan, 1s, black, small, skirt, d_shaft
parts bourns.pec11rn.wire, rogan.1s.black
arg simulator_class "erb::BournsPec11R <erb::Rogan1SBlack, false>"
arg leading_type "erb::EncoderLeadingType::A"
}

control Encoder {
style rogan.2s.black, rogan, 2s, black, medium, skirt, d_shaft
parts bourns.pec11rn.wire, rogan.2s.black
arg simulator_class "erb::BournsPec11R <erb::Rogan2SBlack, false>"
arg leading_type "erb::EncoderLeadingType::A"
}

control Encoder {
style rogan.3s, rogan, 3s, large, skirt, d_shaft
parts bourns.pec11rn.wire, rogan.3s
arg simulator_class "erb::BournsPec11R <erb::Rogan3S, false>"
arg leading_type "erb::EncoderLeadingType::A"
}

control EncoderButton {
style rogan.1s, rogan, 1s, small, skirt, d_shaft
parts bourns.pec11rs.wire, rogan.1s
arg simulator_class "erb::BournsPec11R <erb::Rogan1S, true>"
arg leading_type "erb::EncoderLeadingType::A"
}

control EncoderButton {
style rogan.1s.black, rogan, 1s, black, small, skirt, d_shaft
parts bourns.pec11rs.wire, rogan.1s.black
arg simulator_class "erb::BournsPec11R <erb::Rogan1SBlack, true>"
arg leading_type "erb::EncoderLeadingType::A"
}

control EncoderButton {
style rogan.2s.black, rogan, 2s, black, medium, skirt, d_shaft
parts bourns.pec11rs.wire, rogan.2s.black
arg simulator_class "erb::BournsPec11R <erb::Rogan2SBlack, true>"
arg leading_type "erb::EncoderLeadingType::A"
}

control EncoderButton {
style rogan.3s, rogan, 3s, large, skirt, d_shaft
parts bourns.pec11rs.wire, rogan.3s
arg simulator_class "erb::BournsPec11R <erb::Rogan3S, true>"
arg leading_type "erb::EncoderLeadingType::A"
}

control Led {
4 changes: 4 additions & 0 deletions build-system/erbui/generators/ui/code.py
Original file line number Diff line number Diff line change
@@ -97,6 +97,10 @@ def generate_control (self, module, control):

control_type = '%s <%s>' % (base_control, range)

elif control.kind in ['Encoder', 'EncoderButton']:
leading_type = control.args ['leading_type']
control_type = '%s <%s>' % (control.kind, leading_type)

elif control.kind in ['GateIn', 'AudioIn']:
if control.normalling_from is not None and control.normalling_from.is_nothing:
control_type = '%sJackDetection' % control.kind
11 changes: 11 additions & 0 deletions include/erb/Encoder.h
Original file line number Diff line number Diff line change
@@ -22,6 +22,13 @@ namespace erb



enum class EncoderLeadingType
{
A, B
};


template <EncoderLeadingType LeadingType>
class Encoder
{

@@ -85,4 +92,8 @@ class Encoder



#include "erb/Encoder.hpp"



/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
35 changes: 27 additions & 8 deletions src/Encoder.cpp → include/erb/Encoder.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/*****************************************************************************
Encoder.cpp
Encoder.hpp
Copyright (c) 2020 Raphael DINGE
*Tab=3***********************************************************************/



/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#pragma once


#include "erb/Encoder.h"

/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/



@@ -26,7 +28,8 @@ Name : ctor
==============================================================================
*/

Encoder::Encoder (const uint8_t & data_a, const uint8_t & data_b)
template <EncoderLeadingType LeadingType>
Encoder <LeadingType>::Encoder (const uint8_t & data_a, const uint8_t & data_b)
: impl_data_a (data_a)
, impl_data_b (data_b)
{
@@ -40,7 +43,8 @@ Name : operator int
==============================================================================
*/

Encoder::operator int () const
template <EncoderLeadingType LeadingType>
Encoder <LeadingType>::operator int () const
{
return _val;
}
@@ -55,18 +59,33 @@ Name : impl_preprocess
==============================================================================
*/

void Encoder::impl_preprocess ()
template <EncoderLeadingType LeadingType>
void Encoder <LeadingType>::impl_preprocess ()
{
_state_a = uint8_t (_state_a << 1) | (impl_data_a != 0);
_state_b = uint8_t (_state_b << 1) | (impl_data_b != 0);

if ((_state_a & 0x03) == 0x02 && (_state_b & 0x03) == 0x00)
{
_val = -1;
if constexpr (LeadingType == EncoderLeadingType::A)
{
_val = -1;
}
else
{
_val = 1;
}
}
else if ((_state_b & 0x03) == 0x02 && (_state_a & 0x03) == 0x00)
{
_val = 1;
if constexpr (LeadingType == EncoderLeadingType::A)
{
_val = 1;
}
else
{
_val = -1;
}
}
else
{
12 changes: 9 additions & 3 deletions include/erb/EncoderButton.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ namespace erb



template <EncoderLeadingType LeadingType>
class EncoderButton
{

@@ -37,7 +38,8 @@ class EncoderButton
EncoderButton (const uint8_t & data_a, const uint8_t & data_b, const uint8_t & data_sw);
virtual ~EncoderButton () = default;

Encoder encoder;
Encoder <LeadingType>
encoder;
Button button;


@@ -66,8 +68,8 @@ class EncoderButton
private:
EncoderButton (const EncoderButton & rhs) = delete;
EncoderButton (EncoderButton && rhs) = delete;
EncoderButton & operator = (const EncoderButton & rhs) = delete;
EncoderButton & operator = (EncoderButton && rhs) = delete;
EncoderButton &operator = (const EncoderButton & rhs) = delete;
EncoderButton &operator = (EncoderButton && rhs) = delete;
bool operator == (const EncoderButton & rhs) const = delete;
bool operator != (const EncoderButton & rhs) const = delete;

@@ -81,4 +83,8 @@ class EncoderButton



#include "erb/EncoderButton.hpp"



/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
17 changes: 11 additions & 6 deletions src/EncoderButton.cpp → include/erb/EncoderButton.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/*****************************************************************************
EncoderButton.cpp
EncoderButton.hpp
Copyright (c) 2020 Raphael DINGE
*Tab=3***********************************************************************/



/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#pragma once


#include "erb/EncoderButton.h"

/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/



@@ -26,7 +28,8 @@ Name : ctor
==============================================================================
*/

EncoderButton::EncoderButton (const uint8_t & data_a, const uint8_t & data_b, const uint8_t & data_sw)
template <EncoderLeadingType LeadingType>
EncoderButton <LeadingType>::EncoderButton (const uint8_t & data_a, const uint8_t & data_b, const uint8_t & data_sw)
: encoder (data_a, data_b)
, button (data_sw)
{
@@ -42,7 +45,8 @@ Name : impl_preprocess
==============================================================================
*/

void EncoderButton::impl_preprocess ()
template <EncoderLeadingType LeadingType>
void EncoderButton <LeadingType>::impl_preprocess ()
{
encoder.impl_preprocess ();
button.impl_preprocess ();
@@ -56,7 +60,8 @@ Name : impl_postprocess
==============================================================================
*/

void EncoderButton::impl_postprocess ()
template <EncoderLeadingType LeadingType>
void EncoderButton <LeadingType>::impl_postprocess ()
{
encoder.impl_postprocess ();
button.impl_postprocess ();
4 changes: 2 additions & 2 deletions include/erb/erb-src.gypi
Original file line number Diff line number Diff line change
@@ -40,7 +40,9 @@
'Display.h',
'Display.hpp',
'Encoder.h',
'Encoder.hpp',
'EncoderButton.h',
'EncoderButton.hpp',
'FloatRange.h',
'GateIn.h',
'GateIn.hpp',
@@ -88,8 +90,6 @@
'detail/fnc.hpp',

'../../src/Button.cpp',
'../../src/Encoder.cpp',
'../../src/EncoderButton.cpp',
'../../src/GateOut.cpp',

'../../src/detail/Animation.cpp',
31 changes: 27 additions & 4 deletions include/erb/vcvrack/BoardGeneric.h
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ class BoardGeneric
bool bipolar;
};

struct BindingEncoder
struct BindingEncoderLeadingA
{
void process ();
uint8_t * data_a_ptr;
@@ -174,7 +174,28 @@ class BoardGeneric
param_ptr;
};

struct BindingEncoderButton
struct BindingEncoderLeadingB
{
void process ();
uint8_t * data_a_ptr;
uint8_t * data_b_ptr;
rack::engine::Param *
param_ptr;
};

struct BindingEncoderButtonLeadingA
{
void process ();
uint8_t * data_a_ptr;
uint8_t * data_b_ptr;
uint8_t * data_sw_ptr;
rack::engine::Param *
param_ab_ptr;
rack::engine::Param *
param_sw_ptr;
};

struct BindingEncoderButtonLeadingB
{
void process ();
uint8_t * data_a_ptr;
@@ -317,8 +338,10 @@ class BoardGeneric
BindingButton,
BindingCvIn,
BindingCvInJackDetection,
BindingEncoder,
BindingEncoderButton,
BindingEncoderLeadingA,
BindingEncoderLeadingB,
BindingEncoderButtonLeadingA,
BindingEncoderButtonLeadingB,
BindingGateIn,
BindingGateInJackDetection,
BindingPot,
Loading
Oops, something went wrong.

0 comments on commit 98cdb21

Please sign in to comment.