37 if (renderingStyle() != HORIZONTAL) {
42 paging = splitMenuItemsByPages();
43 if (paging.selectedItemPositionOnPage != lastSelectedItemPosition) {
44 lastSelectedItemPosition = paging.selectedItemPositionOnPage;
49 for (
const auto item : items) {
50 item->readCurrentValue();
52 const int32_t attack =
static_cast<Segment*
>(items[0])->getValue();
53 const int32_t decay =
static_cast<Segment*
>(items[1])->getValue();
54 const int32_t sustain =
static_cast<Segment*
>(items[2])->getValue();
55 const int32_t release =
static_cast<Segment*
>(items[3])->getValue();
58 constexpr int32_t totalWidth = OLED_MAIN_WIDTH_PIXELS;
59 constexpr int32_t totalHeight = OLED_MAIN_VISIBLE_HEIGHT - kTextTitleSizeY - 6;
60 constexpr int32_t padding = 4;
61 constexpr int32_t drawX = padding;
62 constexpr int32_t drawY = OLED_MAIN_TOPMOST_PIXEL + kTextTitleSizeY + padding + 3;
63 constexpr int32_t drawWidth = totalWidth - 2 * padding;
64 constexpr int32_t drawHeight = totalHeight - 2 * padding;
65 constexpr float maxSegmentWidth = drawWidth / 4;
68 const float attackWidth = (attack / 50.0f) * maxSegmentWidth;
69 const float decayNormalized = sigmoidLikeCurve(decay, 10.0f, 50.0f);
70 const float decayWidth = decayNormalized * maxSegmentWidth;
73 const float attackX = round(drawX + attackWidth);
74 const float decayX = round(attackX + decayWidth);
75 constexpr float sustainX = drawX + maxSegmentWidth * 3;
76 const float releaseX = round(
77 sustainX + (release / 50.0f) * (drawX + drawWidth - sustainX));
80 constexpr int32_t baseY = drawY + drawHeight;
81 constexpr int32_t peakY = drawY;
82 const int32_t sustainY = baseY - round((sustain / 50.0f) * drawHeight);
87 image.drawLine(drawX, baseY, attackX, peakY);
88 image.drawLine(attackX, peakY, decayX, sustainY);
89 image.drawLine(decayX, sustainY, sustainX, sustainY);
90 image.drawLine(sustainX, sustainY, releaseX, baseY);
91 image.drawLine(releaseX, baseY, drawX + drawWidth, baseY);
94 for (int32_t y = OLED_MAIN_VISIBLE_HEIGHT; y >= drawY; y -= 4) {
96 if (attackX > drawX + 3) {
97 image.drawPixel(attackX, y);
99 if (decayX - attackX > 4) {
100 image.drawPixel(decayX, y);
102 image.drawPixel(sustainX, y);
106 selectedX = -1, selectedY = -1;
108 drawTransitionSquare(attackX, peakY, 0);
110 drawTransitionSquare(decayX, sustainY, 1);
112 drawTransitionSquare(decayX + (sustainX - decayX) / 2, sustainY, 2);
114 drawTransitionSquare(releaseX, baseY, 3);