Electric Locomotive control system. Touch screen driver control, includes regenerative braking, drives 4 brushless motors, displays speed MPH, system volts and power
Dependencies: BSP_DISCO_F746NG FastPWM LCD_DISCO_F746NG SD_DISCO_F746NG TS_DISCO_F746NG mbed
Diff: dro.h
- Revision:
- 1:8ef34deb5177
- Parent:
- 0:23cc72b18e74
--- a/dro.h Sun Nov 12 06:26:29 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* Updated 12 Nov 2017 - Jon Freeman - - 5" and 7.25" gauge Electric Locomotive Controller - ST DISCO-F746NG -Uses built in display and touch screen. - -Display shows 'analogue' moving coil meter movements for : - Locomotive speed Miles per Hour - System voltage (range 20v - 90v or thereabouts) - Power Watts delivered to drive motors. - -Touch screen has three 'buttons', these are currently unused, and are where the meter movements show. -Idea is to use two for two horns, - -Display has 'slider' touch control. This drives the loco. -Control in central position when not driving or drfting. -Moving towards bottom of screen applies regenerative braking - move further down applies harder braking. -Moving towards top of screen powers drive motors, move further up applies more torque (current controller implemented) -Take finger off and control drifts down to central 'neutral' position. -*/ -#define MAX_TOUCHES 6 // Touch screen can decode up to this many simultaneous finger press positions -#define NEUTRAL_VAL 150 // Number of pixels - -#define SLIDERX 418 // slider graphic x position -#define SLIDERY 2 // slider graphic y position -#define SLIDERW 50 // pixel width of slider -#define SLIDERH 268 // pixel height of slider -const int -BUTTON_RAD = (SLIDERW / 2) - 4, // radius of circular 'knob' in slider control -MIN_POS = BUTTON_RAD + 5, // top of screen -MAX_POS = SLIDERH - (BUTTON_RAD + 1), // bottom of screen -CIRC_CTR = SLIDERX + BUTTON_RAD + 4; - -static const double PI = 4.0 * atan(1.0); -const double LOCO_HANDBRAKE_ESCAPE_SPEED = 0.5; - -enum {NO_DPS, ONE_DP}; -// Assign unique number to every button we may use, and keep count of total number of them -enum { - ENTER, SLIDER, SPEEDO_BUT, VMETER_BUT, AMETER_BUT, - NUMOF_BUTTONS} ; // button names -enum { - STATES, INACTIVE, RUN, NEUTRAL_DRIFT, REGEN_BRAKE, PARK, HANDBRAKE_SLIPPING}; - -struct slide { int position; int oldpos; int state; int direction; bool recalc_run; bool handbrake_slipping; - double handbrake_effort; double loco_speed; } ; -struct point { int x; int y; } ; -//struct rect { struct point a, b; } ; -struct key { int keynum; int x; int y; bool pressed; } ; -struct ky_bd { int count, slider_y; key ky[MAX_TOUCHES + 1]; bool sli; } ; -