fork download
  1. #include <stdlib.h>
  2. #include <avr/io.h>
  3. #include <avr/pgmspace.h>
  4. #include <util/delay.h>
  5. #include "lcd.h"
  6.  
  7. void writeCustomChars(const PROGMEM unsigned char customChars[][8], uint8_t customCharOffset){
  8.  
  9. lcd_command(_BV(LCD_CGRAM)); /* set CG RAM start address 0*/
  10.  
  11. for (uint8_t i = customCharOffset; i < customCharOffset + 5; i++){
  12. for(uint8_t j = 0; j < 8; j++)
  13. lcd_data(pgm_read_byte_near(&customChars[i][j]));
  14. }
  15. }
  16.  
  17. void printDDRAMcustomChars(void){
  18. for(uint8_t i = 0; i < 4; i++){
  19. lcd_gotoxy(2, i);
  20. for(uint8_t j = 0; j < 5; j++){
  21. lcd_putc(j);
  22. }
  23. }
  24. }
  25.  
  26. int main(void){
  27. static const PROGMEM unsigned char customChars[20][8] = {
  28. {
  29. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01 //begin of row 1
  30. },
  31. {
  32. 0x00, 0x03, 0x07, 0x0e, 0x0e, 0x1c, 0x18, 0x18
  33. },
  34. {
  35. 0x0e, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00
  36. },
  37. {
  38. 0x00, 0x18, 0x1c, 0x1e, 0x1e, 0x07, 0x03, 0x03
  39. },
  40. {
  41. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x18 //end of row 1
  42. },
  43. {
  44. 0x03, 0x03, 0x07, 0x07, 0x07, 0x0f, 0x0f, 0x0f //begin of row 2
  45. },
  46. {
  47. 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00
  48. },
  49. {
  50. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  51. },
  52. {
  53. 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
  54. },
  55. {
  56. 0x18, 0x18, 0x1c, 0x1c, 0x1c, 0x1e, 0x1e, 0x1e //end of row 2
  57. },
  58. {
  59. 0x0f, 0x0f, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f //begin of row 3
  60. },
  61. {
  62. 0x00, 0x1f, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00
  63. },
  64. {
  65. 0x00, 0x00, 0x1b, 0x1f, 0x1f, 0x04, 0x00, 0x00
  66. },
  67. {
  68. 0x00, 0x1f, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0x00
  69. },
  70. {
  71. 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f //end of row 3
  72. },
  73. {
  74. 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f //begin of row 4
  75. },
  76. {
  77. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  78. },
  79. {
  80. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  81. },
  82. {
  83. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  84. },
  85. {
  86. 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f //end of row 4
  87. }
  88. };
  89.  
  90. lcd_init(LCD_DISP_ON);
  91. lcd_clrscr();
  92.  
  93. for(uint8_t i = 1; i <= 20; i++){
  94. writeCustomChars(customChars, i);
  95. if( !(i % 5) )
  96. printDDRAMcustomChars();
  97. }
  98.  
  99. for(;;){
  100.  
  101. }
  102. }
  103.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:2:20: fatal error: avr/io.h: No such file or directory
 #include <avr/io.h>
                    ^
compilation terminated.
stdout
Standard output is empty