mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-29 17:35:33 +00:00
Updated library versions and refactored utils
This commit is contained in:
parent
f2162db95c
commit
6cdbf33d21
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
||||
TARGET = main
|
||||
|
||||
CPP_SOURCES = src/main.cpp src/menu.cpp src/util.cpp
|
||||
CPP_SOURCES = src/main.cpp src/util.cpp src/menu.cpp
|
||||
|
||||
LIBDAISY_DIR = ./lib/libDaisy
|
||||
DAISYSP_DIR = ./lib/daisySP
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ddaa1588c793e115f9e0ca915069376caf2e120a
|
||||
Subproject commit c4fe13ce05fb32df9955b9c236ef43d9855c2b94
|
@ -1 +1 @@
|
||||
Subproject commit 2cfc8f7f395b9c159b4e64c34fad1100dd0f5834
|
||||
Subproject commit aaa17b041a4eb0c00a583be6b383af8c02797682
|
10
src/main.cpp
10
src/main.cpp
@ -1,19 +1,17 @@
|
||||
#include "daisysp.h"
|
||||
#include "daisy_patch.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "util.h"
|
||||
#include "menu.h"
|
||||
|
||||
using namespace daisy;
|
||||
using namespace daisysp;
|
||||
|
||||
DaisyPatch patch;
|
||||
Util util(&patch);
|
||||
Menu menu(&patch, &util);
|
||||
Menu menu(&patch);
|
||||
|
||||
int main(void) {
|
||||
patch.Init();
|
||||
@ -28,7 +26,6 @@ int main(void) {
|
||||
void ProcessControls() {
|
||||
patch.UpdateAnalogControls();
|
||||
patch.DebounceControls();
|
||||
|
||||
if (menu.InMenu()) {
|
||||
menu.UpdateMenuPosition();
|
||||
if (patch.encoder.RisingEdge()) {
|
||||
@ -47,11 +44,10 @@ void ProcessOutputs() {}
|
||||
|
||||
void ProcessOled() {
|
||||
patch.display.Fill(false);
|
||||
|
||||
if (menu.InMenu()) {
|
||||
menu.ProcessMenuOled();
|
||||
} else {
|
||||
util.WriteString(0, 0, menu.SelectedName());
|
||||
WriteString(patch, 0, 0, Font_6x8, menu.SelectedName());
|
||||
}
|
||||
patch.display.Update();
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#include "menu.h"
|
||||
|
||||
Menu::Menu(DaisyPatch* m_patch,
|
||||
Util* m_util) {
|
||||
Menu::Menu(DaisyPatch* m_patch) {
|
||||
patch = m_patch;
|
||||
util = m_util;
|
||||
}
|
||||
const std::string MENU_ITEMS[] = {"VCO",
|
||||
"VCA",
|
||||
@ -51,7 +49,7 @@ void Menu::CreateMenuItem(std::string text, int position, bool highlighted) {
|
||||
text.insert(text.end(), MAX_CHAR_LENGTH-text.size(), ' ');
|
||||
patch->display.SetCursor(MENU_X[position-1], MENU_Y[position-1]);
|
||||
if (highlighted) {
|
||||
util->DrawSolidRect(0, MENU_Y[2], SSD1309_WIDTH, MENU_Y[2]+17, true);
|
||||
DrawSolidRect(*patch, 0, MENU_Y[2], SSD1309_WIDTH, MENU_Y[2]+17, true);
|
||||
patch->display.WriteString(cstr, Font_11x18, !highlighted);
|
||||
} else {
|
||||
patch->display.WriteString(cstr, Font_7x10, !highlighted);
|
||||
|
@ -10,9 +10,8 @@ using namespace daisy;
|
||||
class Menu {
|
||||
private:
|
||||
DaisyPatch* patch;
|
||||
Util* util;
|
||||
public:
|
||||
Menu(DaisyPatch*, Util*);
|
||||
Menu(DaisyPatch*);
|
||||
bool InMenu();
|
||||
void SetInMenu(bool);
|
||||
void FilterMenuSelection();
|
||||
|
15
src/util.cpp
15
src/util.cpp
@ -1,21 +1,18 @@
|
||||
#include "util.h"
|
||||
|
||||
Util::Util(DaisyPatch* m_patch) {
|
||||
patch = m_patch;
|
||||
}
|
||||
|
||||
void Util::DrawSolidRect(uint8_t x1,
|
||||
void DrawSolidRect(DaisyPatch patch,
|
||||
uint8_t x1,
|
||||
uint8_t y1,
|
||||
uint8_t x2,
|
||||
uint8_t y2,
|
||||
bool on) {
|
||||
for (int i = std::min(y1, y2); i <= std::max(y1, y2); i++) {
|
||||
patch->display.DrawLine(x1, i, x2, i, on);
|
||||
patch.display.DrawLine(x1, i, x2, i, on);
|
||||
}
|
||||
}
|
||||
|
||||
void Util::WriteString(int x, int y, std::string text) {
|
||||
patch->display.SetCursor(x, y);
|
||||
void WriteString(DaisyPatch patch, int x, int y, FontDef font, std::string text) {
|
||||
patch.display.SetCursor(x, y);
|
||||
char* cstr = &text[0];
|
||||
patch->display.WriteString(cstr, Font_6x8, true);
|
||||
patch.display.WriteString(cstr, font, true);
|
||||
}
|
||||
|
31
src/util.h
31
src/util.h
@ -1,24 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef CASCADE_UTIL_H_
|
||||
#define CASCADE_UTIL_H_
|
||||
|
||||
#include "daisy_patch.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace daisy;
|
||||
|
||||
class Util {
|
||||
private:
|
||||
DaisyPatch* patch;
|
||||
public:
|
||||
Util(DaisyPatch*);
|
||||
|
||||
void DrawSolidRect(uint8_t,
|
||||
uint8_t,
|
||||
uint8_t,
|
||||
uint8_t,
|
||||
bool);
|
||||
void DrawSolidRect(DaisyPatch,
|
||||
uint8_t,
|
||||
uint8_t,
|
||||
uint8_t,
|
||||
uint8_t,
|
||||
bool);
|
||||
|
||||
void WriteString(int,
|
||||
int,
|
||||
std::string);
|
||||
};
|
||||
void WriteString(DaisyPatch,
|
||||
int,
|
||||
int,
|
||||
FontDef,
|
||||
std::string);
|
||||
|
||||
#endif // CASCADE_UTIL_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user