Cornelius Bezuidenhout / Mbed OS Heiko

Dependencies:   BSP_DISCO_F746NG F746_GUI LCD_DISCO_F746NG SDFileSystem TS_DISCO_F746NG ResistiveTouchController Map CYS8218Controller MedianFilter

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CalibrateScreen.cpp Source File

CalibrateScreen.cpp

00001 #include "CalibrateScreen.hpp"
00002 
00003 CalibrateScreen::CalibrateScreen(int *nextScreen, int *ballOnPlate, bool *calStarted, bool *calFinished, int *calPoint, float *calHeldTime) :
00004   Screen(),
00005   _lbTitle( SCREEN_W/2, 0, "Calibrate", Label::CENTER, Font24),
00006   _btBack( 0, SCREEN_H-30, 100, 30, "Back"),
00007   _lbMessage( SCREEN_W/2, SCREEN_H/2-10, "Please remove ball from plate", Label::CENTER, Font20)
00008 {
00009   _nextScreen = nextScreen;
00010   _ballOnPlate = ballOnPlate;
00011   _calStarted = calStarted;
00012   _calHeldTime = calHeldTime;
00013   _calPoint = calPoint;
00014   _calFinished = calFinished;
00015 }
00016 
00017 void CalibrateScreen::Draw()
00018 {
00019   Clear();
00020 
00021   _lbTitle.Draw();
00022   _btBack.Draw();
00023 
00024   DisplayMessage();
00025 }
00026 
00027 void CalibrateScreen::Process()
00028 {
00029   if( _btBack.Touched() )
00030   {
00031     *_calFinished = false;
00032     *_calStarted = false;
00033     *_calPoint = 0;
00034     *_nextScreen = MAIN_SETTINGS_SCREEN;
00035   }
00036 
00037   DisplayMessage();
00038 }
00039 
00040 void CalibrateScreen::DisplayMessage()
00041 {
00042   if( *_calStarted)
00043   {
00044     if( *_ballOnPlate )
00045     {
00046       float _tempHeldTime = 5;
00047       _tempHeldTime -= *_calHeldTime;
00048 
00049       if( _tempHeldTime <= 0 )
00050       {
00051         sprintf(_message, "Release");
00052       }
00053       else
00054       {
00055         sprintf(_message, "%.0f", _tempHeldTime);
00056       }
00057     }
00058     else
00059     {
00060       sprintf(_message, "Touch and hold position %d", *_calPoint+1);
00061     }
00062   }
00063   else
00064   {
00065     if( *_ballOnPlate && !*_calFinished)
00066     {
00067       sprintf(_message, "Please remove ball from plate");
00068     }
00069     else
00070     {
00071       if( *_calFinished )
00072       {
00073           sprintf(_message, "Calibration Done");
00074       }
00075       else
00076       {
00077           *_calStarted = true;
00078       }
00079     }
00080   }
00081 
00082   _lbMessage.Draw(_message);
00083 }