-
Notifications
You must be signed in to change notification settings - Fork 0
/
ezLCDLib.cpp
1998 lines (1805 loc) · 43.5 KB
/
ezLCDLib.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ---------------------------------------------------------------------------
// Created by Ken Segler 6/1/2013.
// Modified by Rich Obermeyer 1/14/2014.
// Modified by Jonathan Doerr 4/11/2014.
// Copyright 2013 - Under creative commons license 3.0:
// Attribution-ShareAlike CC BY-SA
//
// This software is furnished "as is", without technical support, and with no
// warranty, express or implied, as to its usefulness for any purpose.
//
// @file ezLCDLib.cpp
// This file supports the ezLCD3xx interface to an Arduino serial port.
//
// @author Ken Segler - [email protected]
// ---------------------------------------------------------------------------
#include "ezLCDLib.h"
#include <math.h>
#if defined(__AVR_ATmega32U4__) || defined(CORE_TEENSY) || defined(ARDUINO_ARCH_RP2040)
// Arduino Leonardo and Teensy use "Serial" as USB virtual serial
// The first hardware serial port on these boards is "Serial1".
#define arSerial Serial1
#else
// arLCD's Arduino-compatable processor, and most Arduino boards
// use "Serial" as their first hardware serial port.
#define arSerial Serial
#endif
ezLCD3::~ezLCD3()
{
}
ezLCD3::ezLCD3(void) //: Serial(void)
{
}
void ezLCD3::begin( long baud )
{
delay(5000);
timeOutMilliseconds = 500; // .5 seconds
arSerial.begin( baud );
arSerial.setTimeout(0xf0000000);
//while(!sync());
sync();//just one ping please
delay(5);
}
/* itoa: convert n to characters in s */
void ezLCD3::itoa(int value, char* sp, int radix)
{
char tmp[16];// be careful with the length of the buffer
char* tp = tmp;
int i;
unsigned v;
int sign;
sign = (radix == 10 && value < 0);
if (sign) v = -value;
else v = (unsigned)value;
while (v || tp == tmp) {
i = v % radix;
v /= radix; // v/=radix uses less CPU clocks than v=v/radix does
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
if (sign)
*sp++ = '-';
while (tp > tmp)
*sp++ = *--tp;
}
// Begin a timeout. Sets timedOut to false and captures Arduino's
// millisecond clock, for later checking by timeoutCheck().
void ezLCD3::timeoutBegin( void )
{
timedOut = false;
timeOutBeginMillis = millis();
}
// Check if more than "timeOutMilliseconds" has elapsed since
// timeoutBegin() was called. Returns true and sets timedOut
// if a timeout has occurred, or returns false if no timeout.
bool ezLCD3::timeoutCheck( void )
{
if (millis() - timeOutBeginMillis > timeOutMilliseconds) {
timedOut = true;
}
return timedOut;
}
//if any characters are in buffer they are junk left over
//clear them all out before starting new command.
void ezLCD3::ClrSerial( void )
{
while(arSerial.available())
arSerial.read();
}
bool ezLCD3::sync( void )
{
char c = 0;
//unsigned long timeOut=0;
delay(1);
timedOut = false;
//remove any character in receive buffer
//send out a null command to see if GPU is up yet
//arSerial.flush();
arSerial.write('\r');
// delay(1);
// c = arSerial.read();
// if ( c == '\r' ) arSerial.write('\0');
ClrSerial();
delay(1);
arSerial.write('\r');
timeoutBegin();
while( c != '\r' && !timeoutCheck() ) // wait for char or timeout
c = arSerial.read();
if( timedOut || c != '\r' ) {
return false;
}else
return true;
}
bool ezLCD3::waitForCRNTO( void )
{
ClrSerial();
arSerial.write('\r');//always send CR to start command
char c = 0;
timedOut = false;
error = false;
while( c != '\r' ) {
c = arSerial.read();
if( c == 0x31 ) error = true;
}
return true;
}
bool ezLCD3::waitForCR( void )
{
ClrSerial();
arSerial.write('\r');//always send CR to start command
char c=0;
timedOut=false;
error=false;
timeoutBegin();
while( c != '\r' && !timeoutCheck() ) {//wait for CR or timeout
c = arSerial.read();
if( c == 0x31 ) error = true;
}
if( timedOut ) {
while(!sync());
}
return true;
}
void ezLCD3::sendInt( int i )
{
char value[5]= {0, 0, 0, 0, 0};
itoa(i, value, 10);
if(value[0]) arSerial.write(value[0]);
if(value[1]) arSerial.write(value[1]);
if(value[2]) arSerial.write(value[2]);
if(value[3]) arSerial.write(value[3]);
if(value[4]) arSerial.write(value[4]);
}
void ezLCD3::sendIntS( int i )
{
char value[5]= {0, 0, 0, 0, 0};
itoa(i, value, 10);
if(value[0]) arSerial.write(value[0]);
if(value[1]) arSerial.write(value[1]);
if(value[2]) arSerial.write(value[2]);
if(value[3]) arSerial.write(value[3]);
if(value[4]) arSerial.write(value[4]);
arSerial.write(' ');
}
void ezLCD3::sendLong( long i )
{
char value[9]= { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// itoa(i, value, 10);
sprintf( value, "%ld", i );
if( value[0] ) arSerial.write( value[0] );
if( value[1] ) arSerial.write( value[1] );
if( value[2] ) arSerial.write( value[2] );
if( value[3] ) arSerial.write( value[3] );
if( value[4] ) arSerial.write( value[4] );
if( value[5] ) arSerial.write( value[5] );
if( value[6] ) arSerial.write( value[6] );
if( value[7] ) arSerial.write( value[7] );
if( value[8] ) arSerial.write( value[8] );
}
const unsigned char CharacterArray[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
void ezLCD3::PrintHex( int value )
{
int printVar;
printVar = value;
value = (value>>4) & 0x0F;
arSerial.write( ( char ) CharacterArray[ value ] );
value = printVar & 0x0F;
arSerial.write( ( char ) CharacterArray[ value ] );
return;
}
void ezLCD3::stripSpace(char* str)
{
char* i = str;
char* j = str;
while(*j != 0) {
*i = *j++;
if(*i != ' ')
i++;
}
*i = 0;
}
int ezLCD3::getInt( char* str )
{
stripSpace(str);
return atoi(str );
}
long ezLCD3::getLong( char* str )
{
stripSpace(str);
return atol(str );
}
bool ezLCD3::getString( char* str )
{
char c=0;
*str = 0;
timeoutBegin();
do {
if ( arSerial.available() ) {
c = arSerial.read();
*str++ = c;
*str = 0;
}
} while( ( c != '\r' ) && !timeoutCheck() );
if ( timedOut )
return false;
if ( c == '\r' )
return true;
else
return false;
}
bool ezLCD3::getStringToSpace( char* str )
{
char c=0;
*str = 0;
timeoutBegin();
do {
if(arSerial.available()) {
c = arSerial.read();
*str++ = c;
*str = 0;
}
} while( c !='\r' && c !=' ' && !timeoutCheck() );
if( timedOut )
return false;
if( c=='\r' || c==' ' )
return true;
else
return false;
}
void ezLCD3::calibrate( void ) {
sendInt(Calibrate);
waitForCRNTO();
}
void ezLCD3::cls()
{
sendInt(Clr_Screen);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::cls(int bColor)
{
sendInt(Clr_Screen);
arSerial.write(' ');
sendInt(bColor);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::cls(int bColor, int fColor)
{
sendInt(Clr_Screen);
arSerial.write(' ');
sendInt(bColor);
arSerial.write(' ');
sendInt(fColor);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::color(int fColor)
{
sendInt(Color);
arSerial.write(' ');
sendInt(fColor);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::colorID( unsigned char ID, unsigned char r, unsigned char g, unsigned char b )
{
sendInt(eColor_ID);
arSerial.write(' ');
sendInt(ID);
arSerial.write(' ');
sendInt(r);
arSerial.write(' ');
sendInt(g);
arSerial.write(' ');
sendInt(b);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::xy(int x, int y)
{
sendInt(XY);
arSerial.write(' ');
sendInt(x);
arSerial.write(' ');
sendInt(y);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::xy( void )
{
sendInt(XY);
ClrSerial();
arSerial.write('\r');
getStringToSpace( localbuffer );
X = getInt( localbuffer );
getStringToSpace( localbuffer );
Y = getInt( localbuffer );
}
void ezLCD3::xy( const char* str )
{
sendInt(XY);
arSerial.write(' ');
arSerial.write('\"');
sendString(str);
arSerial.write('\"');
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
unsigned int ezLCD3::getX( void )
{
sendInt(XY);
ClrSerial();
arSerial.write('\r');
getStringToSpace( localbuffer );
X = getInt( localbuffer );
getStringToSpace( localbuffer );
Y = getInt( localbuffer );
return X;
}
unsigned int ezLCD3::getY( void )
{
sendInt(XY);
ClrSerial();
arSerial.write('\r');
getStringToSpace( localbuffer );
X = getInt( localbuffer );
getStringToSpace( localbuffer );
Y = getInt( localbuffer );
return Y;
}
void ezLCD3::plot( void )
{
sendInt(Plot);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::point( void )
{
plot( );
}
void ezLCD3::plot( int x, int y )
{
sendInt(Plot);
arSerial.write(' ');
sendInt(x);
arSerial.write(' ');
sendInt(y);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::point( int x, int y )
{
plot( x, y );
}
unsigned int ezLCD3::getPixel( int x, int y )
{
sendInt( Get_Pixel );
arSerial.write(' ');
sendInt(x);
arSerial.write(' ');
sendInt(y);
ClrSerial();
arSerial.write('\r');
getString( localbuffer );
return strtoul(localbuffer, NULL, 16);
}
void ezLCD3::line(int x, int y )
{
sendInt(Line);
arSerial.write(' ');
sendInt(x);
arSerial.write(' ');
sendInt(y);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::lineType( int type )
{
sendInt(Line_Type);
arSerial.write(' ');
sendInt(type);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::lineWidth( int width )
{
sendInt(Line_Width);
arSerial.write(' ');
sendInt(width);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::arc( uint16_t radius, int16_t start, int16_t end, bool fill )
{
sendInt(Arc);
arSerial.write(' ');
sendInt(radius);
arSerial.write(' ');
sendInt(start);
arSerial.write(' ');
sendInt(end);
arSerial.write(' ');
sendInt(fill);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::circle(int radius, bool filled )
{
sendInt(Circle);
arSerial.write(' ');
sendInt(radius);
if(filled) {
arSerial.write(' ');
arSerial.write('f');
}
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::circle(int x, int y, int radius, bool filled )
{
xy( x, y );
sendInt(Circle);
arSerial.write(' ');
sendInt(radius);
if ( filled ) {
arSerial.write(' ');
arSerial.write('f');
}
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::box(int width, int height, bool filled)
{
sendInt(Box);
arSerial.write(' ');
sendInt(width);
arSerial.write(' ');
sendInt(height);
if ( filled ) {
arSerial.write(' ');
arSerial.write('f');
}
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::rect(int x, int y, int width, int height, bool filled)
{
xy( x, y );
sendInt(Box);
arSerial.write(' ');
sendInt(width);
arSerial.write(' ');
sendInt(height);
if ( filled ) {
arSerial.write(' ');
arSerial.write('f');
}
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::pie( uint16_t radius, int16_t start, int16_t end )
{
sendInt(Pie);
arSerial.write(' ');
sendInt(radius);
arSerial.write(' ');
sendInt(start);
arSerial.write(' ');
sendInt(end);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::light(int level)
{
sendInt( Light );
arSerial.write(' ');
sendInt( level );
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
int ezLCD3::light( void )
{
sendInt( Light );
ClrSerial();
arSerial.write('\r');
getString( localbuffer );
return getInt( localbuffer );
}
void ezLCD3::light( int level, unsigned long timeOut, int timeOutBrightness )
{
sendInt( Light );
arSerial.write(' ');
sendInt( level );
arSerial.write(' ');
sendInt( timeOut );
arSerial.write(' ');
sendInt( timeOutBrightness );
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::light( int level, unsigned long timeOut, int timeOutBrightness, int commdis )
{
sendInt( Light );
arSerial.write(' ');
sendInt( level );
arSerial.write(' ');
sendInt( timeOut );
arSerial.write(' ');
sendInt( timeOutBrightness );
arSerial.write(' ');
sendInt( commdis );
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
int ezLCD3::getXmax( void )
{
sendInt(Xmax);
ClrSerial();
arSerial.write('\r');
getString( localbuffer );
return getInt( localbuffer );
}
int ezLCD3::getYmax( void )
{
sendInt(Ymax);
ClrSerial();
arSerial.write('\r');
getString( localbuffer );
return getInt( localbuffer );
}
int ezLCD3::touchX( void )
{
sendInt(Xtouch);
ClrSerial();
arSerial.write('\r');
getString( localbuffer );
return getInt( localbuffer );
}
int ezLCD3::touchY( void )
{
sendInt(Ytouch);
ClrSerial();
arSerial.write('\r');
getString( localbuffer );
return getInt( localbuffer );
}
int ezLCD3::touchS( void )
{
sendInt(Stouch);
ClrSerial();
arSerial.write('\r');
getString( localbuffer );
return getInt( localbuffer );
}
void ezLCD3::sendString( const char* str )
{
unsigned char c;
while( (c = *str++) )
arSerial.write(c);
}
void ezLCD3::string( int ID, const char* str )
{
sendInt(StringID);
arSerial.write(' ');
sendInt(ID);
arSerial.write(' ');
arSerial.write('\"');
sendString(str);
arSerial.write('\"');
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::getStringID( int ID , char* str)
{
sendInt(StringID);
arSerial.write(' ');
sendInt(ID);
ClrSerial();
arSerial.write('\r');
getString(str);
}
void ezLCD3::printNumber(unsigned long n, int base) {
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char* str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
unsigned long m = n;
n /= base;
char c = m - base * n;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
printString( str );
}
void ezLCD3::printFloat(double number, int digits)
{
if (isnan(number)) return;
if (isinf(number)) return;
if (number > 4294967040.0) return;
if (number <-4294967040.0) return;
// Handle negative numbers
if (number < 0.0) {
print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (int i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
print((long int)int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
print(".");
}
// Extract digits from the remainder one at a time
while (digits-- > 0) {
remainder *= 10.0;
int toPrint = int(remainder);
print(toPrint);
remainder -= toPrint;
}
}
void writeit( char c)
{
if(c =='\n') {
arSerial.write(0x5c);
arSerial.write(0x6e);
}
else if (c=='\r') {
arSerial.write(0x5c);
arSerial.write(0x72);
}
else {
arSerial.write(c);
}
}
void ezLCD3::printString( const char* str )
{
int i, tempptr, bcount, tempbcount;
tempptr = 0;//start at beginning of buffer
bcount = strlen( str );//get the number of bytes
while( bcount ) {
if ( bcount <= 62 )
tempbcount = bcount;//send it all
else
tempbcount = 62;
sendInt( Print );
arSerial.write(' ');
arSerial.write('\"');
for ( i = 0; i < tempbcount; i++ ) {
writeit( str[ tempptr + i ] );
}
arSerial.write('\"');
bcount -= tempbcount;//adjust the count
tempptr += tempbcount;//adjust the count
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
}
void ezLCD3::crlf( void )
{
sendInt( Print );
arSerial.write(' ');
arSerial.write('\"');
// arSerial.write('\\');
// arSerial.write('n');
arSerial.write('\\');
arSerial.write('r');
arSerial.write('\"');
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::print( const char* str )
{
printString( str );
}
void ezLCD3::println( const char* str )
{
printString( str );
crlf();
}
void ezLCD3::print( char c )
{
sendInt(Print);
arSerial.write(' ');
arSerial.write('"');
writeit(c);
arSerial.write('"');
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::println( char c )
{
print( c );
crlf();
}
void ezLCD3::println( void )
{
crlf();
}
void ezLCD3::print( int value )
{
printNumber((unsigned long) value, 10 );
}
void ezLCD3::println( int value )
{
printNumber((unsigned long) value, 10 );
crlf();
}
void ezLCD3::print( int value, int mode )
{
printNumber((unsigned long) value, mode );
}
void ezLCD3::println( int value, int mode )
{
printNumber((unsigned long) value, mode );
crlf();
}
void ezLCD3::print( long value )
{
printNumber((unsigned long) value, 10 );
}
void ezLCD3::print( long value, int mode )
{
printNumber((unsigned long) value, mode );
}
void ezLCD3::println( long value, int mode )
{
printNumber((unsigned long) value, mode );
crlf();
}
void ezLCD3::print( double value, int digits )
{
printFloat( value, digits);
}
void ezLCD3::println( double value, int digits )
{
printFloat( value, digits);
crlf();
}
void ezLCD3::print( double value )
{
printFloat( value, 2 );
}
void ezLCD3::println( double value )
{
printFloat( value, 2 );
crlf();
}
void ezLCD3::printStringID( char ID )
{
sendInt(Print);
arSerial.write(' ');
sendInt(ID);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::fontw( int ID, const char* str)
{
sendInt(Fontw);
arSerial.write(' ');
sendInt(ID);
arSerial.write(' ');
sendString(str);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::fontw( int ID, int font)
{
sendInt(Fontw);
arSerial.write(' ');
sendInt(ID);
arSerial.write(' ');
sendInt(font);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::font( const char* str)
{
sendInt(Font);
arSerial.write(' ');
sendString(str);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::font( int font )
{
sendInt(Font);
arSerial.write(' ');
sendInt(font);
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::fontO( bool dir )
{
sendInt(Font_Orient);
arSerial.write(' ');
if(dir)
arSerial.write('1');
else
arSerial.write('0');
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
unsigned char ezLCD3::choice( const char* str, unsigned char c ) {
sendInt(Choice);
arSerial.write(' ');
sendString(str);
arSerial.write(' ');
sendInt(c);
arSerial.write(' ');
ClrSerial();
arSerial.write('\r');
timeOutMilliseconds = 3600000; // 1 hour
do {
getString( localbuffer );
currentData=strlen( localbuffer );
}while( currentData == 0 );
timeOutMilliseconds = 500; // 0.5 seconds
//cls();
//print((int)strlen(localbuffer));
//print((int)localbuffer[0], DEC);
return getInt( localbuffer );
}
void ezLCD3::clipArea( int l, int t, int r, int b)
{
sendInt(ClipArea);
arSerial.write(' ');
sendInt(l);
arSerial.write(' ');
sendInt(t);
arSerial.write(' ');
sendInt(r);
arSerial.write(' ');
sendInt(b);
arSerial.write(' ');
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::clipEnable( bool enable)
{
sendInt(ClipEnable);
arSerial.write(' ');
if(enable)
arSerial.write('1');
else
arSerial.write('0');
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::drawLed( int x, int y, int radius, unsigned char colorLed, unsigned char colorHigh)
{
sendInt( Draw_LED );
arSerial.write(' ');
sendInt( x );
arSerial.write(' ');
sendInt( y );
arSerial.write(' ');
sendInt( radius );
arSerial.write(' ');
sendInt( colorLed );
arSerial.write(' ');
sendInt( colorHigh );
waitForCR();//Clears buffer, send CR and then waits for answer or timeout
}
void ezLCD3::theme(int ID, int EmbossDkColor, int EmbossLtColor, int TextColor0, int TextColor1, int TextColorDisabled, int Color0, int Color1, int ColorDisabled, int CommonBkColor, int Fontw)
{
sendInt(Widget_Theme);
arSerial.write(' ');
sendInt(ID);
arSerial.write(' ');
sendInt(EmbossDkColor);
arSerial.write(' ');
sendInt(EmbossLtColor);
arSerial.write(' ');
sendInt(TextColor0);
arSerial.write(' ');
sendInt(TextColor1);
arSerial.write(' ');
sendInt(TextColorDisabled);
arSerial.write(' ');
sendInt(Color0);
arSerial.write(' ');
sendInt(Color1);
arSerial.write(' ');
sendInt(ColorDisabled);
arSerial.write(' ');
sendInt(CommonBkColor);
arSerial.write(' ');
sendInt(Fontw);