src/display.cpp

Tue, 27 Oct 2020 21:48:28 +0100

author
David Douard <david.douard@sdf3.org>
date
Tue, 27 Oct 2020 21:48:28 +0100
changeset 39
63c6a720cb97
parent 37
07e8ca2bdf6d
child 44
b3c3d54d2c7c
permissions
-rw-r--r--

hp34comm: add support for boot keycode

37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
1 #include "stdio.h"
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
2 #include <mbed.h>
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
3 #include <rtos.h>
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
4 #include "display.h"
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
5
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
6
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
7 Display::Display(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC,
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
8 const char* name)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
9 : SSD1322(Hz, mosi, miso, sclk, CS, reset, DC, name)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
10 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
11 must_refresh = 0;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
12 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
13
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
14 Display::~Display()
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
15 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
16 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
17
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
18 void Display::show_splashscreen()
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
19 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
20 locate(30, 10);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
21 set_font((unsigned char*)Mono19x27);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
22 this->printf("HP34970A");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
23 set_font((unsigned char*)Terminal6x8);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
24 locate(90, 40);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
25 this->printf("David Douard");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
26 locate(0, 52);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
27 this->printf("Clock = %ld ", SystemCoreClock);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
28
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
29 RCC_OscInitTypeDef cfg;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
30 HAL_RCC_GetOscConfig(&cfg);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
31 if (cfg.HSEState == RCC_HSE_BYPASS)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
32 this->printf("HSE:EXT ");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
33 else if (cfg.HSEState == RCC_HSE_ON)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
34 this->printf("HSE:XTAL ");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
35 else
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
36 this->printf("HSE:OFF ");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
37
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
38 if (cfg.HSIState == RCC_HSI_ON)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
39 this->printf("HSI:ON ");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
40 else
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
41 this->printf("HSI:OFF ");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
42
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
43 copy_to_lcd();
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
44 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
45
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
46
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
47 void Display::show(uint8_t cmd, const char *intxt, uint8_t nchar=0)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
48 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
49 uint8_t i;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
50 // uint8_t len;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
51 uint16_t bgcolor, fgcolor;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
52 char *oldv;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
53 // char *txt;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
54 char *txtp;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
55 static char txt[256];
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
56
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
57
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
58 if (cmd == 0xFF) // cls
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
59 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
60 clrbuff();
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
61 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
62 else
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
63 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
64 //txt = (char *)malloc(strlen(intxt)+1);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
65 strcpy(txt, intxt);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
66 txtp = txt;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
67
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
68 for (i=0; i<sizeof(table)/sizeof(table[0]); ++i) {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
69 if (table[i].cmd == cmd) {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
70 bgcolor = table[i].bgcolor;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
71 fgcolor = table[i].color;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
72 background(bgcolor);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
73 foreground(fgcolor);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
74 set_font((unsigned char*) table[i].font);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
75 oldv = table[i].buffer;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
76
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
77 locate(table[i].x0, table[i].y0);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
78
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
79 if (table[i].fmt & 0x01) // ASCII text
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
80 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
81 if (strncmp(oldv, txt, table[i].maxsize) != 0)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
82 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
83 if (table[i].width > 0)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
84 fillrect(table[i].x0,
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
85 table[i].y0,
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
86 table[i].x0 + table[i].width,
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
87 table[i].y0 + table[i].font[2],
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
88 bgcolor);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
89 for (uint8_t k=0; ;k++)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
90 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
91 if (txtp[k] == 0x00)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
92 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
93 this->printf(txtp);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
94 break;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
95 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
96 if (txtp[k] == 0x09)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
97 { // \t is a special char for 'unselected' display value
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
98 txtp[k] = 0x00;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
99 this->printf(txtp);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
100
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
101 if (fgcolor == table[i].color)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
102 fgcolor /= 2;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
103 else
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
104 fgcolor = table[i].color;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
105 foreground(fgcolor);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
106 txtp = &(txtp[k+1]);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
107 k = 0;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
108 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
109 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
110 if (cmd == 0x00) // main area
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
111 must_refresh |= 0x01;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
112 if (cmd == 0x0C) // channels area
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
113 must_refresh |= 0x04;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
114 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
115 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
116 /*
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
117 if (table[i].fmt & 0x02 ) {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
118 // hex
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
119 for (uint8_t j=0;; j++) {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
120 if (txt[j] == 0x00)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
121 break;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
122 this->printf("%02X ", txt[j]);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
123 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
124 for (uint8_t j=3*strlen(txt); j<table[i].maxsize; j++)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
125 this->printf(" ");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
126 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
127 */
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
128 if (table[i].fmt & 0x08 ) // flag indicators
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
129 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
130 // flags
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
131 for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
132 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
133 for (uint8_t k=0; k<8; k++)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
134 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
135 if (1)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
136 { //(txt[j] & (1 << k) ) != (oldv[j] & (1 << k))) {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
137 for (uint8_t l=0;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
138 l<(sizeof(flags)/sizeof(flags[0])); ++l)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
139 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
140 if (flags[l].flag == ((j<<4) + k)) {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
141 if (txtp[j] & (1 << k))
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
142 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
143 foreground(flags[l].reverse ? bgcolor : fgcolor);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
144 background(flags[l].reverse ? fgcolor : bgcolor);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
145 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
146 else
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
147 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
148 foreground(bgcolor);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
149 background(bgcolor);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
150 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
151 if (flags[l].msg != NULL)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
152 { // a string
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
153 locate(flags[l].x, flags[l].y);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
154 this->printf(flags[l].msg);}
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
155 else
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
156 { // an icon
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
157 Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon};
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
158 Bitmap_BW(pic, flags[l].x, flags[l].y);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
159 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
160 must_refresh = 1; //|= zones[m].flag;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
161 break;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
162 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
163 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
164 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
165 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
166 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
167
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
168 // draw frames (Alarm and Channel)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
169 for (uint8_t l=0;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
170 l<(sizeof(frames)/sizeof(frames[0])); ++l)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
171 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
172 uint16_t color;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
173 if (frames[l].flag & txt[0]) // frame flags are on the 1st byte only
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
174 color = fgcolor/6;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
175 else
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
176 color = bgcolor;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
177 hline(frames[l].x0+1, frames[l].x0+3, frames[l].y0, color);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
178 hline(frames[l].x1-3, frames[l].x1-1, frames[l].y0, color);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
179 hline(frames[l].x0+1, frames[l].x1-1, frames[l].y1, color);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
180
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
181 vline(frames[l].x0, frames[l].y0+1, frames[l].y1-1, color);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
182 vline(frames[l].x1, frames[l].y0+1, frames[l].y1-1, color);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
183 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
184 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
185
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
186 for(uint8_t j=0; j<table[i].maxsize; j++)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
187 oldv[j] = txt[j];
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
188 break;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
189 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
190 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
191 //free(txt);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
192 //this->copy_to_lcd();
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
193 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
194 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
195
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
196
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
197 void Display::test_dsp()
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
198 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
199 const FRAME *z;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
200 printf("TEST DSP\r\n");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
201 cls();
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
202 printf("TEST DSP #2\r\n");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
203 show(0x00, "8g8g8g8g8g8g8", 13); // main dsp
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
204 show(0x0C, "888", 3); // channel dsp
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
205 show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
206 copy_to_lcd();
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
207 ThisThread::sleep_for(3ms);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
208 cls();
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
209 printf("TEST DSP #3\r\n");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
210
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
211 for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
212 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
213 z = &zones[i];
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
214 fillrect(z->x0, z->y0, z->x1, z->y1, 4+i);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
215 locate(z->x0+1, z->y0+1);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
216 this->printf("%d", i);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
217 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
218
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
219 /*
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
220 for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++)
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
221 {
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
222 z = &zones[i];
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
223 printf("Zone %d [%x]: %d, %d, %d, %d\n", i, z->flag,
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
224 z->x0, z->y0, z->x1, z->y1);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
225 must_refresh = z->flag;
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
226 wait(1);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
227 }
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
228 printf("Done\n");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
229 wait(2);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
230 printf("Copy ALL\n");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
231 copy_to_lcd();
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
232 */
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
233 ThisThread::sleep_for(2ms);
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
234 cls();
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
235 printf("TEST DSP DONE\r\n");
07e8ca2bdf6d Extracted the display related functions in a Display class
David Douard <david.douard@sdf3.org>
parents:
diff changeset
236 }

mercurial