upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

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.
upm::GroveLEDBar bar(8, 9);
while (shouldRun) {
// count up from green to red
for (int i = 0; i <= 10; i++) {
bar.setBarLevel(i, true);
upm_delay_us(100000);
}
upm_delay(1);
// count down from red to green
for (int i = 0; i <= 10; i++) {
bar.setBarLevel(i, false);
upm_delay_us(100000);
}
upm_delay(1);
}

Public Member Functions

 GroveLEDBar (int dataPin, int clockPin, int instances=1)
 
virtual ~GroveLEDBar ()
 
void setBarLevel (uint8_t level, bool greenToRed=true, unsigned int barNumber=0)
 
- Public Member Functions inherited from MY9221
 MY9221 (int dataPin, int clockPin, int instances=1)
 
virtual ~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

- Protected Attributes inherited from MY9221
my9221_context m_my9221
 

Constructor & Destructor Documentation

GroveLEDBar ( int  dataPin,
int  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 ( )
virtual

GroveLEDBar destructor

Member Function Documentation

void setBarLevel ( uint8_t  level,
bool  greenToRed = true,
unsigned 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: