joystick

Axoloti Control (AxoC) - Joystick control
Author: Mark Harris
License: GPL
Github: tb/ctrl/axoc/joystick.axo

Inlets

bool32 led1

Outlets

frac32 x

frac32 y

bool32 s

Displays

frac32.u.dial x

frac32.u.dial y

bool32 s

Declaration
static const unsigned int SIZE = 2;
static const int32_t F_FREQ = 1 << 23;
int32_t o[SIZE];
Init
int i;
for (i = 0; i < SIZE; i++) {
  o[i] = 0;
}

palSetPadMode(GPIOC, 0, PAL_MODE_INPUT_PULLDOWN);
palSetPadMode(GPIOB, 0, PAL_MODE_OUTPUT_PUSHPULL);
Control Rate
int i = 0;
for (int i = 0; i < SIZE; i++) {
  o[i] = ___SMMLA(((adcvalues[i + 0] << 15) - o[i]) << 1, F_FREQ, o[i]);
}

outlet_x = o[1];
outlet_y = o[0];

int32_t s = palReadPad(GPIOC, 0);

palWritePad(GPIOB, 0, (inlet_led1 > 0));

disp_x = o[1];
disp_y = o[0];
disp_s = s;
outlet_s = s;

Privacy

© 2024 Zrna Research