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.

201 lines
4.0KB

  1. # Copyright 2012 Olivier Gillet.
  2. #
  3. # Author: Olivier Gillet (ol.gillet@gmail.com)
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. # THE SOFTWARE.
  22. #
  23. # See http://creativecommons.org/licenses/MIT/ for more information.
  24. #
  25. # -----------------------------------------------------------------------------
  26. #
  27. # Characters definitions.
  28. characters = []
  29. MASKS = {
  30. 'a': 0x8000,
  31. 'b': 0x4000,
  32. 'c': 0x2000,
  33. 'd': 0x1000,
  34. 'e': 0x0800,
  35. 'f': 0x0400,
  36. 'g': 0x0200,
  37. 'h': 0x0100,
  38. 'j': 0x80,
  39. 'k': 0x40,
  40. 'l': 0x20,
  41. 'm': 0x10,
  42. 'n': 0x08,
  43. 'p': 0x04,
  44. }
  45. characters = {
  46. 'A': 'afepkbc',
  47. 'B': 'adhmbck',
  48. 'C': 'afed',
  49. 'D': 'adhmbc',
  50. 'E': 'afedkp',
  51. 'F': 'afepk',
  52. 'G': 'afedck',
  53. 'H': 'febcpk',
  54. 'I': 'adhm',
  55. 'J': 'bcde',
  56. 'K': 'efpjl',
  57. 'L': 'def',
  58. 'M': 'efgjbc',
  59. 'N': 'efglcb',
  60. 'O': 'abcdef',
  61. 'P': 'abpkef',
  62. 'Q': 'abcdefl',
  63. 'R': 'abpkefl',
  64. 'S': 'afpkcd',
  65. 'T': 'ahm',
  66. 'U': 'bcdef',
  67. 'V': 'fenj',
  68. 'W': 'fenlcb',
  69. 'X': 'gjln',
  70. 'Y': 'gjm',
  71. 'Z': 'ajnd',
  72. 'a': 'abpkecd',
  73. 'b': 'fedlp',
  74. 'c': 'pked',
  75. 'd': 'bcdnk',
  76. 'e': 'afped',
  77. 'f': 'afpe',
  78. 'g': 'agkbcd',
  79. 'h': 'fpkec',
  80. 'i': 'mpkd',
  81. 'j': 'kcd',
  82. 'k': 'hmjl',
  83. 'l': 'hm',
  84. 'm': 'epkmc',
  85. 'n': 'mkc',
  86. 'o': 'pkecd',
  87. 'p': 'afpje',
  88. 'q': 'afpkbl',
  89. 'r': 'mk',
  90. 's': 'agkcd',
  91. 't': 'fedp',
  92. 'u': 'edc',
  93. 'v': 'en',
  94. 'w': 'enlc',
  95. 'x': 'gnjl',
  96. 'y': 'gkbcd',
  97. 'z': 'pnd',
  98. '0': 'abcdefnj',
  99. '1': 'jbc',
  100. '2': 'abpked',
  101. '3': 'abcdk',
  102. '4': 'fpkbc',
  103. '5': 'afpkcd',
  104. '6': 'afpkcde',
  105. '7': 'ajm',
  106. '8': 'abcdefpk',
  107. '9': 'abcpkfd',
  108. '!': 'hm',
  109. '"': 'fh',
  110. '#': 'pkdhmbc',
  111. '$': 'afpkcdhm',
  112. '%': 'jnfc',
  113. '&': 'aghpeld',
  114. '\'': 'h',
  115. '(': 'afed',
  116. ')': 'abcd',
  117. '*': 'ghjmnl',
  118. '+': 'hmpk',
  119. ',': 'n',
  120. '-': 'pk',
  121. '.': 'm',
  122. '/': 'jn',
  123. ':': 'hm',
  124. ';': 'hn',
  125. '<': 'jl',
  126. '>': 'gn',
  127. '?': 'fajm',
  128. '=': 'pkd',
  129. '@': 'kmcbafed',
  130. '[': 'afed',
  131. ']': 'abcd',
  132. '\\': 'gl',
  133. '^': 'nl',
  134. '_': 'd',
  135. '`': 'g',
  136. '{': 'pgnad',
  137. '|': 'hm',
  138. '}': 'ajldk',
  139. '~': 'pk',
  140. # LRDU
  141. '\x80': 'jlbc',
  142. '\x81': 'efgn',
  143. '\x82': 'agj',
  144. '\x83': 'dnl',
  145. # LRDU arrow
  146. '\x84': 'jkl',
  147. '\x85': 'gpn',
  148. '\x86': 'ghj',
  149. '\x87': 'nml',
  150. # Waveforms
  151. '\x88': 'njbc', # Saw
  152. '\x89': 'enjb', # Centered saw
  153. '\x8A': 'mn', # Baby saw
  154. '\x8B': 'nl', # Tri
  155. '\x8C': 'efabc', # Square
  156. '\x8D': 'epkc', # Baby square
  157. '\x8E': 'dhm', # Pulse
  158. '\x8F': 'efgl', # AD
  159. # Spinner
  160. '\x90': 'abcdefn',
  161. '\x91': 'abcdefp',
  162. '\x92': 'abcdefg',
  163. '\x93': 'abcdefh',
  164. '\x94': 'abcdefj',
  165. '\x95': 'abcdefk',
  166. '\x96': 'abcdefl',
  167. '\x97': 'abcdefm',
  168. # Spinner 2
  169. '\x98': 'ab',
  170. '\x99': 'abc',
  171. '\x9A': 'bcd',
  172. '\x9B': 'cde',
  173. '\x9C': 'de',
  174. '\x9D': 'def',
  175. '\x9E': 'efa',
  176. '\x9F': 'fab',
  177. '\xA0': 'abcdefghjklmnp',
  178. '\xFF': 'abcdefghjklmnp',
  179. 'null': 'null'
  180. }
  181. character_table = []
  182. for i in xrange(256):
  183. segments = characters.get(chr(i), '')
  184. character_table.append(sum(MASKS[segment] for segment in segments))
  185. characters = [('characters', character_table)]