My final year project
Dependencies: BSP_DISCO_F746NG F746_GUI LCD_DISCO_F746NG SDFileSystem TS_DISCO_F746NG ResistiveTouchController Map CYS8218Controller MedianFilter
Screens/AutomaticControlScreen.cpp
- Committer:
- Kerneels Bezuidenhout
- Date:
- 2016-10-02
- Revision:
- 19:ef78ac1a98f8
- Parent:
- 18:1b9579ac9f41
- Child:
- 20:70c5b1e499f0
File content as of revision 19:ef78ac1a98f8:
#include "AutomaticControlScreen.hpp" AutomaticControlScreen::AutomaticControlScreen(int *nextScreen, float *xPos, float *yPos, int *Ts, bool *started, int *ballOnPlate, float *xSP, float *ySP) : Screen(), _lbTitle( SCREEN_W/2, 0, "Automatic", Label::CENTER, Font24), _btBack( 0, SCREEN_H-30, 100, 30, "Back"), _btSettings(SCREEN_W-100, SCREEN_H-30, 100, 30, "Settings"), _btStart(0, SCREEN_H-65, SCREEN_W, 30, "Start"), //TODO Custom colors and disabled featrure _btStop(0, SCREEN_H-65, SCREEN_W, 30, "Start"), //TODO Custom colors _btMore((SCREEN_W/2)-50, SCREEN_H-30, 100, 30, "More"), _nlbTs( SCREEN_W/2, 26, "Cycle Time (us):%d", *Ts, Label::CENTER), _gXPos( 0, 40, SCREEN_W/2-1, 158, -170, 170, "X Position (mm)"), _gYPos( SCREEN_W/2+1, 40, SCREEN_W/2-1, 158, -136, 136, "Y Position (mm)") { _nextScreen = nextScreen; _xPos = xPos; _yPos = yPos; _Ts = Ts; _started = started; _xSP = xSP; _ySP = ySP; } void AutomaticControlScreen::Draw() { Clear(); _lbTitle.Draw(); _btBack.Draw(); _btSettings.Draw(); _btStart.Inactivate(); _btStart.Draw(); _btMore.Draw(); _nlbTs.Draw(); _gXPos.Draw(); _gYPos.Draw(); } void AutomaticControlScreen::Process() { if( _btBack.Touched() ) { *_nextScreen = MAIN_MENU_SCREEN; // TODO Add safety logic } if( _btSettings.Touched() ) { //TODO Add AutomaticSettingsScreen } if( _btMore.Touched() ) { *_nextScreen = AUTOMATIC_MORE_SCREEN; //TODO Ensure control system is not active } if( !_btStart.IsActive() ) { if( _ballOnPlate() ) _btStart.Activate(); } else { if( _ballOnPlate() ) { if( _btStart.Touched() ) { } } else { _btStart.Inactivate(); } } //TODO Add stop logic if( *_started && *_ballOnPlate ) { _gXPos.Insert(*_xPos); _gXPos.Update(); if( *_xSP != 0 ) _gXPos.HLine(*_xSP); _gYPos.Insert(*_yPos); _gYPos.Update(); if( *_ySP != 0 ) _gYPos.HLine(*_ySP); _nlbTs.Draw("Cycle Time (us):%d", *_Ts); } }