upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
apa102.h
Go to the documentation of this file.
1 /*
2  * Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
3  * Copyright (c) 2016 Intel Corporation
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <stdint.h>
27 #include "upm.h"
28 #include "mraa/gpio.h"
29 #include "mraa/spi.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
46 typedef struct _apa102_context {
47  mraa_spi_context spi;
48 
49  // optional chip select
50  mraa_gpio_context cs;
51 
52  uint8_t* buffer;
53  int leds;
54  int framelength;
56 
57 
66 apa102_context apa102_init(int ledcount, int bus, int cs);
67 
74 
86 upm_result_t apa102_set_led(apa102_context dev, uint16_t index, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b);
87 
96 upm_result_t apa102_set_led_brightness(apa102_context dev, uint16_t index, uint8_t brightness);
97 
110 upm_result_t apa102_set_leds(apa102_context dev, uint16_t s_index, uint16_t e_index, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b);
111 
121 upm_result_t apa102_set_leds_brightness(apa102_context dev, uint16_t s_index, uint16_t e_index, uint8_t brightness);
122 
129 upm_result_t apa102_refresh(apa102_context dev);
130 
131 #ifdef __cplusplus
132 }
133 #endif
struct _apa102_context * apa102_context
upm_result_t apa102_refresh(apa102_context dev)
Definition: apa102.c:126
void apa102_close(apa102_context dev)
Definition: apa102.c:79
upm_result_t apa102_set_leds_brightness(apa102_context dev, uint16_t s_index, uint16_t e_index, uint8_t brightness)
Definition: apa102.c:114
upm_result_t apa102_set_leds(apa102_context dev, uint16_t s_index, uint16_t e_index, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
Definition: apa102.c:99
upm_result_t apa102_set_led_brightness(apa102_context dev, uint16_t index, uint8_t brightness)
Definition: apa102.c:95
Definition: apa102.h:46
apa102_context apa102_init(int ledcount, int bus, int cs)
Definition: apa102.c:31
upm_result_t apa102_set_led(apa102_context dev, uint16_t index, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
Definition: apa102.c:91