Touch screen drivers control dashboard for miniature locomotive. Features meters for speed, volts, power. Switches for lights, horns. Drives multiple STM3_ESC brushless motor controllers for complete brushless loco system as used in "The Brute" - www.jons-workshop.com

Dependencies:   TS_DISCO_F746NG mbed Servo LCD_DISCO_F746NG BSP_DISCO_F746NG QSPI_DISCO_F746NG AsyncSerial FastPWM

Committer:
JonFreeman
Date:
Mon Jan 14 16:39:41 2019 +0000
Revision:
12:a25bdf135348
Tidied, better documented, more OOP, interim release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JonFreeman 12:a25bdf135348 1 #ifndef JON_FREEMAN_MOVING_COIL_METER
JonFreeman 12:a25bdf135348 2 #define JON_FREEMAN_MOVING_COIL_METER
JonFreeman 12:a25bdf135348 3 #include "mbed.h"
JonFreeman 12:a25bdf135348 4
JonFreeman 12:a25bdf135348 5 /**
JonFreeman 12:a25bdf135348 6 class moving_coil_meter
JonFreeman 12:a25bdf135348 7 Create moving coil meter graphic using STM32F746G-DISCO.
JonFreeman 12:a25bdf135348 8 Usage example :
JonFreeman 12:a25bdf135348 9
JonFreeman 12:a25bdf135348 10 top line of constructor :
JonFreeman 12:a25bdf135348 11 moving_coil_meter::moving_coil_meter ( int bod_col, int bgcol, int needlecol, int textcol, int scalecol,
JonFreeman 12:a25bdf135348 12 int cx, int cy, int size, double lo, double hi, double start_ang, double end_ang,
JonFreeman 12:a25bdf135348 13 int scaleticks, char * units, int decimal_places, bool sign)
JonFreeman 12:a25bdf135348 14
JonFreeman 12:a25bdf135348 15 moving_coil_meter Voltmeter ( LCD_COLOR_BLACK, // Frame / body colour
JonFreeman 12:a25bdf135348 16 LCD_COLOR_WHITE, // Dial face colour
JonFreeman 12:a25bdf135348 17 LCD_COLOR_RED, // Moving needle colour
JonFreeman 12:a25bdf135348 18 LCD_COLOR_BLUE, // Text colour for Units e.g. 'V' and e.g. '32.7'
JonFreeman 12:a25bdf135348 19 LCD_COLOR_MAGENTA, // Scale graduations colour
JonFreeman 12:a25bdf135348 20 VOLTMETER_X, // X co-ord, centre of meter
JonFreeman 12:a25bdf135348 21 VOLTMETER_Y, // Y co-ord, centre of meter
JonFreeman 12:a25bdf135348 22 V_A_SIZE, // Meter is square with rounded corners. This is meter dial face radius
JonFreeman 12:a25bdf135348 23 22.0, // Scale not limited to e.g. 0 to 10. This is reading at anti-clock limit
JonFreeman 12:a25bdf135348 24 59.0, // This is reading at full scale deflection
JonFreeman 12:a25bdf135348 25 1.25 * PI, // Angle of needle at anti-clockwise limit
JonFreeman 12:a25bdf135348 26 -0.25 * PI , // Angle of needle at full scale deflection (clockwise max)
JonFreeman 12:a25bdf135348 27 30, // Number of scale graduation marks drwan
JonFreeman 12:a25bdf135348 28 "V", // Text for Units, e.g. 'V' or 'MPH'
JonFreeman 12:a25bdf135348 29 ONE_DP, // NO_DPS or ONE_DP - supports only no decimal places or one
JonFreeman 12:a25bdf135348 30 false) ; // true to show '+' or '-', false to supress sign display
JonFreeman 12:a25bdf135348 31
JonFreeman 12:a25bdf135348 32 */
JonFreeman 12:a25bdf135348 33 class moving_coil_meter
JonFreeman 12:a25bdf135348 34 {
JonFreeman 12:a25bdf135348 35 int meter_radius, cent_x, cent_y, needle_len, scale_ticks,
JonFreeman 12:a25bdf135348 36 disc_colour, needle_colour, scale_colour, text_colour, body_colour, dec_places;
JonFreeman 12:a25bdf135348 37 int corner_rad, // = (meter_radius / 6),
JonFreeman 12:a25bdf135348 38 screw_hole_offset, // = (meter_radius * 92 / 100),
JonFreeman 12:a25bdf135348 39 screw_rad ; // = (meter_radius / 13);
JonFreeman 12:a25bdf135348 40 char unit_txt[8];
JonFreeman 12:a25bdf135348 41 double start_angle, end_angle, old_angle, value_min, value_max, swept_angle, value_range;
JonFreeman 12:a25bdf135348 42 bool draw_sign;
JonFreeman 12:a25bdf135348 43
JonFreeman 12:a25bdf135348 44 void DrawNeedle (double alpha, int colour) ;
JonFreeman 12:a25bdf135348 45 double get_pointer_angle (double value) ;
JonFreeman 12:a25bdf135348 46 int get_font_size () ;
JonFreeman 12:a25bdf135348 47
JonFreeman 12:a25bdf135348 48 public:
JonFreeman 12:a25bdf135348 49 moving_coil_meter () {} ;// default constructor
JonFreeman 12:a25bdf135348 50 moving_coil_meter (int, int, int, int, int, int, int, int, double, double, double, double, int, char *, int, bool) ;
JonFreeman 12:a25bdf135348 51 void set_value (double v) ;
JonFreeman 12:a25bdf135348 52 void redraw () ;
JonFreeman 12:a25bdf135348 53 void LED (int, int) ;
JonFreeman 12:a25bdf135348 54 } ;
JonFreeman 12:a25bdf135348 55
JonFreeman 12:a25bdf135348 56 #endif