Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1920 - 1
/*****************************************************************************
2
 *   Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net                  *
3
 *   - original LCD control by Thomas "thkais" Kaiser                        *
4
 *   - special number formating routines taken from C-OSD                    *
5
 *      from Claas Anders "CaScAdE" Rathje                                   *
6
 *   - some extension, ellipse and circ_line by Peter "woggle" Mack          *
7
 *                                                                           *
8
 *   This program is free software; you can redistribute it and/or modify    *
9
 *   it under the terms of the GNU General Public License as published by    *
10
 *   the Free Software Foundation; either version 2 of the License.          *
11
 *                                                                           *
12
 *   This program is distributed in the hope that it will be useful,         *
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
15
 *   GNU General Public License for more details.                            *
16
 *                                                                           *
17
 *   You should have received a copy of the GNU General Public License       *
18
 *   along with this program; if not, write to the                           *
19
 *   Free Software Foundation, Inc.,                                         *
20
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
21
 *                                                                           *
22
 *****************************************************************************/
23
 
24
//############################################################################
25
//# HISTORY  lcd.c
26
//#
27
//# 07.03.2013 OG
28
//# - del: Kompatibilitaetsfunktion lcd_printpj_at() entfernt
29
//#
30
//# 06.03.2013 OG
31
//# - lcdx_putc() wurde erweitert mit Unterstuetzung des 8x8 Font (alte Jeti 
32
//#   Funktionen) und Pixel-Verschiebung (xoffs,yoffs)
33
//# - etliche Char basierte Funktionen wurden erweitert um Parameter xoffs,yoffs
34
//#   um die Ausgabe um +/- Pixel zu verschieben. Fuer Pixelgenaue Positionierung
35
//#   von OSD-Screen Elementen.
36
//#   Die neuen Funktionen mit Pixel-Verschiebung beginnen mit lcdx_, writex_ ...
37
//# - add: Kompatibilitaet gewaehrleistet durch Mapper-Funktionen
38
//# - add: defines fuer Char-Drawmode's (MNORMAL, MINVERS, MBIG, MBIGINVERS)
39
//# - del: Jeti-Funktionen (teilweise ersetzt durch Kompatibilitaetsfunktionen)
40
//############################################################################
41
 
42
 
43
#include "../cpu.h"
44
#include <avr/io.h>
45
#include <avr/pgmspace.h>
46
#include <util/delay.h>
47
#include <stdlib.h>
48
#include <string.h>
49
#include <math.h>
50
 
51
#include "font8x6.h"
52
#include "Font8x8.h"
53
#include "../eeprom/eeprom.h"
54
#include "lcd.h"
55
#include "../main.h"
56
#include "../HAL_HW3_9.h"
57
 
58
 
59
#define DISP_W 128
60
#define DISP_H 64
61
 
62
#define DISP_BUFFER ((DISP_H * DISP_W) / 8)
63
#define LINE_BUFFER (((DISP_H/8) * DISP_W) / 8)
64
 
65
#define Jeti 1  // Jeti Routinen
66
 
67
volatile uint8_t display_buffer[DISP_BUFFER];   // Display-Puffer, weil nicht zurückgelesen werden kann
68
volatile uint8_t line_buffer[LINE_BUFFER];              // Zeilen-Puffer, weil nicht zurückgelesen werden kann
69
 
70
volatile uint16_t display_buffer_pointer;               // Pointer auf das aktuell übertragene Byte
71
volatile uint8_t display_buffer_counter;                // Hilfszähler zur Selektierung der Page
72
volatile uint8_t display_page_counter;                  // aktuelle Page-Nummer
73
volatile uint8_t display_mode;                                  // Modus für State-Machine
74
volatile uint8_t LCD_ORIENTATION;
75
 
76
// DOG: 128 x 64 with 6x8 Font => 21 x 8
77
// MAX7456: 30 x 16
78
 
79
uint8_t lcd_xpos;
80
uint8_t lcd_ypos;
81
 
82
        char s[7];
83
 
84
//-----------------------------------------------------------
85
void send_byte (uint8_t data)
86
{
87
        clr_cs ();
88
        SPDR = data;
89
        while (!(SPSR & (1<<SPIF)));
90
        //SPSR = SPSR;
91
        set_cs ();
92
}
93
 
94
 
95
//-----------------------------------------------------------
96
// * Writes one command byte
97
// * cmd           - the command byte
98
//
99
void lcd_command(uint8_t cmd)
100
{
101
//      LCD_SELECT();
102
//      LCD_CMD();
103
//      spi_write(cmd);
104
//      LCD_UNSELECT();
105
        clr_cs ();
106
        SPDR = cmd;
107
        while (!(SPSR & (1<<SPIF)));
108
        //SPSR = SPSR;
109
        set_cs ();
110
}
111
 
112
 
113
//-----------------------------------------------------------
114
void lcd_cls (void)
115
{
116
        uint16_t i, j;
117
 
118
//      memset (display_buffer, 0, 1024);
119
        for (i = 0; i < DISP_BUFFER; i++)
120
                display_buffer[i] = 0x00;
121
        for (i = 0; i < 8; i++)
122
        {
123
                clr_A0 ();
124
                send_byte (0xB0 + i);                   //1011xxxx
125
                send_byte (0x10);                               //00010000
126
//              send_byte(0x04);                                //00000100 gedreht plus 4 Byte
127
//              send_byte(0x00);                                //00000000
128
                send_byte (LCD_ORIENTATION);    //00000000
129
 
130
                set_A0 ();
131
                for (j = 0; j < 128; j++)
132
                        send_byte (0x00);
133
        }
134
 
135
        lcd_xpos = 0;
136
        lcd_ypos = 0;
137
}
138
 
139
 
140
//-----------------------------------------------------------
141
void set_adress (uint16_t adress, uint8_t data)
142
{
143
        uint8_t page;
144
        uint8_t column;
145
 
146
        page = adress >> 7;
147
 
148
        clr_A0 ();
149
        send_byte (0xB0 + page);
150
 
151
        column = (adress & 0x7F) + LCD_ORIENTATION;
152
 
153
        send_byte (0x10 + (column >> 4));
154
        send_byte (column & 0x0F);
155
 
156
        set_A0 ();
157
        send_byte (data);
158
}
159
 
160
 
161
//-----------------------------------------------------------
162
void scroll (void)
163
{
164
        uint16_t adress;
165
 
166
        for (adress = 0; adress < 896; adress++)
167
        {
168
                display_buffer[adress] = display_buffer[adress + 128];
169
                set_adress (adress, display_buffer[adress]);
170
        }
171
 
172
        for (adress = 896; adress < 1024; adress++)
173
        {
174
                display_buffer[adress] = 0;
175
                set_adress (adress, 0);
176
        }
177
}
178
 
179
//####################################################################################
180
//####################################################################################
181
 
182
//-----------------------------------------------------------
183
// + Plot (set one Pixel)
184
//-----------------------------------------------------------
185
// mode:
186
// 0=Clear, 1=Set, 2=XOR
187
void lcd_plot (uint8_t xpos, uint8_t ypos, uint8_t mode)
188
{
189
        uint16_t adress;
190
        uint8_t mask;
191
 
192
        if ((xpos < DISP_W) && (ypos < DISP_H))
193
        {
194
                adress = (ypos / 8) * DISP_W + xpos;            // adress = 0/8 * 128 + 0   = 0
195
                mask = 1 << (ypos & 0x07);                                      // mask = 1<<0 = 1
196
                adress &= DISP_BUFFER - 1;
197
                switch (mode)
198
                {
199
 
200
                case 0:
201
                        display_buffer[adress] &= ~mask;
202
                        break;
203
 
204
                case 1:
205
                        display_buffer[adress] |= mask;
206
                        break;
207
 
208
                case 2:
209
                        display_buffer[adress] ^= mask;
210
                        break;
211
                }
212
                set_adress (adress, display_buffer[adress]);
213
        }
214
}
215
 
216
 
217
 
218
//-----------------------------------------------------------
219
//-----------------------------------------------------------
220
void lcdx_putc( uint8_t x, uint8_t y, uint8_t c, uint8_t mode, int8_t xoffs, int8_t yoffs )
221
{
222
        uint8_t ch;
223
        uint16_t adress;
224
 
225
        uint8_t x1,y1;
226
        uint8_t x0,y0;
227
        uint8_t xw;
228
        uint8_t mask;
229
        uint8_t bit;
230
 
231
        uint8_t *font;
232
 
233
    //------------------------
234
    // char translate
235
    //------------------------
236
        switch (c)
237
    {   // ISO 8859-1
238
 
239
        case 0xc4: c = 0x01; break;             // Ä
240
        case 0xe4: c = 0x02; break;             // ä
241
        case 0xd6: c = 0x03; break;             // Ö
242
        case 0xf6: c = 0x04; break;             // ö
243
        case 0xdc: c = 0x05; break;             // Ü
244
        case 0xfc: c = 0x06; break;             // ü
245
        case 0xdf: c = 0x1e; break;             // ß   c = 0x07;  ° (used by Jeti)
246
        }
247
 
248
    c &= 0x7f;
249
 
250
    //------------------------
251
    // Font Parameter setzen
252
    //------------------------
253
    if( mode <=2 )              // normaler font (8x6)
254
    {
255
        font = (uint8_t *) &font8x6[0][0];
256
        xw   = 6;
257
    }
258
    else                                // grosser font (8x8)
259
    {
260
        font = (uint8_t *) &Font8x8[0][0];
261
        xw   = 8;
262
    }
263
 
264
    //------------------------
265
    //------------------------
266
    x0 = (x*xw) + xoffs;
267
    y0 = (y*8)  + yoffs;
268
 
269
 
270
    if( yoffs == 0)
271
    {
272
                //----------------------------------------------------------
273
        // orginaler Character Algo
274
        //
275
        // funktioniert auch mit x Verschiebung aber nicht
276
        // mit y Verschiebung.
277
        //
278
        // Da 8 Bit aufeinmal gesetzt werden ist dieser Algo
279
        // bzgl. Geschwindigkeit effektiver als der Y-Algo.
280
                //----------------------------------------------------------
281
 
282
                if( mode==MINVERS || mode==MBIGINVERS )
283
                        lcd_frect( (x*xw)+xoffs, (y*8), xw-1, 7, 1); // invertierte Darstellung
284
 
285
                adress = y * 128 + x * xw + xoffs;
286
        adress &= 0x3FF;
287
 
288
        for( x1 = 0; x1 < xw; x1++)
289
        {
290
            ch = pgm_read_byte (font + x1 + c * xw);
291
 
292
                        if( mode==MINVERS || mode==MBIGINVERS )
293
                                display_buffer[adress + x1] ^= ch;
294
                        else
295
                                display_buffer[adress + x1] = ch;
296
 
297
            set_adress (adress + x1, display_buffer[adress + x1]);
298
        }      
299
        }
300
        else
301
        {
302
                //----------------------------------------------------------
303
                // Y-Algo
304
        // neuer Character Algo (nur wenn Pixel y-Verschiebung)
305
                //----------------------------------------------------------
306
                for( x1 = 0; x1 < xw; x1++ )
307
                {
308
                ch = pgm_read_byte (font + x1 + c * xw);
309
 
310
                        mask = 1;
311
 
312
                        for( y1 = 0; y1 < 8; y1++ )
313
                        {
314
                                bit = (ch & mask);
315
 
316
                                if( bit )
317
                                        lcd_plot( x0+x1, y0+y1, ( (mode==MINVERS || mode==MBIGINVERS) ? 0 : 1) );
318
                                else   
319
                                        lcd_plot( x0+x1, y0+y1, ( (mode==MINVERS || mode==MBIGINVERS) ? 1 : 0) );
320
 
321
                                mask = (mask << 1);
322
                        }              
323
                }              
324
        }
325
}
326
 
327
 
328
//-----------------------------------------------------------
329
//--- Kompatibilitaet
330
//-----------------------------------------------------------
331
void lcd_putc( uint8_t x, uint8_t y, uint8_t c, uint8_t mode )
332
{
333
        lcdx_putc( x, y, c, mode, 0,0 );
334
}
335
 
336
 
337
//####################################################################################
338
//####################################################################################
339
 
340
 
341
//-----------------------------------------------------------
342
void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w)
343
{
344
        uint8_t lcd_width;
345
        uint8_t lcd_zpos;
346
        uint8_t i;
347
        uint8_t max = 21;
348
        lcd_width = w;
349
        lcd_xpos = x;
350
        lcd_ypos = y;
351
 
352
        if ((lcd_xpos + lcd_width) > max)
353
                lcd_width = max - lcd_xpos;
354
 
355
        lcd_zpos = lcd_xpos + lcd_width;
356
 
357
        for (i = lcd_xpos; i < lcd_zpos; i++)
358
                lcd_putc (i, lcd_ypos, 0x20, 0);
359
}
360
 
361
 
362
//-----------------------------------------------------------
363
void wait_1ms (void)
364
{
365
        _delay_ms (1);
366
}
367
 
368
 
369
//-----------------------------------------------------------
370
void wait_ms (uint16_t time)
371
{
372
        uint16_t i;
373
 
374
        for (i = 0; i < time; i++)
375
                wait_1ms ();
376
}
377
 
378
 
379
//-----------------------------------------------------------
380
void LCD_Init (uint8_t LCD_Mode)        // LCD_Mode 0= Default Mode 1= EEPROM-Parameter)
381
{
382
        lcd_xpos = 0;
383
        lcd_ypos = 0;
384
 
385
//      DDRB = 0xFF;
386
 
387
        // SPI max. speed
388
        // the DOGM128 lcd controller can work at 20 MHz
389
        SPCR = (1 << SPE) | (1 << MSTR) | (1 << CPHA) | (1 << CPOL);
390
        SPSR = (1 << SPI2X);
391
 
392
        set_cs ();
393
        clr_reset ();
394
        wait_ms (10);
395
        set_reset ();
396
 
397
        clr_cs ();
398
        clr_A0 ();
399
 
400
        send_byte (0x40);               //Display start line = 0
401
        if (LCD_Mode == 1)
402
        {
403
                if (LCD_ORIENTATION == 0)
404
                {
405
                        send_byte (0xA1); // A1 normal A0 reverse(original)
406
                        send_byte (0xC0); // C0 normal C8 reverse(original)
407
                }
408
                else
409
                {
410
                        send_byte (0xA0); // A1 normal A0 reverse(original)
411
                        send_byte (0xC8); // C0 normal C8 reverse(original)
412
                }
413
        }
414
        else
415
        {
416
                send_byte (0xA1); // A1 normal A0 reverse(original)
417
                send_byte (0xC0); // C0 normal C8 reverse(original)
418
        }
419
        if (LCD_Mode == 1)
420
        {
421
                if (Config.LCD_DisplayMode == 0)
422
                        send_byte (0xA6);               //Display normal, not mirrored
423
                else
424
                        send_byte (0xA7);               //Display reverse, not mirrored
425
        }
426
        else
427
                send_byte (0xA6);
428
 
429
 
430
        send_byte (0xA2);               //Set bias 1/9 (Duty 1/65)
431
        send_byte (0x2F);               //Booster, regulator and follower on
432
        send_byte (0xF8);               //Set internal booster to 4x
433
        send_byte (0x00);               //Set internal booster to 4x
434
        send_byte (0x27);               //resistor ratio set
435
 
436
        if (LCD_Mode == 1)
437
        {
438
                send_byte (0x81);               //Electronic volume     register set
439
                send_byte (Config.LCD_Kontrast);                //Electronic volume     register set
440
        }
441
        else
442
        {
443
                send_byte (0x81);
444
                send_byte (0x16);
445
        }
446
 
447
        send_byte (0xAC);               //Cursor
448
        send_byte (0x00);               //No Cursor
449
        send_byte (0xAF);               //No indicator
450
        if (Config.HWSound==0)
451
          {
452
            if (LCD_Mode == 1)
453
            {
454
                    // Helligkeit setzen
455
                    OCR2A = Config.LCD_Helligkeit * 2.55;
456
            }
457
            else
458
            {
459
                    OCR2A = 255;
460
            }
461
          }
462
        lcd_cls ();
463
}
464
 
465
 
466
 
467
 
468
//-----------------------------------------------------------
469
// sicher eine Zeile für die Statusanzeige
470
void copy_line (uint8_t y)
471
{
472
        uint8_t i;
473
        uint16_t adress;
474
 
475
        adress = y * 128 + 0 * 6;
476
        adress &= 0x3FF;
477
 
478
        for (i = 0; i < 6*21; i++)
479
        {
480
                line_buffer[i] = display_buffer[adress+i];
481
                set_adress (adress + i, display_buffer[adress + i]);
482
        }
483
}
484
 
485
 
486
//-----------------------------------------------------------
487
// holt gesicherte Zeile wieder zurück
488
void paste_line (uint8_t y)
489
{
490
        uint8_t i;
491
        uint16_t adress;
492
 
493
        adress = y * 128 + 0 * 6;
494
        adress &= 0x3FF;
495
 
496
        for (i = 0; i < 6*21; i++)
497
        {
498
                display_buffer[adress+i] =line_buffer[i];
499
                set_adress (adress + i, display_buffer[adress + i]);
500
        }
501
}
502
 
503
 
504
//-----------------------------------------------------------
505
//-----------------------------------------------------------
506
void lcdx_puts_at( uint8_t x, uint8_t y, const char *s, uint8_t mode, int8_t xoffs, int8_t yoffs)
507
{
508
        while (*s)
509
        {
510
                lcdx_putc(x, y, *s++, mode, xoffs,yoffs);
511
                x++;
512
        }
513
}/* lcd_puts */
514
 
515
 
516
//-----------------------------------------------------------
517
//-----------------------------------------------------------
518
void lcd_puts_at( uint8_t x, uint8_t y, const char *s, uint8_t mode )
519
{
520
  lcdx_puts_at( x, y, s, mode, 0,0 );
521
}
522
 
523
 
524
//-----------------------------------------------------------
525
void new_line (void)
526
{
527
        lcd_ypos++;
528
 
529
        if (lcd_ypos > 7)
530
        {
531
                scroll ();
532
                lcd_ypos = 7;
533
        }
534
}
535
 
536
 
537
//-----------------------------------------------------------
538
void lcd_printpns (const char *text, uint8_t mode)
539
{
540
        while (pgm_read_byte(text))
541
        {
542
                switch (pgm_read_byte(text))
543
                {
544
 
545
                case 0x0D:
546
                        lcd_xpos = 0;
547
                        break;
548
 
549
                case 0x0A:
550
                        new_line();
551
                        break;
552
 
553
                default:
554
                        lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode);
555
                        lcd_xpos++;
556
                        if (lcd_xpos > 21)
557
                        {
558
                                lcd_xpos = 0;
559
//                              new_line ();
560
                        }
561
                        break;
562
                }
563
                text++;
564
        }
565
}
566
 
567
 
568
//-----------------------------------------------------------
569
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode)
570
{
571
        lcd_xpos = x;
572
        lcd_ypos = y;
573
        lcd_printpns (text, mode);
574
}
575
 
576
 
577
//-----------------------------------------------------------
578
//-----------------------------------------------------------
579
void lcdx_printp (const char *text, uint8_t mode, int8_t xoffs, int8_t yoffs)
580
{
581
        while( pgm_read_byte(text) )
582
        {
583
                switch (pgm_read_byte(text))
584
                {
585
 
586
                case 0x0D:
587
                        lcd_xpos = 0;
588
                        break;
589
 
590
                case 0x0A:
591
                        new_line();
592
                        break;
593
 
594
                default:
595
                        lcdx_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode, xoffs,yoffs);
596
                        lcd_xpos++;
597
                        if (lcd_xpos > 21)
598
                        {
599
                                lcd_xpos = 0;
600
                                new_line ();
601
                        }
602
                        break;
603
                }
604
                text++;
605
        }
606
}
607
 
608
 
609
//-----------------------------------------------------------
610
//-----------------------------------------------------------
611
void lcd_printp (const char *text, uint8_t mode)
612
{
613
        lcdx_printp ( text, mode, 0,0);
614
}
615
 
616
 
617
//-----------------------------------------------------------
618
//-----------------------------------------------------------
619
void lcdx_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode, int8_t xoffs, int8_t yoffs)
620
{
621
        lcd_xpos = x;
622
        lcd_ypos = y;
623
        lcdx_printp (text, mode, xoffs,yoffs);
624
}
625
 
626
 
627
//-----------------------------------------------------------
628
//-----------------------------------------------------------
629
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode)
630
{
631
        lcdx_printp_at ( x, y, text, mode, 0,0);
632
}
633
 
634
 
635
//-----------------------------------------------------------
636
void lcdx_print (uint8_t *text, uint8_t mode, int8_t xoffs, int8_t yoffs)
637
{
638
        while (*text)
639
        {
640
                switch (*text)
641
                {
642
 
643
                case 0x0D:
644
                        lcd_xpos = 0;
645
                        break;
646
 
647
                case 0x0A:
648
                        new_line();
649
                        break;
650
 
651
                default:
652
                        lcdx_putc (lcd_xpos, lcd_ypos, *text, mode, xoffs,yoffs);
653
                        lcd_xpos++;
654
                        if (lcd_xpos > 21)
655
                        {
656
                                lcd_xpos = 0;
657
                                new_line ();
658
                        }
659
                        break;
660
                }
661
                text++;
662
        }
663
}
664
 
665
 
666
//-----------------------------------------------------------
667
//--- lcd_print: Kompatibilitaet
668
//-----------------------------------------------------------
669
void lcd_print (uint8_t *text, uint8_t mode )
670
{
671
        lcdx_print (text, mode, 0,0 );
672
}
673
 
674
 
675
//-----------------------------------------------------------
676
void lcdx_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode, int8_t xoffs, int8_t yoffs)
677
{
678
        lcd_xpos = x;
679
        lcd_ypos = y;
680
        lcdx_print (text, mode, xoffs, yoffs);
681
}
682
 
683
//-----------------------------------------------------------
684
//--- lcd_print_at: Kompatibilitaet
685
//-----------------------------------------------------------
686
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode )
687
{
688
        lcdx_print_at ( x, y, text, mode, 0,0);
689
}
690
 
691
 
692
//-----------------------------------------------------------
693
void print_display (uint8_t *text)
694
{
695
        while (*text)
696
        {
697
                lcd_putc (lcd_xpos, lcd_ypos, *text, 0);
698
                lcd_xpos++;
699
                if (lcd_xpos >= 20)
700
                {
701
                        lcd_xpos = 0;
702
                        new_line ();
703
                }
704
                text++;
705
        }
706
}
707
 
708
 
709
//-----------------------------------------------------------
710
void print_display_at (uint8_t x, uint8_t y, uint8_t *text)
711
{
712
        lcd_xpos = x;
713
        lcd_ypos = y;
714
        print_display (text);
715
}
716
 
717
 
718
//-----------------------------------------------------------
719
// + Line (draws a line from x1,y1 to x2,y2
720
// + Based on Bresenham line-Algorithm
721
// + found in the internet, modified by thkais 2007
722
//-----------------------------------------------------------
723
 
724
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode)
725
{
726
        int x, y, count, xs, ys, xm, ym;
727
 
728
        x = (int) x1;
729
        y = (int) y1;
730
        xs = (int) x2 - (int) x1;
731
        ys = (int) y2 - (int) y1;
732
        if (xs < 0)
733
                xm = -1;
734
        else
735
                if (xs > 0)
736
                        xm = 1;
737
                else
738
                        xm = 0;
739
        if (ys < 0)
740
                ym = -1;
741
        else
742
                if (ys > 0)
743
                        ym = 1;
744
                else
745
                        ym = 0;
746
        if (xs < 0)
747
                xs = -xs;
748
 
749
        if (ys < 0)
750
                ys = -ys;
751
 
752
        lcd_plot ((unsigned char) x, (unsigned char) y, mode);
753
 
754
        if (xs > ys) // Flat Line <45 degrees
755
        {
756
                count = -(xs / 2);
757
                while (x != x2)
758
                {
759
                        count = count + ys;
760
                        x = x + xm;
761
                        if (count > 0)
762
                        {
763
                                y = y + ym;
764
                                count = count - xs;
765
                        }
766
                        lcd_plot ((unsigned char) x, (unsigned char) y, mode);
767
                }
768
        }
769
        else // Line >=45 degrees
770
        {
771
                count =- (ys / 2);
772
                while (y != y2)
773
                {
774
                        count = count + xs;
775
                        y = y + ym;
776
                        if (count > 0)
777
                        {
778
                                x = x + xm;
779
                                count = count - ys;
780
                        }
781
                        lcd_plot ((unsigned char) x, (unsigned char) y, mode);
782
                }
783
        }
784
}
785
 
786
 
787
//-----------------------------------------------------------
788
// + Filled rectangle
789
// + x1, y1 = upper left corner
790
//-----------------------------------------------------------
791
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode)
792
{
793
        uint16_t x2, y2;
794
        uint16_t i;
795
 
796
        if (x1 >= DISP_W)
797
                x1 = DISP_W - 1;
798
 
799
        if (y1 >= DISP_H)
800
                y1 = DISP_H - 1;
801
 
802
        x2 = x1 + widthx;
803
        y2 = y1 + widthy;
804
 
805
        if (x2 > DISP_W)
806
                x2 = DISP_W;
807
 
808
        if (y2 > DISP_H)
809
                y2 = DISP_H;
810
 
811
        for (i = y1; i <= y2; i++)
812
        {
813
                lcd_line (x1, i, x2, i, mode);
814
        }
815
}
816
 
817
 
818
//-----------------------------------------------------------
819
// + outline of rectangle
820
// + x1, y1 = upper left corner
821
//-----------------------------------------------------------
822
 
823
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode)
824
{
825
        uint16_t x2, y2;
826
 
827
        if (x1 >= DISP_W)
828
                x1 = DISP_W - 1;
829
        if (y1 >= DISP_H)
830
                y1 = DISP_H - 1;
831
        x2 = x1 + widthx;
832
        y2 = y1 + widthy;
833
 
834
        if (x2 > DISP_W)
835
                x2 = DISP_W;
836
 
837
        if (y2 > DISP_H)
838
                y2 = DISP_H;
839
 
840
        lcd_line (x1, y1, x2, y1, mode);
841
        lcd_line (x2, y1, x2, y2, mode);
842
        lcd_line (x2, y2, x1, y2, mode);
843
        lcd_line (x1, y2, x1, y1, mode);
844
}
845
 
846
 
847
//-----------------------------------------------------------
848
// + outline of a circle
849
// + Based on Bresenham-algorithm found in wikipedia
850
// + modified by thkais (2007)
851
//-----------------------------------------------------------
852
 
853
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode)
854
{
855
        int16_t f = 1 - radius;
856
        int16_t ddF_x = 0;
857
        int16_t ddF_y = -2 * radius;
858
        int16_t x = 0;
859
        int16_t y = radius;
860
 
861
        lcd_plot (x0, y0 + radius, mode);
862
        lcd_plot (x0, y0 - radius, mode);
863
        lcd_plot (x0 + radius, y0, mode);
864
        lcd_plot (x0 - radius, y0, mode);
865
 
866
        while (x < y)
867
        {
868
                if (f >= 0)
869
                {
870
                        y --;
871
                        ddF_y += 2;
872
                        f += ddF_y;
873
                }
874
                x ++;
875
                ddF_x += 2;
876
                f += ddF_x + 1;
877
 
878
                lcd_plot (x0 + x, y0 + y, mode);
879
                lcd_plot (x0 - x, y0 + y, mode);
880
 
881
                lcd_plot (x0 + x, y0 - y, mode);
882
                lcd_plot (x0 - x, y0 - y, mode);
883
 
884
                lcd_plot (x0 + y, y0 + x, mode);
885
                lcd_plot (x0 - y, y0 + x, mode);
886
 
887
                lcd_plot (x0 + y, y0 - x, mode);
888
                lcd_plot (x0 - y, y0 - x, mode);
889
        }
890
}
891
 
892
 
893
//-----------------------------------------------------------
894
// + filled Circle
895
// + modified circle-algorithm thkais (2007)
896
//-----------------------------------------------------------
897
 
898
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius,uint8_t mode)
899
{
900
        int16_t f = 1 - radius;
901
        int16_t ddF_x = 0;
902
        int16_t ddF_y = -2 * radius;
903
        int16_t x = 0;
904
        int16_t y = radius;
905
 
906
        lcd_line (x0, y0 + radius, x0, y0 - radius, mode);
907
 
908
        lcd_line (x0 + radius, y0, x0 - radius, y0, mode);
909
 
910
        while (x < y)
911
        {
912
                if (f >= 0)
913
                {
914
                        y--;
915
                        ddF_y += 2;
916
                        f += ddF_y;
917
                }
918
                x++;
919
                ddF_x += 2;
920
                f += ddF_x + 1;
921
 
922
                lcd_line (x0 + x, y0 + y, x0 - x, y0 + y, mode);
923
                lcd_line (x0 + x, y0 - y, x0 - x, y0 - y, mode);
924
                lcd_line (x0 + y, y0 + x, x0 - y, y0 + x, mode);
925
                lcd_line (x0 + y, y0 - x, x0 - y, y0 - x, mode);
926
        }
927
}
928
 
929
 
930
//-----------------------------------------------------------
931
//
932
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode)
933
{
934
        uint8_t xc, yc;
935
        double deg_rad;
936
 
937
        deg_rad = (deg * M_PI) / 180.0;
938
 
939
        yc = y - (uint8_t) round (cos (deg_rad) * (double) r);
940
        xc = x + (uint8_t) round (sin (deg_rad) * (double) r);
941
        lcd_line (x, y, xc, yc, mode);
942
}
943
 
944
 
945
//-----------------------------------------------------------
946
//
947
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode)
948
{
949
        uint8_t xc, yc;
950
        double deg_rad;
951
 
952
        deg_rad = (deg * M_PI) / 180.0;
953
 
954
        yc = y - (uint8_t) round (cos (deg_rad) * (double) ry);
955
        xc = x + (uint8_t) round (sin (deg_rad) * (double) rx);
956
        lcd_line (x, y, xc, yc, mode);
957
}
958
 
959
 
960
//-----------------------------------------------------------
961
//
962
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode)
963
{
964
        const int16_t rx2 = rx * rx;
965
        const int16_t ry2 = ry * ry;
966
        int16_t F = round (ry2 - rx2 * ry + 0.25 * rx2);
967
        int16_t ddF_x = 0;
968
        int16_t ddF_y = 2 * rx2 * ry;
969
        int16_t x = 0;
970
        int16_t y = ry;
971
 
972
        lcd_plot (x0, y0 + ry, mode);
973
        lcd_plot (x0, y0 - ry, mode);
974
        lcd_plot (x0 + rx, y0, mode);
975
        lcd_plot (x0 - rx, y0, mode);
976
        // while ( 2*ry2*x < 2*rx2*y ) {  we can use ddF_x and ddF_y
977
        while (ddF_x < ddF_y)
978
        {
979
                if(F >= 0)
980
                {
981
                        y     -= 1;             // south
982
                        ddF_y -= 2 * rx2;
983
                        F     -= ddF_y;
984
                }
985
                x     += 1;                     // east
986
                ddF_x += 2 * ry2;
987
                F     += ddF_x + ry2;
988
                lcd_plot (x0 + x, y0 + y, mode);
989
                lcd_plot (x0 + x, y0 - y, mode);
990
                lcd_plot (x0 - x, y0 + y, mode);
991
                lcd_plot (x0 - x, y0 - y, mode);
992
        }
993
        F = round (ry2 * (x + 0.5) * (x + 0.5) + rx2 * (y - 1) * (y - 1) - rx2 * ry2);
994
        while(y > 0)
995
        {
996
                if(F <= 0)
997
                {
998
                        x     += 1;             // east
999
                        ddF_x += 2 * ry2;
1000
                        F     += ddF_x;
1001
                }
1002
                y     -= 1;                     // south
1003
                ddF_y -= 2 * rx2;
1004
                F     += rx2 - ddF_y;
1005
                lcd_plot (x0 + x, y0 + y, mode);
1006
                lcd_plot (x0 + x, y0 - y, mode);
1007
                lcd_plot (x0 - x, y0 + y, mode);
1008
                lcd_plot (x0 - x, y0 - y, mode);
1009
        }
1010
}
1011
 
1012
 
1013
//-----------------------------------------------------------
1014
//
1015
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode)
1016
{
1017
        lcd_ellipse (x0, y0, radius + 3, radius, mode);
1018
}
1019
 
1020
 
1021
//-----------------------------------------------------------
1022
//
1023
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode)
1024
{
1025
        lcd_ellipse_line(x, y, r + 3, r, deg, mode);
1026
}
1027
 
1028
 
1029
//-----------------------------------------------------------
1030
//
1031
void lcd_view_font (uint8_t page)
1032
{
1033
        int x;
1034
        int y;
1035
 
1036
        lcd_cls ();
1037
        lcd_printp (PSTR("  0123456789ABCDEF\r\n"), 0);
1038
        lcd_printpns_at (0, 7, PSTR(" \x1a    \x1b     Exit"), 0);
1039
 
1040
        lcd_ypos = 2;
1041
        for (y = page * 4 ; y < (page * 4 + 4); y++)
1042
        {
1043
                if (y < 10)
1044
                {
1045
                        lcd_putc (0, lcd_ypos, '0' + y, 0);
1046
                }
1047
                else
1048
                {
1049
                        lcd_putc (0, lcd_ypos, 'A' + y - 10, 0);
1050
                }
1051
                lcd_xpos = 2;
1052
                for (x = 0; x < 16; x++)
1053
                {
1054
                        lcd_putc (lcd_xpos, lcd_ypos, y * 16 + x, 0);
1055
                        lcd_xpos++;
1056
                }
1057
                lcd_ypos++;
1058
        }
1059
}
1060
 
1061
 
1062
//-----------------------------------------------------------
1063
uint8_t hdigit (uint8_t d)
1064
{
1065
        if (d < 10)
1066
        {
1067
                return '0' + d;
1068
        }
1069
        else
1070
        {
1071
                return 'A' + d - 10;
1072
        }
1073
}
1074
 
1075
 
1076
//-----------------------------------------------------------
1077
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode)
1078
{
1079
        lcd_xpos = x;
1080
        lcd_ypos = y;
1081
 
1082
        lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode);
1083
        lcd_putc (lcd_xpos, lcd_ypos, hdigit (h & 0x0f), mode);
1084
}
1085
 
1086
 
1087
//-----------------------------------------------------------
1088
void lcd_print_hex (uint8_t h, uint8_t mode)
1089
{
1090
//      lcd_xpos = x;
1091
//      lcd_ypos = y;
1092
 
1093
        lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode);
1094
        lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h & 0x0f), mode);
1095
        lcd_putc (lcd_xpos++, lcd_ypos, ' ', mode);
1096
}
1097
 
1098
 
1099
//-----------------------------------------------------------
1100
void lcd_write_number_u (uint8_t number)
1101
{
1102
        uint8_t num = 100;
1103
        uint8_t started = 0;
1104
 
1105
        while (num > 0)
1106
        {
1107
                uint8_t b = number / num;
1108
                if (b > 0 || started || num == 1)
1109
                {
1110
                        lcd_putc (lcd_xpos++, lcd_ypos, '0' + b, 0);
1111
                        started = 1;
1112
                }
1113
                number -= b * num;
1114
 
1115
                num /= 10;
1116
        }
1117
}
1118
 
1119
 
1120
//-----------------------------------------------------------
1121
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number)
1122
{
1123
        lcd_xpos = x;
1124
        lcd_ypos = y;
1125
        lcd_write_number_u (number);
1126
}
1127
 
1128
 
1129
//-----------------------------------------------------------
1130
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory
1131
// <num> represents the largest multiple of 10 that will still be displayable as
1132
// the first digit, so num = 10 will be 0-99 and so on
1133
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
1134
//
1135
void writex_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs)
1136
{
1137
        //char s[7];
1138
 
1139
        utoa(number, s, 10 );
1140
 
1141
        uint8_t len = strlen(s);
1142
 
1143
 
1144
        if (length < len)
1145
        {
1146
                for (uint8_t i = 0; i < length; i++)
1147
                {
1148
                        lcdx_putc (x++, y, '*', mode, xoffs,yoffs);
1149
                }
1150
                return;
1151
        }
1152
 
1153
        for (uint8_t i = 0; i < length - len; i++)
1154
        {
1155
                if (pad==1)
1156
                {
1157
                        lcdx_putc (x++, y, '0', mode, xoffs,yoffs);
1158
                }
1159
                else
1160
                {
1161
                        lcdx_putc (x++, y, ' ', mode, xoffs,yoffs);
1162
                }
1163
        }
1164
        lcdx_print_at(x, y, (uint8_t*)s, mode, xoffs,yoffs);
1165
}
1166
 
1167
 
1168
//-----------------------------------------------------------
1169
//-----------------------------------------------------------
1170
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode)
1171
{
1172
        writex_ndigit_number_u( x, y, number, length, pad, mode, 0,0);
1173
}
1174
 
1175
 
1176
//-----------------------------------------------------------
1177
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory
1178
// <num> represents the largest multiple of 10 that will still be displayable as
1179
// the first digit, so num = 10 will be 0-99 and so on
1180
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
1181
//
1182
void writex_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs)
1183
{
1184
        //char s[7];
1185
 
1186
        itoa(number, s, 10 );
1187
 
1188
        uint8_t len = strlen(s);
1189
 
1190
        if (length < len)
1191
        {
1192
                for (uint8_t i = 0; i < length; i++)
1193
                {
1194
                        lcdx_putc (x++, y, '*', mode, xoffs,yoffs);
1195
                }
1196
                return;
1197
        }
1198
 
1199
        for (uint8_t i = 0; i < length - len; i++)
1200
        {
1201
                if (pad)
1202
                {
1203
                        lcdx_putc (x++, y, '0', mode, xoffs,yoffs);
1204
                }
1205
                else
1206
                {
1207
                        lcdx_putc (x++, y, ' ', mode, xoffs,yoffs);
1208
                }
1209
        }
1210
        lcdx_print_at(x, y, (uint8_t*)s, mode, xoffs,yoffs);
1211
}
1212
 
1213
 
1214
//-----------------------------------------------------------
1215
//-----------------------------------------------------------
1216
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode)
1217
{
1218
        writex_ndigit_number_s (x, y, number, length, pad, mode, 0,0);
1219
}
1220
 
1221
 
1222
//-----------------------------------------------------------
1223
// Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory
1224
// as /10th of the value
1225
// <num> represents the largest multiple of 10 that will still be displayable as
1226
// the first digit, so num = 10 will be 0-99 and so on
1227
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
1228
//
1229
void writex_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs)
1230
{
1231
        //char s[7];
1232
 
1233
        itoa(number, s, 10 );
1234
 
1235
        uint8_t len = strlen(s);
1236
 
1237
        if (length < len)
1238
        {
1239
                for (uint8_t i = 0; i < length; i++)
1240
                {
1241
                        lcdx_putc (x++, y, '*', mode, xoffs,yoffs);
1242
                }
1243
                return;
1244
        }
1245
 
1246
        for (uint8_t i = 0; i < length - len; i++)
1247
        {
1248
                if (pad)
1249
                {
1250
                        lcdx_putc (x++, y, '0', mode, xoffs,yoffs);
1251
                }
1252
                else
1253
                {
1254
                        lcdx_putc (x++, y, ' ', mode, xoffs,yoffs);
1255
                }
1256
        }
1257
 
1258
        char rest = s[len - 1];
1259
 
1260
        s[len - 1] = 0;
1261
 
1262
        if (len == 1)
1263
        {
1264
                lcdx_putc (x-1, y, '0', mode, xoffs,yoffs);
1265
        }
1266
        else if (len == 2 && s[0] == '-')
1267
        {
1268
                lcdx_putc (x-1, y, '-', mode, xoffs,yoffs);
1269
                lcdx_putc (x, y, '0', mode, xoffs,yoffs);
1270
        }
1271
        else
1272
        {
1273
                lcdx_print_at(x, y, (uint8_t*)s, mode, xoffs,yoffs);
1274
        }
1275
        x += len - 1;
1276
        lcdx_putc (x++, y, '.', mode, xoffs,yoffs);
1277
        lcdx_putc (x++, y, rest, mode, xoffs,yoffs);
1278
}
1279
 
1280
 
1281
//-----------------------------------------------------------
1282
//-----------------------------------------------------------
1283
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode)
1284
{
1285
  writex_ndigit_number_u_10th ( x, y, number, length, pad, mode, 0,0);
1286
}
1287
 
1288
 
1289
//-----------------------------------------------------------
1290
//-----------------------------------------------------------
1291
void writex_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, int8_t xoffs, int8_t yoffs)
1292
{
1293
        uint8_t num = 100;
1294
 
1295
        while (num > 0)
1296
        {
1297
                uint8_t b = number / num;
1298
 
1299
                if ((num / 10) == 1)
1300
                {
1301
                        lcdx_putc (x++, y, '.', 0, xoffs,yoffs);
1302
                }
1303
                lcdx_putc (x++, y, '0' + b, 0, xoffs,yoffs);
1304
                number -= b * num;
1305
 
1306
                num /= 10;
1307
        }
1308
}
1309
 
1310
 
1311
//-----------------------------------------------------------
1312
//-----------------------------------------------------------
1313
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad)
1314
{
1315
        writex_ndigit_number_u_100th ( x, y, number, length, pad, 0,0);
1316
}
1317
 
1318
 
1319
//-----------------------------------------------------------
1320
// Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory
1321
// as /10th of the value
1322
// <num> represents the largest multiple of 10 that will still be displayable as
1323
// the first digit, so num = 10 will be 0-99 and so on
1324
// <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of   7
1325
//
1326
void writex_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode, int8_t xoffs, int8_t yoffs)
1327
{
1328
        //char s[7];
1329
 
1330
        itoa (number, s, 10 );
1331
 
1332
        uint8_t len = strlen(s);
1333
 
1334
        if (length < len)
1335
        {
1336
                for (uint8_t i = 0; i < length; i++)
1337
                {
1338
                        lcdx_putc (x++, y, '*', mode, xoffs, yoffs);
1339
                }
1340
                return;
1341
        }
1342
 
1343
        for (uint8_t i = 0; i < length - len; i++)
1344
        {
1345
                if (pad)
1346
                {
1347
                        lcdx_putc (x++, y, '0', mode, xoffs, yoffs);
1348
                }
1349
                else
1350
                {
1351
                        lcdx_putc (x++, y, ' ', mode, xoffs, yoffs);
1352
                }
1353
        }
1354
 
1355
        char rest = s[len - 1];
1356
 
1357
        s[len - 1] = 0;
1358
 
1359
        if (len == 1)
1360
        {
1361
                lcdx_putc (x-1, y, '0', mode, xoffs, yoffs);
1362
        }
1363
        else if (len == 2 && s[0] == '-')
1364
        {
1365
                lcdx_putc (x-1, y, '-', mode, xoffs,yoffs);
1366
                lcdx_putc (x, y, '0', mode, xoffs,yoffs);
1367
        }
1368
        else
1369
        {
1370
                lcdx_print_at(x, y, (uint8_t*)s, mode, xoffs, yoffs);
1371
        }
1372
        x += len - 1;
1373
        lcdx_putc (x++, y, '.', mode, xoffs, yoffs);
1374
        lcdx_putc (x++, y, rest, mode, xoffs, yoffs);
1375
}
1376
 
1377
 
1378
//-----------------------------------------------------------
1379
//-----------------------------------------------------------
1380
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode)
1381
{
1382
        writex_ndigit_number_s_10th ( x,  y,  number,  length,  pad,  mode,  0,0);
1383
 
1384
}
1385
 
1386
 
1387
//-----------------------------------------------------------
1388
// write <seconds> as human readable time at <x>/<y> to MAX7456 display mem
1389
//
1390
void writex_time (uint8_t x, uint8_t y, uint16_t seconds, uint8_t mode, int8_t xoffs, int8_t yoffs)
1391
{
1392
        uint16_t min = seconds / 60;
1393
        seconds -= min * 60;
1394
        writex_ndigit_number_u (x, y, min, 2, 0,mode, xoffs,yoffs);
1395
        lcd_putc (x + 2, y, ':', 0);
1396
        writex_ndigit_number_u (x + 3, y, seconds, 2, 1,mode, xoffs,yoffs);
1397
}
1398
 
1399
 
1400
//-----------------------------------------------------------
1401
//-----------------------------------------------------------
1402
void write_time (uint8_t x, uint8_t y, uint16_t seconds)
1403
{
1404
        writex_time ( x,  y,  seconds, 0, 0,0);
1405
}
1406
 
1407
 
1408
//-----------------------------------------------------------
1409
// wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude
1410
//
1411
void write_gps_pos (uint8_t x, uint8_t y, int32_t position)
1412
{
1413
        if (position < 0)
1414
        {
1415
                position ^= ~0;
1416
                position++;
1417
                lcd_putc (x++, y, '-', 0);
1418
        }
1419
        else
1420
        {
1421
                lcd_putc (x++, y, ' ', 0);
1422
        }
1423
        write_ndigit_number_u (x, y, (uint16_t) (position / (int32_t) 10000000), 3, 1,0);
1424
        lcd_putc (x + 3, y, '.', 0);
1425
        position = position - ((position / (int32_t) 10000000) * (int32_t) 10000000);
1426
        write_ndigit_number_u (x + 4, y, (uint16_t) (position / (int32_t) 1000), 4, 1,0);
1427
        position = position - ((uint16_t) (position / (int32_t) 1000) * (int32_t) 1000);
1428
        write_ndigit_number_u (x + 8, y, (uint16_t) position, 3, 1,0);
1429
        lcd_putc (x + 11, y, 0x1e, 0);  // degree symbol
1430
}
1431
 
1432
 
1433
//------------------------------------------------------------------------------------
1434
// Show PKT Baudrate at given position
1435
//
1436
void show_baudrate (uint8_t x, uint8_t y, uint8_t Baudrate, uint8_t mode)
1437
{
1438
  switch (Baudrate)
1439
  {
1440
      case Baud_2400:   lcd_printp_at (x, y, PSTR("2400"), mode);break;
1441
      case Baud_4800:   lcd_printp_at (x, y, PSTR("4800"), mode);break;
1442
      case Baud_9600:   lcd_printp_at (x, y, PSTR("9600"), mode);break;
1443
      case Baud_19200:  lcd_printp_at (x, y, PSTR("19200"), mode);break;
1444
      case Baud_38400:  lcd_printp_at (x, y, PSTR("38400"), mode);break;
1445
      case Baud_57600:  lcd_printp_at (x, y, PSTR("57600"), mode);break;
1446
      case Baud_115200: lcd_printp_at (x, y, PSTR("115200"), mode);break;
1447
        break;
1448
  }
1449
}
1450
 
1451
 
1452
 
1453