Send CC Events on pot movements

We want to send a CC event when a pot is moved.

Copy the SDCC skeleton into a new directory, open the main.c file and enhance the hooks like described below. Thereafter type "make" in the command shell, and upload the new project.hex file to the core.

Within the Init() function, you have to specify, how many pots are connected to the core, and if AIN multiplexers are used:

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the 
// application
/////////////////////////////////////////////////////////////////////////////
void Init(void) __wparam
{
  // initialize the AIN driver
  MIOS_AIN_NumberSet(1);   // only one pot is connected
  MIOS_AIN_UnMuxed();      // no AINX4 modules are used
  MIOS_AIN_DeadbandSet(7); // should be 7 when 7bit resolution is used
}

We add the code which should be executed on pot movements to the AIN_NotifyChange() function:

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{
  // a pot has been moved, send CC# at channel 1
  MIOS_MIDI_TxBufferPut(0xb0); // CC at channel 1
  MIOS_MIDI_TxBufferPut(pin);  // pin number corresponds to CC number
  MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin));   // don't send 10bit pin_value,
                                                     // but 7bit value
}

A list of available MIOS function can be found here.



Last update: 2018-01-06

Copyright 1998-2018, Thorsten Klose. All rights reserved.