Advertisement
Guest User

Scrolling Text Marquee

a guest
May 8th, 2020
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.00 KB | None | 0 0
  1. /*
  2. This pattern animates ASCII characters scrolling across an LED matrix.
  3.  
  4. Demo: https://youtu.be/668eQjiqSRQ
  5.  
  6. The default settings work with the $14 8x8 matrix sold here:
  7.  
  8. https://www.tindie.com/products/electromage/electromage-8x8-led-matrix/
  9.  
  10. You can use the output expander or configure PB for WS2812s (NeoPixels).
  11.  
  12. Use the mapper to define how the matrix is wired (for example, zig-zag).
  13. The 8x8 grid above works with the default "Matrix" example on the Mapper tab.
  14. */
  15.  
  16.  
  17. // Define the message to be scrolled across the display
  18. var messageLength = 12
  19. export var message = array(messageLength) // Exported to set via webSockets
  20.  
  21. // " Hello?!?"
  22. message[0] = 32; message[1] = 32; // Leading spaces
  23. message[2] = 72; // H
  24. message[3] = 101; // e
  25. message[4] = 108; // l
  26. message[5] = 108; // l
  27. message[6] = 111; // o
  28. message[7] = 30; message[8] = 33; message[9] = 31 // "?!?"
  29.  
  30. /*
  31. ASCII Chart
  32.  
  33. 32 48 0 65 A 74 J 83 S 97 a 106 j 115 s
  34. 33 ! 49 1 66 B 75 K 84 T 98 b 107 k 116 t
  35. 34 " 50 2 67 C 76 L 85 U 99 c 108 l 117 u
  36. 35 # 51 3 68 D 77 M 86 V 100 d 109 m 118 v
  37. 36 $ 52 4 69 E 78 N 87 W 101 e 110 n 119 w
  38. 37 % 53 5 70 F 79 O 88 X 102 f 111 o 120 x
  39. 38 & 54 6 71 G 80 P 89 Y 103 g 112 p 121 y
  40. 39 ' 55 7 72 H 81 Q 90 Z 104 h 113 q 122 z
  41. 40 ( 56 8 73 I 82 R 105 i 114 r
  42. 41 ) 57 9
  43. 42 * 58 : 91 [ 123 {
  44. 43 + 59 ; 92 \ 124 |
  45. 44 , 60 < 93 ] 125 }
  46. 45 - 61 = 94 ^ 126 ~
  47. 46 . 62 > 95 _
  48. 47 / 63 ? 96 `
  49. 64 @
  50. */
  51.  
  52.  
  53.  
  54. // Define the font's character set bitmap. See "Font Implementation" below.
  55. var charRows = 8 // Rows in a character. 1 array per row.
  56. var charCols = 8 // Columns in a character. 1 bit per column.
  57.  
  58. var fontCharCount = 128 // Max characters in the font. Must be a multiple of 4.
  59. var fontBitmap = array(charRows)
  60. for (row = 0; row < charRows; row++) fontBitmap[row] = array(fontCharCount / 4)
  61.  
  62. // Global 8x8bit array for storing and fetching characters from fontBitmap
  63. var character = array(charRows)
  64.  
  65.  
  66. // Define and allocate the matrix display
  67. var matrixRows = 8
  68. var matrixCols = 8
  69. var renderBuffer = array(matrixRows)
  70. for (row = 0; row < matrixRows; row++) renderBuffer[row] = array(matrixCols)
  71.  
  72.  
  73.  
  74. // -----------------------------------------------------------------------------
  75. //
  76. // Let's render!
  77.  
  78. var speed = 3 // Characters we want to scroll by every second
  79. var timer = 0 // Accumulates the ms between each beforeRender()
  80.  
  81. // Calculate the ms between each left shift of the message across matrix columns
  82. var colShiftPeriod = 1000 / speed / charCols
  83.  
  84. export function beforeRender(delta) {
  85. timer += delta
  86. if (timer > colShiftPeriod) {
  87. timer -= colShiftPeriod
  88. loadNextCol() // Shift and load a new column every colShiftPeriod ms
  89. }
  90. }
  91.  
  92. export function render2D(index, x, y) {
  93. // y is in world units of 0...1 where (0,0) is the top-left and y is +↓
  94. row = floor(y * matrixRows)
  95.  
  96. // The column to render is like the row, but physical column 0 (the leftmost)
  97. // starts bufferPointer columns into the renderBuffer.
  98. col = (floor(x * matrixCols) + bufferPointer) % matrixCols
  99.  
  100. if (renderBuffer[row][col]) hsv(0.07, 0.5, 1) // warm white
  101. }
  102.  
  103.  
  104.  
  105. // When we render the renderBuffer, we start by loading the leftmost column
  106. // of the matrix from from the `bufferPointer` column in the renderBuffer.
  107. var bufferPointer = 0
  108.  
  109. /*
  110. Example: 8x8 matrix, rendering halfway through "AC": Right side of A, left of C
  111.  
  112. renderbuffer[r][c] Renders as:
  113.  
  114. `bufferPointer` == 4 means leftmost column is here, and wraps around to 3
  115. col = 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
  116. row = 0 . . . 1 1 . . . 0 1 . . . . . . 1
  117. 1 . . 1 1 1 1 . . 1 1 1 . . . . 1 1
  118. 2 . 1 1 . . 1 1 . 2 . 1 1 . . 1 1 .
  119. 3 . 1 1 . . 1 1 . 3 . 1 1 . . 1 1 .
  120. 4 . 1 1 . 1 1 1 . 4 1 1 1 . . 1 1 .
  121. 4 . . 1 1 . 1 1 . 4 . 1 1 . . . 1 1
  122. 5 . . . 1 . 1 1 . 5 . 1 1 . . . . 1
  123. 7 . . . . . . . . 7 . . . . . . . .
  124. This column will be replaced with the next column of "C",
  125. ↑ then we'll advance `bufferPointer`
  126.  
  127. Each element is a 16.16 fixed point number, so you could decide to pack HSV or
  128. RGB info into each byte, but this example is monochrome so each element just
  129. stores a 0 or 1, making rendering as simple as:
  130.  
  131. if (renderBuffer[row][col]) hsv(0,0,1)
  132. */
  133.  
  134. var messageCols = messageLength * charCols // e.g., 12 chars have 96 columns
  135. var messageColPointer = 0 // The next column of the overall message to load
  136.  
  137. // Load the next column from `message` into `renderBuffer` at `bufferPointer`
  138. function loadNextCol() {
  139. charIndex = message[floor(messageColPointer / charCols)]
  140. fetchCharacter(charIndex) // loads global `character` with ASCII charIndex
  141.  
  142. colIndex = messageColPointer % charCols
  143. for (row = 0; row < charRows; row++) {
  144. bit = (((character[row] << colIndex) & 0b1000000) == 0b1000000)
  145. renderBuffer[row][bufferPointer] = bit
  146. }
  147.  
  148. bufferPointer = (bufferPointer + 1) % matrixCols
  149. messageColPointer = (messageColPointer + 1) % messageCols
  150. }
  151.  
  152.  
  153.  
  154. /* -----------------------------------------------------------------------------
  155.  
  156. Font Implementation
  157.  
  158. Pixelblaze currently supports up to 64 arrays with 2048 array elements.
  159.  
  160. To store a character set of 8x8 bit characters, we use 8 arrays,
  161. one for each row.
  162.  
  163. Four 8-bit maps are packed into each 32 bit array element. This makes
  164. the bitwise code a little hard to follow, but uses memory effeciently.
  165. The 8 most significant bits are referred to as "bank 0"; the next eight
  166. bits just left of the binary point are "bank 1", etc.
  167.  
  168. Here's the scheme used to store the font bitmap. A period is a zero.
  169.  
  170. ASCII character A B C D E
  171. `charIndex` 65 66 67 68 69
  172. array element [16] [16] [16] [16] [17]
  173. bank 0 1 2 3 0
  174. fontBitmap[0] ..11.... 111111.. ..1111.. 11111... 1111111.
  175. fontBitmap[1] .1111... .11..11. .11..11. .11.11.. .11...1.
  176. fontBitmap[2] 11..11.. .11..11. 11...... .11..11. .11.1...
  177. fontBitmap[3] 11..11.. .11111.. 11...... .11..11. .1111...
  178. fontBitmap[4] 111111.. .11..11. 11...... .11..11. .11.1...
  179. fontBitmap[5] 11..11.. .11..11. .11..11. .11.11.. .11...1.
  180. fontBitmap[6] 11..11.. 111111.. ..1111.. 11111... 1111111.
  181. fontBitmap[7] ........ ........ ........ ........ ........
  182.  
  183. charIndex 0..31 (traditionally the ASCII control characters) are left
  184. blank for user-defined custom characters.
  185. */
  186.  
  187. /*
  188. Font and character functions
  189.  
  190. The storeCharacter functions take the character index (< `fontCharCount`) and
  191. 8 rows of 8 bits. Each row is a byte representing 8 bits of on/off bitmap data
  192. to become the pixels of a character. Therefore, this implementation is
  193. currently tightly coupled to 8-bit wide characters.
  194. */
  195.  
  196. /*
  197. At character index `charIndex`, store 8 bytes of row data specified as
  198. sequential arguments r0-r7. This allows us to easily use the public domain
  199. font specified as comma-delimited hex bytes at:
  200.  
  201. https://github.com/rene-d/fontino/blob/master/font8x8_ib8x8u.ino
  202. */
  203. function storeCharacter(charIndex, r0, r1, r2, r3, r4, r5, r6, r7) {
  204. element = floor(charIndex / 4)
  205. bank = charIndex % 4
  206. packByte(0, element, bank, r0)
  207. packByte(1, element, bank, r1)
  208. packByte(2, element, bank, r2)
  209. packByte(3, element, bank, r3)
  210. packByte(4, element, bank, r4)
  211. packByte(5, element, bank, r5)
  212. packByte(6, element, bank, r6)
  213. packByte(7, element, bank, r7)
  214. }
  215.  
  216. /*
  217. This alternate style stores the character using the 8 row global array named
  218. `character`. It could be useful for storing sprites after transformations to
  219. create animations.
  220. */
  221. function storeCharacter2(charIndex) {
  222. element = floor(charIndex / 4)
  223. bank = charIndex % 4
  224. for (var row = 0; row < charRows; row++) {
  225. packByte(row, element, bank, character[row])
  226. }
  227. }
  228.  
  229. // Loads the global `character` from the specified charIndex
  230. function fetchCharacter(charIndex) {
  231. element = floor(charIndex / 4)
  232. bank = charIndex % 4
  233. for (var row = 0; row < charRows; row++) {
  234. character[row] = unpackByte(row, element, bank)
  235. }
  236. }
  237.  
  238. /*
  239. For a given row of a font's pixel data (fontBitmap[row]), there's a
  240. (fontCharCount / 4) element long array that holds 32 bits per array element.
  241. Thinking of each array element as a 4-byte word, the "bank" (0..3) specifies
  242. which set of 8 bits we're storing for a particular character. Characters are
  243. referred to by their charIndex (ASCII number), so:
  244. bank 0 in elements 0, 1, & 2 store the data for characters 0, 4, 8, etc;
  245. Bank 1 in elements 0, 1, & 2 store the data for characters 1, 5, 9, etc.
  246.  
  247. The method below is used because the bitwise operators only work on
  248. the top 16 bits.
  249. */
  250. var byteHolder = array(4)
  251. function packByte(row, element, bank, byte) {
  252. original = fontBitmap[row][element]
  253.  
  254. // Load a 4-element array with the individual bytes in this 32 bit 'word'
  255. for (_bank = 0; _bank < 4; _bank++) {
  256. byteHolder[_bank] = (((original << (_bank * 8)) & 0xFF00) >> 8) & 0xFF
  257. }
  258.  
  259. // Override the 8 bits we're trying to store
  260. byteHolder[bank] = byte
  261.  
  262. // Reassemble the 32 bit 'word'
  263. fontBitmap[row][element] = (byteHolder[0] << 8)
  264. + byteHolder[1]
  265. + (byteHolder[2] >> 8)
  266. + (byteHolder[3] >> 16)
  267. }
  268.  
  269. // Inverse of packByte()
  270. function unpackByte(row, element, bank) {
  271. word = fontBitmap[row][element]
  272. if (bank > 1) {
  273. byte = word << (8 * (bank - 1))
  274. } else if (bank == 0) {
  275. byte = word >> 8
  276. } else {
  277. byte = word
  278. }
  279. return byte & 0xFF // Zero out all but the 8 bits left of the binary point
  280. }
  281.  
  282.  
  283.  
  284. /*
  285. Font Data
  286.  
  287. Public domain, courtesy of
  288. https://github.com/rene-d/fontino/blob/master/font8x8_ib8x8u.ino
  289. */
  290.  
  291. storeCharacter( 32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) // 0x20 (space)
  292. storeCharacter( 33, 0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00) // 0x21 (exclam)
  293. storeCharacter( 34, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00) // 0x22 (quotedbl)
  294. storeCharacter( 35, 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00) // 0x23 (numbersign)
  295. storeCharacter( 36, 0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, 0x00) // 0x24 (dollar)
  296. storeCharacter( 37, 0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00) // 0x25 (percent)
  297. storeCharacter( 38, 0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00) // 0x26 (ampersand)
  298. storeCharacter( 39, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00) // 0x27 (quotesingle)
  299. storeCharacter( 40, 0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00) // 0x28 (parenleft)
  300. storeCharacter( 41, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00) // 0x29 (parenright)
  301. storeCharacter( 42, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00) // 0x2a (asterisk)
  302. storeCharacter( 43, 0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00) // 0x2b (plus)
  303. storeCharacter( 44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60) // 0x2c (comma)
  304. storeCharacter( 45, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00) // 0x2d (hyphen)
  305. storeCharacter( 46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00) // 0x2e (period)
  306. storeCharacter( 47, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00) // 0x2f (slash)
  307. storeCharacter( 48, 0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0x7c, 0x00) // 0x30 (zero)
  308. storeCharacter( 49, 0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00) // 0x31 (one)
  309. storeCharacter( 50, 0x78, 0xcc, 0x0c, 0x38, 0x60, 0xc4, 0xfc, 0x00) // 0x32 (two)
  310. storeCharacter( 51, 0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00) // 0x33 (three)
  311. storeCharacter( 52, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00) // 0x34 (four)
  312. storeCharacter( 53, 0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00) // 0x35 (five)
  313. storeCharacter( 54, 0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00) // 0x36 (six)
  314. storeCharacter( 55, 0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00) // 0x37 (seven)
  315. storeCharacter( 56, 0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00) // 0x38 (eight)
  316. storeCharacter( 57, 0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00) // 0x39 (nine)
  317. storeCharacter( 58, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00) // 0x3a (colon)
  318. storeCharacter( 59, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0x00) // 0x3b (semicolon)
  319. storeCharacter( 60, 0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00) // 0x3c (less)
  320. storeCharacter( 61, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00) // 0x3d (equal)
  321. storeCharacter( 62, 0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00) // 0x3e (greater)
  322. storeCharacter( 63, 0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00) // 0x3f (question)
  323. storeCharacter( 64, 0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00) // 0x40 (at)
  324. storeCharacter( 65, 0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00) // 0x41 (A)
  325. storeCharacter( 66, 0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00) // 0x42 (B)
  326. storeCharacter( 67, 0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00) // 0x43 (C)
  327. storeCharacter( 68, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00) // 0x44 (D)
  328. storeCharacter( 69, 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00) // 0x45 (E)
  329. storeCharacter( 70, 0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00) // 0x46 (F)
  330. storeCharacter( 71, 0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3e, 0x00) // 0x47 (G)
  331. storeCharacter( 72, 0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00) // 0x48 (H)
  332. storeCharacter( 73, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00) // 0x49 (I)
  333. storeCharacter( 74, 0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00) // 0x4a (J)
  334. storeCharacter( 75, 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00) // 0x4b (K)
  335. storeCharacter( 76, 0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00) // 0x4c (L)
  336. storeCharacter( 77, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00) // 0x4d (M)
  337. storeCharacter( 78, 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00) // 0x4e (N)
  338. storeCharacter( 79, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00) // 0x4f (O)
  339. storeCharacter( 80, 0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00) // 0x50 (P)
  340. storeCharacter( 81, 0x78, 0xcc, 0xcc, 0xcc, 0xdc, 0x78, 0x1c, 0x00) // 0x51 (Q)
  341. storeCharacter( 82, 0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00) // 0x52 (R)
  342. storeCharacter( 83, 0x78, 0xcc, 0xe0, 0x70, 0x1c, 0xcc, 0x78, 0x00) // 0x53 (S)
  343. storeCharacter( 84, 0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00) // 0x54 (T)
  344. storeCharacter( 85, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00) // 0x55 (U)
  345. storeCharacter( 86, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00) // 0x56 (V)
  346. storeCharacter( 87, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00) // 0x57 (W)
  347. storeCharacter( 88, 0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00) // 0x58 (X)
  348. storeCharacter( 89, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00) // 0x59 (Y)
  349. storeCharacter( 90, 0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00) // 0x5a (Z)
  350. storeCharacter( 91, 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00) // 0x5b (bracketleft)
  351. storeCharacter( 92, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00) // 0x5c (backslash)
  352. storeCharacter( 93, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00) // 0x5d (bracketright)
  353. storeCharacter( 94, 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00) // 0x5e (asciicircum)
  354. storeCharacter( 95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff) // 0x5f (underscore)
  355. storeCharacter( 96, 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00) // 0x60 (grave)
  356. storeCharacter( 97, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00) // 0x61 (a)
  357. storeCharacter( 98, 0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00) // 0x62 (b)
  358. storeCharacter( 99, 0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00) // 0x63 (c)
  359. storeCharacter(100, 0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00) // 0x64 (d)
  360. storeCharacter(101, 0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00) // 0x65 (e)
  361. storeCharacter(102, 0x38, 0x6c, 0x60, 0xf0, 0x60, 0x60, 0xf0, 0x00) // 0x66 (f)
  362. storeCharacter(103, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8) // 0x67 (g)
  363. storeCharacter(104, 0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00) // 0x68 (h)
  364. storeCharacter(105, 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00) // 0x69 (i)
  365. storeCharacter(106, 0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78) // 0x6a (j)
  366. storeCharacter(107, 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00) // 0x6b (k)
  367. storeCharacter(108, 0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00) // 0x6c (l)
  368. storeCharacter(109, 0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, 0x00) // 0x6d (m)
  369. storeCharacter(110, 0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00) // 0x6e (n)
  370. storeCharacter(111, 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00) // 0x6f (o)
  371. storeCharacter(112, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0) // 0x70 (p)
  372. storeCharacter(113, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e) // 0x71 (q)
  373. storeCharacter(114, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0xf0, 0x00) // 0x72 (r)
  374. storeCharacter(115, 0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x00) // 0x73 (s)
  375. storeCharacter(116, 0x10, 0x30, 0x7c, 0x30, 0x30, 0x34, 0x18, 0x00) // 0x74 (t)
  376. storeCharacter(117, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00) // 0x75 (u)
  377. storeCharacter(118, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00) // 0x76 (v)
  378. storeCharacter(119, 0x00, 0x00, 0xc6, 0xd6, 0xfe, 0xfe, 0x6c, 0x00) // 0x77 (w)
  379. storeCharacter(120, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00) // 0x78 (x)
  380. storeCharacter(121, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8) // 0x79 (y)
  381. storeCharacter(122, 0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00) // 0x7a (z)
  382. storeCharacter(123, 0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00) // 0x7b (braceleft)
  383. storeCharacter(124, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00) // 0x7c (bar)
  384. storeCharacter(125, 0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00) // 0x7d (braceright)
  385. storeCharacter(126, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) // 0x7e (asciitilde)
  386.  
  387.  
  388. // Other user-defined custom characters
  389.  
  390. // ASCII 63 is the question mark - here's an alternative from the
  391. // Sinclair ZX81 font, stored in custom slot 30
  392. storeCharacter(30,
  393. 0b00000000,
  394. 0b00111100,
  395. 0b01000010,
  396. 0b00000100,
  397. 0b00001000,
  398. 0b00000000,
  399. 0b00001000,
  400. 0b00000000
  401. )
  402.  
  403. // This demonstrates copying the character, altering it, then storing it in the
  404. // next slot. You could use this for programmatic animation.
  405. fetchCharacter(30)
  406. character[7] = 0b00001000
  407. storeCharacter2(31)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement