### Build and Run NumWorks C App Source: https://context7.com/numworks/epsilon-sample-app-c/llms.txt Instructions to compile, install, and run a C application on NumWorks calculators. It requires ARM GCC toolchain and nwlink, and uses a Makefile for automation. The output is a .nwa file. ```shell # Install dependencies (macOS) brew install numworks/tap/arm-none-eabi-gcc node # Clean previous builds and compile make clean && make build # Connect NumWorks calculator via USB and install make run # Build output location ls output/app.nwa ``` -------------------------------- ### Build and Run Sample App (Shell) Source: https://github.com/numworks/epsilon-sample-app-c/blob/master/README.md Shell commands for building and running the sample C application on a NumWorks calculator. It includes steps for cleaning the project, building the application into an installable `.nwa` file, and deploying it to a connected calculator. ```shell brew install numworks/tap/arm-none-eabi-gcc node # Or equivalent on your OS make clean && make build ``` ```shell # Now connect your NumWorks calculator to your computer using the USB cable make run ``` -------------------------------- ### Load External Data with eadk_external_data in C and Makefile Source: https://context7.com/numworks/epsilon-sample-app-c/llms.txt Accesses external data files bundled with the application using the `eadk_external_data` pointer. Applications can include files like `input.txt` which are loaded at runtime. The provided C code demonstrates printing the content of `eadk_external_data`, and the Makefile example shows how to specify the external data file when running the application. ```c #include #include // App metadata (required) const char eadk_app_name[] __attribute__((section(".rodata.eadk_app_name"))) = "MyApp"; const uint32_t eadk_api_level __attribute__((section(".rodata.eadk_api_level"))) = 0; int main(int argc, char * argv[]) { // Print external data content (from src/input.txt) printf("External data: '%s'\n", eadk_external_data); eadk_timing_msleep(3000); return 0; } ``` ```makefile # In Makefile - specify external data file when running run: $(BUILD_DIR)/app.nwa src/input.txt $(NWLINK) install-nwa --external-data src/input.txt $< ``` -------------------------------- ### Generate Random Values with eadk_random in C Source: https://context7.com/numworks/epsilon-sample-app-c/llms.txt Generates a random unsigned 32-bit integer value using `eadk_random()`. This function can be used for creating random colors, positions, or any other randomized behavior within an application. Example functions demonstrate generating random colors and screen rectangles. ```c #include eadk_color_t random_color() { return (eadk_color_t)eadk_random(); } eadk_rect_t random_screen_rect() { uint16_t x = eadk_random() % (EADK_SCREEN_WIDTH - 1); uint16_t y = eadk_random() % (EADK_SCREEN_HEIGHT - 1); uint16_t width = eadk_random() % (EADK_SCREEN_WIDTH - x); uint16_t height = eadk_random() % (EADK_SCREEN_HEIGHT - y); return (eadk_rect_t){x, y, width, height}; } ``` -------------------------------- ### Display 'Hello, world!' on NumWorks Calculator (C) Source: https://github.com/numworks/epsilon-sample-app-c/blob/master/README.md This C code snippet demonstrates how to display a string on the NumWorks calculator's screen using the EDK library. It initializes the display and prints 'Hello, world!' at the top-left corner with specified colors, followed by a 3-second delay. ```c #include int main(int argc, char * argv[]) { eadk_display_draw_string("Hello, world!", (eadk_point_t){0, 0}, true, eadk_color_black, eadk_color_white); eadk_timing_msleep(3000); } ``` -------------------------------- ### Fill Rectangles with Uniform Color using EADK (C) Source: https://context7.com/numworks/epsilon-sample-app-c/llms.txt Shows how to fill rectangular areas on the screen with a solid color using `eadk_display_push_rect_uniform`. Can fill the entire screen or specific regions. Requires `eadk.h`. ```c #include void draw_random_colorful_rectangles() { // Fill entire screen with black background eadk_display_push_rect_uniform(eadk_screen_rect, eadk_color_black); // Draw 100 random colored rectangles for (int i = 0; i < 100; i++) { uint16_t x = eadk_random() % (EADK_SCREEN_WIDTH - 1); uint16_t y = eadk_random() % (EADK_SCREEN_HEIGHT - 1); uint16_t width = eadk_random() % (EADK_SCREEN_WIDTH - x); uint16_t height = eadk_random() % (EADK_SCREEN_HEIGHT - y); eadk_rect_t rect = {x, y, width, height}; eadk_color_t color = (eadk_color_t)eadk_random(); eadk_display_push_rect_uniform(rect, color); } } ``` -------------------------------- ### Draw Rectangle with Pixel Buffer using EADK (C) Source: https://context7.com/numworks/epsilon-sample-app-c/llms.txt Demonstrates drawing a rectangle using a pixel buffer with `eadk_display_push_rect`. This allows for custom graphics and images by providing color data for each pixel. Requires `eadk.h`, `stdlib.h`, and `string.h`. ```c #include #include #include void draw_random_buffer() { // Define a 30x30 pixel rectangle at top-left eadk_rect_t rect = {0, 0, 30, 30}; // Allocate pixel buffer size_t bufferSize = rect.width * rect.height * sizeof(eadk_color_t); eadk_color_t *pixels = (eadk_color_t *)malloc(bufferSize); if (pixels == NULL) { return; // Handle allocation failure } // Initialize buffer to zero memset(pixels, 0, bufferSize); // Fill with random colors for (int i = 0; i < rect.width * rect.height; i++) { pixels[i] = (eadk_color_t)eadk_random(); } // Push the pixel buffer to the display eadk_display_push_rect(rect, pixels); // Clean up free(pixels); } ``` -------------------------------- ### Render Text with EADK Display Functions (C) Source: https://context7.com/numworks/epsilon-sample-app-c/llms.txt Demonstrates rendering text strings on the NumWorks calculator display using `eadk_display_draw_string`. Allows customization of font size, position, and colors. Requires the `eadk.h` header. ```c #include int main(int argc, char * argv[]) { // Draw "Hello, world!" at top-left corner (0,0) // Parameters: string, position, large_font, text_color, background_color eadk_display_draw_string( "Hello, world!", (eadk_point_t){0, 0}, true, // large font eadk_color_black, // text color eadk_color_white // background color ); // Draw at different position with different colors eadk_display_draw_string( "NumWorks", (eadk_point_t){100, 50}, false, // small font eadk_color_white, eadk_color_black ); eadk_timing_msleep(3000); // Wait 3 seconds to view result return 0; } ``` -------------------------------- ### Handle Keyboard Input with eadk_keyboard_scan and eadk_keyboard_key_down in C Source: https://context7.com/numworks/epsilon-sample-app-c/llms.txt Reads the current keyboard state using `eadk_keyboard_scan()` and checks if specific keys are pressed with `eadk_keyboard_key_down()`. This enables responsive input handling for interactive applications by allowing movement of a cursor based on arrow key presses and exiting with the back key. ```c #include void move_pointer() { uint16_t size = 10; // Start cursor at screen center eadk_rect_t cursor = { (EADK_SCREEN_WIDTH - size) / 2, (EADK_SCREEN_HEIGHT - size) / 2, size, size }; while (true) { // Scan keyboard state eadk_keyboard_state_t keyboard = eadk_keyboard_scan(); // Check for exit (Back key) if (eadk_keyboard_key_down(keyboard, eadk_key_back)) { return; } // Handle arrow key navigation with bounds checking if (eadk_keyboard_key_down(keyboard, eadk_key_left) && cursor.x > 0) { cursor.x -= 1; } if (eadk_keyboard_key_down(keyboard, eadk_key_up) && cursor.y > 0) { cursor.y -= 1; } if (eadk_keyboard_key_down(keyboard, eadk_key_right) && cursor.x < EADK_SCREEN_WIDTH - size) { cursor.x += 1; } if (eadk_keyboard_key_down(keyboard, eadk_key_down) && cursor.y < EADK_SCREEN_HEIGHT - size) { cursor.y += 1; } // Draw cursor at new position eadk_display_push_rect_uniform(cursor, (eadk_color_t)eadk_random()); // Small delay for smooth movement eadk_timing_msleep(20); } } ``` -------------------------------- ### Pause Execution with eadk_timing_msleep in C Source: https://context7.com/numworks/epsilon-sample-app-c/llms.txt Pauses program execution for a specified number of milliseconds using `eadk_timing_msleep()`. This function is useful for creating animations, adding delays between visual updates, or allowing users time to read displayed content. ```c #include int main(int argc, char * argv[]) { eadk_display_draw_string("Loading...", (eadk_point_t){0, 0}, true, eadk_color_black, eadk_color_white); // Wait 3 seconds (3000 milliseconds) eadk_timing_msleep(3000); eadk_display_draw_string("Ready!", (eadk_point_t){0, 20}, true, eadk_color_black, eadk_color_white); return 0; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.