_LCD1602_init.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. Queue<int> _LCD_print_queue = Queue<int>(5);
  2. _LCD_print_bufforT _LCD_print_buffors[1];
  3. _LCD_print_screensT _LCD_print_screens[10];
  4. void LCD_print_background_add(_LCD_print_bufforT* _LCD_print_buffors, int screenID, int cursor1, int cursor2, char character ,long time_seq_id, long time_min_run ) {
  5. //time_seq_id - used to maintain single display context
  6. //time_max - used to how much time to keep in displayed text
  7. // Serial.println(" runned LCD_print_background_screen_add bbuf: ");
  8. // Serial.print(sizeof(_LCD_print_buffors));
  9. Serial.print("CB:");
  10. int curr_buf_ind;
  11. int i ;
  12. for(i=1;i<=100;i++) {
  13. if(_LCD_print_buffors[i].screenID<=0) {
  14. Serial.print("i<=0["); Serial.print(i); Serial.print("]");
  15. curr_buf_ind = i;
  16. //if(_LCD_print_buffors[i + 1].screenID<=0)
  17. break;
  18. }
  19. }
  20. Serial.print(curr_buf_ind); Serial.print(". ");
  21. //char b = character.charAt(0);
  22. Serial.print(" added lcd buf at ind "); Serial.println(curr_buf_ind );
  23. int b_ascii_value = character;
  24. _LCD_print_buffors[curr_buf_ind] = { screenID , cursor1 , cursor2, b_ascii_value, time_seq_id , time_min_run} ;
  25. /*
  26. _LCD_print_buffors[screenID].screenID=screenID ;
  27. _LCD_print_buffors[screenID].cursor1=cursor1 ;
  28. _LCD_print_buffors[screenID].cursor2=cursor2 ;
  29. _LCD_print_buffors[screenID].character=b_ascii_value ;
  30. _LCD_print_buffors[screenID].time_seq_id=time_seq_id ;
  31. _LCD_print_buffors[screenID].time_min_run=time_min_run ;
  32. */
  33. }
  34. void LCD_print_background_screen_add(_LCD_print_screensT* _LCD_print_screens, int screenID,long time_seq_id, long time_min_run, char LCDarray1, char LCDarray2 ) {
  35. //time_seq_id - used to maintain single display context
  36. //time_max - used to how much time to keep in displayed text
  37. _LCD_print_screens[screenID].screenID=screenID ;
  38. _LCD_print_screens[screenID].time_seq_id=time_seq_id ;
  39. _LCD_print_screens[screenID].time_min_run=time_min_run ;
  40. _LCD_print_screens[screenID].LCDarray1=LCDarray1 ;
  41. _LCD_print_screens[screenID].LCDarray2=LCDarray2 ;
  42. Serial.print(" added to screen a1 "); Serial.println(String(LCDarray1) );
  43. // unsigned char LCDarray2buf[16];
  44. // LCDarray2.toCharArray(LCDarray2buf, 15);
  45. /*
  46. for ( int positionCounter1 = 0;
  47. positionCounter1 < 24; positionCounter1++)
  48. {
  49. LCD_print_background_add( _LCD_print_buffors, screenID, positionCounter1, 0, LCDarray1[positionCounter1], time_seq_id, time_min_run);
  50. Serial.print("A.");
  51. }
  52. for ( int positionCounter2 = 0;
  53. positionCounter2 < 24; positionCounter2++)
  54. {
  55. LCD_print_background_add( _LCD_print_buffors, screenID, positionCounter2, 1, LCDarray2[positionCounter2], time_seq_id, time_min_run);
  56. }
  57. Serial.print(" :");
  58. Serial.print(sizeof(_LCD_print_buffors));
  59. Serial.print(" :");
  60. */
  61. }
  62. // _LCD_print_bufforT _LCD_print_bufforss[] = { 0 , 0, "T", 10000, 50000 } ;
  63. void LCD_print_background(int cursor1, int cursor2, int character ,long time_seq_id, long time_min_run ) {
  64. //time_seq_id - used to maintain single display context
  65. //time_max - used to how much time to keep in displayed text
  66. }
  67. void _LCD_print_screens_list(_LCD_print_screensT* _LCD_print_screens ) {
  68. int i;
  69. Serial.print("sizeof(_LCD_print_screens): ");
  70. Serial.println(sizeof(_LCD_print_screens));
  71. for(i=0;i<=10;i++) { //sizeof(_LCD_print_buffors)
  72. Serial.print(" $i[");
  73. Serial.print(i);
  74. Serial.print("] screenID: ");
  75. Serial.print(_LCD_print_screens[i].screenID);
  76. String str((char*) _LCD_print_screens[i].LCDarray1);
  77. Serial.print(" LCDarray1 ph: ");
  78. Serial.println( str);
  79. Serial.print(" LCDarray1 len: ");
  80. Serial.println( sizeof(str));
  81. Serial.print(" LCDarray1: ");
  82. Serial.println( Serial.println((char*) _LCD_print_screens[i].LCDarray1) );
  83. Serial.print(" LCDarray2: ");
  84. Serial.write(_LCD_print_screens[i].LCDarray2);
  85. Serial.print(" time_seq_id: ");
  86. Serial.write( _LCD_print_screens[i].time_seq_id );
  87. Serial.print(" time_seq_id: ");
  88. Serial.println(_LCD_print_screens[i].time_seq_id);
  89. }
  90. }
  91. void _LCD_print_buffors_list(_LCD_print_bufforT* _LCD_print_buffors, int LCDtim ) {
  92. int i;
  93. Serial.print("sizeof(_LCD_print_buffors): ");
  94. Serial.println(sizeof(_LCD_print_buffors));
  95. for(i=0;i<=100;i++) { //sizeof(_LCD_print_buffors)
  96. Serial.print(" $i[");
  97. Serial.print(i);
  98. Serial.print("] _LCD_print_buffors screenID: ");
  99. Serial.print(_LCD_print_buffors[i].screenID);
  100. Serial.print(" cursor1: ");
  101. Serial.print(_LCD_print_buffors[i].cursor1);
  102. Serial.print(" cursor2: ");
  103. Serial.print(_LCD_print_buffors[i].cursor2);
  104. Serial.print(" character: ");
  105. Serial.write( _LCD_print_buffors[i].character );
  106. Serial.print(" time_seq_id: ");
  107. Serial.print(_LCD_print_buffors[i].time_seq_id);
  108. Serial.print(" time_min_run: ");
  109. Serial.println(_LCD_print_buffors[i].time_min_run);
  110. }
  111. lcd.setCursor(0,0);
  112. lcd.print("print_buffors"); // Print a message to the LCD.
  113. lcd.setCursor(0,1);
  114. lcd.print(String( _LCD_print_buffors[0].character));
  115. lcd.print(" , ");
  116. lcd.print(String( _LCD_print_buffors[1].character));
  117. delay(LCDtim * 5);
  118. }
  119. void LCD_print(String LCDarray1, String LCDarray2 ,int LCDtim) {
  120. delay(LCDtim);
  121. unsigned char LCDarray1buf[16];
  122. LCDarray1.toCharArray(LCDarray1buf, 16);
  123. unsigned char LCDarray2buf[16];
  124. LCDarray2.toCharArray(LCDarray2buf, 16);
  125. // lcd.setCursor(0,0);
  126. // lcd.print(LCDarray1);
  127. // lcd.setCursor(0,1);
  128. // lcd.print(LCDarray1);
  129. lcd.setCursor(16,0);
  130. for ( int positionCounter1 = 0;
  131. positionCounter1 <= 24 ;//LCDarray1.length(); // 24;
  132. positionCounter1++)
  133. {
  134. lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.
  135. if(positionCounter1 >= LCDarray1.length()) lcd.print(" ");
  136. else lcd.print(LCDarray1[positionCounter1]); // Print a message to the LCD.
  137. delay(LCDtim); //wait for 250 microseconds
  138. if(positionCounter1==10) delay(LCDtim *7 );
  139. }
  140. // lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.
  141. lcd.setCursor(16,1);
  142. for ( int positionCounter2 = 0;
  143. positionCounter2 <= 24;//LCDarray2.length();//24;
  144. positionCounter2++)
  145. {
  146. lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.
  147. if(positionCounter2 >= LCDarray2.length()) lcd.print(" ");
  148. else lcd.print(LCDarray2[positionCounter2]); // Print a message to the LCD.
  149. delay(LCDtim); //wait for 250 microseconds
  150. if(positionCounter2==10) delay(LCDtim *7 );
  151. }
  152. delay(LCDtim * 5); //wait for 250 microseconds
  153. // lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.
  154. delay(LCDtim);
  155. /*
  156. struct record
  157. {
  158. int bookId;
  159. int qtyInStock;
  160. };
  161. typedef struct record Record;
  162. void sold(int id, Record* records) {
  163. int i;
  164. for(i=0;i<3;i++) {
  165. if(records[i].bookId == id) {
  166. records[i].qtyInStock--;
  167. }
  168. }
  169. }
  170. */
  171. /*
  172. void updateId(int id, int new_id, Record* records) {
  173. int i;
  174. for(i=0;i<3;i++) {
  175. if(records[i].bookId == id) {
  176. records[i].bookid = new_id;
  177. }
  178. }
  179. }
  180. */
  181. /*
  182. void updateQty(int id, int new_qty, Record* records) {
  183. int i;
  184. for(i=0;i<3;i++) {
  185. if(records[i].bookId == id) {
  186. records[i].qtyInStock = new_qty;
  187. }
  188. }
  189. }
  190. */
  191. }
  192. String make_str16(String str){
  193. for(int i = 0; i < (16 - str.length()); i++)
  194. str += ' ';
  195. return str;
  196. }