Skip to content

Commit

Permalink
Applet API fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
djphazer committed Jan 18, 2024
1 parent 8422d60 commit a98a637
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 32 deletions.
14 changes: 7 additions & 7 deletions software/src/APP_CALIBR8OR.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#include "src/drivers/FreqMeasure/OC_FreqMeasure.h"
#include "HemisphereApplet.h"

#define CAL8_MAX_TRANSPOSE 60
const int CAL8OR_PRECISION = 10000;
static constexpr int CAL8_MAX_TRANSPOSE = 60;
static constexpr int CAL8OR_PRECISION = 10000;

// channel configs
struct Cal8ChannelConfig {
Expand Down Expand Up @@ -248,7 +248,7 @@ class Calibr8or : public HSApplication {
ProcessMIDI();

// ClockSetup applet handles internal clock duties
HS::clock_setup_applet.instance[0].Controller();
HS::clock_setup_applet.instance[0]->Controller();

// -- core processing --
for (int ch = 0; ch < NR_OF_CHANNELS; ++ch) {
Expand Down Expand Up @@ -283,7 +283,7 @@ class Calibr8or : public HSApplication {

void View() {
if (clock_setup) {
HS::clock_setup_applet.instance[0].View();
HS::clock_setup_applet.instance[0]->View();
return;
}

Expand Down Expand Up @@ -371,7 +371,7 @@ class Calibr8or : public HSApplication {
if ( event.control == OC::CONTROL_BUTTON_DOWN || event.control == OC::CONTROL_BUTTON_UP)
UpOrDownButtonPress(event.control == OC::CONTROL_BUTTON_UP);
else if (clock_setup) // pass button down to Clock Setup
HS::clock_setup_applet.instance[0].OnButtonPress();
HS::clock_setup_applet.instance[0]->OnButtonPress();
}

void UpOrDownButtonPress(bool up) {
Expand Down Expand Up @@ -407,7 +407,7 @@ class Calibr8or : public HSApplication {
// Left encoder: Octave or VScaling + Scale Select
void OnLeftEncoderMove(int direction) {
if (clock_setup) {
HS::clock_setup_applet.instance[0].OnEncoderMove(direction);
HS::clock_setup_applet.instance[0]->OnEncoderMove(direction);
return;
}
if (preset_select) {
Expand Down Expand Up @@ -446,7 +446,7 @@ class Calibr8or : public HSApplication {
// Right encoder: Semitones or Bias Offset + Root Note
void OnRightEncoderMove(int direction) {
if (clock_setup) {
HS::clock_setup_applet.instance[0].OnEncoderMove(direction);
HS::clock_setup_applet.instance[0]->OnEncoderMove(direction);
return;
}
if (preset_select) {
Expand Down
32 changes: 16 additions & 16 deletions software/src/APP_HEMISPHERE.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ class HemisphereManager : public HSApplication {
doSave = 1;
hem_active_preset->SetAppletId(h, HS::available_applets[index].id);

uint64_t data = HS::available_applets[index].instance[h].OnDataRequest();
uint64_t data = HS::available_applets[index].instance[h]->OnDataRequest();
if (data != applet_data[h]) doSave = 1;
applet_data[h] = data;
hem_active_preset->SetData(h, data);
}
uint64_t data = HS::clock_setup_applet.instance[0].OnDataRequest();
uint64_t data = HS::clock_setup_applet.instance[0]->OnDataRequest();
if (data != clock_data) doSave = 1;
clock_data = data;
hem_active_preset->SetClockData(data);
Expand All @@ -252,14 +252,14 @@ class HemisphereManager : public HSApplication {
hem_active_preset = (HemispherePreset*)(hem_presets + id);
if (hem_active_preset->is_valid()) {
clock_data = hem_active_preset->GetClockData();
HS::clock_setup_applet.instance[0].OnDataReceive(clock_data);
HS::clock_setup_applet.instance[0]->OnDataReceive(clock_data);

for (int h = 0; h < 2; h++)
{
int index = get_applet_index_by_id( hem_active_preset->GetAppletId(h) );
applet_data[h] = hem_active_preset->GetData(h);
SetApplet(h, index);
HS::available_applets[index].instance[h].OnDataReceive(applet_data[h]);
HS::available_applets[index].instance[h]->OnDataReceive(applet_data[h]);
}
}
preset_id = id;
Expand All @@ -269,7 +269,7 @@ class HemisphereManager : public HSApplication {
// does not modify the preset, only the manager
void SetApplet(int hemisphere, int index) {
my_applet[hemisphere] = index;
HS::available_applets[index].instance[hemisphere].BaseStart(hemisphere);
HS::available_applets[index].instance[hemisphere]->BaseStart(hemisphere);
}

void ChangeApplet(int h, int dir) {
Expand Down Expand Up @@ -319,7 +319,7 @@ class HemisphereManager : public HSApplication {
CheckPresetTriggers();

// Clock Setup applet handles internal clock duties
HS::clock_setup_applet.instance[0].Controller();
HS::clock_setup_applet.instance[0]->Controller();

// execute Applets
for (int h = 0; h < 2; h++)
Expand Down Expand Up @@ -350,7 +350,7 @@ class HemisphereManager : public HSApplication {
}
}
}
HS::available_applets[index].instance[h].BaseController();
HS::available_applets[index].instance[h]->BaseController();
}
}

Expand Down Expand Up @@ -386,16 +386,16 @@ class HemisphereManager : public HSApplication {
DrawConfigMenu();
}
else if (clock_setup) {
HS::clock_setup_applet.instance[0].View();
HS::clock_setup_applet.instance[0]->View();
}
else if (help_hemisphere > -1) {
int index = my_applet[help_hemisphere];
HS::available_applets[index].instance[help_hemisphere].BaseView();
HS::available_applets[index].instance[help_hemisphere]->BaseView();
} else {
for (int h = 0; h < 2; h++)
{
int index = my_applet[h];
HS::available_applets[index].instance[h].BaseView();
HS::available_applets[index].instance[h]->BaseView();
}

if (clock_m->IsRunning()) {
Expand Down Expand Up @@ -428,7 +428,7 @@ class HemisphereManager : public HSApplication {
// button down
if (down) {
// Clock Setup is more immediate for manual triggers
if (clock_setup) HS::clock_setup_applet.instance[0].OnButtonPress();
if (clock_setup) HS::clock_setup_applet.instance[0]->OnButtonPress();
// TODO: consider a new OnButtonDown handler for applets
return;
}
Expand All @@ -439,7 +439,7 @@ class HemisphereManager : public HSApplication {
} else if (!clock_setup) {
// regular applets get button release
int index = my_applet[h];
HS::available_applets[index].instance[h].OnButtonPress();
HS::available_applets[index].instance[h]->OnButtonPress();
}
}

Expand Down Expand Up @@ -516,12 +516,12 @@ class HemisphereManager : public HSApplication {
}

if (clock_setup) {
HS::clock_setup_applet.instance[0].OnEncoderMove(event.value);
HS::clock_setup_applet.instance[0]->OnEncoderMove(event.value);
} else if (select_mode == h) {
ChangeApplet(h, event.value);
} else {
int index = my_applet[h];
HS::available_applets[index].instance[h].OnEncoderMove(event.value);
HS::available_applets[index].instance[h]->OnEncoderMove(event.value);
}
}

Expand All @@ -547,12 +547,12 @@ class HemisphereManager : public HSApplication {
void SetHelpScreen(int hemisphere) {
if (help_hemisphere > -1) { // Turn off the previous help screen
int index = my_applet[help_hemisphere];
HS::available_applets[index].instance[help_hemisphere].ToggleHelpScreen();
HS::available_applets[index].instance[help_hemisphere]->ToggleHelpScreen();
}

if (hemisphere > -1) { // Turn on the next hemisphere's screen
int index = my_applet[hemisphere];
HS::available_applets[index].instance[hemisphere].ToggleHelpScreen();
HS::available_applets[index].instance[hemisphere]->ToggleHelpScreen();
}

help_hemisphere = hemisphere;
Expand Down
2 changes: 1 addition & 1 deletion software/src/APP_SCENES.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class ScenesApp : public HSApplication {
const int data2 = usbMIDI.getData2();
f.MIDIState.ProcessMIDIMsg(usbMIDI.getChannel(), message, data1, data2);
}
HS::clock_setup_applet.instance[0].Controller();
HS::clock_setup_applet.instance[0]->Controller();

const int OCTAVE = (12 << 7);
// -- core processing --
Expand Down
2 changes: 1 addition & 1 deletion software/src/HemisphereApplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void HemisphereApplet::BaseView() {
gfxHeader(applet_name());
// If active, draw the full screen view instead of the application screen
if (full_screen) this->DrawFullScreen();
else View();
else this->View();
}

/*
Expand Down
5 changes: 1 addition & 4 deletions software/src/HemisphereApplet.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace HS {
typedef struct Applet {
int id;
uint8_t categories;
HemisphereApplet* instance;
HemisphereApplet* instance[2];
/*
void (*Start)(bool); // Initialize when selected
void (*Controller)(bool, bool); // Interrupt Service Routine
Expand All @@ -119,9 +119,6 @@ typedef struct {

static IOFrame frame;

extern Applet available_applets[];
extern Applet clock_setup_applet;

}

using namespace HS;
Expand Down
2 changes: 1 addition & 1 deletion software/src/OC_apps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
#include "util/util_pagestorage.h"
#include "util/EEPROMStorage.h"

#include "APP_HEMISPHERE.h"
#include "APP_CALIBR8OR.h"
#include "APP_SCENES.h"
#include "APP_HEMISPHERE.h"
#include "APP_ASR.h"
#include "APP_H1200.h"
#include "APP_AUTOMATONNETZ.h"
Expand Down
2 changes: 1 addition & 1 deletion software/src/applets/ClockSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,4 @@ class ClockSetup : public HemisphereApplet {
}
};

ClockSetup ClockSetup_instance[1];
ClockSetup ClockSetup_instance[2];
2 changes: 1 addition & 1 deletion software/src/hemisphere_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class_name class_name ## _instance[2]

#define DECLARE_APPLET(id, categories, class_name) \
{ id, categories, class_name ## _instance }
{ id, categories, { &class_name ## _instance[0], &class_name ## _instance[1] } }

#include "applets/ADSREG.h"
#include "applets/ADEG.h"
Expand Down

0 comments on commit a98a637

Please sign in to comment.