Archiviato
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/tutorials/tutorial_9_breaking_up_a_sketch_into_smaller_files.md

32 righe
2.0 KiB
Markdown

2016-07-18 02:26:00 +00:00
Tutorial 9 - breaking up a sketch into smaller files
2016-05-09 14:05:08 +00:00
====================================================
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.
2016-07-18 02:26:00 +00:00
The object instantiations are grouped into six files located in the keybrd_DH library, and included in keybrd_DH.ino:
2016-05-09 14:05:08 +00:00
2016-07-18 02:26:00 +00:00
// ========= 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>
2016-05-09 14:05:08 +00:00
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:
2016-07-18 02:26:00 +00:00
* instantiations_LEDs_1.h
* instantiations_LEDs_2.h
* instantiations_LEDs_3.h
2016-05-09 14:05:08 +00:00
Example 2.
2016-05-11 15:25:48 +00:00
You use Colemak and want QWERTY users to to try your new keyboard design.
2016-05-09 14:05:08 +00:00
So you publish your keybrd extension library with two versions of instantiations_matrix.h:
2016-07-22 08:11:38 +00:00
* instantiations_rows_colemak.h
* instantiations_rows_QWERTY.h
2016-05-11 15:25:48 +00:00
2016-07-18 02:26:00 +00:00
<br>
2016-07-21 20:20:07 +00:00
<a rel="license" href="https://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by/4.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">keybrd tutorial</span> by <a xmlns:cc="https://creativecommons.org/ns" href="https://github.com/wolfv6/keybrd" property="cc:attributionName" rel="cc:attributionURL">Wolfram Volpi</a> is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.<br />Permissions beyond the scope of this license may be available at <a xmlns:cc="https://creativecommons.org/ns" href="https://github.com/wolfv6/keybrd/issues/new" rel="cc:morePermissions">https://github.com/wolfv6/keybrd/issues/new</a>.