objc

Instance Methods | Class Methods

The LED class. More...

#import <Application/Application.h>

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

Instance Methods

(BOOL- setState:
 Set the LED on/off state. More...
 
(BOOL- setBrightness:
 Set LED brightness (linear scale). More...
 
(BOOL- blinkWithDuration:repeats:
 Blink the LED at a fixed duty cycle. More...
 
(BOOL- fadeWithDuration:repeats:
 Fade the LED brightness up/down. More...
 
- Instance Methods inherited from NXObject
(id- retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id- autorelease
 Adds the receiver to the autorelease pool.
 
- Instance Methods inherited from Object
(void) - dealloc
 Free resources for an existing instance.
 
(id- init
 Initialize the instance, after allocation. More...
 
(Class- class
 Returns the class of the instance. More...
 
(Class- superclass
 Returns the superclass of the instance. More...
 
(BOOL- isEqual:
 Compares the receiver to another object for equality. More...
 
(BOOL- isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL- conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
(NXString *) - description
 Returns a string that represents the instance. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL- respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(LED *) + status
 Returns the on-board status LED. More...
 
(LED *) + binaryOnPin:
 Create or return a binary (on/off) LED on a GPIO pin. More...
 
(LED *) + linearOnPin:
 Create or return a linear-brightness LED on a GPIO/PWM-capable pin. More...
 
- Class Methods inherited from NXObject
(id+ allocWithZone:
 Allocates a new instance of an object in a specific memory zone. More...
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(id+ alloc
 Allocate a new class instance. More...
 
(Class+ class
 Returns the class object. More...
 
(Class+ superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL+ conformsTo:
 Checks if the class conforms to a protocol. More...
 
(NXString *) + description
 Returns a string that represents the class. More...
 

Additional Inherited Members

- Protected Attributes inherited from NXObject
id _zone
 The memory zone where the object is allocated.
 
unsigned short _retain
 The retain count of the object.
 
id _next
 The next object in an autorelease pool.
 
- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

The LED class.

LED represents a class for changing Light Emitting Diode (LED) state. You can create a LED instance to control the state (on/off) and brightness of the LED, depending on the hardware capabilities.

LEDs can either be the on-board status LED or external LEDs connected to GPIO pins, and can either be configured as binary (on/off) or support varying linear brightness levels, using PWM (Pulse Width Modulation) for finer control.

Examples:
examples/Application/blink/main.m.

Definition at line 27 of file LED.h.

Method Documentation

◆ binaryOnPin:()

+ (LED *) binaryOnPin: (uint8_t)  pin

Create or return a binary (on/off) LED on a GPIO pin.

Parameters
pinGPIO pin number.
Returns
An LED instance configured for on/off only, or nil on error (invalid pin or unsupported).

◆ blinkWithDuration:repeats:()

- (BOOL) blinkWithDuration: (NXTimeInterval duration
repeats: (BOOL repeats 

Blink the LED at a fixed duty cycle.

Parameters
durationPeriod in seconds for a full on/off cycle.
repeatsYES to continue blinking until stopped; NO for one cycle.
Returns
YES if the blink was started; NO if unsupported or busy.

◆ fadeWithDuration:repeats:()

- (BOOL) fadeWithDuration: (NXTimeInterval duration
repeats: (BOOL repeats 

Fade the LED brightness up/down.

Parameters
durationDuration in seconds for a full fade in/out cycle.
repeatsYES to continue fading until stopped; NO for one cycle.
Returns
YES if the fade was started; NO if unsupported or busy.

◆ linearOnPin:()

+ (LED *) linearOnPin: (uint8_t)  pin

Create or return a linear-brightness LED on a GPIO/PWM-capable pin.

Parameters
pinGPIO pin number (should support PWM for brightness control).
Returns
An LED instance with brightness control, or nil on error.

◆ setBrightness:()

- (BOOL) setBrightness: (uint8_t)  brightness

Set LED brightness (linear scale).

Parameters
brightnessBrightness from 0 (off) to 255 (full).
Returns
YES on success; NO if brightness is unsupported for this LED.

For binary LEDs, non-zero values are typically treated as ON.

◆ setState:()

- (BOOL) setState: (BOOL on

Set the LED on/off state.

Parameters
onYES to turn on, NO to turn off.
Returns
YES on success; NO if not supported or on failure.

◆ status()

+ (LED *) status

Returns the on-board status LED.

Returns
An LED instance if the board exposes a status LED; nil otherwise.

Returns an instance of the on-board status LED, which may be simple on/off or able to display different brightness or colors.


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