uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
Data Structures | Typedefs | Enumerations | Functions
hmi.h File Reference

API of the uMIDI-HMI module. More...

#include <stdbool.h>
#include <stdint.h>
#include "gpio.h"
Include dependency graph for hmi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  hmi_config
 Configuration structure for the HMI module. More...
 

Typedefs

typedef uint8_t hmi_led_pattern_t
 A bitmask that specifies an LED pattern to display. More...
 

Enumerations

enum  hmi_led {
  HMI_LED1 = 1, HMI_LED2 = 3, HMI_LED3 = 5, HMI_LED4 = 7,
  HMI_LED5 = 6, HMI_LED6 = 4, HMI_LED7 = 2, HMI_LED8 = 0
}
 Enumeration for the available LEDs on the HMI board. More...
 
enum  hmi_bar_graph_percentage {
  HMI_BAR_000_PERCENT, HMI_BAR_013_PERCENT, HMI_BAR_025_PERCENT, HMI_BAR_038_PERCENT,
  HMI_BAR_050_PERCENT, HMI_BAR_063_PERCENT, HMI_BAR_075_PERCENT, HMI_BAR_088_PERCENT,
  HMI_BAR_100_PERCENT
}
 Enumeration for possible percentages to display. More...
 

Functions

void init_hmi_module (const struct hmi_config *config)
 Initializes the HMI module according to the provided configuration. More...
 
void show_bar_graph (enum hmi_bar_graph_percentage percentage)
 Uses the HMI's LEDs to display a nice "bar graph". More...
 
void show_led_pattern (hmi_led_pattern_t pattern)
 Displays the specified pattern on the HMI's LEDs. More...
 
void set_hmi_led (enum hmi_led led, bool value)
 Turns a specific LED on or off. More...
 
void poll_hmi (void)
 Polls the HMI inputs and executes registered callbacks if an event occurred. More...
 

Detailed Description

API of the uMIDI-HMI module.

To use the uMIDI HMI, please follow these steps:

  1. Connect uMIDI to the HMI board.
  2. Define event handlers for the HMI inputs.
  3. Define a hmi_config and map your event handlers to the callbacks.
  4. Call init_hmi_module providing it with your hmi_config.
  5. Register poll_hmi as a mid-frequency background task.

Typedef Documentation

◆ hmi_led_pattern_t

typedef uint8_t hmi_led_pattern_t

A bitmask that specifies an LED pattern to display.

Counting from LSB to MSB: 1 → LED on; 0 → LED off

Enumeration Type Documentation

◆ hmi_bar_graph_percentage

Enumeration for possible percentages to display.

Enumerator
HMI_BAR_000_PERCENT 

the bar graph is empty

HMI_BAR_013_PERCENT 

the bar graph shows 1/8

HMI_BAR_025_PERCENT 

the bar graph shows 2/8

HMI_BAR_038_PERCENT 

the bar graph shows 3/8

HMI_BAR_050_PERCENT 

the bar graph shows 4/8

HMI_BAR_063_PERCENT 

the bar graph shows 5/8

HMI_BAR_075_PERCENT 

the bar graph shows 6/8

HMI_BAR_088_PERCENT 

the bar graph shows 7/8

HMI_BAR_100_PERCENT 

the bar graph is full

◆ hmi_led

enum hmi_led

Enumeration for the available LEDs on the HMI board.

Provides a pin mapping to the GPIO header. The values can be used to get a pointer to a specific LED output pin "by name":

const struct gpio_pin * const pin_pointer = &hmi_config->output_header->pin2 + HMI_LED3;
Enumerator
HMI_LED1 

LED1.

HMI_LED2 

LED2.

HMI_LED3 

LED3.

HMI_LED4 

LED4.

HMI_LED5 

LED5.

HMI_LED6 

LED6.

HMI_LED7 

LED7.

HMI_LED8 

LED8.

Function Documentation

◆ init_hmi_module()

void init_hmi_module ( const struct hmi_config config)

Initializes the HMI module according to the provided configuration.

Registers event callbacks and configures GPIO ports used by the HMI module.

Parameters
configthe HMI module configuration

◆ poll_hmi()

void poll_hmi ( void  )

Polls the HMI inputs and executes registered callbacks if an event occurred.

This procedure must be called in a slow background task to be able to process input events from the HMI board.

◆ set_hmi_led()

void set_hmi_led ( enum hmi_led  led,
bool  value 
)

Turns a specific LED on or off.

Parameters
ledthe LED to control
valuetrue → LED on; false → LED off

◆ show_bar_graph()

void show_bar_graph ( enum hmi_bar_graph_percentage  percentage)

Uses the HMI's LEDs to display a nice "bar graph".

Parameters
percentagethe percentage to display

◆ show_led_pattern()

void show_led_pattern ( hmi_led_pattern_t  pattern)

Displays the specified pattern on the HMI's LEDs.

Parameters
patternthe pattern to show
See also
hmi_led_pattern_t