picofuse-objc

Instance Methods | Class Methods | List of all members
NXDigitalInput Class Reference

A pin which is read, and which sends a message to a target when its level changes, as an event source of the application. More...

#import <Application/Application.h>

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

Instance Methods

(NXPinPull) - pull
 Returns whether it's pulled up, down, or neither.
 
(BOOL) - isAttached
 Returns YES if it's attached, so it can be read and sends its message.
 
(BOOL) - isDebounced
 Returns YES if it's debounced, which it is unless it's been set otherwise.
 
(void) - setDebounced:
 Sets whether it's debounced, from when it's next attached. More...
 
- Instance Methods inherited from NXPin
(uint8_t) - bank
 Returns the bank, which is 0 on a Pico.
 
(uint8_t) - pin
 Returns the pin in the bank.
 
(BOOL) - boolValue
 Returns YES if the pin is high, or NO if it's low or can't be read.
 
- 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

(NXDigitalInput *) + inputWithPin:pull:target:selector:
 Returns an input on a pin of bank 0, which isn't attached. More...
 
(NXDigitalInput *) + inputWithBank:pin:pull:target:selector:
 Returns an input on a pin of a bank, which isn't attached.
 
(NXDigitalInput *) + userButtonWithTarget:selector:
 Returns an input on the board's user button, which isn't attached. 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 NXPin
uint8_t _bank
 The bank, which is 0 on a Pico.
 
uint8_t _pin
 The pin in the bank.
 
- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

A pin which is read, and which sends a message to a target when its level changes, as an event source of the application.

It's a GPIO device of picofuse's HID while it's attached with -[NXApplication attachEventSource:], and it can only be read then. The message is sent on any of the run loop's workers, with the input as its argument.

It's debounced, so a change within 20ms of the last is ignored, as for a button. One which isn't (see -setDebounced:) sends its message for every edge, as for a signal from a chip, such as a sensor's or a display's.

Definition at line 104 of file NXPin.h.

Method Documentation

◆ inputWithPin:pull:target:selector:()

+ (NXDigitalInput *) inputWithPin: (uint8_t)  pin
pull: (NXPinPull)  pull
target: (id)  target
selector: (SEL)  selector 

Returns an input on a pin of bank 0, which isn't attached.

Parameters
pinThe pin in the bank.
pullWhether it's pulled up, down, or neither.
targetWhat the message is sent to when its level changes, which is retained.
selectorA method of the target which has the input as its one argument, such as -pinDidChange:.
Returns
The input, or nil if the selector isn't a method of the target which takes one object.

◆ setDebounced:()

- (void) setDebounced: (BOOL)  debounced

Sets whether it's debounced, from when it's next attached.

Parameters
debouncedNO to send its message for every edge, however close together. The pin's level may have changed again by the time it's sent.

◆ userButtonWithTarget:selector:()

+ (NXDigitalInput *) userButtonWithTarget: (id)  target
selector: (SEL)  selector 

Returns an input on the board's user button, which isn't attached.

Parameters
targetWhat the message is sent to when it's pressed or released, which is retained.
selectorA method of the target which has the input as its one argument.
Returns
The input, or nil if the board has no user button, such as a Pico W, whose BOOTSEL button isn't a GPIO, or a Mac or Linux. The button is pulled up and pressing it connects it to ground, so -boolValue is NO while it's pressed.

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