Skip to content

Commit 707ccee

Browse files
author
Martin Klang
committed
refactor Screen to remove PLATFORM dependency
1 parent 44b15b8 commit 707ccee

9 files changed

Lines changed: 27 additions & 107 deletions

File tree

LibSource/Patch.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,31 +75,6 @@ int Patch::getElapsedCycles(){
7575
return *DWT_CYCCNT;
7676
}
7777

78-
#ifdef USE_SCREEN
79-
void drawMessage(ScreenBuffer& screen){
80-
ProgramVector* pv = getProgramVector();
81-
if(pv->message != NULL){
82-
screen.setTextSize(1);
83-
screen.setTextWrap(true);
84-
screen.print(0, 26, pv->message);
85-
}
86-
}
87-
void drawTitle(const char* title, ScreenBuffer& screen){
88-
// draw title
89-
screen.setTextSize(2);
90-
screen.print(0, 16, title);
91-
}
92-
void Patch::processScreen(ScreenBuffer& screen){
93-
// screen.clear();
94-
const char* title = getInitialisingPatchProcessor()->getPatchName();
95-
drawTitle(title, screen);
96-
drawMessage(screen);
97-
// const char title[] = "KickBox";
98-
// screen.setTextSize(2);
99-
// screen.print(0, 16, title);
100-
}
101-
#endif /* USE_SCREEN */
102-
10378
#ifdef USE_MIDI_CALLBACK
10479
void Patch::processMidi(MidiMessage msg){}
10580

LibSource/Patch.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
#include "PatchParameter.h"
88
#include "SmoothValue.h"
99
#include "OpenWareMidiControl.h"
10-
#ifdef USE_SCREEN
11-
#include "ScreenBuffer.h"
12-
#endif /* USE_SCREEN */
1310

1411
#ifdef USE_MIDI_CALLBACK
1512
#include "MidiMessage.h"
@@ -68,11 +65,6 @@ class Patch {
6865
virtual void buttonChanged(PatchButtonId bid, uint16_t value, uint16_t samples){}
6966
/* virtual void parameterChanged(PatchParameterId pid, float value, int samples){} */
7067
virtual void processAudio(AudioBuffer& audio) = 0;
71-
#ifdef USE_SCREEN
72-
uint16_t getScreenWidth();
73-
uint16_t getScreenHeight();
74-
virtual void processScreen(ScreenBuffer& screen);
75-
#endif /* USE_SCREEN */
7668
#ifdef USE_MIDI_CALLBACK
7769
virtual void processMidi(MidiMessage msg);
7870
virtual void sendMidi(MidiMessage msg);

LibSource/ScreenBuffer.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
#include <stdint.h>
55
#include "device.h"
66

7-
#if defined SSD1309
8-
typedef uint8_t Colour;
9-
// Color definitions mono
10-
#define BLACK 0x00
11-
#define WHITE 0x01
12-
#elif defined SSD1331 || defined SEPS114A
13-
typedef uint16_t Colour;
7+
enum ScreenDriver {
8+
SSD1309 = 0x01,
9+
SSD1331 = 0x02
10+
};
11+
12+
// #if defined SSD1309
13+
// typedef uint8_t Colour;
14+
// // Color definitions mono
15+
// #define BLACK 0x00
16+
// #define WHITE 0x01
17+
// #elif defined SSD1331 || defined SEPS114A
18+
// typedef uint16_t Colour;
1419
// Color definitions
1520
#define BLACK 0x0000
1621
#define BLUE 0x001F
@@ -20,10 +25,11 @@ typedef uint16_t Colour;
2025
#define MAGENTA 0xF81F
2126
#define YELLOW 0xFFE0
2227
#define WHITE 0xFFFF
23-
#else
24-
#error "Invalid configuration"
25-
#endif
28+
// #else
29+
// #define NO_SCREEN
30+
// #endif
2631

32+
template<ScreenDriver driver, typename Colour>
2733
class ScreenBuffer {
2834
private:
2935
const uint16_t width;
@@ -89,9 +95,4 @@ class ScreenBuffer {
8995
static ScreenBuffer* create(uint16_t width, uint16_t height);
9096
};
9197

92-
/* class VideoPatch : public Patch { */
93-
/* public: */
94-
/* virtual void processVideo(ScreenBuffer& video, AudioBuffer& audio) = 0; */
95-
/* }; */
96-
9798
#endif // __ScreenBuffer_h__

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ Make sure to do a `make clean` before compiling a new patch, or add `clean` to y
7373
* PATCHOUT: number of output channels, default 2
7474
* SLOT: user program slot to store patch in, default 0
7575
* TARGET: changes the output prefix, default 'patch'
76-
* PLATFORM: Alchemist, Wizard, Prism, Magus, Player, default 'OWL'
7776

7877
If you follow the convention of SimpleDelay then you don't have to specify `PATCHCLASS` and `PATCHFILE`, they will be deduced from `PATCHNAME`.
7978
t
@@ -122,18 +121,18 @@ do it like this from the main directory of OwlProgram (this will store in slot 6
122121

123122
# Examples
124123

125-
Compile the puredata file owl_hypersaw.pd[[7]](#ref7) for magus platform:
124+
Compile the puredata file owl_hypersaw.pd[[7]](#ref7):
126125

127-
make HEAVY=owl_hypersaw PLATFORM=Magus clean patch
126+
make HEAVY=owl_hypersaw clean patch
128127

129128

130-
Compile puredata file owl_hypersaw.pd for magus platform and send to device to be run immediately:
129+
Compile puredata file owl_hypersaw.pd and send to device to be run immediately:
131130

132-
make HEAVY=owl_hypersaw PLATFORM=Magus clean run
131+
make HEAVY=owl_hypersaw clean run
133132

134-
Compile KickBox[[8]](#ref8) C++ patch for for magus platform:
133+
Compile KickBox[[8]](#ref8) C++ patch:
135134

136-
make PATCHNAME=KickBox PLATFORM=Magus clean patch
135+
make PATCHNAME=KickBox clean patch
137136

138137

139138
# References

Source/PatchProgram.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ void onButtonChanged(uint8_t id, uint16_t value, uint16_t samples){
4646
processor.patch->buttonChanged((PatchButtonId)id, value, samples);
4747
}
4848

49-
#ifdef USE_SCREEN
50-
void onDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){
51-
if(processor.patch != NULL){
52-
ScreenBuffer screen(width, height);
53-
screen.setBuffer(pixels);
54-
processor.patch->processScreen(screen);
55-
}
56-
}
57-
#endif /* USE_SCREEN */
58-
5949
#ifdef USE_MIDI_CALLBACK
6050
void onMidiCallback(uint8_t port, uint8_t status, uint8_t d1, uint8_t d2){
6151
static MidiMessage msg;
@@ -88,10 +78,6 @@ void registerPatch(const char* name, uint8_t inputs, uint8_t outputs, Patch* pat
8878
static SampleBuffer* samples;
8979
void setup(ProgramVector* pv){
9080
setSystemTables(pv);
91-
#ifdef USE_SCREEN
92-
void* drawArgs[] = {(void*)SYSTEM_FUNCTION_DRAW, (void*)&onDrawCallback};
93-
getProgramVector()->serviceCall(OWL_SERVICE_REGISTER_CALLBACK, drawArgs, 2);
94-
#endif /* USE_SCREEN */
9581
#ifdef USE_MIDI_CALLBACK
9682
void* midiRxArgs[] = {(void*)SYSTEM_FUNCTION_MIDI, (void*)&onMidiCallback};
9783
getProgramVector()->serviceCall(OWL_SERVICE_REGISTER_CALLBACK, midiRxArgs, 2);

Source/ScreenBuffer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "ScreenBuffer.h"
2+
3+
#ifndef NO_SCREEN
4+
25
#include <string.h>
36
#include <stddef.h>
47
#include "font.c"
@@ -226,3 +229,4 @@ void ScreenBuffer::write(uint8_t c) {
226229
}
227230
}
228231
}
232+
#endif

Source/device.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
#include <inttypes.h>
22

3-
#if defined OWL_MAGUS
4-
#define USE_SCREEN
5-
#define SSD1309
6-
#define AUDIO_MAX_BLOCK_SIZE 512
7-
#elif defined OWL_PRISM
8-
#define USE_SCREEN
9-
#define SEPS114A
10-
#define AUDIO_MAX_BLOCK_SIZE 256
11-
#elif defined OWL_PLAYER
12-
#define USE_SCREEN
13-
#define SSD1309
14-
#define AUDIO_MAX_BLOCK_SIZE 512
15-
#elif defined OWL_ALCHEMIST
16-
#define AUDIO_MAX_BLOCK_SIZE 512
17-
#elif defined OWL_WIZARD
18-
#define AUDIO_MAX_BLOCK_SIZE 512
19-
#endif
20-
213
#define USE_MIDI_CALLBACK
224

235
#if !defined OWL_CLASSIC

Source/main.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ int main(void){
6969
return -1;
7070
}
7171

72-
if(pv->audio_blocksize > AUDIO_MAX_BLOCK_SIZE){
73-
error(CONFIGURATION_ERROR_STATUS, "Invalid blocksize");
74-
return -1;
75-
}
76-
7772
size_t before = xPortGetFreeHeapSize();
7873
setup(pv);
7974
pv->heap_bytes_used = before - xPortGetFreeHeapSize();

compile.mk

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CPP_SRC += WavetableOscillator.cpp PolyBlepOscillator.cpp
1010
CPP_SRC += SmoothValue.cpp PatchParameter.cpp
1111
CPP_SRC += PatchProgram.cpp
1212
# CPP_SRC += ShortPatchProgram.cpp
13+
CPP_SRC += ScreenBuffer.cpp ScreenBufferDevice.cpp
1314

1415
SOURCE = $(BUILDROOT)/Source
1516
LIBSOURCE = $(BUILDROOT)/LibSource
@@ -53,21 +54,6 @@ CXXFLAGS = -fno-rtti -fno-exceptions
5354

5455
ifdef HEAVY
5556
CPPFLAGS += -D__unix__ -DHV_SIMD_NONE
56-
else ifeq ($(PLATFORM),Alchemist)
57-
CPPFLAGS += -DOWL_ALCHEMIST
58-
else ifeq ($(PLATFORM),Wizard)
59-
CPPFLAGS += -DOWL_WIZARD
60-
else ifeq ($(PLATFORM),Prism)
61-
CPPFLAGS += -DOWL_PRISM
62-
CPP_SRC += ScreenBuffer.cpp ScreenBufferDevice.cpp
63-
else ifeq ($(PLATFORM),Magus)
64-
CPPFLAGS += -DOWL_MAGUS
65-
CPP_SRC += ScreenBuffer.cpp ScreenBufferDevice.cpp
66-
else ifeq ($(PLATFORM),Player)
67-
CPPFLAGS += -DOWL_PLAYER
68-
CPP_SRC += ScreenBuffer.cpp ScreenBufferDevice.cpp
69-
else
70-
CPPFLAGS += -DOWL_CLASSIC
7157
endif
7258

7359
CC=gcc

0 commit comments

Comments
 (0)