NXShield  v1.07
NXShield Library Reference by OpenElectrons.com
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
NXShield Class Reference

This class defines methods to access NXShield features. More...

#include <NXShield.h>

Public Member Functions

 NXShield (uint8_t i2c_address_a=SH_Bank_A, uint8_t i2c_address_b=SH_Bank_B)
 
void init (SH_Protocols protocol=SH_HardwareI2C)
 
void initLEDTimers ()
 
void initProtocols (SH_Protocols protocol=SH_HardwareI2C)
 
bool getButtonState (uint8_t btn)
 
void waitForButtonPress (uint8_t btn, uint8_t led_pattern=1)
 
void ledSetRGB (uint8_t red=0, uint8_t green=0, uint8_t blue=0)
 
void ledBreathingPattern ()
 
void ledHeartBeatPattern ()
 

Public Attributes

uint8_t m_protocol
 
NXShieldBank bank_a
 
NXShieldBankB bank_b
 

Detailed Description

This class defines methods to access NXShield features.

Constructor & Destructor Documentation

NXShield::NXShield ( uint8_t  i2c_address_a = SH_Bank_A,
uint8_t  i2c_address_b = SH_Bank_B 
)

class constructor for NXShield; optional custom i2c addresses may be supplied for both banks

Member Function Documentation

bool NXShield::getButtonState ( uint8_t  btn)

Get the button state of the specific button on NXShield.

Parameters
btnButton to get state for (BTN_GO, BTN_LEFT, BTN_RIGHT)
Returns
true or false for specified button on the NXShield
void NXShield::init ( SH_Protocols  protocol = SH_HardwareI2C)

the initialization of the NXShield; This function initializes the LED related timers, and communication protocols.

Parameters
protocoloptional, specify the i2c protocol to use for the NXShield and highspeed i2c port
void NXShield::initLEDTimers ( )

the initialization of the NXShield LED timers.

void NXShield::initProtocols ( SH_Protocols  protocol = SH_HardwareI2C)

the initialization of NXShield communication protocols.

Parameters
protocoloptional, specify the i2c protocol to use for the NXShield and highspeed i2c port
void NXShield::ledBreathingPattern ( )

The LED is brightened and dimmed in a breathing pattern. Call this function repeatedly to make the pattern.

void NXShield::ledHeartBeatPattern ( )

The LED is brightened and dimmed in a HeartBeat pattern. Call this function repeatedly to make the pattern.

void NXShield::ledSetRGB ( uint8_t  red = 0,
uint8_t  green = 0,
uint8_t  blue = 0 
)

Set the colors of LED on the NXShield; The values of red, green, blue are between 0 to 8 (for 8 intensity levels).

Parameters
redIntensity for red color (between 0 and 8)
greenIntensity for green color (between 0 and 8)
blueIntensity for blue color (between 0 and 8)
void NXShield::waitForButtonPress ( uint8_t  btn,
uint8_t  led_pattern = 1 
)

Wait inside function until specified button is pressed on NXShield (BTN_GO, BTN_LEFT, BTN_RIGHT)

Parameters
btnButton to get state for (BTN_GO, BTN_LEFT, BTN_RIGHT)
led_pattern0 for LED off. 1 to brighten/lighten LED with breathing pattern (default). 2 to brighten/lighten LED with heart beat pattern.

Member Data Documentation

NXShieldBank NXShield::bank_a

Variable for the bank_a of NXShield

NXShieldBankB NXShield::bank_b

Variable for the bank_b of NXShield

uint8_t NXShield::m_protocol

Global variable representing the i2c protocol to use; whether software or hardware


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