Deluge Firmware 1.3.0
Build date: 2025.04.16
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);
106void clearTickSquares(bool shouldSend = true);
107void setTickSquares(const uint8_t* squares, const uint8_t* colours);
108void renderExplodeAnimation(int32_t explodedness, bool shouldSendOut = true);
109void renderAudioClipExplodeAnimation(int32_t explodedness, bool shouldSendOut = true);
110void clearSideBar();
111void renderFade(int32_t progress);
112void recordTransitionBegin(uint32_t newTransitionLength);
113int32_t getTransitionProgress();
114void renderAudioClipExpandOrCollapse();
115void setupInstrumentClipCollapseAnimation(bool collapsingOutOfClipMinder);
116void setupAudioClipCollapseOrExplodeAnimation(AudioClip* clip);
117
118void setGreyoutAmount(float newAmount);
119
120static inline void flashMainPad(int32_t x, int32_t y, int32_t colour = 0) {
121 auto idx = y + (x * kDisplayHeight);
122 if (colour > 0) {
124 return;
125 }
126 PIC::flashMainPad(idx);
127}
128
129void setTimerForSoon();
130void renderZoomedSquare(int32_t outputSquareStartOnOutImage, int32_t outputSquareEndOnOutImage,
131 uint32_t outImageTimesBigerThanNormal, uint32_t sourceImageFade, uint32_t* output,
132 uint8_t* inputImageRow, int32_t inputImageWidth, bool* drawingAnything);
133bool shouldNotRenderDuringTimerRoutine();
134void renderAudioClipCollapseAnimation(int32_t progress);
135
136void timerRoutine();
137void copyBetweenImageStores(uint8_t* dest, uint8_t* source, int32_t destWidth, int32_t sourceWidth, int32_t copyWidth);
138void moveBetweenImageStores(uint8_t* dest, uint8_t* source, int32_t destWidth, int32_t sourceWidth, int32_t copyWidth);
139
140} // 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