gtext.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. #include <avr/io.h>
  2. #include "sed1335.h"
  3. #include "gtext.h"
  4. #include <avr/pgmspace.h>
  5. #include <util/delay.h>
  6. #include <string.h>
  7. unsigned char blackbg = 0; //0=bez tła, 1=tło z paskami, 2=tło jednolite
  8. unsigned char color = 0x3; //kolor tekstu
  9. PROGMEM unsigned char const FontTable[][13] = {
  10. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, //
  11. {0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, }, // ! //
  12. {0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, // "
  13. {0x00, 0x12, 0x12, 0x12, 0x7e, 0x24, 0x24, 0x7e, 0x48, 0x48, 0x48, 0x00, 0x00, }, // #
  14. {0x00, 0x08, 0x3e, 0x49, 0x48, 0x38, 0x0e, 0x09, 0x49, 0x3e, 0x08, 0x00, 0x00, }, // $
  15. {0x00, 0x31, 0x4a, 0x4a, 0x34, 0x08, 0x08, 0x16, 0x29, 0x29, 0x46, 0x00, 0x00, }, // %
  16. {0x00, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x39, 0x45, 0x42, 0x46, 0x39, 0x00, 0x00, }, // &
  17. {0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, // '
  18. {0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x00, }, // (
  19. {0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x00, }, // )
  20. {0x00, 0x00, 0x00, 0x08, 0x49, 0x2a, 0x1c, 0x2a, 0x49, 0x08, 0x00, 0x00, 0x00, }, // *
  21. {0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, }, // + //
  22. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x18, 0x30, }, // , //
  23. {0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, // - //
  24. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, }, // .
  25. {0x00, 0x02, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00, }, // /
  26. {0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, }, // 0 //
  27. {0x00, 0x38, 0x78, 0xd8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xfe, 0x00, 0x00, }, // 1 //
  28. {0x00, 0x7c, 0xc6, 0xc6, 0x06, 0x1c, 0x30, 0x60, 0xc0, 0xc0, 0xfe, 0x00, 0x00, }, // 2 //
  29. {0x00, 0x7c, 0xc6, 0xc6, 0x06, 0x3c, 0x06, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // 3 //
  30. {0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xcc, 0xff, 0x0c, 0x0c, 0x0c, 0x00, 0x00, }, // 4 //
  31. {0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, }, // 5 //
  32. {0x00, 0x3c, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // 6 //
  33. {0x00, 0xfe, 0x06, 0x06, 0x0c, 0x0c, 0x0c, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, }, // 7 //
  34. {0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // 8 //
  35. {0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, }, // 9 //
  36. {0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, }, // :
  37. {0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10, 0x00, }, // ;
  38. {0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, }, // < //
  39. {0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, }, // =
  40. {0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00, }, // >
  41. {0x00, 0x3c, 0x42, 0x42, 0x02, 0x04, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00, }, // ?
  42. {0x00, 0x1c, 0x22, 0x4a, 0x56, 0x52, 0x52, 0x52, 0x4e, 0x20, 0x1e, 0x00, 0x00, }, // @
  43. {0x00, 0x38, 0x6c, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, }, // A //
  44. {0x00, 0xfc, 0xc6, 0xc6, 0xc6, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0xfc, 0x00, 0x00, }, // B //
  45. {0x00, 0x7c, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // C //
  46. {0x00, 0xf8, 0xcc, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xcc, 0xf8, 0x00, 0x00, }, // D //
  47. {0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, }, // E //
  48. {0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, }, // F //
  49. {0x00, 0x7c, 0xc6, 0xc6, 0xc0, 0xc0, 0xce, 0xc6, 0xc6, 0xc6, 0x3a, 0x00, 0x00, }, // G //
  50. {0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, }, // H //
  51. {0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, }, // I //
  52. {0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x38, 0x00, 0x00, }, // J //
  53. {0x00, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0x00, 0x00, }, // K //
  54. {0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, }, // L //
  55. {0x00, 0xc6, 0xee, 0xd6, 0xd6, 0xd6, 0xd6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, }, // M //
  56. {0x00, 0xc6, 0xe6, 0xe6, 0xf6, 0xf6, 0xde, 0xde, 0xce, 0xce, 0xc6, 0x00, 0x00, }, // N //
  57. {0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // O //
  58. {0x00, 0xfc, 0xc6, 0xc6, 0xc6, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, }, // P //
  59. {0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xda, 0xe6, 0x7c, 0x03, 0x00, }, // Q //
  60. {0x00, 0xfc, 0xc6, 0xc6, 0xc6, 0xfc, 0xd8, 0xcc, 0xcc, 0xc6, 0xc6, 0x00, 0x00, }, // R //
  61. {0x00, 0x7c, 0xc6, 0xc6, 0xc0, 0x30, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // S //
  62. {0x00, 0xfe, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, }, // T //
  63. {0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // U //
  64. {0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x00, }, // V //
  65. {0x00, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xd6, 0xee, 0xee, 0xc6, 0x00, 0x00, }, // W //
  66. {0x00, 0xc6, 0xc6, 0x6c, 0x6c, 0x38, 0x38, 0x6c, 0x6c, 0xc6, 0xc6, 0x00, 0x00, }, // X //
  67. {0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, }, // Y //
  68. {0x00, 0xfe, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc0, 0xfe, 0x00, 0x00, }, // Z //
  69. {0x0e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, }, // [
  70. {0x00, 0xc0, 0xc0, 0xe0, 0x30, 0x30, 0x18, 0x18, 0x0c, 0x06, 0x06, 0x00, 0x00, }, // odwrotny /
  71. {0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x70, 0x00, }, // ]
  72. {0x18, 0x3c, 0x7e, 0xdb, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, }, // ^ ↑
  73. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, }, // _
  74. {0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, // `
  75. {0x00, 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x3e, 0xc6, 0xc6, 0xc6, 0x3a, 0x00, 0x00, }, // a //
  76. {0xc0, 0xc0, 0xc0, 0xdc, 0xe6, 0xc6, 0xc6, 0xc6, 0xc6, 0xe6, 0xdc, 0x00, 0x00, }, // b //
  77. {0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, }, // c //
  78. {0x06, 0x06, 0x06, 0x3e, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x3a, 0x00, 0x00, }, // d //
  79. {0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, }, // e //
  80. {0x1c, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, }, // f //
  81. {0x00, 0x00, 0x06, 0x3a, 0xcc, 0xcc, 0xcc, 0x38, 0x60, 0xfc, 0xc6, 0xc6, 0x7c, }, // g //
  82. {0xc0, 0xc0, 0xc0, 0xfc, 0xe6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, }, // h //
  83. {0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, }, // i //
  84. {0x0c, 0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xd8, 0x70, }, // j //
  85. {0xc0, 0xc0, 0xc0, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0x00, 0x00, }, // k //
  86. {0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, }, // l //
  87. {0x00, 0x00, 0x00, 0xec, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0x00, 0x00, }, // m //
  88. {0x00, 0x00, 0x00, 0xdc, 0xe6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, }, // n //
  89. {0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // o //
  90. {0x00, 0x00, 0x00, 0xdc, 0xe6, 0xc6, 0xc6, 0xc6, 0xc6, 0xe6, 0xdc, 0xc0, 0xc0, }, // p //
  91. {0x00, 0x00, 0x00, 0x3a, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x3e, 0x06, 0x06, }, // q //
  92. {0x00, 0x00, 0x00, 0xdc, 0xe6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, }, // r //
  93. {0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0x30, 0x0c, 0x06, 0xc6, 0x7c, 0x00, 0x00, }, // s //
  94. {0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1c, 0x00, 0x00, }, // t //
  95. {0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xce, 0x76, 0x00, 0x00, }, // u //
  96. {0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x38, 0x38, 0x00, 0x00, }, // v //
  97. {0x00, 0x00, 0x00, 0xc6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0x6c, 0x00, 0x00, }, // w //
  98. {0x00, 0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0xc6, 0x00, 0x00, }, // x //
  99. {0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x66, 0x3e, 0x06, 0x0e, 0xfc, }, // y //
  100. {0x00, 0x00, 0x00, 0xfe, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xfe, 0x00, 0x00, }, // z //
  101. {0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, // 0x7b ° //
  102. {0x7C, 0x42, 0x42, 0x7C, 0x48, 0x44, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, }, // 0x7c małe R na górze
  103. {0xff, 0xff, 0xff, 0x7e, 0x7e, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x3c, 0x3c, 0x3c, }, // 0x7d brzydki wykrzyknik
  104. {0x00, 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x3e, 0xc6, 0xc6, 0xc6, 0x3a, 0x18, 0x0c, }, // 0x7e ą //
  105. {0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x18, 0x0c, }, // 0x7f ę //
  106. {0x00, 0x38, 0x18, 0x18, 0x18, 0x1e, 0x78, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, }, // 0x80 ł //
  107. {0x0c, 0x18, 0x00, 0x7c, 0xc6, 0xc0, 0x30, 0x0c, 0x06, 0xc6, 0x7c, 0x00, 0x00, }, // 0x81 ś //
  108. {0x0c, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // 0x82 ó //
  109. {0x18, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, }, // 0x83 Ó //
  110. {0x00, 0x00, 0x00, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff, 0x00, 0x00, }, // 0x84 ramka pusta
  111. {0x00, 0x00, 0x00, 0xff, 0x83, 0x85, 0x85, 0xc9, 0xa9, 0x91, 0xff, 0x00, 0x00, }, // 0x85 ramka z ptaszkiem
  112. {0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xdb, 0x7e, 0x3c, 0x18, }, // 0x86 ↓
  113. };
  114. void GLCD_Clear(void){ //zastępuję funkcję z sed1335.c
  115. unsigned int i;
  116. GLCD_SetCursorAddress(SED1335_GRAPHICSTART);
  117. GLCD_WriteCommand(SED1335_MWRITE);
  118. for(i = 0; i < SED1335_GRAPHICSIZE; i++)
  119. GLCD_WriteData(0x00);
  120. GLCD_SetCursorAddress(SED1335_TGRAPHICSTART);
  121. GLCD_WriteCommand(SED1335_MWRITE);
  122. for(i = 0; i < SED1335_GRAPHICSIZE; i++)
  123. GLCD_WriteData(0x00);
  124. GLCD_WriteCommand(SED1335_DISP_ON);
  125. GLCD_WriteData(SED1335_FLASH);
  126. }
  127. void GLCD_TLGoTo(unsigned int x, unsigned int y){
  128. GLCD_SetCursorAddress(SED1335_TGRAPHICSTART + y*80 + x*2);
  129. }
  130. static unsigned char cur_x, cur_y;
  131. void GLCD_GraphicGoTo_T(unsigned int x, unsigned int y){
  132. GLCD_SetCursorAddress(SED1335_GRAPHICSTART + y*80 + x*2);
  133. }
  134. void grayscale(const unsigned char * const c_ptr){ //zamień dane z FontTable na takie do wysłania do lcd, i wyślij
  135. unsigned char x;
  136. unsigned char i,j;
  137. char c = pgm_read_byte(c_ptr);
  138. for(i=0;i<2;i++){
  139. x = 0;
  140. for(j=0;j<4;j++){
  141. x <<= 2;
  142. if(c&128){
  143. x |= color;
  144. }
  145. c <<= 1;
  146. }
  147. GLCD_WriteData(x);
  148. }
  149. }
  150. /*inline static void ch_pos(void){
  151. if(cur_x>X_MAX){
  152. cur_x = 0;
  153. if(++cur_y>Y_MAX) cur_y = 0;
  154. }
  155. }*/
  156. #define ch_pos() if(cur_x>X_MAX){ cur_x=0; if(++cur_y>Y_MAX) cur_y=0; }
  157. void cursor(unsigned char x, unsigned char y){ //ustaw kursor tekstowy
  158. if(x>X_MAX) x=X_MAX;
  159. if(y>Y_MAX) y=Y_MAX;
  160. cur_x = x;
  161. cur_y = y;
  162. }
  163. void background(unsigned char cnt){ //rysowanie tła - do reszty funkcji
  164. unsigned char i, tmp_cnt, tmp_data;
  165. for(i=0;i<13;i++){
  166. tmp_data = blackbg?((i==0||i==12)&&blackbg!=2?0xaa:0x55):0;
  167. tmp_cnt = cnt;
  168. GLCD_GraphicGoTo_T(cur_x, cur_y*15+i);
  169. GLCD_WriteCommand(SED1335_MWRITE);
  170. while(tmp_cnt--){
  171. GLCD_WriteData(tmp_data);
  172. GLCD_WriteData(tmp_data);
  173. }
  174. }
  175. GLCD_WriteCommand(SED1335_DISP_ON);
  176. GLCD_WriteData(SED1335_FLASH);
  177. }
  178. void puttext_P(const char *text){ //wypisz tekst z flasha
  179. unsigned char i=0;
  180. static char buffer[X_MAX+1];
  181. while((buffer[i++] = pgm_read_byte(text++)));
  182. puttext(buffer);
  183. }
  184. void puttext(const char *text){ //wypisz tekst z ramu
  185. register unsigned char cnt=0, i, j;
  186. cnt = strlen(text);
  187. background(cnt);
  188. for(i=0;i<13;i++){
  189. GLCD_TLGoTo(cur_x, cur_y*15+i);
  190. GLCD_WriteCommand(SED1335_MWRITE);
  191. for(j=0;j<cnt;j++){
  192. grayscale(&FontTable[text[j]-' '][i]);
  193. }
  194. }
  195. cur_x += cnt;
  196. ch_pos();
  197. GLCD_WriteCommand(SED1335_DISP_ON);
  198. GLCD_WriteData(SED1335_FLASH);
  199. }
  200. void putchar(char c){ //wypisz jeden znak
  201. unsigned char i;
  202. background(1);
  203. for(i=0; i<13; i++){
  204. GLCD_TLGoTo(cur_x, cur_y*15+i);
  205. GLCD_WriteCommand(SED1335_MWRITE);
  206. grayscale(&FontTable[c-' '][i]);
  207. }
  208. ++cur_x;
  209. ch_pos();
  210. GLCD_WriteCommand(SED1335_DISP_ON);
  211. GLCD_WriteData(SED1335_FLASH);
  212. }
  213. void clear_to(unsigned char pos){ //wyczyść do pozycji
  214. unsigned char i, j, cnt;
  215. cnt = pos-cur_x+1; //ilość znaków do wyczyszczenia
  216. background(cnt);
  217. for(i=0;i<13;i++){
  218. GLCD_TLGoTo(cur_x, cur_y*15+i);
  219. GLCD_WriteCommand(SED1335_MWRITE);
  220. for(j=0;j<cnt;j++){
  221. GLCD_WriteData(0); //dwa razy bo 2bpp, stąd dwa bajty na znak
  222. GLCD_WriteData(0);
  223. }
  224. }
  225. if(pos > X_MAX){
  226. cur_x = 0;
  227. if(++cur_y > Y_MAX) cur_y = 0;
  228. } else {
  229. cur_x = pos+1;
  230. }
  231. GLCD_WriteCommand(SED1335_DISP_ON);
  232. GLCD_WriteData(SED1335_FLASH);
  233. }
  234. /*
  235. void clearline(void){ //wyczyść do końca linii - nie używać - zamiast tego jest makro
  236. while(cur_x <= X_MAX){
  237. putchar(' ');
  238. if(!cur_x) break;
  239. }
  240. }*/