An LED, or a chain of NeoPixels, which is turned on and off, dimmed, colored, or blinked. More...
#import <Application/Application.h>


Instance Methods | |
| (size_t) | - count |
| Returns the number of LEDs, which is more than 1 for a chain of NeoPixels. | |
| (void) | - setBoolValue: |
| Turns it on or off, or every LED of a chain, and stops a blink. | |
| (void) | - setBoolValue:atIndex: |
| Turns an LED of a chain on or off, and stops a blink. | |
| (void) | - setBrightness: |
| Dims it, or every LED of a chain, and stops a blink. More... | |
| (void) | - setBrightness:atIndex: |
| Dims an LED of a chain, and stops a blink. | |
| (void) | - setColor: |
| Colors it, or every LED of a chain, and stops a blink. More... | |
| (void) | - setColor:atIndex: |
| Colors an LED of a chain, and stops a blink. | |
| (BOOL) | - blinkWithInterval:repeats: |
| Blinks it, starting off, and turning on and off every interval. More... | |
| (BOOL) | - blinkWithInterval:repeats:atIndex: |
| Blinks an LED of a chain, in its color, at full brightness. More... | |
| (void) | - clear |
| Turns it off, or every LED of a chain, and stops a blink. | |
Instance Methods inherited from NXObject | |
| (void) | - dealloc |
| Frees the instance. More... | |
| (NXZone *) | - zone |
| Returns the zone in which the instance was allocated. More... | |
| (id) | - retain |
| Increases the retain count of the receiver. More... | |
| (void) | - release |
| Decreases the retain count of the receiver. More... | |
| (id) | - autorelease |
| Releases the receiver later, when the current autorelease pool of the thread is drained. More... | |
| (id) | - copy |
| Returns a copy which can't be changed by anything else, which the caller owns and has to release. More... | |
| (uintptr_t) | - hash |
| Returns a number for the object, which is the same for objects which are equal by isEqual:. More... | |
| (NXString *) | - description |
| Returns a string which describes the instance, for logging. More... | |
Instance Methods inherited from Object | |
| (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... | |
Instance Methods inherited from <ObjectProtocol> | |
| (BOOL) | - respondsToSelector: |
| Checks if the receiver responds to a selector. More... | |
Class Methods | |
| (NXLight *) | + default |
| Returns the board's own LED. More... | |
| (NXLight *) | + binaryWithPin: |
| Returns an LED on a pin of bank 0, which is on or off. More... | |
| (NXLight *) | + pwmWithPin: |
| Returns an LED on a pin of bank 0 driven by PWM, which can be dimmed. More... | |
| (NXLight *) | + rgbWithRedPin:greenPin:bluePin:inverted: |
| Returns an RGB LED on three pins of bank 0 driven by PWM, which can be colored and dimmed. More... | |
| (NXLight *) | + neopixelWithPin:count: |
| Returns a chain of NeoPixels, or WS2812s, whose data is on a pin of bank 0. More... | |
| (NXLight *) | + deviceWithName: |
| Returns a Linux LED device, by its name in /sys/class/leds, such as "ACT". More... | |
Class Methods inherited from NXObject | |
| (id) | + alloc |
| Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More... | |
| (id) | + allocWithZone: |
| Allocates a new instance in a specific zone. More... | |
| (id) | + new |
| Allocates and initializes a new instance, as [[cls alloc] init] does. More... | |
| (NXString *) | + description |
| Returns the name of the class. | |
Class Methods inherited from Object | |
| (void) | + initialize |
| Performs one-time initialization for the class. 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... | |
Additional Inherited Members | |
Protected Attributes inherited from Object | |
| Class | isa |
| A pointer to the object's class structure. More... | |
An LED, or a chain of NeoPixels, which is turned on and off, dimmed, colored, or blinked.
It's an LED of picofuse's hardware, which can be a pin which is on or off, a pin driven by PWM, which can be dimmed, an RGB LED on three pins driven by PWM, which can be colored, a chain of NeoPixels, which can each be colored, the LED of a Pico W's Wi-Fi chip, or a Linux LED device. A device can have lights of its own too, such as -[PimoroniDisplayPack light].
Only an RGB LED and a chain of NeoPixels have colors: any other light takes a color as a brightness, from how bright the color looks, times its opacity. Only PWM, RGB and NeoPixels can be dimmed: any other light is on at any brightness but zero. An RGB LED or a NeoPixel turned on is white, and dimming one keeps its color.
A light blinks while an application which NXApplicationMain started runs, as its run loop polls picofuse's hardware, which turns it on and off. Only one blink is running for a light at a time, even for a chain of NeoPixels, and setting it, or clearing it, stops it.
Lights need picofuse's hardware to have started, which NXApplicationMain does before it makes the delegate, or hw_init() does. It's the light's from when it's made until it's deallocated, and its pins are released then.
| + (NXLight *) binaryWithPin: | (uint8_t) | pin |
Returns an LED on a pin of bank 0, which is on or off.
| - (BOOL) blinkWithInterval: | (NXDuration) | interval | |
| repeats: | (BOOL) | repeats | |
Blinks it, starting off, and turning on and off every interval.
| interval | How long it's on, and off, for, rounded up to a millisecond. |
| repeats | YES to blink until it's set or cleared, or NO to turn on once, after the interval, and stay on. |
| - (BOOL) blinkWithInterval: | (NXDuration) | interval | |
| repeats: | (BOOL) | repeats | |
| atIndex: | (size_t) | index | |
Blinks an LED of a chain, in its color, at full brightness.
Only one LED of a chain blinks at a time.
| + (NXLight *) default |
Returns the board's own LED.
Returns a Linux LED device, by its name in /sys/class/leds, such as "ACT".
| + (NXLight *) neopixelWithPin: | (uint8_t) | pin | |
| count: | (uint8_t) | count | |
Returns a chain of NeoPixels, or WS2812s, whose data is on a pin of bank 0.
| pin | The pin. |
| count | The number of NeoPixels in the chain, from 1. |
| + (NXLight *) pwmWithPin: | (uint8_t) | pin |
Returns an LED on a pin of bank 0 driven by PWM, which can be dimmed.
| + (NXLight *) rgbWithRedPin: | (uint8_t) | red | |
| greenPin: | (uint8_t) | green | |
| bluePin: | (uint8_t) | blue | |
| inverted: | (BOOL) | inverted | |
Returns an RGB LED on three pins of bank 0 driven by PWM, which can be colored and dimmed.
| red | The red LED's pin. |
| green | The green LED's pin. |
| blue | The blue LED's pin. |
| inverted | NO if a pin's LED is lit by a high output, as where they share a cathode, or YES if it's lit by a low one, as where they share an anode. |
| - (void) setBrightness: | (float) | brightness |
Dims it, or every LED of a chain, and stops a blink.
| brightness | From 0, which is off, to 1, which is full, clamped. |
| - (void) setColor: | (NXColor *) | color |
Colors it, or every LED of a chain, and stops a blink.
| color | The color, where nil is off. |