From 6f4db948e308ff62442e2656705bd163509f37b8 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 7 Feb 2025 23:20:02 +1100 Subject: [PATCH] Add `introspection.c` example. --- modules/hello_world/hello_world.c | 4 +++- modules/hello_world/introspection.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 modules/hello_world/introspection.c diff --git a/modules/hello_world/hello_world.c b/modules/hello_world/hello_world.c index 9a4a70f492..0dbe2ce817 100644 --- a/modules/hello_world/hello_world.c +++ b/modules/hello_world/hello_world.c @@ -4,8 +4,10 @@ ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(20250122); +extern int keymap_byte_count(void); // example of use of introspection + uint32_t delayed_hello_world(uint32_t trigger_time, void *cb_arg) { - print("Hello, world! I'm a QMK based keyboard!\n"); + printf("Hello, world! I'm a QMK based keyboard! The keymap array size is %d bytes.\n", keymap_byte_count()); return 0; } diff --git a/modules/hello_world/introspection.c b/modules/hello_world/introspection.c new file mode 100644 index 0000000000..f33371c8f7 --- /dev/null +++ b/modules/hello_world/introspection.c @@ -0,0 +1,6 @@ +// Copyright 2025 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later + +int keymap_byte_count(void) { + return sizeof(keymaps); +}