upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions
GroveLEDBar Class Reference

API for Grove LED Bars base on the MY9221. More...

Detailed Description

This is a 10-segment LED bar, with 8 green segments, 1 yellow segment, and one red segment. They can be daisy chained together so that this module can control multiple LED bars.

my9221.jpg
// Instantiate a GroveLEDBar, we use D8 for the data, and D9 for the
// clock. This was tested with a Grove LED bar.
while (shouldRun)
{
// count up from green to red
for (int i=0; i<=10; i++)
{
bar->setBarLevel(i, true);
usleep(100000);
}
sleep(1);
// count down from red to green
for (int i=0; i<=10; i++)
{
bar->setBarLevel(i, false);
usleep(100000);
}
sleep(1);
}

Public Member Functions

 GroveLEDBar (uint8_t dataPin, uint8_t clockPin, int instances=1)
 
 ~GroveLEDBar ()
 
void setBarLevel (uint8_t level, bool greenToRed=true, int barNumber=0)
 
- Public Member Functions inherited from MY9221
 MY9221 (uint8_t dataPin, uint8_t clockPin, int instances=1)
 
 ~MY9221 ()
 
void setAutoRefresh (bool enable)
 
void setLED (int led, bool on)
 
void setLowIntensityValue (int intensity)
 
void setHighIntensityValue (int intensity)
 
void setAll ()
 
void clearAll ()
 
void refresh ()
 

Additional Inherited Members

- Static Public Attributes inherited from MY9221
static const int LEDS_PER_INSTANCE = 12
 
- Protected Member Functions inherited from MY9221
virtual void lockData ()
 
virtual void send16bitBlock (uint16_t data)
 
- Protected Attributes inherited from MY9221
bool m_autoRefresh
 
uint16_t m_lowIntensity
 
uint16_t m_highIntensity
 
unsigned int m_instances
 
uint16_t * m_bitStates
 
uint16_t m_commandWord
 
mraa::Gpio m_gpioClk
 
mraa::Gpio m_gpioData
 

Constructor & Destructor Documentation

GroveLEDBar ( uint8_t  dataPin,
uint8_t  clockPin,
int  instances = 1 
)

Instantiates an GroveLEDBar object

Parameters
dataPinData pin
clockPinClock pin
instancesNumber of daisy-chained Grove LED Bars, default 1

Here is the call graph for this function:

GroveLEDBar destructor

Member Function Documentation

void setBarLevel ( uint8_t  level,
bool  greenToRed = true,
int  barNumber = 0 
)

Sets the bar level

Parameters
levelSelected level for the bar (0 - 10). 0 is off
greenToRedtrue if you start the level on the first green LED, false otherwise
barNumberIf you have multiple LED bars chained together, this argument selects a specific bar starting at 0. The default is 0.

Here is the call graph for this function:

Inheritance diagram for GroveLEDBar:
Inheritance graph
[legend]
Collaboration diagram for GroveLEDBar:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: