Keyboard firmwares for Atmel AVR and Cortex-M
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.

MEMO.txt 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. TODO
  2. ----
  3. X test on remote site
  4. tmk.github.io/tmk_editor/hhkb/?
  5. github pages
  6. https://help.github.com/articles/user-organization-and-project-pages
  7. X save file button
  8. https://developer.mozilla.org/en-US/docs/Web/API/Blob
  9. var typedArray = GetTheTypedArraySomehow();
  10. var blob = new Blob([typedArray], {type: "application/octet-binary"}); // pass a useful mime type here
  11. "application/octet-stream"
  12. var url = URL.createObjectURL(blob);
  13. TrueErgonomic
  14. var a = document.getElementById("download-link");
  15. a.href = window.URL.createObjectURL(blob);
  16. a.download = 'TrulyErgonomic_v3_3.hex';
  17. // a.textContent = 'Download file.';
  18. a.className = 'TE_link';
  19. a.click()
  20. keyboard key text css
  21. align of wrapped text
  22. edit action for FN key
  23. action map support
  24. Macro editor
  25. Where it converts key postion into matrix position at?
  26. Convert table? UI can use position of elemen placing.
  27. UI uses matrix posiotn for ID of element.
  28. P load/save JSON
  29. X save hex(binary)
  30. firmware
  31. P load binary
  32. P Mass Storage or HID comm
  33. X fixed address for keymaps
  34. ld script/Firmware structure
  35. ----------------------------
  36. Flash Map of ATMega32U4(32KB)
  37. +------------+ 0x0000
  38. | .vectors | 0xac (43vectors * 4bytes)
  39. | .progmem | PROGMEM variables and PSTR
  40. | .init0-9 |
  41. | .text | code
  42. | .fini9-0 |
  43. | | > text region
  44. |------------| _etext
  45. | .data |
  46. | .bss |
  47. | .noinit |
  48. | | > data region
  49. |------------| 0x6800
  50. | .keymap | > keymap region(2KB)
  51. |------------| 0x7000
  52. | bootloader | 4KB
  53. +------------+ 0x7FFF
  54. TMK keymapping mode
  55. -------------------
  56. keymap 8bit code
  57. Special 8bit code Fn0-32 can be assigned for action code.
  58. actions[] -> ---------------
  59. | action x 32 |
  60. keymaps[] -> ---------------
  61. | keymap 0 |
  62. ---------------
  63. | keymap 1 |
  64. ---------------
  65. | keymap 2 |
  66. ---------------
  67. | keymap 3 |
  68. ---------------
  69. Interface: uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) in keymap.h
  70. action_t keymap_fn_to_action(uint8_t keycode) in keymap.h
  71. static const uint16_t PROGMEM fn_actions[] = {
  72. [0] = ACTION_LAYER_MOMENTARY(0),
  73. [1] = ACTION_LAYER_MOMENTARY(1),
  74. [2] = ACTION_LAYER_MOMENTARY(2),
  75. [3] = ACTION_LAYER_MOMENTARY(3),
  76. [4] = ACTION_LAYER_TOGGLE(0),
  77. [5] = ACTION_LAYER_TOGGLE(1),
  78. [6] = ACTION_LAYER_TOGGLE(2),
  79. [7] = ACTION_LAYER_TOGGLE(3),
  80. [8] = ACTION_LAYER_TAP_TOGGLE(0),
  81. [9] = ACTION_LAYER_TAP_TOGGLE(1),
  82. [10] = ACTION_LAYER_TAP_TOGGLE(2),
  83. [11] = ACTION_LAYER_TAP_TOGGLE(3),
  84. };
  85. actionmap 16bit code
  86. All key action can be defined in 16bit code.
  87. Memory usage will be about doubled size compared to keymap 8bit code.
  88. Map Structure:
  89. actionmaps[] -> ---------------
  90. | actionmap 0 |
  91. ---------------
  92. | actionmap 1 |
  93. ---------------
  94. | actionmap 2 |
  95. ---------------
  96. | actionmap 3 |
  97. ---------------
  98. Interface: action_t action_for_key(uint8_t layer, key_t key) in action.h
  99. Flash usage cosidaration
  100. ATmega32U4
  101. 32KB Firmware -24KB(with full option)
  102. Keymapping 4KB-
  103. Bootloader 4KB(Atmel stock) or 512B(Teensy)
  104. ATmega16U4
  105. 16KB Firmware -10KB
  106. Keymapping 2KB-
  107. Bootloader 4KB(Atmel stock) or 512B(Teensy)
  108. PS/2 and ADB have 256 keys in map, so use 512B each layer.
  109. 8layers will be available for ATMega32U4 and 4layers for 16U4. This seems like enough in most case.
  110. Hex file format
  111. http://en.wikipedia.org/wiki/Intel_HEX
  112. 1.Start code: ':'
  113. 2.Byte Count: 2 hex(0-255)
  114. 3.Address: 4 hex(0-2^16)
  115. 4.Record Type: 2 hex(00-05)
  116. 00: Data record. which contains 16bit address and data.
  117. 01: End of File record. It must appear in the last line.(usually :00000001FF)
  118. 02: Extended Segment Address Record.
  119. 03: Start Segment Address Record.
  120. 04: Extended Linear Address Record. Upper two bytes of 32 bit address.
  121. 05: Start Linear Address Record.
  122. 5.Data: byte_count * hex(a sequence of bytes)
  123. 6.Checksum: 2 hex LSB of 2's complement of the sum of fields: 'Byte Count', 'Address', 'Record Type' and 'Data'.
  124. checksum = ~(the sum of bytes)&0xff + 1 = (the sum)&0xff^0xff + 1
  125. HHKB key matrix
  126. COL 0 1 2 3 4 5 6 7
  127. ROW ---------------------------------------------------------------
  128. 0| 2 q w s a z x c
  129. 1| 3 4 r e d f v b
  130. 2| 5 6 y t g h n _NONE_
  131. 3| 1 Esc Tab Control LShift LAlt LMeta Space
  132. 4| 7 8 u i k j m _NONE_
  133. 5| \ ` Delete Return Fn RShift RAlt RMeta
  134. 6| 9 0 o p ; l , _NONE_
  135. 7| - + ] [ ' / . _NONE_
  136. Key to matrix Table
  137. /* Qwerty
  138. * ,-----------------------------------------------------------.
  139. * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
  140. * |-----------------------------------------------------------|
  141. * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
  142. * |-----------------------------------------------------------|
  143. * |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter |
  144. * |-----------------------------------------------------------|
  145. * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn |
  146. * `-----------------------------------------------------------'
  147. * |Gui|Alt | Space |Alt |Gui|
  148. * `-------------------------------------------'
  149. */
  150. [
  151. 0x31, 0x30, 0x00, 0x10, 0x11, 0x20, 0x21, 0x40, 0x41, 0x60, 0x61, 0x70, 0x71, 0x50, 0x51,
  152. 0x32, 0x01, 0x02, 0x13, 0x12, 0x23, 0x22, 0x42, 0x43, 0x62, 0x63, 0x73, 0x72, 0x52,
  153. 0x33, 0x04, 0x03, 0x14, 0x15, 0x24, 0x25, 0x45, 0x44, 0x65, 0x64, 0x66, 0x53,
  154. 0x34, 0x05, 0x06, 0x07, 0x16, 0x17, 0x26, 0x46, 0x66, 0x76, 0x75, 0x55, 0x54,
  155. 0x35, 0x36, 0x37, 0x57, 0x56,
  156. ]
  157. Keycodes
  158. KC_NO = 0x00,
  159. KC_ROLL_OVER,
  160. KC_POST_FAIL,
  161. KC_UNDEFINED,
  162. KC_A,
  163. KC_B,
  164. KC_C,
  165. KC_D,
  166. KC_E,
  167. KC_F,
  168. KC_G,
  169. KC_H,
  170. KC_I,
  171. KC_J,
  172. KC_K,
  173. KC_L,
  174. KC_M, /* 0x10 */
  175. KC_N,
  176. KC_O,
  177. KC_P,
  178. KC_Q,
  179. KC_R,
  180. KC_S,
  181. KC_T,
  182. KC_U,
  183. KC_V,
  184. KC_W,
  185. KC_X,
  186. KC_Y,
  187. KC_Z,
  188. KC_1,
  189. KC_2,
  190. KC_3, /* 0x20 */
  191. KC_4,
  192. KC_5,
  193. KC_6,
  194. KC_7,
  195. KC_8,
  196. KC_9,
  197. KC_0,
  198. KC_ENTER,
  199. KC_ESCAPE,
  200. KC_BSPACE,
  201. KC_TAB,
  202. KC_SPACE,
  203. KC_MINUS,
  204. KC_EQUAL,
  205. KC_LBRACKET,
  206. KC_RBRACKET, /* 0x30 */
  207. KC_BSLASH, /* \ (and |) */
  208. KC_NONUS_HASH, /* Non-US # and ~ */
  209. KC_SCOLON, /* ; (and :) */
  210. KC_QUOTE, /* ' and " */
  211. KC_GRAVE, /* Grave accent and tilde */
  212. KC_COMMA, /* , and < */
  213. KC_DOT, /* . and > */
  214. KC_SLASH, /* / and ? */
  215. KC_CAPSLOCK,
  216. KC_F1,
  217. KC_F2,
  218. KC_F3,
  219. KC_F4,
  220. KC_F5,
  221. KC_F6,
  222. KC_F7, /* 0x40 */
  223. KC_F8,
  224. KC_F9,
  225. KC_F10,
  226. KC_F11,
  227. KC_F12,
  228. KC_PSCREEN,
  229. KC_SCROLLLOCK,
  230. KC_PAUSE,
  231. KC_INSERT,
  232. KC_HOME,
  233. KC_PGUP,
  234. KC_DELETE,
  235. KC_END,
  236. KC_PGDOWN,
  237. KC_RIGHT,
  238. KC_LEFT, /* 0x50 */
  239. KC_DOWN,
  240. KC_UP,
  241. KC_NUMLOCK,
  242. KC_KP_SLASH,
  243. KC_KP_ASTERISK,
  244. KC_KP_MINUS,
  245. KC_KP_PLUS,
  246. KC_KP_ENTER,
  247. KC_KP_1,
  248. KC_KP_2,
  249. KC_KP_3,
  250. KC_KP_4,
  251. KC_KP_5,
  252. KC_KP_6,
  253. KC_KP_7,
  254. KC_KP_8, /* 0x60 */
  255. KC_KP_9,
  256. KC_KP_0,
  257. KC_KP_DOT,
  258. KC_NONUS_BSLASH, /* Non-US \ and | */
  259. KC_APPLICATION,
  260. KC_POWER,
  261. KC_KP_EQUAL,
  262. KC_F13,
  263. KC_F14,
  264. KC_F15,
  265. KC_F16,
  266. KC_F17,
  267. KC_F18,
  268. KC_F19,
  269. KC_F20,
  270. KC_F21, /* 0x70 */
  271. KC_F22,
  272. KC_F23,
  273. KC_F24,
  274. KC_EXECUTE,
  275. KC_HELP,
  276. KC_MENU,
  277. KC_SELECT,
  278. KC_STOP,
  279. KC_AGAIN,
  280. KC_UNDO,
  281. KC_CUT,
  282. KC_COPY,
  283. KC_PASTE,
  284. KC_FIND,
  285. KC__MUTE,
  286. KC__VOLUP, /* 0x80 */
  287. KC__VOLDOWN,
  288. KC_LOCKING_CAPS, /* locking Caps Lock */
  289. KC_LOCKING_NUM, /* locking Num Lock */
  290. KC_LOCKING_SCROLL, /* locking Scroll Lock */
  291. KC_KP_COMMA,
  292. KC_KP_EQUAL_AS400, /* equal sign on AS/400 */
  293. KC_INT1,
  294. KC_INT2,
  295. KC_INT3,
  296. KC_INT4,
  297. KC_INT5,
  298. KC_INT6,
  299. KC_INT7,
  300. KC_INT8,
  301. KC_INT9,
  302. KC_LANG1, /* 0x90 */
  303. KC_LANG2,
  304. KC_LANG3,
  305. KC_LANG4,
  306. KC_LANG5,
  307. KC_LANG6,
  308. KC_LANG7,
  309. KC_LANG8,
  310. KC_LANG9,
  311. KC_ALT_ERASE,
  312. KC_SYSREQ,
  313. KC_CANCEL,
  314. KC_CLEAR,
  315. KC_PRIOR,
  316. KC_RETURN,
  317. KC_SEPARATOR,
  318. KC_OUT, /* 0xA0 */
  319. KC_OPER,
  320. KC_CLEAR_AGAIN,
  321. KC_CRSEL,
  322. KC_EXSEL, /* 0xA4 */
  323. /* NOTE: Following codes(0xB0-DD) are not used. Leave them for reference. */
  324. KC_KP_00 = 0xB0,
  325. KC_KP_000,
  326. KC_THOUSANDS_SEPARATOR,
  327. KC_DECIMAL_SEPARATOR,
  328. KC_CURRENCY_UNIT,
  329. KC_CURRENCY_SUB_UNIT,
  330. KC_KP_LPAREN,
  331. KC_KP_RPAREN,
  332. KC_KP_LCBRACKET, /* { */
  333. KC_KP_RCBRACKET, /* } */
  334. KC_KP_TAB,
  335. KC_KP_BSPACE,
  336. KC_KP_A,
  337. KC_KP_B,
  338. KC_KP_C,
  339. KC_KP_D,
  340. KC_KP_E, /* 0xC0 */
  341. KC_KP_F,
  342. KC_KP_XOR,
  343. KC_KP_HAT,
  344. KC_KP_PERC,
  345. KC_KP_LT,
  346. KC_KP_GT,
  347. KC_KP_AND,
  348. KC_KP_LAZYAND,
  349. KC_KP_OR,
  350. KC_KP_LAZYOR,
  351. KC_KP_COLON,
  352. KC_KP_HASH,
  353. KC_KP_SPACE,
  354. KC_KP_ATMARK,
  355. KC_KP_EXCLAMATION,
  356. KC_KP_MEM_STORE, /* 0xD0 */
  357. KC_KP_MEM_RECALL,
  358. KC_KP_MEM_CLEAR,
  359. KC_KP_MEM_ADD,
  360. KC_KP_MEM_SUB,
  361. KC_KP_MEM_MUL,
  362. KC_KP_MEM_DIV,
  363. KC_KP_PLUS_MINUS,
  364. KC_KP_CLEAR,
  365. KC_KP_CLEAR_ENTRY,
  366. KC_KP_BINARY,
  367. KC_KP_OCTAL,
  368. KC_KP_DECIMAL,
  369. KC_KP_HEXADECIMAL, /* 0xDD */
  370. /* Modifiers */
  371. KC_LCTRL = 0xE0,
  372. KC_LSHIFT,
  373. KC_LALT,
  374. KC_LGUI,
  375. KC_RCTRL,
  376. KC_RSHIFT,
  377. KC_RALT,
  378. KC_RGUI,