Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/checkbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ typedef uint8_t Checkbox;
? CHECKBOX_ON_COLOR \
: CHECKBOX_OFF_COLOR)))

/// c: bitfield where the checkbox lives
/// b: bit the checkbox represents (1 << x)
/// p: the position to draw the checkbox
#define checkbox_draw_inv(c, b, p) (plot_pad((p), (flag_is_set((c), (b)) \
? CHECKBOX_OFF_COLOR \
: CHECKBOX_ON_COLOR)))

/// c: bitfield where the checkbox bit lives
/// b: bit the checkbox represents (1 << x)
/// i: index of button that was pressed
Expand Down
12 changes: 12 additions & 0 deletions include/colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@
extern const uint8_t root_note_color[3];
extern const uint8_t white_note_color[3];
extern const uint8_t black_note_color[3];
extern const uint8_t invalid_note_color[3];
extern const uint8_t c_note_color[3];
extern const uint8_t no_note_color[3];

extern const uint8_t layout_octave_color[3];
extern const uint8_t layout_transpose_color[3];
extern const uint8_t scale_button_color[3];

extern const uint8_t white_key_color[3];
extern const uint8_t black_key_color[3];
extern const uint8_t slider_color[3];
extern const uint8_t off_color[3];
extern const uint8_t on_color[3];

extern const uint8_t note_octave_up_colors[10][3];
extern const uint8_t note_octave_down_colors[10][3];
extern const uint8_t note_transpose_up_colors[12][3];
extern const uint8_t note_transpose_down_colors[12][3];

extern const uint8_t sequence_colors[8][3];
extern const uint8_t number_colors[4][3];
extern const uint8_t drum_colors[4][3];
Expand Down
9 changes: 7 additions & 2 deletions include/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef enum
LP_NOTES_MODE,
LP_SEQUENCER_MODE,
LP_USER_MODE,
LP_NUM_MODES
LP_NUM_MODES,
} LpState;

/// Global program flags.
Expand All @@ -33,7 +33,8 @@ typedef enum
LP_ARMED = 1 << 6,
LP_RCV_CLOCK = 1 << 7,
LP_RCV_CLOCK_PORT = 1 << 8,
LP_IS_ARP = 1 << 9
LP_IS_ARP = 1 << 9,
LP_IS_SETUP2 = 1 << 10
} LpFlags;

/// The number of notes needed for all 8 sequences. Two of these are used: one
Expand Down Expand Up @@ -74,8 +75,12 @@ extern Note* lp_note_storage;
extern Scale lp_scale;
extern Voices lp_voices;
extern PadNotes lp_pad_notes;
extern PadNotes lp_pad_highlights;
extern Sequencer lp_sequencer;

extern TextDisplayer lp_text_displayer;
extern int8_t lp_quick_scale_current;

// Setup UI elements
extern Slider lp_tempo_slider;
extern Slider lp_swing_slider;
Expand Down
4 changes: 4 additions & 0 deletions include/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
#define MULTICHANNEL_CHECKBOX_POS (55)
#define CONTROL_CHECKBOX_POS (81)

#define NOTE_HIGHLIGHT_ONLY_POS (28)
#define SCALE_HIGHLIGHT_ONLY_POS (48)
#define SCALE_HIGHLIGHT_ONLY_INV_POS (28)

#define MOD_WHEEL_POS (51)
#define MOD_WHEEL_X (0)
#define MOD_WHEEL_Y (4)
Expand Down
5 changes: 3 additions & 2 deletions include/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ typedef struct
void keyboard_init(Keyboard* k, Layout* l);

/// Toggles a note on or off and updates the layout and scale to match.
uint8_t keyboard_handle_press(Keyboard* k, uint8_t index, uint8_t value);
uint8_t keyboard_handle_press(Keyboard* k, uint8_t index, uint8_t value, uint8_t y, uint8_t is_highlight_press);

/// Draws the keyboard to the grid.
void keyboard_draw(Keyboard* k);
void keyboard_draw(Keyboard* k, uint8_t draw_highlighted);
void keyboard_draw_y(Keyboard* k, uint8_t draw_highlighted, uint8_t y);

/// When a change is made to the layout or scale, this function updates the
/// keyboard to reflect the current state.
Expand Down
13 changes: 11 additions & 2 deletions include/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include "app.h"
#include "buttons.h"
#include "colors.h"
#include "keyboard.h"
#include "scale.h"
#include "voices.h"
#include "util.h"

#define LAYOUT_DEFAULT_OCTAVE 3

/// The bits where row offset lives. Excludes the drum flag bit, so that
/// the drums state doesn't get trashed when you use the row offset slider.
#define ROW_OFFSET_MASK (0x7F)
Expand All @@ -26,6 +26,9 @@ typedef enum
/// calculating every time a pad is pressed.
typedef int8_t PadNotes[GRID_SIZE][GRID_SIZE];

/// Cache of which pads are highlighted for note mode
typedef int8_t PadHighlights[GRID_SIZE];

/// Represents a layout of a scale on a grid. Determines which note and octave
/// to start from, and the distance in scale steps between rows of the grid.
typedef struct
Expand All @@ -41,6 +44,9 @@ typedef struct
/// rows. To tune in 4ths for a chromatic scale, this would be set to 5.
int8_t row_offset;

/// How many spaces up/down to translate the view
int8_t offset_horizontal;
int8_t offset_vertical;
} Layout;

/// Initialize the layout data.
Expand All @@ -64,11 +70,14 @@ void layout_set_drums(Layout* l);

/// Toggles the note in the scale, and updates the layout.
void layout_toggle_note(Layout* l, uint8_t note);
/// Toggles the note highlight
void layout_toggle_highlight(Layout* l, uint8_t note_highlight);

/// Draws the layout onto the grid.
void layout_draw(Layout* l);
void layout_draw_scale(Layout* l);
void layout_draw_drums(Layout* l);
void layout_draw_transpose_octave_buttons(Layout* l);

/// Increases or decreases the root note by a half step.
void layout_transpose(Layout* l, int8_t direction);
Expand Down
22 changes: 22 additions & 0 deletions include/scale.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "app.h"
#include "util.h"
#include "layout.h"

/// Represents a musical scale as a subset of 12 chromatic notes.
typedef struct
Expand All @@ -15,6 +16,11 @@ typedef struct
/// note) is enabled. [0] (the root note) is always on.
uint16_t notes;

/// Bitfield indicating whether the nth note is lighted or not
/// which applies if the highlight setting is turned on
/// Otherwise, white keys are lighted and black keys are dark
uint16_t notes_highlighted;

/// Array of ints indicating how many half steps the nth scale note is
/// offset from the root note (only the first num_notes entries are set)
int8_t offsets[NUM_NOTES];
Expand All @@ -28,11 +34,27 @@ void scale_init(Scale* s);
/// root note) is contained in the scale.
uint8_t scale_contains_note(Scale* s, uint8_t note);

/// Returns true or false depending on whether then nth note (counted from the
/// root note) is contained in the scale's highlight list
uint8_t scale_contains_highlight(Scale* s, uint8_t note);

/// Sets all the notes of the scale at once.
void scale_set_notes(Scale* s, uint16_t notes);

/// Toggles the nth note in the scale. Automatically updates num_notes and
/// offsets.
void scale_toggle_note(Scale* s, uint8_t note);

/// Toggles the nth note's highlight
void scale_toggle_highlight(Scale* s, uint8_t note);

extern const uint16_t quick_scale_bitfields[32];
extern const char* quick_scale_names[32];

void quick_scale_draw();
uint16_t quick_scale_convert_notes(uint16_t in);
uint8_t quick_scale_handle_press(Layout* l, uint8_t index, uint8_t value, uint8_t is_highlight_mode);
uint8_t quick_scale_handle_prev_next(Layout* l, uint8_t index, uint8_t value, uint8_t note_held, uint8_t is_highlight_mode);
void quick_scale_apply(Layout* l, uint8_t is_highlight_mode);

#endif
9 changes: 7 additions & 2 deletions include/seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ void notes_setup_become_active();
void notes_setup_become_inactive();
void notes_mode_draw();
void notes_setup_draw();
uint8_t notes_mode_handle_press(uint8_t index, uint8_t value);
uint8_t notes_mode_handle_press(uint8_t index, uint8_t value, uint8_t shift_held, uint8_t note_held);
uint8_t notes_setup_handle_press(uint8_t index, uint8_t value);

void scales_setup_become_active();
void scales_setup_become_inactive();
void scales_setup_draw();
uint8_t scales_setup_handle_press(uint8_t index, uint8_t value);

void user_mode_become_active();
void user_mode_become_inactive();
void user_setup_become_active();
Expand All @@ -86,6 +91,6 @@ uint8_t user_setup_handle_press(uint8_t index, uint8_t value);
******************************************************************************/

/// Switch the mode or switch between normal and setup modes.
void set_state(LpState st, uint8_t setup);
void set_state(LpState st, uint8_t setup, uint8_t shift_held);

#endif
3 changes: 2 additions & 1 deletion include/sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ typedef enum
SEQ_DRUM_MULTICHANNEL = 1 << 11, // Send each note on its own channel
SEQ_FULL_VELOCITY = 1 << 12, // Always send notes at full velocity
SEQ_MOD_WHEEL = 1 << 13, // Show the mod wheel in notes mode
SEQ_MOD_CC = 1 << 14 // Send CC from mod wheel instead of aftertouch
SEQ_MOD_CC = 1 << 14, // Send CC from mod wheel instead of aftertouch
NOTE_HIGHLIGHT_ONLY = 1 << 15 // Always show all notes and only highlight the ones in the scale
} SequenceFlags;

#define SEQ_QUEUED_OFFSET (4)
Expand Down
26 changes: 26 additions & 0 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define UTIL_H

#include "app.h"
#include "colors.h"

/*******************************************************************************
* Defines/helpers
Expand Down Expand Up @@ -101,6 +102,31 @@ void modifier_index_assign(uint8_t index, uint8_t value);
void clear_leds();
void clear_pad_leds();

const uint16_t font_4x4[64];

typedef struct
{
uint8_t active;
const char *text;
char text_visible[3];
uint8_t y; // 0-4 (0 is bottom, 4 is top)
const uint8_t *color;

uint8_t text_index;
uint8_t millis_per_frame; // Setting for how many milliseconds each 'frame' of the animation should last
uint8_t frame_millis_remain; // Counter for millisecons
uint8_t frame_offset; // Number from 0 to 3 indicating how many pixels left the current text has moved so far

void (*callback_finished)(void);
} TextDisplayer;

void text_display_init(TextDisplayer* td);
void text_display_tick(TextDisplayer* td);
void text_display(TextDisplayer* td, const char *text, uint8_t y, const uint8_t *color, void (*callback_finished)(void));
void text_display_stop(TextDisplayer* td);
void text_draw(TextDisplayer *td);
void text_draw_letter(char c, int8_t x, int8_t y, const uint8_t *color);

#ifdef VIRTUAL_LPP
#include <stdio.h>
#define LP_LOG(x, ...) printf(x "\n", __VA_ARGS__)
Expand Down
Binary file modified resources/subsequencely.syx
Binary file not shown.
Loading