objc

Data Structures | Enumerations | Functions
Application Framework

Application-related classes and types, including application lifecycle, event handling, display and frames, and hardware interfaces. More...

Collaboration diagram for Application Framework:

Data Structures

class  GPIO
 The GPIO class. More...
 
class  LED
 The LED class. More...
 
class  Application
 The main application class that coordinates application-wide functionality. More...
 
class  NXTimer
 The NXTimer class. More...
 
protocol  <ApplicationDelegate>
 A protocol that defines the methods for an application delegate. More...
 
protocol  <GPIODelegate>
 A protocol that defines the methods for a GPIO delegate. More...
 
protocol  <InputManagerSource>
 A protocol that defines the methods for an input manager source. More...
 
protocol  <InputManagerDelegate>
 A protocol that defines the methods for an input manager delegate. More...
 
protocol  <TimerDelegate>
 A protocol that defines the methods for a timer delegate. More...
 

Enumerations

enum  GPIOEvent { GPIOEventRising = HW_GPIO_RISING, GPIOEventFalling = HW_GPIO_FALLING, GPIOEventChanged }
 GPIO input types for handling GPIO events. More...
 
enum  NXApplicationSignal {
  NXApplicationSignalNone = 0, NXApplicationSignalTerm, NXApplicationSignalInt, NXApplicationSignalQuit = (1 << 2),
  NXApplicationPowerSourceUSB = (1 << 3), NXApplicationPowerSourceBattery, NXApplicationWatchdogDidReset
}
 Application signal types for handling system events. More...
 
enum  NXApplicationCapability { NXApplicationCapabilityNone = 0, NXApplicationCapabilityMulticore = (1 << 0), NXApplicationCapabilityPower = (1 << 1), NXApplicationCapabilityWatchdog = (1 << 2) }
 Application capabilities. More...
 

Functions

int NXApplicationMain (int argc, char *argv[], Class delegate, NXApplicationCapability capabilities)
 Main entry point for NXApplication-based programs. More...
 

Detailed Description

Application-related classes and types, including application lifecycle, event handling, display and frames, and hardware interfaces.

Enumeration Type Documentation

◆ GPIOEvent

enum GPIOEvent

GPIO input types for handling GPIO events.

Enumerator
GPIOEventRising 

Rising edge detected.

GPIOEventFalling 

Falling edge detected.

GPIOEventChanged 

Both edges detected.

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

Definition at line 15 of file GPIOTypes.h.

15  {
20 } GPIOEvent;
Falling edge detected.
Definition: GPIOTypes.h:17
Rising edge detected.
Definition: GPIOTypes.h:16
GPIO pin falling edge interrupt.
Definition: gpio.h:52
GPIO pin rising edge interrupt.
Definition: gpio.h:51
GPIOEvent
GPIO input types for handling GPIO events.
Definition: GPIOTypes.h:15
Both edges detected.
Definition: GPIOTypes.h:18

◆ NXApplicationCapability

Application capabilities.

Define capabilities to enable in the application. These are passed to NXApplicationMain which then enables the corresponding features.

NXApplicationCapabilityMulticore enables the use of multiple CPU cores to process tasks concurrently. NXApplicationCapabilityPower enables power management features, which means additional signals are passed to the application for power-related events, such as power source and battery changes.

NXApplicationCapabilityWatchdog enables the use of a watchdog timer to monitor the application's health, and resets the device if it becomes unresponsive.

Enumerator
NXApplicationCapabilityNone 

No capability.

NXApplicationCapabilityMulticore 

Enable Multicore capability.

NXApplicationCapabilityPower 

Enable Power management.

NXApplicationCapabilityWatchdog 

Enable Watchdog.

Definition at line 60 of file NXApplication+Types.h.

60  {
63  NXApplicationCapabilityPower = (1 << 1),
Enable Multicore capability.
Enable Power management.
NXApplicationCapability
Application capabilities.

◆ NXApplicationSignal

Application signal types for handling system events.

This enum defines the various signals that the application delegate can receive related to system events.

NXApplicationSignalInt indicates that the application is being interrupted, usually by the user pressing Ctrl+C. NXApplicationSignalQuit indicates that the application is being asked to quit, typically by the user sending a SIGQUIT signal. NXApplicationSignalTerm indicates that the application is being terminated, typically by the user sending a SIGTERM signal. When the watchdog is enabled, it may also indicate that the application manually triggered a restart.

NXApplicationSignalPowerSourceUSB indicates that the power source has changed to USB. NXApplicationSignalPowerSourceBattery indicates that either the power source has changed to battery, or the battery level has changed. The battery level can be monitored using the appropriate APIs.

Enumerator
NXApplicationSignalNone 

No signal.

NXApplicationSignalTerm 

Termination signal (SIGTERM equivalent)

NXApplicationSignalInt 

Interrupt signal (SIGINT/Ctrl+C equivalent)

NXApplicationSignalQuit 

Quit signal (SIGQUIT equivalent)

NXApplicationPowerSourceUSB 

Power source changed to USB.

NXApplicationPowerSourceBattery 

Power source changed to battery, or battery level changed.

NXApplicationWatchdogDidReset 

Application was reset by a watchdog timer.

Definition at line 29 of file NXApplication+Types.h.

29  {
32  (1 << 0),
34  (1 << 1),
35  NXApplicationSignalQuit = (1 << 2),
36  NXApplicationPowerSourceUSB = (1 << 3),
38  (1 << 4),
40  (1 << 5),
Application was reset by a watchdog timer.
Power source changed to USB.
Quit signal (SIGQUIT equivalent)
Power source changed to battery, or battery level changed.
Termination signal (SIGTERM equivalent)
NXApplicationSignal
Application signal types for handling system events.
Interrupt signal (SIGINT/Ctrl+C equivalent)

Function Documentation

◆ NXApplicationMain()

int NXApplicationMain ( int  argc,
char *  argv[],
Class  delegate,
NXApplicationCapability  capabilities 
)

Main entry point for NXApplication-based programs.

Parameters
argcThe number of command-line arguments passed to the program.
argvAn array of command-line argument strings.
delegateThe class to use as the application delegate.
capabilitiesThe capabilities to enable for the application.
Returns
The exit status of the application (0 for success, non-zero for error).

This function serves as the main entry point for applications built with the Application framework. It initializes the application runtime, sets up the event loop, and manages the application lifecycle from startup to shutdown.

The function handles:

  • Runtime initialization and configuration
  • Command-line argument processing
  • Application instance creation and setup
  • Main event loop execution
  • Cleanup and resource deallocation on exit

This function should be called from your program's main() function, typically by simply returning the result of NXApplicationMain().

Note
This function does not return until the application terminates.
Command-line arguments are processed according to application configuration.
The return value should be used as the program's exit status.
int main(int argc, char *argv[]) {
return NXApplicationMain(argc, argv, MyAppDelegateClass,
}
Examples:
examples/Application/blink/main.m, examples/Application/gpio/main.m, examples/Application/helloworld/main.m, examples/Application/timer/main.m, examples/Network/ntp/main.m, and examples/Network/scan/main.m.