Improve Menu Implementation situation, optimize parameter set for part

This commit is contained in:
Jan-Henrik 2019-10-14 23:51:38 +02:00
parent 88916400d2
commit 91fd3e4302
5 changed files with 106 additions and 51 deletions

View file

@ -5,6 +5,9 @@
#include <stm32f37x_conf.h> #include <stm32f37x_conf.h>
#include <u8g2.h> #include <u8g2.h>
#define DISPLAY_WIDTH 128
#define DISPLAY_HEIGHT 64
class Display { class Display {
public: public:
Display() {} Display() {}

View file

@ -12,7 +12,7 @@ GPIO gpio;
Display display; Display display;
UI ui; UI ui;
//SystemClock system_clock; //SystemClock system_clock;
Part part[4]; Part part[PART_COUNT];
// Default interrupt handlers. // Default interrupt handlers.
extern "C" { extern "C" {

View file

@ -1,11 +1,15 @@
#ifndef MIDI2CV_PART_H #ifndef MIDI2CV_PART_H
#define MIDI2CV_PART_H #define MIDI2CV_PART_H
enum MIDIThruMode { OFF, #define PART_COUNT 4
ON,
POLYCHAIN };
enum BiOutputType { #define TOTAL_COLUMN_COUNT 4
typedef enum { MIDI_THRU_OFF,
MIDI_THRU_ON,
MIDI_THRU_POLYCHAIN } MIDIThruMode_t;
typedef enum {
BI_OFF = 0, BI_OFF = 0,
BI_PITCH_UNI, BI_PITCH_UNI,
BI_PITCH_BI, BI_PITCH_BI,
@ -13,9 +17,9 @@ enum BiOutputType {
BI_SQUARE, BI_SQUARE,
BI_SINE, BI_SINE,
BI_TRIANGLE BI_TRIANGLE
}; } BiOutputType_t;
enum UniOutputType { typedef enum {
UNI_OFF = 0, UNI_OFF = 0,
UNI_PITCH, UNI_PITCH,
UNI_VELOCITY, UNI_VELOCITY,
@ -24,26 +28,40 @@ enum UniOutputType {
UNI_BREATH, UNI_BREATH,
UNI_EXP, UNI_EXP,
UNI_GATE UNI_GATE
}; } UniOutputType_t;
enum GateOutputType { typedef enum {
GATE_OFF = 0, GATE_OFF = 0,
GATE_GATE, GATE_GATE,
GATE_TRIGGER GATE_TRIGGER
}; } GateOutputType_t;
typedef enum {
VOICE_COUNT_1 = 1,
VOICE_COUNT_2 = 2,
VOICE_COUNT_3 = 3,
VOICE_COUNT_4 = 4
} PartVoiceCount_t;
typedef enum {
VOICE_DETAIL_S,
VOICE_DETAIL_M,
VOICE_DETAIL_L,
VOICE_DETAIL_XL
} PartVoiceDetail_t;
class Part { class Part {
public: public:
Part() Part()
: poly_voice_count(1) : part_voice_count(VOICE_COUNT_1)
, output_column_count(1) , part_voice_detail(VOICE_DETAIL_S)
, midi_filter_channel_enabled(true) , midi_filter_channel_enabled(true)
, midi_filter_channel(1) , midi_filter_channel(1)
, midi_filter_lowest_note(0) , midi_filter_lowest_note(0)
, midi_filter_highest_note(127) , midi_filter_highest_note(127)
, midi_thru_mode(OFF) , midi_thru_mode(MIDI_THRU_OFF)
{ {
for (int i = 0; i < 4; i++) { for (int i = 0; i < TOTAL_COLUMN_COUNT; i++) {
output_type_row_0[i] = BI_OFF; output_type_row_0[i] = BI_OFF;
output_type_row_1[i] = UNI_OFF; output_type_row_1[i] = UNI_OFF;
output_type_row_2[i] = UNI_OFF; output_type_row_2[i] = UNI_OFF;
@ -52,18 +70,22 @@ class Part {
} }
void ProcessMidiInput(/* TODO: Inputs */); void ProcessMidiInput(/* TODO: Inputs */);
uint8_t RequiredColumns();
private: private:
uint8_t poly_voice_count; PartVoiceCount_t part_voice_count;
uint8_t output_column_count; PartVoiceDetail_t part_voice_detail;
bool midi_filter_channel_enabled; bool midi_filter_channel_enabled;
uint8_t midi_filter_channel; uint8_t midi_filter_channel;
uint8_t midi_filter_lowest_note; uint8_t midi_filter_lowest_note;
uint8_t midi_filter_highest_note; uint8_t midi_filter_highest_note;
MIDIThruMode midi_thru_mode; MIDIThruMode_t midi_thru_mode;
BiOutputType output_type_row_0[4]; BiOutputType_t output_type_row_0[TOTAL_COLUMN_COUNT];
UniOutputType output_type_row_1[4]; UniOutputType_t output_type_row_1[TOTAL_COLUMN_COUNT];
UniOutputType output_type_row_2[4]; UniOutputType_t output_type_row_2[TOTAL_COLUMN_COUNT];
GateOutputType output_type_row_3[4]; GateOutputType_t output_type_row_3[TOTAL_COLUMN_COUNT];
}; };
extern Part parts[];
#endif #endif

View file

@ -1,36 +1,53 @@
#include "ui.h" #include "ui.h"
#include "drivers/display.h" #include "drivers/display.h"
#include "part.h"
#include "stmlib/utils/random.h" #include "stmlib/utils/random.h"
#include <u8g2.h> #include <u8g2.h>
using namespace stmlib; using namespace stmlib;
#define HEADER_HEIGHT 16
const char part_names[4][2] = { "A", "B", "C", "D" };
void UI::Update() void UI::Update()
{ {
u8g2_t* u8g2_ = display.u8g2();
static float x = 0, y = 16, dx = 1, dy = 1, ddx = .2, ddy = .2; switch (current_menu) {
u8g2_ClearBuffer(u8g2_); case MENU_PART_1:
u8g2_SetFont(u8g2_, u8g2_font_6x10_mf); case MENU_PART_2:
u8g2_DrawStr(u8g2_, (int)x, (int)y, "send nudes"); case MENU_PART_3:
x += dx * ddx; case MENU_PART_4:
y += dy * ddy; DrawHeader();
if (x >= 70 || x <= 0) { DrawPartMenu(current_menu);
ddx = Random::GetFloat() / 4.0 + 0.1; break;
} default:
if (x >= 70)
dx = -1; break;
if (x <= 0) }
dx = 1; }
if (y >= 64 || y <= 7) {
ddy = Random::GetFloat() / 4.0 + 0.1; void UI::DrawHeader()
} {
if (y >= 64) for (int i = 0; i < PART_COUNT; i++) {
dy = -1; u8g2_SetFontMode(display.u8g2(), 1);
if (y <= 7) u8g2_SetDrawColor(display.u8g2(), 1);
dy = 1; if (current_menu == i)
display.Swap(); u8g2_DrawBox(display.u8g2(), i * (DISPLAY_WIDTH / PART_COUNT), 0, (DISPLAY_WIDTH / PART_COUNT), HEADER_HEIGHT);
else
u8g2_DrawFrame(display.u8g2(), i * (DISPLAY_WIDTH / PART_COUNT), 0, (DISPLAY_WIDTH / PART_COUNT), HEADER_HEIGHT);
u8g2_SetDrawColor(display.u8g2(), 2);
u8g2_DrawStr(display.u8g2(), i * (DISPLAY_WIDTH / PART_COUNT) + 2, 2, part_names[i]);
u8g2_SetDrawColor(display.u8g2(), 1);
}
}
void UI::DrawPartMenu(Menu_t menu)
{
} }
void UI::Flush() void UI::Flush()
{ {
display.Flush(); display.Flush();
} }

View file

@ -3,16 +3,29 @@
#include "stmlib/stmlib.h" #include "stmlib/stmlib.h"
typedef enum {
MENU_PART_1,
MENU_PART_2,
MENU_PART_3,
MENU_PART_4,
MENU_COUNT
} Menu_t;
class UI { class UI {
public: public:
UI() {} UI() {}
~UI() {} ~UI() {}
void Update(); void Update();
void Flush(); void Flush();
private: private:
DISALLOW_COPY_AND_ASSIGN(UI); Menu_t current_menu;
void DrawHeader();
void DrawPartMenu(Menu_t menu);
DISALLOW_COPY_AND_ASSIGN(UI);
}; };
extern UI ui; extern UI ui;