Cornelius Bezuidenhout / Mbed OS Heiko

Dependencies:   BSP_DISCO_F746NG F746_GUI LCD_DISCO_F746NG SDFileSystem TS_DISCO_F746NG ResistiveTouchController Map CYS8218Controller MedianFilter

Revision:
14:5beb6b4850b7
Child:
15:bc63b55a426d
diff -r 21dc070a47a9 -r 5beb6b4850b7 Screens/AutomaticControlScreen.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Screens/AutomaticControlScreen.cpp	Sun Oct 02 11:41:46 2016 +0200
@@ -0,0 +1,82 @@
+#include "ManualControlScreen.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, 31, SCREEN_W/2,  167, -170, 170, "X Position (mm)"),
+  _gYPos( SCREEN_W/2+1, 31, SCREEN_W/2-1,  167, -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(int *nextScreen, float *xPos, float *yPos, int *Ts, bool *started, int *ballOnPlate, float *xSP, float *ySp)
+{
+  if( _btBack.Touched() )
+  {
+    *_nextScreen = MAIN_MENU_SCREEN;
+    // TODO Add safety logic
+  }
+
+  if( _btSettings.Touched() )
+  {
+    //TODO Add AutomaticSettingsScreen
+  }
+
+  if( _btMore.Touched() )
+  {
+    //TODO Add AutomaticMoreScreen
+  }
+
+  if( _btStart.Touched() )
+  {
+    //TODO Add Start logic
+  }
+
+  if( _btStop.Touched() )
+  {
+    //TODO Add stop logic
+  }
+
+  if( *_started && *_ballOnPlate )
+  {
+    _gXPos.Insert(*_xPos);
+    _gXPos.Update();
+
+    if( *_xSP != 0 )
+      _gXPos.HLine(*_xSP);
+
+    _gYPos.Inser(*_yPos);
+    _gYPos.Update();
+
+    if( *_ySP != 0 )
+      _gYPos.HLine(*_ySP);
+
+  }
+
+}