_LCD1602_func.h 9.4 KB

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