Subversion Repositories testOled

Rev

Rev 10 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 11
Line 5... Line 5...
5
 *      Author: mike
5
 *      Author: mike
6
 */
6
 */
7
 
7
 
8
#include "main.h"
8
#include "main.h"
9
#include "display.h"
9
#include "display.h"
10
#include "timing.h"
10
#include "libIgnTiming/timing.h"
11
#include <cstring>
11
#include <cstring>
12
#include "libOLED/stm32_halDisplay.H"
12
#include "libOLED/stm32_halDisplay.H"
13
#include "libOLED/fontclass.H"
13
#include "libOLED/fontclass.H"
14
#include "libOLED/displayDial.H"
14
#include "libOLED/displayDial.H"
15
#include "libOLED/displayXY.H"
15
#include "libOLED/displayXY.H"
Line 26... Line 26...
26
 
26
 
27
        int x = 500;
27
        int x = 500;
28
        int y = 20;
28
        int y = 20;
29
        int ph = 0;
29
        int ph = 0;
30
 
30
 
31
        uint32_t press;
31
        uint32_t press; // pressure millibar * 100
32
        int32_t temp;
32
        int32_t temp;   // temperature * 10
-
 
33
        bool button;    // user pressed button
33
}
34
}
34
 
35
 
35
uint8_t displayBuffer[2][dataSize(WIDTH, HEIGHT)];
36
uint8_t displayBuffer[MAX_DISPLAYS][dataSize(WIDTH, HEIGHT)];
36
 
37
 
37
stm32_halDisplay_t displays[MAX_DISPLAYS] =
38
stm32_halDisplay_t displays[MAX_DISPLAYS] =
38
        {
39
        {
39
                stm32_halDisplay_t(WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer[0],
40
                stm32_halDisplay_t(WIDTH, HEIGHT, DISPLAY_RAMWIDTH, displayBuffer[0],
40
                                                   &hspi1,
41
                                                   &hspi1,
Line 88... Line 89...
88
                        return -1;
89
                        return -1;
89
                stm32_halDisplay_t &display = displays[dialIndex];
90
                stm32_halDisplay_t &display = displays[dialIndex];
90
                display.clearDisplay(BLACK);
91
                display.clearDisplay(BLACK);
91
 
92
 
92
                displayDial1.draw_scale(0, 100, 4, 2, 25);
93
                displayDial1.draw_scale(0, 100, 4, 2, 25);
93
                displayDial2.draw_scale(0, 100, 4, 2, 25);
94
                displayDial2.draw_scale(0, 1000, 4, 2, 250);
94
 
95
 
95
                //      dispXY.drawAxes();
96
                //      dispXY.drawAxes();
96
                x += 50;
97
                x += 50;
97
                y = (m.ap_sin(ph + (x / 10)) * 39) / 20 + 500; // wobbling about 1000 mB down to about 490mB
98
                y = (m.ap_sin(ph + (x / 10)) * 39) / 20 + 500; // wobbling about 1000 mB down to about 490mB
98
 
99
 
Line 102... Line 103...
102
                        if (ph > 360 * m.SINE_SCALING)
103
                        if (ph > 360 * m.SINE_SCALING)
103
                                ph -= 360 * m.SINE_SCALING;
104
                                ph -= 360 * m.SINE_SCALING;
104
 
105
 
105
                        x = 500;
106
                        x = 500;
106
                }
107
                }
107
                display.dim(false);
108
                display.dim(button ? 0 : 255);
108
                char buff[10];
109
                char buff[10];
109
                int tim = timing(x, 1000 - y);
110
                int tim = mapTiming(x, 1000 - y);
110
                small_sprintf(buff, "%2d.%1d\xb0", tim / 10, tim % 10);
111
                small_sprintf(buff, "%2d.%1d\xb0", tim / 10, tim % 10);
111
 
112
 
112
                //      dispXY.plotPoint(x, y, buff, buff1, buff2);
113
                //      dispXY.plotPoint(x, y, buff, buff1, buff2);
113
 
114
 
114
                displayDial1.draw_limits();
115
                displayDial1.draw_limits();
115
                displayDial2.draw_limits();
116
                displayDial2.draw_limits();
116
 
117
 
-
 
118
                displayDial1.set_title("Batt");
117
                displayDial1.set_units("degC");
119
                displayDial1.set_units("degC");
118
                displayDial2.set_units("slide");
120
                displayDial2.set_units("press");
119
 
121
 
120
                displayDial1.draw_value(temp, 1);
122
                displayDial1.draw_value(temp / 10, 1);
121
                displayDial1.draw_needle(temp * 360 / 10000);
123
                displayDial1.draw_needle(temp * 360 / 10000);
122
                displayDial2.draw_value(y, display_t::NO_DECIMAL);
124
                displayDial2.draw_value(press / 100, display_t::NO_DECIMAL, 4);
123
                displayDial2.draw_needle(y / 3);
125
                displayDial2.draw_needle(press / 300);
124
 
126
 
125
                display.dim(true);
-
 
126
                display.display();
127
                display.display();
127
 
128
 
128
                return 0;
129
                return 0;
129
        }
130
        }
130
 
131
 
131
        void cc_feed(uint32_t pressVal, int32_t tempVal)
132
        void cc_feed(uint32_t pressVal, int32_t tempVal)
132
        {
133
        {
133
                press = pressVal;
134
                press = pressVal;
134
                temp = tempVal;
135
                temp = tempVal;
135
        }
136
        }
-
 
137
 
-
 
138
        void cc_feed_pushbutton(uint8_t buttonVal)
-
 
139
        {
-
 
140
                button = buttonVal;
-
 
141
        }
136
#if defined __cplusplus
142
#if defined __cplusplus
137
}
143
}
138
#endif
144
#endif