Module Descriptor and Compiled Parameter Table

I tried Google Protocol Buffers to describe and transfer modules’ schema before. This approach, however, did not work well because it required large amount of resources both in program and in RAM spaces of a PSoC processor. It limited available resources for module functionality. I finally gave up the approach.

I am trying another approach to describe a module using JSON and to compile it into a parameter table implemented using C macros. The module program does not have to include the schema. Sharing the JSON schema file by Analog 3 modules is good enough. It is nice if the module has the schema internally though. Google Protocol Buffer may help compressing the data in the case.

Here is an example of schema and generated table for MIDI Gateway module:

{
    "name": "midigw",
    "type": "Module",
    "member": [
        {
            "name": "MIDI channel",
            "type": "NumberSelector",
            "min": 1,
            "max": 16
        },
        {
            "name": "Voices",
            "type": "Selector",
            "choices": ["mono", "duo", "poly 4", "poly 5", "poly 6", "poly 8", "poly 10", "poly 16"]
        },
        {
            "name": "Retrigger",
            "type": "Switch",
            "default": True
        }
    ]
}

#define P_N1_MIDI_CHANNEL_OFFSET 0
#define P_L_VOICES_OFFSET        1
#define P_B_RETRIGGER_OFFSET     2
#define P_BUFFER_SIZE            3

static uint8_t p_buffer[P_BUFFER_SIZE];

#define P_N1_MIDI_CHANNEL (*(uint8_t*)&p_buffer[P_N1_MIDI_CHANNEL_OFFSET])
#define P_N1_MIDI_CHANNEL_VALUE_OFFSET 1

#define P_L_VOICES       (*(uint8_t*)&p_buffer[P_L_VOICES_OFFSET])
#define P_L_VOICES__MONO     0
#define P_L_VOICES__DUO      1
#define P_L_VOICES__POLY_4   2
#define P_L_VOICES__POLY_5   2
#define P_L_VOICES__POLY_6   2
#define P_L_VOICES__POLY_8   2
#define P_L_VOICES__POLY_10  2
#define P_L_VOICES__POLY_16  2

#define P_B_RETRIGGER (*(uint8_t*)&p_buffer[P_B_RETRIGGER_OFFSET])

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.