Test program for BaseMachineUIController Library

Dependencies:   AverageAnalogIn BaseMachineUIController ExioBufferdController MCP23S17 PinDetect RotaryEncoder Sequence SequencerDisplay mbed-rtos mbed st7567LCD AT24C1024

main.cpp

Committer:
ryood
Date:
2016-11-06
Revision:
1:46e088b12083
Parent:
0:f3abbd84d67f
Child:
2:354ca389e975

File content as of revision 1:46e088b12083:

/*
 * main.cpp
 * BaseMachineUIController Test
 *
 * mbed Rev 121 / mbed-rtos Rev 117
 *
 * 2016.11.06 Created
 *
 */

#include "mbed.h"
#include "rtos.h"

#define UART_TRACE  (0)
#include "BaseMachineUIController.h"

BaseMachineUIController UIController;

uint8_t step = 0;
int isStepChanged = false;
bool isRunning = false;

void stepUp(void const* args)
{
    if (isRunning) {
        step++;
        if (step == 16)
        {
            step = 0;
        }
        UIController.setPlayingStep(step);
    }
}

int main()
{    
    #if (UART_TRACE)
    printf("*** BaseMachineUIController Test***\r\n");
    #endif
    
    UIController.init();
    
    RtosTimer stepTimer(stepUp, osTimerPeriodic, (void *)0);
    stepTimer.start(125);
    
    while (true)
    {
        UIController.update();

        isRunning = UIController.getIsRunning();
        
        OscillatorParam osc;
        UIController.getOscillatorParam(&osc);
        
        FilterParam flt;
        UIController.getFilterParam(&flt);
        
        EnvelopeParam env;
        UIController.getEnvelopeParam(&env);
        
        int bpm = UIController.getBpm();
        int accentLevel = UIController.getAccentLevel();
        
        #if (UART_TRACE)
        printf("%d %d ", osc.waveShape, osc.pulseWidth); 
        printf("%d %d ", flt.cutoff, flt.resonance); 
        printf("%d %d %d %d %d ", env.level, env.length, env.duration, env.decay, env.sustain); 
        printf("%d %d\r\n", bpm, accentLevel);
        #endif
    }
}