Rev 11 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 11 | Rev 19 | ||
|---|---|---|---|
| Line 6... | Line 6... | ||
| 6 | displayXY_t ::displayXY_t(display_t &disp, |
6 | displayXY_t ::displayXY_t(display_t &disp, |
| 7 | int xmin, int xmax, int ymin, int ymax) : display(disp), x_min(xmin), x_max(xmax), y_min(ymin), y_max(ymax), |
7 | int xmin, int xmax, int ymin, int ymax) : display(disp), x_min(xmin), x_max(xmax), y_min(ymin), y_max(ymax), |
| 8 | left_margin(MARGIN), right_margin(display.width() - MARGIN), plot_width(right_margin - left_margin), |
8 | left_margin(MARGIN), right_margin(display.width() - MARGIN), plot_width(right_margin - left_margin), |
| 9 | top_margin(MARGIN), bottom_margin(display.height() - BOTTOM_MARGIN), plot_height(bottom_margin - top_margin), next_persist(0) |
9 | top_margin(MARGIN), bottom_margin(display.height() - BOTTOM_MARGIN), plot_height(bottom_margin - top_margin), next_persist(0) |
| 10 | { |
10 | { |
| 11 | for (uint8_t i = 0; i < PERSIST; i++) |
11 | for (uint16_t i = 0; i < PERSIST; i++) |
| 12 | { |
12 | { |
| 13 | persist_x[i] = left_margin; |
13 | persist_x[i] = left_margin; |
| 14 | persist_y[i] = bottom_margin; |
14 | persist_y[i] = bottom_margin; |
| 15 | } |
15 | } |
| 16 | }; |
16 | }; |
| Line 27... | Line 27... | ||
| 27 | { |
27 | { |
| 28 | int y_coord = (plot_height * (y - y_min)) / (y_max - y_min); |
28 | int y_coord = (plot_height * (y - y_min)) / (y_max - y_min); |
| 29 | int x_coord = (plot_width * (x - x_min)) / (x_max - x_min); |
29 | int x_coord = (plot_width * (x - x_min)) / (x_max - x_min); |
| 30 | display.drawLine(left_margin, y_coord, right_margin, y_coord, WHITE, 0b111000); |
30 | display.drawLine(left_margin, y_coord, right_margin, y_coord, WHITE, 0b111000); |
| 31 | display.drawLine(x_coord, top_margin, x_coord, bottom_margin, WHITE, 0b111000); |
31 | display.drawLine(x_coord, top_margin, x_coord, bottom_margin, WHITE, 0b111000); |
| 32 | // imitate persistent plot |
- | |
| 33 | persist_x[next_persist] = x_coord; |
32 | persist_x[next_persist] = x_coord; |
| 34 | persist_y[next_persist] = y_coord; |
33 | persist_y[next_persist] = y_coord; |
| 35 | next_persist++; |
34 | next_persist++; |
| 36 | if (next_persist > PERSIST) |
35 | if (next_persist > PERSIST) |
| 37 | next_persist = 0; |
36 | next_persist = 0; |
| 38 | - | ||
| 39 | for (uint8_t i = 0; i < PERSIST; i++) |
37 | for (uint16_t i = 0; i < PERSIST; i++) |
| 40 | { |
38 | { |
| 41 | display.drawPixel(persist_x[i], persist_y[i], WHITE); |
39 | display.drawPixel(persist_x[i], persist_y[i], WHITE); |
| 42 | } |
40 | } |
| 43 | 41 | ||
| 44 | if(message) |
42 | if(message) |
| Line 46... | Line 44... | ||
| 46 | display.gotoxy(0, 48); |
44 | display.gotoxy(0, 48); |
| 47 | display.printString(large_font, message, 0, OVERLAY); |
45 | display.printString(large_font, message, 0, OVERLAY); |
| 48 | } |
46 | } |
| 49 | if (message_upper) |
47 | if (message_upper) |
| 50 | { |
48 | { |
| 51 | display.gotoxy(64,48); |
49 | display.gotoxy(56,48); |
| 52 | display.printString(small_font, message_upper, 0, OVERLAY); |
50 | display.printString(small_font, message_upper, 0, OVERLAY); |
| 53 | } |
51 | } |
| 54 | if (message_lower) |
52 | if (message_lower) |
| 55 | { |
53 | { |
| 56 | display.gotoxy(64,56); |
54 | display.gotoxy(56,56); |
| 57 | display.printString(small_font, message_lower, 0, OVERLAY); |
55 | display.printString(small_font, message_lower, 0, OVERLAY); |
| 58 | } |
56 | } |
| 59 | 57 | ||
| 60 | } |
58 | } |