Guest User

Untitled

a guest
Mar 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.22 KB | None | 0 0
  1. #include <MD_MAX72xx.h>
  2. #include <avr/pgmspace.h>
  3.  
  4. const uint8_t PROGMEM font[] =
  5. {
  6. 0, // 0
  7. 0, // 1
  8. 0, // 2
  9. 0, // 3
  10. 0, // 4
  11. 0, // 5
  12. 0, // 6
  13. 0, // 7
  14. 0, // 8
  15. 0, // 9
  16. 0, // 10
  17. 0, // 11
  18. 0, // 12
  19. 0, // 13
  20. 0, // 14
  21. 0, // 15
  22. 5,0xff,0x00,0x00,0x00,0x00, // 16 - 'Bars'
  23. 5,0xff,0xff,0x00,0x00,0x00, // 17 - 'Bars'
  24. 5,0xff,0xff,0xff,0x00,0x00, // 18 - 'Bars'
  25. 5,0xff,0xff,0xff,0xff,0x00, // 19 - 'Bars'
  26. 5,0xff,0xff,0xff,0xff,0xff, // 20 - 'Bars'
  27. 5,0x00,0xff,0xff,0xff,0xff, // 21 - 'Bars'
  28. 5,0x00,0x00,0xff,0xff,0xff, // 22 - 'Bars'
  29. 5,0x00,0x00,0x00,0xff,0xff, // 23 - 'Bars'
  30. 5,0x00,0x00,0x00,0x00,0xff, // 24 - 'Bars'
  31. 5,0x60,0x70,0x3f,0x02,0x1c, // 25 - 'Musical Note'
  32. 5,0x03,0x33,0x48,0x48,0x48, // 26 - 'Deg C'
  33. 5,0x03,0x7b,0x28,0x28,0x08, // 27 - 'Deg F'
  34. 5,0x04,0x0c,0x1c,0x0c,0x04, // 28 - 'Down Pointer'
  35. 5,0x3e,0x1c,0x08,0x00,0x00, // 29 - 'Right Pointer'
  36. 5,0x08,0x1c,0x3e,0x00,0x00, // 30 - 'Left Pointer'
  37. 5,0x10,0x18,0x1c,0x18,0x10, // 31 - 'Up Pointer'
  38. 5,0x00,0x00,0x00,0x00,0x00, // 32 - 'Space'
  39. 5,0x5f,0x00,0x00,0x00,0x00, // 33 - '!'
  40. 5,0x07,0x00,0x07,0x00,0x00, // 34 - '"'
  41. 5,0x14,0x7f,0x14,0x7f,0x14, // 35 - '#'
  42. 5,0x24,0x2a,0x7f,0x2a,0x12, // 36 - '$'
  43. 5,0x23,0x13,0x08,0x64,0x62, // 37 - '%'
  44. 5,0x36,0x49,0x55,0x22,0x50, // 38 - '&'
  45. 5,0x00,0x05,0x03,0x00,0x00, // 39 - '''
  46. 5,0x1c,0x22,0x41,0x00,0x00, // 40 - '('
  47. 5,0x41,0x22,0x1c,0x00,0x00, // 41 - ')'
  48. 5,0x14,0x08,0x3e,0x08,0x14, // 42 - '*'
  49. 5,0x08,0x08,0x3e,0x08,0x08, // 43 - '+'
  50. 5,0xa0,0x60,0x00,0x00,0x00, // 44 - ','
  51. 5,0x08,0x08,0x08,0x08,0x08, // 45 - '-'
  52. 5,0x60,0x60,0x00,0x00,0x00, // 46 - '.'
  53. 5,0x20,0x10,0x08,0x04,0x02, // 47 - '/'
  54. 5,0x3e,0x51,0x49,0x45,0x3e, // 48 - '0'
  55. 5,0x42,0x7f,0x40,0x00,0x00, // 49 - '1'
  56. 5,0x42,0x61,0x51,0x49,0x46, // 50 - '2'
  57. 5,0x21,0x41,0x45,0x4b,0x31, // 51 - '3'
  58. 5,0x18,0x14,0x12,0x7f,0x10, // 52 - '4'
  59. 5,0x27,0x45,0x45,0x45,0x39, // 53 - '5'
  60. 5,0x3c,0x4a,0x49,0x49,0x30, // 54 - '6'
  61. 5,0x01,0x71,0x09,0x05,0x03, // 55 - '7'
  62. 5,0x36,0x49,0x49,0x49,0x36, // 56 - '8'
  63. 5,0x06,0x49,0x49,0x29,0x1e, // 57 - '9'
  64. 5,0x6c,0x6c,0x00,0x00,0x00, // 58 - ':'
  65. 5,0xac,0x6c,0x00,0x00,0x00, // 59 - ';'
  66. 5,0x08,0x14,0x22,0x41,0x00, // 60 - '<'
  67. 5,0x14,0x14,0x14,0x14,0x14, // 61 - '='
  68. 5,0x41,0x22,0x14,0x08,0x00, // 62 - '>'
  69. 5,0x02,0x01,0x51,0x09,0x06, // 63 - '?'
  70. 5,0x32,0x49,0x79,0x41,0x3e, // 64 - '@'
  71. 5,0x7e,0x11,0x11,0x11,0x7e, // 65 - 'A'
  72. 5,0x7f,0x49,0x49,0x49,0x36, // 66 - 'B'
  73. 5,0x3e,0x41,0x41,0x41,0x22, // 67 - 'C'
  74. 5,0x7f,0x41,0x41,0x22,0x1c, // 68 - 'D'
  75. 5,0x7f,0x49,0x49,0x49,0x41, // 69 - 'E'
  76. 5,0x7f,0x09,0x09,0x09,0x01, // 70 - 'F'
  77. 5,0x3e,0x41,0x49,0x49,0x7a, // 71 - 'G'
  78. 5,0x7f,0x08,0x08,0x08,0x7f, // 72 - 'H'
  79. 5,0x41,0x41,0x7f,0x41,0x41, // 73 - 'I'
  80. 5,0x20,0x40,0x41,0x3f,0x01, // 74 - 'J'
  81. 5,0x7f,0x08,0x14,0x22,0x41, // 75 - 'K'
  82. 5,0x7f,0x40,0x40,0x40,0x40, // 76 - 'L'
  83. 5,0x7f,0x02,0x0c,0x02,0x7f, // 77 - 'M'
  84. 5,0x7f,0x04,0x08,0x10,0x7f, // 78 - 'N'
  85. 5,0x3e,0x41,0x41,0x41,0x3e, // 79 - 'O'
  86. 5,0x7f,0x09,0x09,0x09,0x06, // 80 - 'P'
  87. 5,0x3e,0x41,0x51,0x21,0x5e, // 81 - 'Q'
  88. 5,0x7f,0x09,0x19,0x29,0x46, // 82 - 'R'
  89. 5,0x46,0x49,0x49,0x49,0x31, // 83 - 'S'
  90. 5,0x01,0x01,0x7f,0x01,0x01, // 84 - 'T'
  91. 5,0x3f,0x40,0x40,0x40,0x3f, // 85 - 'U'
  92. 5,0x1f,0x20,0x40,0x20,0x1f, // 86 - 'V'
  93. 5,0x3f,0x40,0x38,0x40,0x3f, // 87 - 'W'
  94. 5,0x63,0x14,0x08,0x14,0x63, // 88 - 'X'
  95. 5,0x07,0x08,0x70,0x08,0x07, // 89 - 'Y'
  96. 5,0x61,0x51,0x49,0x45,0x43, // 90 - 'Z'
  97. 5,0x7f,0x41,0x41,0x00,0x00, // 91 - '['
  98. 5,0x02,0x04,0x08,0x10,0x20, // 92 - '\'
  99. 5,0x41,0x41,0x7f,0x00,0x00, // 93 - ']'
  100. 5,0x04,0x02,0x01,0x02,0x04, // 94 - '^'
  101. 5,0x40,0x40,0x40,0x40,0x40, // 95 - '_'
  102. 5,0x01,0x02,0x04,0x00,0x00, // 96 - '`'
  103. 5,0x20,0x54,0x54,0x54,0x78, // 97 - 'a'
  104. 5,0x7f,0x50,0x48,0x48,0x30, // 98 - 'b'
  105. 5,0x38,0x44,0x44,0x44,0x20, // 99 - 'c'
  106. 5,0x30,0x48,0x48,0x50,0x7f, // 100 - 'd'
  107. 5,0x38,0x54,0x54,0x54,0x18, // 101 - 'e'
  108. 5,0x08,0x7e,0x09,0x01,0x02, // 102 - 'f'
  109. 5,0x18,0xa4,0xa4,0xa4,0x7c, // 103 - 'g'
  110. 5,0x7f,0x08,0x04,0x04,0x78, // 104 - 'h'
  111. 5,0x40,0x44,0x7d,0x40,0x40, // 105 - 'i'
  112. 5,0x40,0x80,0x88,0x7a,0x00, // 106 - 'j'
  113. 5,0x7f,0x10,0x28,0x44,0x00, // 107 - 'k'
  114. 5,0x41,0x7f,0x40,0x00,0x00, // 108 - 'l'
  115. 5,0x7c,0x04,0x18,0x04,0x78, // 109 - 'm'
  116. 5,0x7c,0x08,0x04,0x04,0x78, // 110 - 'n'
  117. 5,0x38,0x44,0x44,0x44,0x38, // 111 - 'o'
  118. 5,0xf8,0x28,0x24,0x24,0x18, // 112 - 'p'
  119. 5,0x18,0x24,0x24,0x28,0xf8, // 113 - 'q'
  120. 5,0x7c,0x08,0x04,0x04,0x08, // 114 - 'r'
  121. 5,0x48,0x54,0x54,0x54,0x20, // 115 - 's'
  122. 5,0x04,0x3f,0x44,0x40,0x20, // 116 - 't'
  123. 5,0x3c,0x40,0x40,0x20,0x7c, // 117 - 'u'
  124. 5,0x1c,0x20,0x40,0x20,0x1c, // 118 - 'v'
  125. 5,0x3c,0x40,0x30,0x40,0x3c, // 119 - 'w'
  126. 5,0x44,0x28,0x10,0x28,0x44, // 120 - 'x'
  127. 5,0x4c,0x90,0x90,0x90,0x7c, // 121 - 'y'
  128. 5,0x44,0x64,0x54,0x4c,0x44, // 122 - 'z'
  129. 5,0x08,0x36,0x41,0x00,0x00, // 123 - '{'
  130. 5,0x7f,0x00,0x00,0x00,0x00, // 124 - '|'
  131. 5,0x41,0x36,0x08,0x00,0x00, // 125 - '}'
  132. 5,0x08,0x08,0x2a,0x1c,0x08, // 126 - 'Right Arrow'
  133. 5,0x08,0x1c,0x2a,0x08,0x08, // 127 - 'Left Arrow'
  134. 0, // 128
  135. 0, // 129
  136. 0, // 130
  137. 0, // 131
  138. 0, // 132
  139. 0, // 133
  140. 0, // 134
  141. 0, // 135
  142. 0, // 136
  143. 0, // 137
  144. 0, // 138
  145. 0, // 139
  146. 0, // 140
  147. 0, // 141
  148. 0, // 142
  149. 0, // 143
  150. 0, // 144
  151. 5,0x1c,0x3e,0x3e,0x3e,0x1c, // 145 - 'Filled ball'
  152. 5,0x1c,0x22,0x22,0x22,0x1c, // 146 - 'Empty ball'
  153. 5,0x08,0x1c,0x3e,0x1c,0x08, // 147 - 'Filled diamond'
  154. 5,0x08,0x14,0x22,0x14,0x08, // 148 - 'Empty diamond'
  155. 5,0x77,0x00,0x00,0x00,0x00, // 149 - 'Pipe'
  156. 5,0x1c,0xa2,0x62,0x22,0x22, // 150 - 'C sedilla'
  157. 5,0x60,0x50,0x48,0x44,0x7e, // 151 - 'Triangle'
  158. 5,0x40,0x44,0x4a,0x51,0x40, // 152 - '<='
  159. 5,0x40,0x51,0x4a,0x44,0x40, // 153 - '>='
  160. 5,0x10,0x38,0x54,0x10,0x1f, // 154 - 'Return'
  161. 5,0x04,0x02,0x7f,0x02,0x04, // 155 - 'Up Arrow'
  162. 5,0x10,0x20,0x7f,0x20,0x10, // 156 - 'Down Arrow'
  163. 0, // 157
  164. 0, // 158
  165. 0, // 159
  166. 0, // 160
  167. 5,0x70,0x50,0x70,0x00,0x00, // 161
  168. 5,0x0f,0x01,0x01,0x00,0x00, // 162
  169. 5,0x40,0x40,0x78,0x00,0x00, // 163
  170. 5,0x10,0x20,0x40,0x00,0x00, // 164
  171. 5,0x60,0x60,0x00,0x00,0x00, // 165
  172. 5,0x0a,0x0a,0x4a,0x2a,0x1e, // 166
  173. 5,0x42,0x32,0x12,0x0a,0x06, // 167
  174. 5,0x20,0x10,0x08,0x7c,0x02, // 168
  175. 5,0x18,0x08,0x4c,0x48,0x38, // 169
  176. 5,0x48,0x48,0x78,0x48,0x48, // 170
  177. 5,0x48,0x28,0x18,0x7c,0x08, // 171
  178. 5,0x08,0x7c,0x08,0x28,0x18, // 172
  179. 5,0x40,0x48,0x48,0x78,0x40, // 173
  180. 5,0x54,0x54,0x54,0x54,0x7c, // 174
  181. 5,0x18,0x00,0x58,0x40,0x38, // 175
  182. 5,0x08,0x08,0x08,0x08,0x08, // 176
  183. 5,0x01,0x41,0x3d,0x09,0x07, // 177
  184. 5,0x10,0x08,0x7c,0x02,0x01, // 178
  185. 5,0x0e,0x02,0x43,0x22,0x1e, // 179
  186. 5,0x42,0x42,0x7e,0x42,0x42, // 180
  187. 5,0x22,0x12,0x0a,0x7f,0x02, // 181
  188. 5,0x42,0x3f,0x02,0x42,0x3e, // 182
  189. 5,0x0a,0x0a,0x7f,0x0a,0x0a, // 183
  190. 5,0x08,0x46,0x42,0x22,0x1e, // 184
  191. 5,0x04,0x03,0x42,0x3e,0x02, // 185
  192. 5,0x42,0x42,0x42,0x42,0x7e, // 186
  193. 5,0x02,0x4f,0x22,0x1f,0x02, // 187
  194. 5,0x4a,0x4a,0x40,0x20,0x1c, // 188
  195. 5,0x42,0x22,0x12,0x2a,0x46, // 189
  196. 5,0x02,0x3f,0x42,0x4a,0x46, // 190
  197. 5,0x06,0x48,0x40,0x20,0x1e, // 191
  198. 5,0x08,0x46,0x4a,0x32,0x1e, // 192
  199. 5,0x0a,0x4a,0x3e,0x09,0x08, // 193
  200. 5,0x0e,0x00,0x4e,0x20,0x1e, // 194
  201. 5,0x04,0x45,0x3d,0x05,0x04, // 195
  202. 5,0x7f,0x08,0x10,0x00,0x00, // 196
  203. 5,0x44,0x24,0x1f,0x04,0x04, // 197
  204. 5,0x20,0x22,0x22,0x22,0x20, // 198
  205. 5,0x42,0x2a,0x12,0x2a,0x06, // 199
  206. 5,0x22,0x12,0x7b,0x16,0x22, // 200
  207. 5,0x40,0x20,0x1f,0x00,0x00, // 201
  208. 5,0x78,0x00,0x02,0x04,0x78, // 202
  209. 5,0x3f,0x44,0x44,0x44,0x44, // 203
  210. 5,0x02,0x42,0x42,0x22,0x1e, // 204
  211. 5,0x04,0x02,0x04,0x08,0x30, // 205
  212. 5,0x32,0x02,0x7f,0x02,0x32, // 206
  213. 5,0x02,0x12,0x22,0x52,0x0e, // 207
  214. 5,0x2a,0x2a,0x2a,0x40,0x00, // 208
  215. 5,0x38,0x24,0x22,0x20,0x70, // 209
  216. 5,0x40,0x28,0x10,0x28,0x06, // 210
  217. 5,0x0a,0x3e,0x4a,0x4a,0x4a, // 211
  218. 5,0x04,0x7f,0x04,0x14,0x0c, // 212
  219. 5,0x40,0x42,0x42,0x7e,0x40, // 213
  220. 5,0x4a,0x4a,0x4a,0x4a,0x7e, // 214
  221. 5,0x04,0x05,0x45,0x25,0x1c, // 215
  222. 5,0x0f,0x40,0x20,0x1f,0x00, // 216
  223. 5,0x7c,0x00,0x7e,0x40,0x30, // 217
  224. 5,0x7e,0x40,0x20,0x10,0x08, // 218
  225. 5,0x7e,0x42,0x42,0x42,0x7e, // 219
  226. 5,0x0e,0x02,0x42,0x22,0x1e, // 220
  227. 5,0x42,0x42,0x40,0x20,0x18, // 221
  228. 5,0x04,0x08,0x02,0x04,0x00, // 222
  229. 5,0x0e,0x0a,0x0e,0x00,0x00, // 223
  230. 5,0x38,0x44,0x48,0x30,0x4c, // 224 - 'Alpha'
  231. 5,0x20,0x55,0x54,0x55,0x78, // 225 - 'a umlaut'
  232. 5,0xfc,0x2a,0x2a,0x2a,0x14, // 226 - 'Beta'
  233. 5,0x28,0x54,0x54,0x44,0x20, // 227 - 'Epsilon'
  234. 5,0xfc,0x20,0x20,0x10,0x3c, // 228 - 'mu'
  235. 5,0x38,0x44,0x4c,0x54,0x24, // 229 - 'sigma'
  236. 5,0xf0,0x28,0x24,0x24,0x18, // 230 - 'rho'
  237. 5,0x10,0xa8,0xa8,0xa8,0x78, // 231 - 'g'
  238. 5,0x20,0x40,0x3e,0x02,0x02, // 232 - 'square root'
  239. 5,0x04,0x04,0x00,0x0e,0x00, // 233
  240. 5,0x40,0x80,0x88,0x7a,0x00, // 234 - 'j'
  241. 5,0x05,0x02,0x05,0x00,0x00, // 235 - 'asterisk note'
  242. 5,0x18,0x24,0x7e,0x24,0x10, // 236 - 'cents'
  243. 5,0x14,0x7f,0x54,0x40,0x40, // 237 - 'pound sterling'
  244. 5,0x7c,0x09,0x05,0x05,0x78, // 238 - 'n accent'
  245. 5,0x38,0x45,0x44,0x45,0x38, // 239 - 'o umlaut'
  246. 5,0xfc,0x28,0x24,0x24,0x18, // 240 - 'p'
  247. 5,0x18,0x24,0x24,0x28,0xfc, // 241 - 'q'
  248. 5,0x3e,0x45,0x45,0x45,0x3e, // 242 - 'Theta'
  249. 5,0x30,0x28,0x10,0x28,0x18, // 243 - 'infinity'
  250. 5,0x58,0x64,0x04,0x64,0x58, // 244
  251. 5,0x3c,0x41,0x40,0x21,0x7c, // 245 - 'u umlaut'
  252. 5,0x63,0x55,0x49,0x41,0x41, // 246 - 'Sigma upper'
  253. 5,0x42,0x3e,0x02,0x7e,0x42, // 247 - 'Pi'
  254. 5,0x45,0x29,0x11,0x29,0x45, // 248 - 'x bar'
  255. 5,0x18,0xa0,0xa0,0xa0,0x78, // 249 - 'y'
  256. 5,0x14,0x14,0x7c,0x14,0x12, // 250
  257. 5,0x44,0x3c,0x14,0x14,0x74, // 251 - 'Exit (jap)'
  258. 5,0x7c,0x14,0x1c,0x14,0x7c, // 252 - 'Entrance (jap)'
  259. 5,0x08,0x08,0x2a,0x08,0x08, // 253 - 'divide'
  260. 0, // 254
  261. 5,0x7f,0x7f,0x7f,0x7f,0x7f, // 255 - '5x7 block'
  262. };
  263.  
  264.  
  265.  
  266. MD_MAX72XX row1 = MD_MAX72XX(2, 4, 3, 12);
  267. MD_MAX72XX row2 = MD_MAX72XX(5, 7, 6, 12);
  268.  
  269. char msg1[] = "TEST";
  270. char msg2[] = "This is a test";
  271.  
  272. void setup() {
  273. row1.setFont(font);
  274. row2.setFont(font);
  275. row1.begin();
  276. row2.begin();
  277. row1.clear();
  278. row2.clear();
  279. }
  280.  
  281. void loop(){
  282. runTimeRow1();
  283. runTimeRow2();
  284. delay(5000);
  285. row1.clear();
  286. row2.clear();
  287. }
  288.  
  289. void runTimeRow1() {
  290. uint8_t data_1[5];
  291. int lines_1 = 0, j_1 = 95, k_1 = 0, lim_1 = 0;
  292. int i_1 = 0;
  293. for(i_1 = sizeof(msg1)-2; i_1 >= 0 ; i_1--){
  294. int alpha_1 = msg1[i_1]+0;
  295. row1.getChar(alpha_1, 5, data_1);
  296. if(alpha_1 == 32){
  297. lim_1 = 2-1;
  298. }else if(alpha_1 == 73 || alpha_1 == 105){
  299. lim_1 = 3-1;
  300. }else{
  301. lim_1 = 5-1;
  302. }
  303. for(k_1 = lim_1; k_1 > -1; k_1--){
  304. row1.setColumn(lines_1, data_1[k_1]);
  305. ++lines_1;
  306. }
  307. row1.setColumn(lines_1, 0x00);
  308. ++lines_1;
  309. }
  310. }
  311.  
  312. void runTimeRow2() {
  313. uint8_t data_2[5];
  314. int lines_2 = 0, j_2 = 95, k_2 = 0, lim_2 = 0;
  315. int i_2 = 0;
  316. for(i_2 = sizeof(msg2)-2; i_2 >= 0 ; i_2--){
  317. int alpha_2 = msg2[i_2]+0;
  318. row1.getChar(alpha_2, 5, data_2);
  319. if(alpha_2 == 32){
  320. lim_2 = 2-1;
  321. }
  322. else{
  323. lim_2 = 5-1;
  324. }
  325. for(k_2 = lim_2; k_2 > -1; k_2--){
  326. row2.setColumn(lines_2, data_2[k_2]);
  327. ++lines_2;
  328. }
  329. row2.setColumn(lines_2, 0x00);
  330. ++lines_2;
  331. }
  332. }
Add Comment
Please, Sign In to add comment