BioSignalPi  v2
pifacecontrolandview.cpp
Go to the documentation of this file.
1 #include "pifacecontrolandview.h"
2 #include "pifacecad.h"
3 #include <chrono>
4 #include <thread>
5 #include "abstractmenu.h"
6 #include "basemenu.h"
7 
8 
9 
10 
11 
13  QObject(parent)
14 {
15 
16 }
17 
19 
20 }
21 
23 {
24  pifacecad_open();
25  pifacecad_lcd_backlight_on();
26  pifacecad_lcd_write("Chose option");
27  AbstractMenu* currentMenu=new BaseMenu();
28  currentMenu->next();
29 
30  while(true){
31  if(!pifacecad_read_switch(7)){
32  currentMenu->next();
33  }else if(!pifacecad_read_switch(5)){
34  AbstractMenu* tempMenu;
35  tempMenu=currentMenu->newMenu();
36  if (tempMenu){
37  delete currentMenu;
38  currentMenu=tempMenu;
39  }
40  else
41  delete tempMenu;
42  currentMenu->setLowerText();
43 
44  }else if(!pifacecad_read_switch(4))
45  break;
46 
47 
48  std::this_thread::sleep_for(std::chrono::milliseconds(300)); // IMPORTANT if not using this time-out the read_switch fucntion would read a push more then once.
49  }
50  pifacecad_lcd_clear();
51  pifacecad_lcd_home();
52  delete currentMenu;
53  pifacecad_lcd_write("QUIT");
54  pifacecad_close();
55 
56  emit finished();
57 }
PiFaceControlAndView(QObject *parent=0)
void run()
Main eventloop.
virtual void setLowerText()
Sets the second row of the PiFace CAD to the current option choosen Uses the C library pifacecad...
Homepage of the Menu-system for the PiFace GUI.
Definition: basemenu.h:9
void finished()
Emits when it wants to be terminated.
Abstract menu object for PiFace CAD.
Definition: abstractmenu.h:17
virtual AbstractMenu * newMenu()=0
Pure virtual function, creates the next Menu object Pure virtual function, that is meant to create a ...
virtual void next()
Toggles the second row of the PiFace CAD to the next option Uses the C library pifacecad.h to control the display.