monome / norns

norns is many sound instruments.
http://monome.org
GNU General Public License v3.0
614 stars 144 forks source link

grid rotation #642

Closed okyeron closed 5 years ago

okyeron commented 5 years ago

This was mentioned on lines earlier today and I thought I might give this a go. So far I'm ~failing~ getting closer.

I'd like to walk thru my process and anyone can nudge me in the right direction.

What am I missing below - to get a grid.rotation function working? (I've not gotten to adding to menu.lua yet)

device_monome.c

// set grid rotation
void dev_monome_set_rotation(struct dev_monome *md, uint8_t rotation) {
    monome_set_rotation(md->m, rotation);
}

device_monome.h

// set grid rotation
extern void dev_monome_set_rotation(struct dev_monome *md, uint8_t val);

weaver.c

static int _grid_set_rotation(lua_State *l);

lua_register(lvm, "grid_set_rotation", &_grid_set_rotation);

/***
 * grid: set rotation
 * @param dev grid device
 * @param z (rotation 0-3)
 */
int _grid_set_rotation(lua_State *l) {
  if (lua_gettop(l) != 2) {
    return luaL_error(l, "wrong number of arguments");
  }

  luaL_checktype(l, 1, LUA_TLIGHTUSERDATA);
  struct dev_monome *md = lua_touserdata(l, 1);
  int z = (int) luaL_checkinteger(l, 2); // don't convert value!
  dev_monome_set_rotation(md, z);
  lua_settop(l, 0);
  return 0;
}

grid.lua

-- set grid rotation
-- @tparam integer val : rotation 0,90,180,270 as [0, 3]
function Grid:rotation(val)
  grid_set_rotation(self.dev, val)
end

EDIT - OK - looks like I was missing a bunch of stuff in grid.lua - kinda difficult to paste it in here.

I've got it to where the lua does not error, but then anything other than grid.rotation(0) just shows a blank grid.

okyeron commented 5 years ago

work in progress here: https://github.com/okyeron/norns/tree/grid-rotation

okyeron commented 5 years ago

Turns out my teensy-grid was ignoring some led stuff from quads 3/4 so rotation wasn't showing up for me. Fixed that and it looks like this is working.

Needs testing

PR here - https://github.com/monome/norns/pull/643

tehn commented 5 years ago

fixed by #643