Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
daisyy-hardware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sdiy
daisyy
daisyy-hardware
Commits
49a842aa
Commit
49a842aa
authored
1 year ago
by
David Huss
Browse files
Options
Downloads
Patches
Plain Diff
More generic functions for ui setup
parent
1145822a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
code/daisy-looper/button_grid.h
+15
-18
15 additions, 18 deletions
code/daisy-looper/button_grid.h
code/daisy-looper/daisy-looper.ino
+4
-1
4 additions, 1 deletion
code/daisy-looper/daisy-looper.ino
code/daisy-looper/ui.h
+36
-48
36 additions, 48 deletions
code/daisy-looper/ui.h
with
55 additions
and
67 deletions
code/daisy-looper/button_grid.h
+
15
−
18
View file @
49a842aa
...
...
@@ -93,36 +93,33 @@ class ButtonGrid {
void
setup
()
{
Serial
.
println
(
"Running Setup for ButtonGrid"
);
for
(
int
n
=
0
;
n
<
6
;
n
++
)
{
// If this is the home button setup callbacks
if
(
grid_buttons_
[
n
].
is_home
)
{
Serial
.
print
(
"Home button "
);
Serial
.
println
(
n
);
// // When homebutton is held switch to this UI Mode
// grid_buttons_[n].button.onHold([ui, n](){ ui->setMode(ui_mode); });
// // When homebutton is released hide ALL button descriptions
// grid_buttons_[n].button.onReleased([ui, n](){
// ui->setMode(UI_MODE_DEFAULT);
// for (int i=0; i<6; i++) {
// grid_buttons_[i].should_render_description = false;
// }
// });
}
else
{
if
(
!
grid_buttons_
[
n
].
is_home
)
{
Serial
.
println
(
n
);
// Not a home button, display help on long hold and hide on release
grid_buttons_
[
n
].
button
->
onLongHold
([
this
,
n
](){
// TODO: Doesn't register for some reason?
Serial
.
println
(
"Show DESCROOOTT"
);
grid_buttons_
[
n
].
should_render_description
=
true
;
});
grid_buttons_
[
n
].
button
->
onReleased
([
this
,
n
](){
// TODO: Doesn't register for some reason?
Serial
.
println
(
"NOPE"
);
grid_buttons_
[
n
].
should_render_description
=
false
;
});
}
}
}
int
homeButtonIndex
()
{
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
if
(
grid_buttons_
[
i
].
is_home
)
{
return
i
;
}
}
}
void
hideAllDescriptions
()
{
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
grid_buttons_
[
i
].
should_render_description
=
false
;
}
}
void
render
(
int
button_enum
)
{
int
width
=
display
.
width
();
int
height
=
display
.
height
();
...
...
This diff is collapsed.
Click to expand it.
code/daisy-looper/daisy-looper.ino
+
4
−
1
View file @
49a842aa
...
...
@@ -20,7 +20,10 @@
#include
"helpers.h"
#include
"ui.h"
static
const
size_t
buffer_length
=
48000
*
5
;
#define BUFFER_LENGTH_SECONDS 5
static
const
size_t
buffer_length
=
48000
*
BUFFER_LENGTH_SECONDS
;
static
float
DSY_SDRAM_BSS
buffer
[
buffer_length
];
// Create instances of audio stuff
...
...
This diff is collapsed.
Click to expand it.
code/daisy-looper/ui.h
+
36
−
48
View file @
49a842aa
...
...
@@ -4,6 +4,15 @@
#ifndef Ui_h
#define Ui_h
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print (x)
#define DEBUG_PRINTLN(x) Serial.println (x)
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x)
#endif
#include
"Adafruit_SH110X.h"
#include
"Adafruit_GFX.h"
#include
"potentiometers.h"
...
...
@@ -224,18 +233,39 @@ class Ui {
button_6
.
reset
();
}
Button
*
setupButtonGrid
(
int
n
)
{
Serial
.
println
(
"[UI] Setup Rec Menu"
);
// Find the index of the home button
int
home_button_index
=
button_grids
[
n
].
homeButtonIndex
();
// Create a pointer to the hoime button
Button
*
home_button
=
button_grids
[
n
].
grid_buttons_
[
home_button_index
].
button
;
// Reset the controls
resetControls
();
// Setup the button grid
button_grids
[
n
].
setup
();
// Return to default mode on release
home_button
->
onReleased
([
this
,
n
](){
this
->
setMode
(
UI_MODE_DEFAULT
);
this
->
button_grids
[
n
].
hideAllDescriptions
();
});
// Return pointer to the home button
return
home_button
;
}
// Setup the Recording Menu
void
setupRecMenu
()
{
// Only run once when the ui_mode changed
if
(
ui_mode
==
UI_MODE_REC_MENU
&&
last_ui_mode
!=
UI_MODE_REC_MENU
)
{
int
n
=
0
;
Serial
.
println
(
"[UI] Setup Rec Menu"
);
// Reset controls
resetControls
();
// Setup
button_grids
[
n
].
setup
();
// Setup button Grid
Button
*
home_button
=
setupButtonGrid
(
n
);
// Toggle between momentary and toggle recording modes
button_2
.
onPress
([
this
,
n
](){
...
...
@@ -280,48 +310,6 @@ class Ui {
looper
.
setRecStartMode
((
atoav
::
RecStartMode
)
button_grids
[
n
].
grid_buttons_
[
5
].
active
);
});
// // Display descriptions on Long Hold:
// button_2.onLongHold([this, n](){
// button_grids[n].grid_buttons_[1].should_render_description = true;
// });
// button_2.onReleased([this, n](){
// button_grids[n].grid_buttons_[1].should_render_description = false;
// });
// button_3.onLongHold([this, n](){
// button_grids[n].grid_buttons_[2].should_render_description = true;
// });
// button_3.onReleased([this, n](){
// button_grids[n].grid_buttons_[2].should_render_description = false;
// });
// button_4.onLongHold([this, n](){
// button_grids[n].grid_buttons_[3].should_render_description = true;
// });
// button_4.onReleased([this, n](){
// button_grids[n].grid_buttons_[3].should_render_description = false;
// });
// button_5.onLongHold([this, n](){
// button_grids[n].grid_buttons_[4].should_render_description = true;
// });
// button_5.onReleased([this, n](){
// button_grids[n].grid_buttons_[4].should_render_description = false;
// });
// button_6.onLongHold([this, n](){
// button_grids[n].grid_buttons_[5].should_render_description = true;
// });
// button_6.onReleased([this, n](){
// button_grids[n].grid_buttons_[5].should_render_description = false;
// });
// Store the last ui mode, for the check on top
last_ui_mode
=
ui_mode
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment