Jon Freeman / Mbed 2 deprecated Brute_TS_Controller_2018_11

Dependencies:   TS_DISCO_F746NG mbed Servo LCD_DISCO_F746NG BSP_DISCO_F746NG QSPI_DISCO_F746NG AsyncSerial FastPWM

Committer:
JonFreeman
Date:
Mon Apr 09 07:51:37 2018 +0000
Revision:
4:67478861c670
Child:
5:21a8ac83142c
First edit of code from 2017 for new Twin BLDC controller boards

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JonFreeman 4:67478861c670 1 #include "mbed.h"
JonFreeman 4:67478861c670 2 #include "TS_DISCO_F746NG.h"
JonFreeman 4:67478861c670 3 #include "LCD_DISCO_F746NG.h"
JonFreeman 4:67478861c670 4 #include "Electric_Loco.h"
JonFreeman 4:67478861c670 5
JonFreeman 4:67478861c670 6 #define VOLTMETER_X 68 // Voltmeter screen position
JonFreeman 4:67478861c670 7 #define VOLTMETER_Y 68
JonFreeman 4:67478861c670 8 #define AMMETER_X 68 // Ammeter screen position - Now replaced by Power meter
JonFreeman 4:67478861c670 9 #define AMMETER_Y 202
JonFreeman 4:67478861c670 10 #define SPEEDO_X 274 // Speedometer screen position
JonFreeman 4:67478861c670 11 #define SPEEDO_Y 135
JonFreeman 4:67478861c670 12 #define V_A_SIZE 54 // Size of voltmeter and ammeter
JonFreeman 4:67478861c670 13 #define SPEEDO_SIZE 112
JonFreeman 4:67478861c670 14
JonFreeman 4:67478861c670 15 #define SPEEDO_BODY_COLOUR LCD_COLOR_BLACK
JonFreeman 4:67478861c670 16 #define SPEEDO_DIAL_COLOUR LCD_COLOR_WHITE
JonFreeman 4:67478861c670 17 #define SPEEDO_TEXT_COLOUR LCD_COLOR_BLUE
JonFreeman 4:67478861c670 18
JonFreeman 4:67478861c670 19 #define VMETER_BODY_COLOUR LCD_COLOR_BLACK
JonFreeman 4:67478861c670 20 #define VMETER_DIAL_COLOUR LCD_COLOR_WHITE
JonFreeman 4:67478861c670 21 #define VMETER_TEXT_COLOUR LCD_COLOR_BLUE
JonFreeman 4:67478861c670 22
JonFreeman 4:67478861c670 23 #define AMETER_BODY_COLOUR LCD_COLOR_BLACK
JonFreeman 4:67478861c670 24 #define AMETER_DIAL_COLOUR LCD_COLOR_WHITE
JonFreeman 4:67478861c670 25 #define AMETER_TEXT_COLOUR LCD_COLOR_BLUE
JonFreeman 4:67478861c670 26
JonFreeman 4:67478861c670 27 extern LCD_DISCO_F746NG lcd;
JonFreeman 4:67478861c670 28 extern TS_DISCO_F746NG touch_screen;
JonFreeman 4:67478861c670 29 extern Serial pc;
JonFreeman 4:67478861c670 30
JonFreeman 4:67478861c670 31 static const int char_widths[] = {5, 7, 11, 14, 17, 17} ,
JonFreeman 4:67478861c670 32 meter_radius_min = 30, meter_radius_max = 120;
JonFreeman 4:67478861c670 33
JonFreeman 4:67478861c670 34
JonFreeman 4:67478861c670 35 // Uses our own generated sine and cosines from lookup table. For some unexplained reason, using inbuilt sin and cos fns cause display flicker !
JonFreeman 4:67478861c670 36 extern double jcos (double angle); // Used in DrawNeedle, plain sin and cos functions cause display flicker !!
JonFreeman 4:67478861c670 37 extern double jsin (double angle);
JonFreeman 4:67478861c670 38
JonFreeman 4:67478861c670 39 /*void costabgen (int points) {
JonFreeman 4:67478861c670 40 double angle = 0.0;
JonFreeman 4:67478861c670 41 while (angle < 2.1 * PI) {
JonFreeman 4:67478861c670 42 pc.printf ("Angle %f, my cos %+f, c cos %+f\r\n", angle, jcos(angle), cos(angle));
JonFreeman 4:67478861c670 43 // pc.printf ("Angle %f, my sin %+f, c sin %+f\r\n", angle, jsin(angle), sin(angle));
JonFreeman 4:67478861c670 44 angle += PI / 24;
JonFreeman 4:67478861c670 45 }
JonFreeman 4:67478861c670 46 // double angle;
JonFreeman 4:67478861c670 47 *//* int step, perline = 0;
JonFreeman 4:67478861c670 48 double interval = PI / 2.0 / (double)points;
JonFreeman 4:67478861c670 49 pc.printf ("//At costabgen with %d points\r\n", points);
JonFreeman 4:67478861c670 50 pc.printf ("static const double costab[] = {\r\n");
JonFreeman 4:67478861c670 51 for (step = 0; step <= points; step++) {
JonFreeman 4:67478861c670 52 angle = interval * (double)step;
JonFreeman 4:67478861c670 53 // pc.printf ("cos %+.3f = %+.3f\r\n", angle, cos(angle));
JonFreeman 4:67478861c670 54 if (++perline == 8) {
JonFreeman 4:67478861c670 55 pc.printf ("%+.6f,\r\n", cos(angle));
JonFreeman 4:67478861c670 56 perline = 0;
JonFreeman 4:67478861c670 57 }
JonFreeman 4:67478861c670 58 else
JonFreeman 4:67478861c670 59 pc.printf ("%+.6f, ", cos(angle));
JonFreeman 4:67478861c670 60 wait (0.025);
JonFreeman 4:67478861c670 61 }
JonFreeman 4:67478861c670 62 pc.printf ("0.0\t}\t;\r\n//End of costab\r\n");
JonFreeman 4:67478861c670 63 */
JonFreeman 4:67478861c670 64 //}
JonFreeman 4:67478861c670 65
JonFreeman 4:67478861c670 66 /**
JonFreeman 4:67478861c670 67 * @brief Fills a triangle (between 3 points).
JonFreeman 4:67478861c670 68 * @param x1: Point 1 X position
JonFreeman 4:67478861c670 69 * @param y1: Point 1 Y position
JonFreeman 4:67478861c670 70 * @param x2: Point 2 X position
JonFreeman 4:67478861c670 71 * @param y2: Point 2 Y position
JonFreeman 4:67478861c670 72 * @param x3: Point 3 X position
JonFreeman 4:67478861c670 73 * @param y3: Point 3 Y position
JonFreeman 4:67478861c670 74 * @retval None
JonFreeman 4:67478861c670 75 */
JonFreeman 4:67478861c670 76 static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3)
JonFreeman 4:67478861c670 77 {
JonFreeman 4:67478861c670 78 int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
JonFreeman 4:67478861c670 79 yinc1 = 0, yinc2 = 0, den = 0, num = 0, num_add = 0, num_pixels = 0,
JonFreeman 4:67478861c670 80 curpixel = 0;
JonFreeman 4:67478861c670 81
JonFreeman 4:67478861c670 82 deltax = abs(x2 - x1); /* The difference between the x's */
JonFreeman 4:67478861c670 83 deltay = abs(y2 - y1); /* The difference between the y's */
JonFreeman 4:67478861c670 84 x = x1; /* Start x off at the first pixel */
JonFreeman 4:67478861c670 85 y = y1; /* Start y off at the first pixel */
JonFreeman 4:67478861c670 86
JonFreeman 4:67478861c670 87 if (x2 >= x1) { /* The x-values are increasing */
JonFreeman 4:67478861c670 88 xinc1 = 1;
JonFreeman 4:67478861c670 89 xinc2 = 1;
JonFreeman 4:67478861c670 90 } else { /* The x-values are decreasing */
JonFreeman 4:67478861c670 91 xinc1 = -1;
JonFreeman 4:67478861c670 92 xinc2 = -1;
JonFreeman 4:67478861c670 93 }
JonFreeman 4:67478861c670 94
JonFreeman 4:67478861c670 95 if (y2 >= y1) { /* The y-values are increasing */
JonFreeman 4:67478861c670 96 yinc1 = 1;
JonFreeman 4:67478861c670 97 yinc2 = 1;
JonFreeman 4:67478861c670 98 } else { /* The y-values are decreasing */
JonFreeman 4:67478861c670 99 yinc1 = -1;
JonFreeman 4:67478861c670 100 yinc2 = -1;
JonFreeman 4:67478861c670 101 }
JonFreeman 4:67478861c670 102
JonFreeman 4:67478861c670 103 if (deltax >= deltay) { /* There is at least one x-value for every y-value */
JonFreeman 4:67478861c670 104 xinc1 = 0; /* Don't change the x when numerator >= denominator */
JonFreeman 4:67478861c670 105 yinc2 = 0; /* Don't change the y for every iteration */
JonFreeman 4:67478861c670 106 den = deltax;
JonFreeman 4:67478861c670 107 num = deltax / 2;
JonFreeman 4:67478861c670 108 num_add = deltay;
JonFreeman 4:67478861c670 109 num_pixels = deltax; /* There are more x-values than y-values */
JonFreeman 4:67478861c670 110 } else { /* There is at least one y-value for every x-value */
JonFreeman 4:67478861c670 111 xinc2 = 0; /* Don't change the x for every iteration */
JonFreeman 4:67478861c670 112 yinc1 = 0; /* Don't change the y when numerator >= denominator */
JonFreeman 4:67478861c670 113 den = deltay;
JonFreeman 4:67478861c670 114 num = deltay / 2;
JonFreeman 4:67478861c670 115 num_add = deltax;
JonFreeman 4:67478861c670 116 num_pixels = deltay; /* There are more y-values than x-values */
JonFreeman 4:67478861c670 117 }
JonFreeman 4:67478861c670 118
JonFreeman 4:67478861c670 119 for (curpixel = 0; curpixel <= num_pixels; curpixel++) {
JonFreeman 4:67478861c670 120 lcd.DrawLine(x, y, x3, y3);
JonFreeman 4:67478861c670 121
JonFreeman 4:67478861c670 122 num += num_add; /* Increase the numerator by the top of the fraction */
JonFreeman 4:67478861c670 123 if (num >= den) { /* Check if numerator >= denominator */
JonFreeman 4:67478861c670 124 num -= den; /* Calculate the new numerator value */
JonFreeman 4:67478861c670 125 x += xinc1; /* Change the x as appropriate */
JonFreeman 4:67478861c670 126 y += yinc1; /* Change the y as appropriate */
JonFreeman 4:67478861c670 127 }
JonFreeman 4:67478861c670 128 x += xinc2; /* Change the x as appropriate */
JonFreeman 4:67478861c670 129 y += yinc2; /* Change the y as appropriate */
JonFreeman 4:67478861c670 130 }
JonFreeman 4:67478861c670 131 }
JonFreeman 4:67478861c670 132
JonFreeman 4:67478861c670 133 double anglefix (double a) { // Ensures 0.0 <= angle <= + two PI
JonFreeman 4:67478861c670 134 while (a > PI) a -= 2.0 * PI;
JonFreeman 4:67478861c670 135 while (a < 0.0) a += 2.0 * PI;
JonFreeman 4:67478861c670 136 return a;
JonFreeman 4:67478861c670 137 }
JonFreeman 4:67478861c670 138
JonFreeman 4:67478861c670 139 class moving_coil_meter
JonFreeman 4:67478861c670 140 {
JonFreeman 4:67478861c670 141 int meter_radius, cent_x, cent_y, needle_len, scale_ticks,
JonFreeman 4:67478861c670 142 disc_colour, needle_colour, scale_colour, text_colour, body_colour, dec_places;
JonFreeman 4:67478861c670 143 double start_angle, end_angle, old_angle, value_min, value_max, rad_per_value, swept_angle, value_range;
JonFreeman 4:67478861c670 144 double Value; // This is the one that determines pointer angle
JonFreeman 4:67478861c670 145
JonFreeman 4:67478861c670 146 void DrawNeedle (double alpha, int colour) ;
JonFreeman 4:67478861c670 147 void DrawScaleGraduations(int colour) ;
JonFreeman 4:67478861c670 148 double get_pointer_angle (double value) ;
JonFreeman 4:67478861c670 149 int get_font () ;
JonFreeman 4:67478861c670 150
JonFreeman 4:67478861c670 151 public:
JonFreeman 4:67478861c670 152
JonFreeman 4:67478861c670 153 moving_coil_meter () { // constructor
JonFreeman 4:67478861c670 154 meter_radius = 100;
JonFreeman 4:67478861c670 155 value_min = -1.0;
JonFreeman 4:67478861c670 156 value_max = 1.0;
JonFreeman 4:67478861c670 157 cent_x = cent_y = 150;
JonFreeman 4:67478861c670 158 disc_colour = LCD_COLOR_BLACK;
JonFreeman 4:67478861c670 159 needle_colour = LCD_COLOR_WHITE;
JonFreeman 4:67478861c670 160 scale_colour = LCD_COLOR_MAGENTA;
JonFreeman 4:67478861c670 161 text_colour = LCD_COLOR_RED;
JonFreeman 4:67478861c670 162 body_colour = LCD_COLOR_CYAN;
JonFreeman 4:67478861c670 163 old_angle = 0.0;
JonFreeman 4:67478861c670 164 }
JonFreeman 4:67478861c670 165
JonFreeman 4:67478861c670 166 bool setup (int cx, int cy, int size, double lo, double hi, double start_ang, double end_ang, int scaleticks, char * units, int decimal_places) ;
JonFreeman 4:67478861c670 167 void set_colours (int bod_colour, int bgcol, int needlecol, int textcolour, int scalecol) ;
JonFreeman 4:67478861c670 168 void set_value (double v) ;
JonFreeman 4:67478861c670 169 } Voltmeter, Powermeter, Speedo; // 3 instances of moving coil meter graphic
JonFreeman 4:67478861c670 170
JonFreeman 4:67478861c670 171 void moving_coil_meter::set_colours (int bod_col, int bgcol, int needlecol, int textcol, int scalecol) {
JonFreeman 4:67478861c670 172 body_colour = bod_col;
JonFreeman 4:67478861c670 173 disc_colour = bgcol;
JonFreeman 4:67478861c670 174 needle_colour = needlecol;
JonFreeman 4:67478861c670 175 text_colour = textcol;
JonFreeman 4:67478861c670 176 scale_colour = scalecol;
JonFreeman 4:67478861c670 177 }
JonFreeman 4:67478861c670 178
JonFreeman 4:67478861c670 179 void moving_coil_meter::DrawNeedle (double alpha, int colour)
JonFreeman 4:67478861c670 180 {
JonFreeman 4:67478861c670 181 point pixpts[4];
JonFreeman 4:67478861c670 182 int save_colour, ssa, sca;
JonFreeman 4:67478861c670 183 alpha = anglefix (alpha);
JonFreeman 4:67478861c670 184 double shortln = (needle_len / 18.7),
JonFreeman 4:67478861c670 185 sina = jsin(alpha),
JonFreeman 4:67478861c670 186 cosa = jcos(alpha);
JonFreeman 4:67478861c670 187
JonFreeman 4:67478861c670 188 save_colour = lcd.GetTextColor ();
JonFreeman 4:67478861c670 189 ssa = (int)(shortln * sina);
JonFreeman 4:67478861c670 190 sca = (int)(shortln * cosa);
JonFreeman 4:67478861c670 191 old_angle = alpha;
JonFreeman 4:67478861c670 192 pixpts[0].x = cent_x - ssa;//(int)(shortln * sin(alpha));
JonFreeman 4:67478861c670 193 pixpts[0].y = cent_y - sca;//(int)(shortln * cos(alpha));
JonFreeman 4:67478861c670 194 pixpts[1].x = cent_x + (int)(needle_len * cosa);
JonFreeman 4:67478861c670 195 pixpts[1].y = cent_y - (int)(needle_len * sina); // - as increasing y is downwards
JonFreeman 4:67478861c670 196 pixpts[2].x = cent_x + ssa;//(int)(shortln * sin(alpha));
JonFreeman 4:67478861c670 197 pixpts[2].y = cent_y + sca;//(int)(shortln * cos(alpha));
JonFreeman 4:67478861c670 198 lcd.SetTextColor (colour);
JonFreeman 4:67478861c670 199 lcd.FillCircle (cent_x, cent_y, (int)(needle_len / 15.0));
JonFreeman 4:67478861c670 200 FillTriangle (pixpts[0].x, pixpts[1].x, pixpts[2].x, pixpts[0].y, pixpts[1].y, pixpts[2].y);
JonFreeman 4:67478861c670 201 lcd.SetTextColor (save_colour);
JonFreeman 4:67478861c670 202 }
JonFreeman 4:67478861c670 203
JonFreeman 4:67478861c670 204 void moving_coil_meter::DrawScaleGraduations (int colour)
JonFreeman 4:67478861c670 205 {
JonFreeman 4:67478861c670 206 int save_colour = lcd.GetTextColor ();
JonFreeman 4:67478861c670 207 int i, radius_inner = (int) meter_radius - 2, radius_outer = (int) (meter_radius * 0.9);
JonFreeman 4:67478861c670 208 double ang, cosang, sinang, angle_step;
JonFreeman 4:67478861c670 209 lcd.SetTextColor (colour);
JonFreeman 4:67478861c670 210 ang = start_angle;
JonFreeman 4:67478861c670 211 angle_step = (start_angle - end_angle) / scale_ticks;
JonFreeman 4:67478861c670 212 for (i = 0; i <= scale_ticks; i++) { //
JonFreeman 4:67478861c670 213 cosang = cos(ang);
JonFreeman 4:67478861c670 214 sinang = sin(ang);
JonFreeman 4:67478861c670 215 lcd.DrawLine (cent_x + radius_outer * cosang, cent_y - radius_outer * sinang, cent_x + radius_inner * cosang, cent_y - radius_inner * sinang);
JonFreeman 4:67478861c670 216 ang -= angle_step;
JonFreeman 4:67478861c670 217 }
JonFreeman 4:67478861c670 218 lcd.SetTextColor (save_colour);
JonFreeman 4:67478861c670 219 }
JonFreeman 4:67478861c670 220
JonFreeman 4:67478861c670 221 void displaytext (int x, int y, const int font, char * txt) ;
JonFreeman 4:67478861c670 222
JonFreeman 4:67478861c670 223 bool moving_coil_meter::setup (int cx, int cy, int size, double lo, double hi, double start_ang, double end_ang, int scaleticks, char * units, int decimal_places)
JonFreeman 4:67478861c670 224 {
JonFreeman 4:67478861c670 225 bool retval = true;
JonFreeman 4:67478861c670 226 int font, charwid, x_offset;
JonFreeman 4:67478861c670 227 if (size < meter_radius_min || size > meter_radius_max)
JonFreeman 4:67478861c670 228 return false;
JonFreeman 4:67478861c670 229 meter_radius = size;
JonFreeman 4:67478861c670 230 if (meter_radius > cx || meter_radius > cy)
JonFreeman 4:67478861c670 231 return false;
JonFreeman 4:67478861c670 232 int corner_rad = meter_radius / 6,
JonFreeman 4:67478861c670 233 screw_hole_offset = meter_radius * 92 / 100,
JonFreeman 4:67478861c670 234 screw_rad = meter_radius / 13;
JonFreeman 4:67478861c670 235 cent_x = cx;
JonFreeman 4:67478861c670 236 cent_y = cy;
JonFreeman 4:67478861c670 237
JonFreeman 4:67478861c670 238 start_angle = start_ang;
JonFreeman 4:67478861c670 239 end_angle = end_ang;
JonFreeman 4:67478861c670 240 value_min = lo;
JonFreeman 4:67478861c670 241 value_max = hi;
JonFreeman 4:67478861c670 242 scale_ticks = scaleticks;
JonFreeman 4:67478861c670 243 swept_angle = abs(start_angle - end_angle);
JonFreeman 4:67478861c670 244 value_range = (value_max - value_min);
JonFreeman 4:67478861c670 245 rad_per_value = swept_angle / value_range;
JonFreeman 4:67478861c670 246 dec_places = decimal_places;
JonFreeman 4:67478861c670 247
JonFreeman 4:67478861c670 248 needle_len = (int)(0.87 * (double)meter_radius);
JonFreeman 4:67478861c670 249 int oldcolour1 = lcd.GetTextColor ();
JonFreeman 4:67478861c670 250 int oldcolour2 = lcd.GetBackColor ();
JonFreeman 4:67478861c670 251 lcd.SetTextColor (body_colour);
JonFreeman 4:67478861c670 252 // Draw meter body as solid square with rounded corners, complete with mounting screw holes !
JonFreeman 4:67478861c670 253 lcd.FillRect (cent_x - meter_radius, cent_y - meter_radius - corner_rad, meter_radius * 2, corner_rad);
JonFreeman 4:67478861c670 254 lcd.FillRect (cent_x - meter_radius, cent_y + meter_radius, meter_radius * 2, corner_rad + 1);
JonFreeman 4:67478861c670 255 lcd.FillRect (cent_x - meter_radius - corner_rad, cent_y - meter_radius, 1 +(meter_radius + corner_rad) * 2, meter_radius * 2);
JonFreeman 4:67478861c670 256 lcd.FillCircle (cent_x - meter_radius, cent_y - meter_radius, corner_rad); // meter box has rounded corners
JonFreeman 4:67478861c670 257 lcd.FillCircle (cent_x - meter_radius, cent_y + meter_radius, corner_rad);
JonFreeman 4:67478861c670 258 lcd.FillCircle (cent_x + meter_radius, cent_y - meter_radius, corner_rad);
JonFreeman 4:67478861c670 259 lcd.FillCircle (cent_x + meter_radius, cent_y + meter_radius, corner_rad);
JonFreeman 4:67478861c670 260 lcd.SetTextColor (LCD_COLOR_DARKGRAY);
JonFreeman 4:67478861c670 261 lcd.FillCircle (cent_x - screw_hole_offset, cent_y - screw_hole_offset, screw_rad); // panel mounting screw holes near corners
JonFreeman 4:67478861c670 262 lcd.FillCircle (cent_x - screw_hole_offset, cent_y + screw_hole_offset, screw_rad);
JonFreeman 4:67478861c670 263 lcd.FillCircle (cent_x + screw_hole_offset, cent_y - screw_hole_offset, screw_rad);
JonFreeman 4:67478861c670 264 lcd.FillCircle (cent_x + screw_hole_offset, cent_y + screw_hole_offset, screw_rad);
JonFreeman 4:67478861c670 265 lcd.SetTextColor (disc_colour);
JonFreeman 4:67478861c670 266 lcd.FillCircle (cent_x, cent_y, meter_radius);
JonFreeman 4:67478861c670 267 DrawScaleGraduations (scale_colour); //drew the green trace around active needle-sweep angle
JonFreeman 4:67478861c670 268
JonFreeman 4:67478861c670 269 font = get_font ();
JonFreeman 4:67478861c670 270 charwid = char_widths[font];
JonFreeman 4:67478861c670 271 x_offset = charwid * strlen(units) / 2;
JonFreeman 4:67478861c670 272 lcd.SetTextColor (text_colour);
JonFreeman 4:67478861c670 273 lcd.SetBackColor (disc_colour);
JonFreeman 4:67478861c670 274 // displaytext (cent_x - x_offset, cent_y + (meter_radius * 7) / 19, font, units);
JonFreeman 4:67478861c670 275 displaytext (cent_x - x_offset, cent_y + (meter_radius * 6) / 19, font, units);
JonFreeman 4:67478861c670 276 lcd.SetBackColor (oldcolour2);
JonFreeman 4:67478861c670 277 lcd.SetTextColor (oldcolour1);
JonFreeman 4:67478861c670 278 return retval;
JonFreeman 4:67478861c670 279 }
JonFreeman 4:67478861c670 280
JonFreeman 4:67478861c670 281 int moving_coil_meter::get_font ()
JonFreeman 4:67478861c670 282 {
JonFreeman 4:67478861c670 283 int font = meter_radius - meter_radius_min;
JonFreeman 4:67478861c670 284 font /= 17;
JonFreeman 4:67478861c670 285 if (font > 4)
JonFreeman 4:67478861c670 286 font = 4;
JonFreeman 4:67478861c670 287 if (font < 2)
JonFreeman 4:67478861c670 288 font = 2;
JonFreeman 4:67478861c670 289 return font;
JonFreeman 4:67478861c670 290 }
JonFreeman 4:67478861c670 291
JonFreeman 4:67478861c670 292 double moving_coil_meter::get_pointer_angle (double v)
JonFreeman 4:67478861c670 293 {
JonFreeman 4:67478861c670 294 double vabvmin, retval;
JonFreeman 4:67478861c670 295 if (v < value_min) v = value_min;
JonFreeman 4:67478861c670 296 if (v > value_max) v = value_max;
JonFreeman 4:67478861c670 297 Value = v; // clipped copy of supplied value
JonFreeman 4:67478861c670 298 vabvmin = v - value_min;
JonFreeman 4:67478861c670 299 retval = start_angle - (vabvmin * rad_per_value);
JonFreeman 4:67478861c670 300 return anglefix (retval);
JonFreeman 4:67478861c670 301 }
JonFreeman 4:67478861c670 302
JonFreeman 4:67478861c670 303 void moving_coil_meter::set_value (double meter_read_value)
JonFreeman 4:67478861c670 304 {
JonFreeman 4:67478861c670 305 char txt[32];
JonFreeman 4:67478861c670 306 int x_offset, font, charwid, lenchk;//,
JonFreeman 4:67478861c670 307 DrawNeedle (old_angle, disc_colour); // un-draw needle
JonFreeman 4:67478861c670 308 DrawNeedle (get_pointer_angle (meter_read_value), needle_colour) ; // re-draw needle
JonFreeman 4:67478861c670 309 if (dec_places == ONE_DP)
JonFreeman 4:67478861c670 310 sprintf (txt, " %+.1f \0", meter_read_value);
JonFreeman 4:67478861c670 311 else
JonFreeman 4:67478861c670 312 sprintf (txt, " %+.0f \0", meter_read_value);
JonFreeman 4:67478861c670 313 lenchk = strlen(txt);
JonFreeman 4:67478861c670 314 font = get_font();
JonFreeman 4:67478861c670 315 charwid = char_widths[font];
JonFreeman 4:67478861c670 316 x_offset = charwid * lenchk / 2;
JonFreeman 4:67478861c670 317 lcd.SetTextColor (text_colour);
JonFreeman 4:67478861c670 318 lcd.SetBackColor (disc_colour);
JonFreeman 4:67478861c670 319 if (lenchk > 0 && lenchk < 9)
JonFreeman 4:67478861c670 320 displaytext (cent_x - x_offset, cent_y + (meter_radius * 11) / 19, font, txt);
JonFreeman 4:67478861c670 321 }
JonFreeman 4:67478861c670 322 //bool moving_coil_meter::setup (int cx, int cy, int size, double lo, double hi, double start_ang, double end_ang,
JonFreeman 4:67478861c670 323 // int scale_ticks, char * units)
JonFreeman 4:67478861c670 324 void vm_set () //x y size minv maxv min angle max angle,
JonFreeman 4:67478861c670 325 {
JonFreeman 4:67478861c670 326 Speedo.set_colours (SPEEDO_BODY_COLOUR, SPEEDO_DIAL_COLOUR, LCD_COLOR_RED, SPEEDO_TEXT_COLOUR, LCD_COLOR_BLACK);
JonFreeman 4:67478861c670 327 Speedo.setup (SPEEDO_X, SPEEDO_Y, SPEEDO_SIZE, 0.0, 12.0, 1.25 * PI, -0.25 * PI , 12, "MPH", ONE_DP);
JonFreeman 4:67478861c670 328 Voltmeter.set_colours (LCD_COLOR_BLACK, LCD_COLOR_WHITE, LCD_COLOR_RED, LCD_COLOR_BLUE, LCD_COLOR_MAGENTA);
JonFreeman 4:67478861c670 329 Voltmeter.setup (VOLTMETER_X, VOLTMETER_Y, V_A_SIZE, 22.0, 59.0, 1.25 * PI, -0.25 * PI , 30, "V", ONE_DP);
JonFreeman 4:67478861c670 330 Powermeter.set_colours (LCD_COLOR_BLACK, LCD_COLOR_WHITE, LCD_COLOR_RED, LCD_COLOR_BLUE, LCD_COLOR_BLUE);
JonFreeman 4:67478861c670 331 Powermeter.setup (AMMETER_X, AMMETER_Y, V_A_SIZE, -1400.0, 1400.0, 1.25 * PI, -0.25 * PI , 14, "Watt", NO_DPS);
JonFreeman 4:67478861c670 332 }
JonFreeman 4:67478861c670 333
JonFreeman 4:67478861c670 334 //void update_meters (double speed, double current, double voltage)
JonFreeman 4:67478861c670 335 void update_meters (double speed, double power, double voltage)
JonFreeman 4:67478861c670 336 {
JonFreeman 4:67478861c670 337 // Powermeter.set_value(voltage * current);
JonFreeman 4:67478861c670 338 Powermeter.set_value(power);
JonFreeman 4:67478861c670 339 Voltmeter.set_value (voltage);
JonFreeman 4:67478861c670 340 Speedo.set_value (speed);
JonFreeman 4:67478861c670 341 }
JonFreeman 4:67478861c670 342
JonFreeman 4:67478861c670 343
JonFreeman 4:67478861c670 344
JonFreeman 4:67478861c670 345 struct rect { struct point a, b; } ;
JonFreeman 4:67478861c670 346
JonFreeman 4:67478861c670 347 struct butt_on {
JonFreeman 4:67478861c670 348 struct rect area;
JonFreeman 4:67478861c670 349 int border_colour, body_colour;
JonFreeman 4:67478861c670 350 bool in_use, pressed;//, released;
JonFreeman 4:67478861c670 351 char txt1[12];
JonFreeman 4:67478861c670 352 char txt2[12];
JonFreeman 4:67478861c670 353 } ;
JonFreeman 4:67478861c670 354
JonFreeman 4:67478861c670 355 struct butt_on button[NUMOF_BUTTONS];
JonFreeman 4:67478861c670 356
JonFreeman 4:67478861c670 357 int get_button_press (struct point & pt) ;
JonFreeman 4:67478861c670 358 int get_but_p (int x, int y)
JonFreeman 4:67478861c670 359 {
JonFreeman 4:67478861c670 360 struct point p;
JonFreeman 4:67478861c670 361 p.x = x;
JonFreeman 4:67478861c670 362 p.y = y;
JonFreeman 4:67478861c670 363 return get_button_press (p);
JonFreeman 4:67478861c670 364 }
JonFreeman 4:67478861c670 365
JonFreeman 4:67478861c670 366
JonFreeman 4:67478861c670 367 void read_keypresses (struct ky_bd & a)
JonFreeman 4:67478861c670 368 {
JonFreeman 4:67478861c670 369 int x;
JonFreeman 4:67478861c670 370 a.count = 0;
JonFreeman 4:67478861c670 371 a.sli = false;
JonFreeman 4:67478861c670 372 for (x = 0; x < MAX_TOUCHES; x++)
JonFreeman 4:67478861c670 373 a.ky[x].keynum = -1;
JonFreeman 4:67478861c670 374 int touches, but;
JonFreeman 4:67478861c670 375 TS_StateTypeDef TS_State;
JonFreeman 4:67478861c670 376 touch_screen.GetState(&TS_State);
JonFreeman 4:67478861c670 377 touches = TS_State.touchDetected;
JonFreeman 4:67478861c670 378 for (int h = 0; h < touches; h++) {
JonFreeman 4:67478861c670 379 but = get_but_p (TS_State.touchX[h], TS_State.touchY[h]);
JonFreeman 4:67478861c670 380 if (but > - 1) {
JonFreeman 4:67478861c670 381 a.ky[a.count].keynum = but;
JonFreeman 4:67478861c670 382 a.ky[a.count].x = TS_State.touchX[h];
JonFreeman 4:67478861c670 383 a.ky[a.count].y = TS_State.touchY[h];
JonFreeman 4:67478861c670 384 if (but == SLIDER) {
JonFreeman 4:67478861c670 385 a.sli = true;
JonFreeman 4:67478861c670 386 a.slider_y = a.ky[a.count].y;
JonFreeman 4:67478861c670 387 }
JonFreeman 4:67478861c670 388 a.count++;
JonFreeman 4:67478861c670 389 }
JonFreeman 4:67478861c670 390 }
JonFreeman 4:67478861c670 391 }
JonFreeman 4:67478861c670 392
JonFreeman 4:67478861c670 393
JonFreeman 4:67478861c670 394 void displaytext (int x, int y, char * txt)
JonFreeman 4:67478861c670 395 {
JonFreeman 4:67478861c670 396 lcd.DisplayStringAt(x, y, (uint8_t *)txt, LEFT_MODE);
JonFreeman 4:67478861c670 397 }
JonFreeman 4:67478861c670 398
JonFreeman 4:67478861c670 399 void displaytext (int x, int y, const int font, char * txt)
JonFreeman 4:67478861c670 400 {
JonFreeman 4:67478861c670 401 sFONT * const fp[] = {&Font8, &Font12, &Font16, &Font20, &Font24};
JonFreeman 4:67478861c670 402 lcd.SetFont(fp[font]);
JonFreeman 4:67478861c670 403 displaytext (x, y, txt);
JonFreeman 4:67478861c670 404 }
JonFreeman 4:67478861c670 405
JonFreeman 4:67478861c670 406 void displaytext (int x, int y, const int font, uint32_t BCol, uint32_t TCol, char * txt)
JonFreeman 4:67478861c670 407 {
JonFreeman 4:67478861c670 408 uint32_t otc, obc;
JonFreeman 4:67478861c670 409 otc = lcd.GetTextColor();
JonFreeman 4:67478861c670 410 obc = lcd.GetBackColor();
JonFreeman 4:67478861c670 411 lcd.SetTextColor(TCol);
JonFreeman 4:67478861c670 412 lcd.SetBackColor(BCol);
JonFreeman 4:67478861c670 413 displaytext (x, y, font, txt);
JonFreeman 4:67478861c670 414 lcd.SetTextColor(otc);
JonFreeman 4:67478861c670 415 lcd.SetBackColor(obc);
JonFreeman 4:67478861c670 416 }
JonFreeman 4:67478861c670 417
JonFreeman 4:67478861c670 418 void draw_button (struct butt_on & bu)
JonFreeman 4:67478861c670 419 {
JonFreeman 4:67478861c670 420 int oldbgcolour;
JonFreeman 4:67478861c670 421 lcd.SetTextColor (bu.body_colour);
JonFreeman 4:67478861c670 422 lcd.FillRect(bu.area.a.x + 2, bu.area.a.y + 2, bu.area.b.x - bu.area.a.x - 2, bu.area.b.y - bu.area.a.y - 2); //, bu.body_colour);
JonFreeman 4:67478861c670 423 oldbgcolour = lcd.GetBackColor();
JonFreeman 4:67478861c670 424 lcd.SetBackColor(bu.body_colour);
JonFreeman 4:67478861c670 425 lcd.SetTextColor(LCD_COLOR_BLACK);
JonFreeman 4:67478861c670 426 if (strlen(bu.txt2) == 0) {
JonFreeman 4:67478861c670 427 displaytext (bu.area.a.x + 4, bu.area.a.y + 14, 4, bu.txt1); // largest font 4
JonFreeman 4:67478861c670 428 } else {
JonFreeman 4:67478861c670 429 displaytext (bu.area.a.x + 4, bu.area.a.y + 4, 3, bu.txt1); // not so large font 3
JonFreeman 4:67478861c670 430 displaytext (bu.area.a.x + 4, bu.area.a.y + 26, bu.txt2);
JonFreeman 4:67478861c670 431 }
JonFreeman 4:67478861c670 432 lcd.SetBackColor(LCD_COLOR_BLACK);
JonFreeman 4:67478861c670 433 lcd.SetTextColor(bu.border_colour);
JonFreeman 4:67478861c670 434 lcd.DrawRect(bu.area.a.x, bu.area.a.y, bu.area.b.x - bu.area.a.x, bu.area.b.y - bu.area.a.y); //, bu.border_colour);
JonFreeman 4:67478861c670 435 lcd.DrawRect(bu.area.a.x + 1, bu.area.a.y + 1, bu.area.b.x - bu.area.a.x - 1, bu.area.b.y - bu.area.a.y - 1); //, bu.border_colour);
JonFreeman 4:67478861c670 436 lcd.SetBackColor(oldbgcolour);
JonFreeman 4:67478861c670 437 }
JonFreeman 4:67478861c670 438
JonFreeman 4:67478861c670 439 void draw_button_hilight (int but, int colour)
JonFreeman 4:67478861c670 440 {
JonFreeman 4:67478861c670 441 if (but < 0 || but > NUMOF_BUTTONS) {
JonFreeman 4:67478861c670 442 pc.printf ("Button out of range in draw_button_hilight %d\r\n", but) ;
JonFreeman 4:67478861c670 443 } else {
JonFreeman 4:67478861c670 444 struct butt_on * bu = &button[but];
JonFreeman 4:67478861c670 445 int oldbgcolour = lcd.GetBackColor();//, minx, miny, maxx, maxy;
JonFreeman 4:67478861c670 446 lcd.SetTextColor(colour);
JonFreeman 4:67478861c670 447 lcd.DrawRect(bu->area.a.x - 1, bu->area.a.y - 1, bu->area.b.x - bu->area.a.x + 2, bu->area.b.y - bu->area.a.y + 2);
JonFreeman 4:67478861c670 448 lcd.DrawRect(bu->area.a.x - 2, bu->area.a.y - 2, bu->area.b.x - bu->area.a.x + 4, bu->area.b.y - bu->area.a.y + 4);
JonFreeman 4:67478861c670 449 lcd.DrawRect(bu->area.a.x - 2, bu->area.a.y - 3, bu->area.b.x - bu->area.a.x + 5, bu->area.b.y - bu->area.a.y + 6);
JonFreeman 4:67478861c670 450 lcd.SetBackColor(oldbgcolour);
JonFreeman 4:67478861c670 451 }
JonFreeman 4:67478861c670 452 }
JonFreeman 4:67478861c670 453
JonFreeman 4:67478861c670 454 void draw_button (struct butt_on & bu, int body_colour)
JonFreeman 4:67478861c670 455 {
JonFreeman 4:67478861c670 456 bu.body_colour = body_colour;
JonFreeman 4:67478861c670 457 draw_button (bu);
JonFreeman 4:67478861c670 458 }
JonFreeman 4:67478861c670 459
JonFreeman 4:67478861c670 460 void setup_button (struct butt_on & bu, int x1, int y1, int dx, int dy, int bord, int body, char * txt1, char * txt2)
JonFreeman 4:67478861c670 461 {
JonFreeman 4:67478861c670 462 static const int margin = 3;
JonFreeman 4:67478861c670 463 int xsize = lcd.GetXSize();
JonFreeman 4:67478861c670 464 int ysize = lcd.GetXSize();
JonFreeman 4:67478861c670 465 int x2 = x1 + dx, y2 = y1 + dy;
JonFreeman 4:67478861c670 466 if (x1 < margin) x1 = margin;
JonFreeman 4:67478861c670 467 if (y1 < margin) y1 = margin;
JonFreeman 4:67478861c670 468 if (x2 > xsize - margin) x2 = xsize - margin;
JonFreeman 4:67478861c670 469 if (y2 > ysize - margin) y2 = ysize - margin;
JonFreeman 4:67478861c670 470 bu.area.a.x = x1;
JonFreeman 4:67478861c670 471 bu.area.a.y = y1;
JonFreeman 4:67478861c670 472 bu.area.b.x = x2;
JonFreeman 4:67478861c670 473 bu.area.b.y = y2;
JonFreeman 4:67478861c670 474 bu.border_colour = bord;
JonFreeman 4:67478861c670 475 bu.body_colour = body;
JonFreeman 4:67478861c670 476 strcpy (bu.txt1, txt1);
JonFreeman 4:67478861c670 477 strcpy (bu.txt2, txt2);
JonFreeman 4:67478861c670 478 bu.in_use = true;
JonFreeman 4:67478861c670 479 bu.pressed = false;
JonFreeman 4:67478861c670 480 draw_button(bu);
JonFreeman 4:67478861c670 481 }
JonFreeman 4:67478861c670 482
JonFreeman 4:67478861c670 483 bool ifpressed (int key)
JonFreeman 4:67478861c670 484 {
JonFreeman 4:67478861c670 485 return button[key].pressed;
JonFreeman 4:67478861c670 486 }
JonFreeman 4:67478861c670 487
JonFreeman 4:67478861c670 488 bool is_button_pressed (struct point & pt, struct butt_on & bu)
JonFreeman 4:67478861c670 489 {
JonFreeman 4:67478861c670 490 if (bu.in_use) {
JonFreeman 4:67478861c670 491 if (bu.area.a.x < pt.x && bu.area.b.x > pt.x
JonFreeman 4:67478861c670 492 && bu.area.a.y < pt.y && bu.area.b.y > pt.y)
JonFreeman 4:67478861c670 493 return true;
JonFreeman 4:67478861c670 494 }
JonFreeman 4:67478861c670 495 return false;
JonFreeman 4:67478861c670 496 }
JonFreeman 4:67478861c670 497
JonFreeman 4:67478861c670 498 bool keyrelease (int key)
JonFreeman 4:67478861c670 499 {
JonFreeman 4:67478861c670 500 bool rv = false;
JonFreeman 4:67478861c670 501 if (button[key].pressed) {
JonFreeman 4:67478861c670 502 rv = true;
JonFreeman 4:67478861c670 503 button[key].pressed = false;
JonFreeman 4:67478861c670 504 }
JonFreeman 4:67478861c670 505 return rv;
JonFreeman 4:67478861c670 506 }
JonFreeman 4:67478861c670 507 void setpressed (int key, bool torf)
JonFreeman 4:67478861c670 508 {
JonFreeman 4:67478861c670 509 button[key].pressed = torf;
JonFreeman 4:67478861c670 510 }
JonFreeman 4:67478861c670 511 void setinuse (int key, bool torf)
JonFreeman 4:67478861c670 512 {
JonFreeman 4:67478861c670 513 button[key].in_use = torf;
JonFreeman 4:67478861c670 514 }
JonFreeman 4:67478861c670 515
JonFreeman 4:67478861c670 516
JonFreeman 4:67478861c670 517 int get_button_press (struct point & pt)
JonFreeman 4:67478861c670 518 {
JonFreeman 4:67478861c670 519 for (int j = 0; j < NUMOF_BUTTONS; j++)
JonFreeman 4:67478861c670 520 if (button[j].in_use && is_button_pressed (pt, button[j]))
JonFreeman 4:67478861c670 521 return j;
JonFreeman 4:67478861c670 522 return -1;
JonFreeman 4:67478861c670 523 }
JonFreeman 4:67478861c670 524
JonFreeman 4:67478861c670 525 void setup_buttons ()
JonFreeman 4:67478861c670 526 {
JonFreeman 4:67478861c670 527 setup_button (button[SPEEDO_BUT],
JonFreeman 4:67478861c670 528 SPEEDO_X - SPEEDO_SIZE, SPEEDO_Y - SPEEDO_SIZE,
JonFreeman 4:67478861c670 529 SPEEDO_SIZE * 2, SPEEDO_SIZE * 2, SPEEDO_BODY_COLOUR, LCD_COLOR_RED, " X", "") ;
JonFreeman 4:67478861c670 530 setup_button (button[VMETER_BUT],
JonFreeman 4:67478861c670 531 VOLTMETER_X - V_A_SIZE, VOLTMETER_Y - V_A_SIZE, V_A_SIZE * 2, V_A_SIZE * 2, VMETER_BODY_COLOUR, LCD_COLOR_RED, " Y", "") ;
JonFreeman 4:67478861c670 532 setup_button (button[AMETER_BUT],
JonFreeman 4:67478861c670 533 AMMETER_X - V_A_SIZE, AMMETER_Y - V_A_SIZE, V_A_SIZE * 2, V_A_SIZE * 2, AMETER_BODY_COLOUR, LCD_COLOR_RED, " Z", "") ;
JonFreeman 4:67478861c670 534 setup_button (button[SLIDER], SLIDERX, SLIDERY, SLIDERW, SLIDERH, LCD_COLOR_BLUE, LCD_COLOR_MAGENTA, "", "") ;
JonFreeman 4:67478861c670 535 }
JonFreeman 4:67478861c670 536
JonFreeman 4:67478861c670 537
JonFreeman 4:67478861c670 538 void SliderGraphic (struct slide & q) {
JonFreeman 4:67478861c670 539 int
JonFreeman 4:67478861c670 540 colr,
JonFreeman 4:67478861c670 541 oldbgcolr = lcd.GetBackColor (),
JonFreeman 4:67478861c670 542 oldtxtcolr = lcd.GetTextColor ();
JonFreeman 4:67478861c670 543 char txt[4];
JonFreeman 4:67478861c670 544 txt[1] = 0;
JonFreeman 4:67478861c670 545 if (q.position > MAX_POS)
JonFreeman 4:67478861c670 546 q.position = MAX_POS;
JonFreeman 4:67478861c670 547 if (q.position < MIN_POS)
JonFreeman 4:67478861c670 548 q.position = MIN_POS;
JonFreeman 4:67478861c670 549 if (q.position == NEUTRAL_VAL)
JonFreeman 4:67478861c670 550 q.state = NEUTRAL_DRIFT;
JonFreeman 4:67478861c670 551 if (q.position > NEUTRAL_VAL)
JonFreeman 4:67478861c670 552 q.state = REGEN_BRAKE;
JonFreeman 4:67478861c670 553 if (q.position < NEUTRAL_VAL)
JonFreeman 4:67478861c670 554 if (q.state == REGEN_BRAKE) { // Ensure transition from BRAKE to RUN passes through NEUTRAL
JonFreeman 4:67478861c670 555 q.position = NEUTRAL_VAL;
JonFreeman 4:67478861c670 556 q.state = NEUTRAL_DRIFT;
JonFreeman 4:67478861c670 557 }
JonFreeman 4:67478861c670 558 else
JonFreeman 4:67478861c670 559 q.state = RUN;
JonFreeman 4:67478861c670 560 if (q.position == MAX_POS) {
JonFreeman 4:67478861c670 561 if (q.loco_speed < LOCO_HANDBRAKE_ESCAPE_SPEED)
JonFreeman 4:67478861c670 562 q.state = PARK;
JonFreeman 4:67478861c670 563 else {
JonFreeman 4:67478861c670 564 q.state = REGEN_BRAKE;
JonFreeman 4:67478861c670 565 q.position--;
JonFreeman 4:67478861c670 566 }
JonFreeman 4:67478861c670 567 }
JonFreeman 4:67478861c670 568 if (q.position != q.oldpos) {
JonFreeman 4:67478861c670 569 // Draw slider background colour rectangle overwriting previous circles
JonFreeman 4:67478861c670 570 // Redraw black vertical
JonFreeman 4:67478861c670 571 // Draw new circles
JonFreeman 4:67478861c670 572 // Write text char
JonFreeman 4:67478861c670 573 lcd.SetTextColor(LCD_COLOR_MAGENTA);
JonFreeman 4:67478861c670 574 lcd.FillRect (SLIDERX + 1, q.oldpos - BUTTON_RAD, SLIDERW - 2, SLIDERW);
JonFreeman 4:67478861c670 575 lcd.SetTextColor(LCD_COLOR_BLACK);
JonFreeman 4:67478861c670 576 lcd.FillRect (SLIDERX + (SLIDERW / 2) - 3, 6, 7, SLIDERH - 8);
JonFreeman 4:67478861c670 577 q.oldpos = q.position;
JonFreeman 4:67478861c670 578 lcd.SetTextColor(LCD_COLOR_WHITE);
JonFreeman 4:67478861c670 579 lcd.DrawCircle (CIRC_CTR, q.position, BUTTON_RAD); // seel also FillCircle
JonFreeman 4:67478861c670 580 lcd.DrawCircle (CIRC_CTR, q.position, BUTTON_RAD - 1);
JonFreeman 4:67478861c670 581 switch (q.state) {
JonFreeman 4:67478861c670 582 case RUN:
JonFreeman 4:67478861c670 583 txt[0] = 'R';
JonFreeman 4:67478861c670 584 colr = LCD_COLOR_GREEN;
JonFreeman 4:67478861c670 585 break;
JonFreeman 4:67478861c670 586 case NEUTRAL_DRIFT:
JonFreeman 4:67478861c670 587 txt[0] = 'N';
JonFreeman 4:67478861c670 588 colr = LCD_COLOR_BLUE;
JonFreeman 4:67478861c670 589 break;
JonFreeman 4:67478861c670 590 case REGEN_BRAKE:
JonFreeman 4:67478861c670 591 txt[0] = 'B';
JonFreeman 4:67478861c670 592 colr = LCD_COLOR_ORANGE;
JonFreeman 4:67478861c670 593 break;
JonFreeman 4:67478861c670 594 case PARK:
JonFreeman 4:67478861c670 595 txt[0] = 'P';
JonFreeman 4:67478861c670 596 colr = LCD_COLOR_RED;
JonFreeman 4:67478861c670 597 break;
JonFreeman 4:67478861c670 598 default:
JonFreeman 4:67478861c670 599 txt[0] = 'X';
JonFreeman 4:67478861c670 600 colr = LCD_COLOR_CYAN;
JonFreeman 4:67478861c670 601 } // End of switch
JonFreeman 4:67478861c670 602 lcd.SetTextColor(colr);
JonFreeman 4:67478861c670 603 lcd.FillCircle (CIRC_CTR, q.position, BUTTON_RAD - 2);
JonFreeman 4:67478861c670 604 lcd.SetBackColor (colr);
JonFreeman 4:67478861c670 605 lcd.SetTextColor(LCD_COLOR_YELLOW);
JonFreeman 4:67478861c670 606 displaytext(SLIDERX + 17, q.position - 10, 4, txt); // largest font
JonFreeman 4:67478861c670 607 lcd.SetBackColor (LCD_COLOR_BLACK);
JonFreeman 4:67478861c670 608 } // End of else
JonFreeman 4:67478861c670 609 lcd.SetTextColor (oldtxtcolr);
JonFreeman 4:67478861c670 610 lcd.SetBackColor (oldbgcolr);
JonFreeman 4:67478861c670 611 // pc.printf ("SliderG %d, %d, %d\r\n", q.position, q.oldpos, q.state);
JonFreeman 4:67478861c670 612 }
JonFreeman 4:67478861c670 613
JonFreeman 4:67478861c670 614
JonFreeman 4:67478861c670 615
JonFreeman 4:67478861c670 616