keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

tutorial_9_breaking_up_a_sketch_into_smaller_files.md 2.0KB

Tutorial 9 - breaking up a sketch into smaller files

A keybrd sketch can become quite lengthy, which can make it harder to navigate and understand.

The keybrd_DH sketch has about 800 lines of code; 700 of which are for instantiating objects. The object instantiations are grouped into six files located in the keybrd_DH library, and included in keybrd_DH.ino:

// ========= INSTANTIATE THE KEYBOARD ==========
#include "config.h"
#include <instantiations_pins.h>
#include <instantiations_scancodes.h>
#include <instantiations_layercodes.h>
#include <instantiations_rows_L.h>
#include <instantiations_rows_R.h>

Splitting your code into groups of instantiations also provides organizational and reusability benefits.

Example 1. You have three versions of LED indicators you are experimenting with:

  • instantiations_LEDs_1.h
  • instantiations_LEDs_2.h
  • instantiations_LEDs_3.h

Example 2. You use Colemak and want QWERTY users to to try your new keyboard design. So you publish your keybrd extension library with two versions of instantiations_matrix.h:

  • instantiations_rows_colemak.h
  • instantiations_rows_QWERTY.h


Creative Commons License
keybrd tutorial by Wolfram Volpi is licensed under a Creative Commons Attribution 4.0 International License.
Permissions beyond the scope of this license may be available at https://github.com/wolfv6/keybrd/issues/new.