upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
my9221.h
Go to the documentation of this file.
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * These modules were rewritten, based on original work by:
6  *
7  * (original my9221/groveledbar)
8  * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
9  * Copyright (c) 2014 Intel Corporation.
10  *
11  * (grovecircularled)
12  * Author: Jun Kato and Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
13  * Contributions: Jon Trulson <jtrulson@ics.com>
14  * Copyright (c) 2014 Intel Corporation.
15  *
16  * Permission is hereby granted, free of charge, to any person obtaining
17  * a copy of this software and associated documentation files (the
18  * "Software"), to deal in the Software without restriction, including
19  * without limitation the rights to use, copy, modify, merge, publish,
20  * distribute, sublicense, and/or sell copies of the Software, and to
21  * permit persons to whom the Software is furnished to do so, subject to
22  * the following conditions:
23  *
24  * The above copyright notice and this permission notice shall be
25  * included in all copies or substantial portions of the Software.
26  *
27  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34  */
35 #pragma once
36 
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <upm.h>
40 
41 #include <mraa/gpio.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
58  typedef struct _my9221_context {
59  mraa_gpio_context gpioClk;
60  mraa_gpio_context gpioData;
61 
62  bool autoRefresh;
63  // we're only doing 8-bit greyscale, so the high order bits are
64  // always 0
65  uint16_t lowIntensity;
66  uint16_t highIntensity;
67 
68  unsigned int instances;
69  unsigned int maxLEDS;
70 
71  // an array of uint16_t's representing our bit states (on/off)
72  // intensities. Only the low 8 bits are used, but in the future
73  // 16bit support can work here as well.
74  uint16_t *bitStates;
75 
76  uint16_t commandWord;
77 
78  bool initialized;
79 
80  // A helper for the users of this driver
81  unsigned int max_leds_per_instance;
82  } *my9221_context;
83 
84 
94  my9221_context my9221_init(int dataPin, int clockPin,
95  int instances);
96 
102  void my9221_close(my9221_context dev);
103 
113  void my9221_set_auto_refresh(const my9221_context dev, bool enable);
114 
123  void my9221_set_led(const my9221_context dev, int led, bool on);
124 
135  int intensity);
136 
147  int intensity);
148 
154  void my9221_set_all(const my9221_context dev);
155 
161  void my9221_clear_all(const my9221_context dev);
162 
170  void my9221_refresh(const my9221_context dev);
171 
179  int my9221_get_max_leds(const my9221_context dev);
180 
181 #ifdef __cplusplus
182 }
183 #endif
int my9221_get_max_leds(const my9221_context dev)
Definition: my9221.c:224
void my9221_clear_all(const my9221_context dev)
Definition: my9221.c:190
void my9221_set_all(const my9221_context dev)
Definition: my9221.c:179
struct _my9221_context * my9221_context
void my9221_refresh(const my9221_context dev)
Definition: my9221.c:201
my9221_context my9221_init(int dataPin, int clockPin, int instances)
Definition: my9221.c:51
void my9221_set_high_intensity_value(const my9221_context dev, int intensity)
Definition: my9221.c:171
Definition: my9221.h:58
void my9221_set_low_intensity_value(const my9221_context dev, int intensity)
Definition: my9221.c:163
void my9221_set_led(const my9221_context dev, int led, bool on)
Definition: my9221.c:146
void my9221_close(my9221_context dev)
Definition: my9221.c:123
void my9221_set_auto_refresh(const my9221_context dev, bool enable)
Definition: my9221.c:217