Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.94 KB | None | 0 0
  1. /*
  2. A simple code to display a static 'A' to the Bi-Color LED Matrix 2188.
  3. *Here Only one color is used!!
  4. *The rows are selected sequentially, and the column data are loaded.
  5. */
  6.  
  7. #include <avr/io.h>
  8. #define F_CPU 1000000
  9. #include <util/delay.h>
  10. #include <avr/interrupt.h>
  11.  
  12. #define GREEN_COLM PORTA
  13. #define RED_COLM PORTD
  14. #define ROW PORTB
  15. #define OFF_FULL_COLM 0xFF
  16. #define ON_FULL_COLM 0x00
  17. #define ON_FULL_ROW 0xFF
  18.  
  19. #define ON_ROW 1
  20. #define ON_COLM 0
  21.  
  22.  
  23.  
  24. #define UP 'u'
  25. #define LEFT 'l'
  26. #define DOWN 'd'
  27. #define RIGHT 'r'
  28. #define RED_COLOR 'r'
  29. #define GREEN_COLOR 'g'
  30. #define BOTH_COLOR 'b'
  31.  
  32. #define N 8
  33.  
  34.  
  35. unsigned char sh =7;
  36. unsigned char sh1 =0;
  37.  
  38.  
  39. const uint64_t IMAGES[] = {
  40. 0x6666667e66663c00,
  41. 0x3e66663e66663e00,
  42. 0x3c66060606663c00,
  43. 0x3e66666666663e00,
  44. 0x7e06063e06067e00,
  45. 0x0606063e06067e00,
  46. 0x3c66760606663c00,
  47. 0x6666667e66666600,
  48. 0x3c18181818183c00,
  49. 0x1c36363030307800,
  50. 0x66361e0e1e366600,
  51. 0x7e06060606060600,
  52. 0xc6c6c6d6feeec600,
  53. 0xc6c6e6f6decec600,
  54. 0x3c66666666663c00,
  55. 0x06063e6666663e00,
  56. 0x603c766666663c00,
  57. 0x66361e3e66663e00,
  58. 0x3c66603c06663c00,
  59. 0x18181818185a7e00,
  60. 0x7c66666666666600,
  61. 0x183c666666666600,
  62. 0xc6eefed6c6c6c600,
  63. 0xc6c66c386cc6c600,
  64. 0x1818183c66666600,
  65. 0x7e060c1830607e00,
  66. 0x0000000000000000,
  67. 0x7c667c603c000000,
  68. 0x3e66663e06060600,
  69. 0x3c6606663c000000,
  70. 0x7c66667c60606000,
  71. 0x3c067e663c000000,
  72. 0x0c0c3e0c0c6c3800,
  73. 0x3c607c66667c0000,
  74. 0x6666663e06060600,
  75. 0x3c18181800180000,
  76. 0x1c36363030003000,
  77. 0x66361e3666060600,
  78. 0x1818181818181800,
  79. 0xd6d6feeec6000000,
  80. 0x6666667e3e000000,
  81. 0x3c6666663c000000,
  82. 0x06063e66663e0000,
  83. 0xf0b03c36363c0000,
  84. 0x060666663e000000,
  85. 0x3e403c027c000000,
  86. 0x1818187e18180000,
  87. 0x7c66666666000000,
  88. 0x183c666600000000,
  89. 0x7cd6d6d6c6000000,
  90. 0x663c183c66000000,
  91. 0x3c607c6666000000,
  92. 0x3c0c18303c000000
  93. };
  94. const int IMAGES_LEN = sizeof(IMAGES)/8;
  95.  
  96.  
  97. unsigned char symbol[8];
  98.  
  99.  
  100. void draw(uint64_t alpha,char clr){
  101. int i;
  102. for(i = 0; i < 8; i++)
  103. {
  104. symbol[i] = (alpha>>(8*i)) & 0x000000FF;
  105. }
  106.  
  107.  
  108. int k;
  109. for(k=0;k<200;k++){
  110. for(i=0;i<N;i++)
  111. {
  112. ROW = 0;
  113. if(clr==GREEN_COLOR){
  114. GREEN_COLM = ~(symbol[i]);
  115. RED_COLM = OFF_FULL_COLM;
  116. }
  117. else if(clr==RED_COLOR){
  118. GREEN_COLM = OFF_FULL_COLM;
  119. RED_COLM = ~(symbol[i]);
  120. }
  121. else {
  122. GREEN_COLM = RED_COLM = ~(symbol[i]);
  123. }
  124.  
  125. ROW = 1<<i;
  126.  
  127. _delay_us(300);
  128. }
  129. }
  130.  
  131.  
  132. }
  133.  
  134. void drawSymbolShiftLeftIn(uint64_t alpha,char clr){
  135.  
  136. int i;
  137. for(i = 0; i < 8; i++)
  138. {
  139. symbol[i] = (alpha>>(8*i)) & 0x000000FF;
  140. }
  141.  
  142.  
  143. int k;
  144. for(k=0;k<200;k++){
  145. for(i=0;i<N;i++)
  146. {
  147. ROW = 0;
  148. if(clr==GREEN_COLOR){
  149. GREEN_COLM = ~(symbol[i]<<sh);
  150. RED_COLM = OFF_FULL_COLM;
  151. }
  152. else if(clr==RED_COLOR){
  153. GREEN_COLM = OFF_FULL_COLM;
  154. RED_COLM = ~(symbol[i]<<sh);
  155. }
  156. else {
  157. GREEN_COLM = RED_COLM = ~(symbol[i]<<sh);
  158. }
  159.  
  160. ROW = 1<<i;
  161.  
  162. _delay_us(300);
  163. }
  164. }
  165. sh--;
  166.  
  167.  
  168. }
  169. void drawSymbolShiftLeftOut(uint64_t alpha,char clr){
  170.  
  171. int i;
  172. for(i = 0; i < 8; i++)
  173. {
  174. symbol[i] = (alpha>>(8*i)) & 0x000000FF;
  175. }
  176.  
  177.  
  178. int k;
  179. for(k=0;k<200;k++){
  180. for(i=0;i<N;i++)
  181. {
  182. ROW = 0;
  183. if(clr==GREEN_COLOR){
  184. GREEN_COLM = ~(symbol[i]>>sh1);
  185. RED_COLM = OFF_FULL_COLM;
  186. }
  187. else if(clr==RED_COLOR){
  188. GREEN_COLM = OFF_FULL_COLM;
  189. RED_COLM = ~(symbol[i]>>sh1);
  190. }
  191. else {
  192. GREEN_COLM = RED_COLM = ~(symbol[i]>>sh1);
  193. }
  194.  
  195. ROW = 1<<i;
  196.  
  197. _delay_us(300);
  198. }
  199. }
  200. sh1++;
  201.  
  202.  
  203. }
  204.  
  205.  
  206. void drawSymbolShiftRightIn(uint64_t alpha,char clr){
  207.  
  208. int i;
  209. for(i = 0; i < 8; i++)
  210. {
  211. symbol[i] = (alpha>>(8*i)) & 0x000000FF;
  212. }
  213.  
  214.  
  215. int k;
  216. for(k=0;k<200;k++){
  217. for(i=0;i<N;i++)
  218. {
  219. ROW = 0;
  220. if(clr==GREEN_COLOR){
  221. GREEN_COLM = ~(symbol[i]>>sh);
  222. RED_COLM = OFF_FULL_COLM;
  223. }
  224. else if(clr==RED_COLOR){
  225. GREEN_COLM = OFF_FULL_COLM;
  226. RED_COLM = ~(symbol[i]>>sh);
  227. }
  228. else {
  229. GREEN_COLM = RED_COLM = ~(symbol[i]>>sh);
  230. }
  231.  
  232. ROW = 1<<i;
  233.  
  234. _delay_us(300);
  235. }
  236. }
  237. sh--;
  238.  
  239.  
  240. }
  241. void drawSymbolShiftRightOut(uint64_t alpha,char clr){
  242.  
  243. int i;
  244. for(i = 0; i < 8; i++)
  245. {
  246. symbol[i] = (alpha>>(8*i)) & 0x000000FF;
  247. }
  248.  
  249.  
  250. int k;
  251. for(k=0;k<200;k++){
  252. for(i=0;i<N;i++)
  253. {
  254. ROW = 0;
  255. if(clr==GREEN_COLOR){
  256. GREEN_COLM = ~(symbol[i]<<sh1);
  257. RED_COLM = OFF_FULL_COLM;
  258. }
  259. else if(clr==RED_COLOR){
  260. GREEN_COLM = OFF_FULL_COLM;
  261. RED_COLM = ~(symbol[i]<<sh1);
  262. }
  263. else {
  264. GREEN_COLM = RED_COLM = ~(symbol[i]<<sh1);
  265. }
  266.  
  267. ROW = 1<<i;
  268.  
  269. _delay_us(300);
  270. }
  271. }
  272. sh1++;
  273.  
  274.  
  275. }
  276.  
  277.  
  278.  
  279. int main(void)
  280. {
  281.  
  282. DDRA = 0xFF; // red
  283. DDRB = 0xFF; // row
  284. DDRD = 0xFF; // green
  285.  
  286.  
  287. /* while(1){
  288. draw(IMAGES[1],GREEN_COLOR);
  289. }*/
  290. unsigned char count = 0;
  291. while(count!=6)
  292. {
  293. drawSymbolShiftLeftIn(IMAGES[1],GREEN_COLOR);
  294.  
  295. count++;
  296.  
  297. }
  298. while(1)
  299. {
  300. drawSymbolShiftLeftOut(IMAGES[1],GREEN_COLOR);
  301.  
  302. count++;
  303.  
  304. }
  305. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement