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
2 changes: 2 additions & 0 deletions apps/bees/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ CSRCS += \
$(APP_DIR)/src/ops/op_gate.c \
$(APP_DIR)/src/ops/op_harry.c \
$(APP_DIR)/src/ops/op_hid_word.c \
$(APP_DIR)/src/ops/op_hist2.c \
$(APP_DIR)/src/ops/op_history.c \
$(APP_DIR)/src/ops/op_is.c \
$(APP_DIR)/src/ops/op_iter.c \
Expand Down Expand Up @@ -93,6 +94,7 @@ CSRCS += \
$(APP_DIR)/src/ops/op_preset.c \
$(APP_DIR)/src/ops/op_random.c \
$(APP_DIR)/src/ops/op_route.c \
$(APP_DIR)/src/ops/op_route2.c \
$(APP_DIR)/src/ops/op_route8.c \
$(APP_DIR)/src/ops/op_route16.c \
$(APP_DIR)/src/ops/op_screen.c \
Expand Down
12 changes: 12 additions & 0 deletions apps/bees/src/op.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const op_id_t userOpTypes[NUM_USER_OP_TYPES] = {
eOpMonomeGridRaw, // "gridraw"
eOpHarry,
eOpHid,
eOpHist2,
eOpHistory,
eOpIs,
eOpIter,
Expand Down Expand Up @@ -69,6 +70,7 @@ const op_id_t userOpTypes[NUM_USER_OP_TYPES] = {
eOpPoly,
eOpRandom,
eOpRoute,
eOpRoute2,
eOpRoute8,
eOpRoute16,
eOpScreen,
Expand Down Expand Up @@ -421,6 +423,16 @@ const op_desc_t op_registry[numOpClasses] = {
.size = sizeof(op_list4_t),
.init = &op_list4_init,
.deinit = NULL
}, {
.name = "ROUTE2",
.size = sizeof(op_route2_t),
.init = &op_route2_init,
.deinit = NULL
}, {
.name = "HIST2",
.size = sizeof(op_hist2_t),
.init = &op_hist2_init,
.deinit = NULL
}
};

Expand Down
2 changes: 2 additions & 0 deletions apps/bees/src/op.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ typedef enum {
eOpCkdiv,
eOpLinlin,
eOpList4,
eOpRoute2,
eOpHist2,
// eOpMidiBend,
// eOpMidiTouch,
numOpClasses // dummy/count
Expand Down
2 changes: 2 additions & 0 deletions apps/bees/src/op_derived.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "ops/op_harry.h"
#include "ops/op_hid_word.h"
#include "ops/op_history.h"
#include "ops/op_hist2.h"
#include "ops/op_is.h"
#include "ops/op_iter.h"
#include "ops/op_life_classic.h"
Expand Down Expand Up @@ -68,6 +69,7 @@
#include "ops/op_sub.h"
#include "ops/op_random.h"
#include "ops/op_route.h"
#include "ops/op_route2.h"
#include "ops/op_route8.h"
#include "ops/op_route16.h"
#include "ops/op_screen.h"
Expand Down
71 changes: 71 additions & 0 deletions apps/bees/src/ops/op_hist2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include "net_protected.h"
#include "op_hist2.h"

//-------------------------------------------------
//----- static function declaration
static void op_hist2_in_in(op_hist2_t* history, const io_t v);

// pickle / unpickle
static u8* op_hist2_pickle(op_hist2_t* op, u8* dst);
static const u8* op_hist2_unpickle(op_hist2_t* op, const u8* src);


//-------------------------------------------------
//----- static vars
static op_in_fn op_hist2_in_fn[1] = {
(op_in_fn)&op_hist2_in_in
};

static const char* op_hist2_instring = "IN\0 ";
static const char* op_hist2_outstring = "O0\0 O1\0 ";
static const char* op_hist2_opstring = "HIST2";

//-------------------------------------------------
//----- external function definitions
void op_hist2_init(void* mem) {
op_hist2_t* history = (op_hist2_t*)mem;
history->super.numInputs = 1;
history->super.numOutputs = 2;
history->outs[0] = -1;
history->outs[1] = -1;

history->super.in_fn = op_hist2_in_fn;
history->super.pickle = (op_pickle_fn) (&op_hist2_pickle);
history->super.unpickle = (op_unpickle_fn) (&op_hist2_unpickle);

history->super.in_val = history->in_val;
history->super.out = history->outs;
history->super.opString = op_hist2_opstring;
history->super.inString = op_hist2_instring;
history->super.outString = op_hist2_outstring;
history->super.type = eOpHist2;
history->in_val[0] = &(history->in);

history->in = 0;
}

//-------------------------------------------------
//----- static function definitions
static void op_hist2_in_in(op_hist2_t* history, const io_t v) {
// printf("history at %d received A %d\n", (int)history, (int)*v);

history->in = v;

history->val[1] = history->val[0];
history->val[0] = v;

net_activate(history, 0, history->val[0]);
net_activate(history, 1, history->val[1]);
}


// pickle / unpickle
u8* op_hist2_pickle(op_hist2_t* op, u8* dst) {
dst = pickle_io(op->in, dst);
return dst;
}

const u8* op_hist2_unpickle(op_hist2_t* op, const u8* src ) {
src = unpickle_io(src, &(op->in));
return src;
}
19 changes: 19 additions & 0 deletions apps/bees/src/ops/op_hist2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _op_hist2_H_
#define _op_hist2_H_

#include "op.h"
#include "op_math.h"
#include "types.h"

//--- op_hist2_t
typedef struct op_hist2_struct {
op_t super;
io_t val[2];
volatile io_t in;
volatile io_t* in_val[1];
op_out_t outs[2];
} op_hist2_t;

void op_hist2_init(void* hist2);

#endif // header guard
91 changes: 91 additions & 0 deletions apps/bees/src/ops/op_route2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include "net_protected.h"
#include "print_funcs.h"

#include "pickle.h"
#include "op_route.h"

//-------------------------------------------------
//----- descriptor
static const char* op_route2_instring = "VAL\0 TO\0 ";
static const char* op_route2_outstring = "O0\0 O1\0 ";
static const char* op_route2_opstring = "ROUTE2";

//-------------------------------------------------
//----- static function declaration


// set inputs
static void op_route2_in_val(op_route2_t* route, const io_t v);
static void op_route2_in_to(op_route2_t* route, const io_t v);
// pickle / unpickle
static u8* op_route2_pickle(op_route2_t* route, u8* dst);
const static u8* op_route2_unpickle(op_route2_t* route, const u8* src);

// array of input functions
static op_in_fn op_route2_in[2] = {
(op_in_fn)&op_route2_in_val,
(op_in_fn)&op_route2_in_to
};

//----- external function definition

/// initialize
void op_route2_init(void* op) {
op_route2_t* route = (op_route2_t*)op;

// superclass functions
route->super.in_fn = op_route2_in;
route->super.pickle = (op_pickle_fn) (&op_route2_pickle);
route->super.unpickle = (op_unpickle_fn) (&op_route2_unpickle);

// superclass state
route->super.numInputs = 2;
route->super.numOutputs = 2;
route->outs[0] = -1;
route->outs[1] = -1;

route->super.in_val = route->in_val;
route->in_val[0] = &(route->val);
route->in_val[1] = &(route->to);

route->super.out = route->outs;
route->super.opString = op_route2_opstring;
route->super.inString = op_route2_instring;
route->super.outString = op_route2_outstring;
route->super.type = eOpRoute2;

// class state
route->val = 0;
route->to = 0;
}

//-------------------------------------------------
//----- static function definition

//===== operator input

// input state
static void op_route2_in_val(op_route2_t* route, const io_t v) {
route->val = v;
net_activate(route, route->to, route->val);
}

// to where
static void op_route2_in_to(op_route2_t* route, const io_t v) {
io_t val = v;
if(val<0) val = 0;
else if(val>1) val = 1;
route->to = val;
}


// serialization
u8* op_route2_pickle(op_route2_t* route, u8* dst) {
dst = pickle_io(route->to, dst);
return dst;
}

const u8* op_route2_unpickle(op_route2_t* route, const u8* src) {
src = unpickle_io(src, &(route->to));
return src;
}
22 changes: 22 additions & 0 deletions apps/bees/src/ops/op_route2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef _OP_ROUTE2_H_
#define _OP_ROUTE2_H_

#include "op.h"
#include "op_math.h"
#include "types.h"

//--- op_split_t : switch (non-system)
typedef struct op_route2_struct {
// superclass
op_t super;
// state variables / inputs
volatile io_t val;
volatile io_t to;
// pointers for external access
volatile io_t* in_val[2];
op_out_t outs[2];
} op_route2_t;

extern void op_route2_init(void* split4);

#endif // header guard