Deluge Firmware 1.3.0
Build date: 2026.07.15
Loading...
Searching...
No Matches
pad_leds.h
1/*
2 * Copyright © 2014-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "drivers/pic/pic.h"
22#include <cstdint>
23
24#define FLASH_CURSOR_FAST 0
25#define FLASH_CURSOR_OFF 1
26#define FLASH_CURSOR_SLOW 2
27
28extern "C" {
29#include "RZA1/uart/sio_char.h"
30}
31
32class UI;
33class AudioClip;
34
35namespace PadLEDs {
36extern RGB image[kDisplayHeight][kDisplayWidth + kSideBarWidth]; // 255 = full brightness
37extern uint8_t occupancyMask[kDisplayHeight][kDisplayWidth + kSideBarWidth]; // 64 = full occupancy
38extern RGB imageStore[kDisplayHeight * 2][kDisplayWidth + kSideBarWidth]; // 255 = full brightness
39extern uint8_t occupancyMaskStore[kDisplayHeight * 2][kDisplayWidth + kSideBarWidth]; // 64 = full occupancy
40
41extern bool transitionTakingPlaceOnRow[kDisplayHeight];
42
43extern int32_t explodeAnimationYOriginBig;
44extern int32_t explodeAnimationXStartBig;
45extern int32_t explodeAnimationXWidthBig;
46
47extern int8_t explodeAnimationDirection;
48extern UI* explodeAnimationTargetUI;
49extern bool renderingLock;
50extern uint8_t flashCursor;
51
52extern int16_t animatedRowGoingTo[];
53extern int16_t animatedRowGoingFrom[];
54extern uint8_t numAnimatedRows;
55
56extern int32_t zoomPinSquare[kDisplayHeight];
57extern bool zoomingIn;
58extern int8_t zoomMagnitude;
59
60void init();
61void sortLedsForCol(int32_t x);
62void set(Cartesian pad, RGB colour);
63void renderInstrumentClipCollapseAnimation(int32_t xStart, int32_t xEnd, int32_t progress);
64void renderClipExpandOrCollapse();
65void renderNoteRowExpandOrCollapse();
66void clearAllPadsWithoutSending();
67void clearMainPadsWithoutSending();
68void clearColumnWithoutSending(int32_t x);
69
70void sendOutMainPadColours();
71void sendOutMainPadColoursSoon();
72void sendOutSidebarColours();
73void sendOutSidebarColoursSoon();
74
75void skipGreyoutFade();
76void reassessGreyout(bool doInstantly = false);
77void doGreyoutInstantly();
78
79void setRefreshTime(int32_t newTime);
80void changeRefreshTime(int32_t offset);
81void changeDimmerInterval(int32_t offset);
82void setDimmerInterval(int32_t newInterval);
83void setBrightnessLevel(uint8_t level);
84void renderZoom();
85void renderZoomWithProgress(int32_t inImageTimesBiggerThanNative, uint32_t inImageFadeAmount, uint8_t* innerImage,
86 uint8_t* outerImage, int32_t innerImageLeftEdge, int32_t outerImageLeftEdge,
87 int32_t innerImageRightEdge, int32_t outerImageRightEdge, int32_t innerImageTotalWidth,
88 int32_t outerImageTotalWidth);
89
90namespace horizontal {
91void setupScroll(int8_t thisScrollDirection, uint8_t thisAreaToScroll, bool scrollIntoNothing = false,
92 int32_t numSquaresToScroll = kDisplayWidth);
93void renderScroll();
94} // namespace horizontal
95
96namespace vertical {
97void setupScroll(int8_t thisScrollDirection, bool scrollIntoNothing = false);
98void renderScroll();
99
100extern uint8_t squaresScrolled;
101extern int8_t scrollDirection;
102extern bool scrollingToNothing;
103} // namespace vertical
104
105RGB prepareColour(int32_t x, int32_t y, RGB colourSource);
108void refreshSidebarOccupancy(RGB rowImage[], uint8_t rowOccupancyMask[]);
112void clearTransitionStoreOffScreenRows();
113void clearTickSquares(bool shouldSend = true);
114void setTickSquares(const uint8_t* squares, const uint8_t* colours);
115void renderExplodeAnimation(int32_t explodedness, bool shouldSendOut = true);
116void renderAudioClipExplodeAnimation(int32_t explodedness, bool shouldSendOut = true);
117void clearSideBar();
118void renderFade(int32_t progress);
119void recordTransitionBegin(uint32_t newTransitionLength);
120int32_t getTransitionProgress();
121void renderAudioClipExpandOrCollapse();
122void setupInstrumentClipCollapseAnimation(bool collapsingOutOfClipMinder);
126void enableKeyboardSidebarMorph(RGB sessionSectionColour);
127void setupAudioClipCollapseOrExplodeAnimation(AudioClip* clip);
128
129void setGreyoutAmount(float newAmount);
130
131static inline void flashMainPad(int32_t x, int32_t y, int32_t colour = 0) {
132 auto idx = y + (x * kDisplayHeight);
133 if (colour > 0) {
135 return;
136 }
137 PIC::flashMainPad(idx);
138}
139
140void setTimerForSoon();
141void renderZoomedSquare(int32_t outputSquareStartOnOutImage, int32_t outputSquareEndOnOutImage,
142 uint32_t outImageTimesBigerThanNormal, uint32_t sourceImageFade, uint32_t* output,
143 uint8_t* inputImageRow, int32_t inputImageWidth, bool* drawingAnything);
144bool shouldNotRenderDuringTimerRoutine();
145void renderAudioClipCollapseAnimation(int32_t progress);
146
147void timerRoutine();
148void copyBetweenImageStores(uint8_t* dest, uint8_t* source, int32_t destWidth, int32_t sourceWidth, int32_t copyWidth);
149void moveBetweenImageStores(uint8_t* dest, uint8_t* source, int32_t destWidth, int32_t sourceWidth, int32_t copyWidth);
150
151} // namespace PadLEDs
Definition audio_clip.h:35
static void flashMainPadWithColourIdx(size_t idx, int32_t colour_idx)
Flash a pad using the PIC's built-in timer and colour system.
Definition pic.h:158
Definition ui.h:92