Projekt

Allgemein

Profil

Eval » Historie » Version 27

Maximilian Seesslen, 24.08.2022 14:07

1 1 Maximilian Seesslen
h1. Eval
2
3
h2. Widgets
4
5 3 Maximilian Seesslen
There is a ODesktop that holds a list of OScreens (or only the curent).
6 1 Maximilian Seesslen
There is a OScreen that holds a list of OWidgets.
7
When the touch is pressed, the corresponding button can be determined.
8
An signal can be emmited.
9
An press-event can be queued, An release-event can be queued. An click-event can be queued if current button matches original pressed button.
10
11
* OButton::draw(): completely draws the widget
12
* OButton::update(): only draw status-relevant items, e.g. pressed, released, time changed...
13
14 2 Maximilian Seesslen
All screens can be prepared at start.
15 1 Maximilian Seesslen
A Screen can be active or inactive.
16 3 Maximilian Seesslen
17 12 Maximilian Seesslen
Only one screen is active plus an navigation-screen?
18
19 3 Maximilian Seesslen
h2. Touch
20
21 16 Maximilian Seesslen
There is an touch class that helps converting raw values to X-Y-coordinates. [[Biwak:touch]]
22 17 Maximilian Seesslen
CTouch will emit signals "pressed, released, clicked" that can be connected to libocelli.
23 2 Maximilian Seesslen
24 1 Maximilian Seesslen
h2. Watch
25
26 5 Maximilian Seesslen
* the OWatch class shows an clock with specific style, analog or digital
27 1 Maximilian Seesslen
28 6 Maximilian Seesslen
h2. Example: Minutnik
29 1 Maximilian Seesslen
30
* Main screen; CWatch, Add-Button
31
* Add-Screen
32
** Espresso, Weisswurst, Weiches Ei, Hartes Ei, Nudeln, Pizza, Waschmaschine, Cancel; Height 32
33
* Alarm Screen
34
* Logo, Splash screen at boot time and stand-by-screen
35 7 Maximilian Seesslen
* Release v2.0.0: Mode-Screen: Minutnik, Clock, StopWatch
36 6 Maximilian Seesslen
37 7 Maximilian Seesslen
h2. Example: CANDis
38 1 Maximilian Seesslen
39 7 Maximilian Seesslen
* Main screen
40 10 Maximilian Seesslen
** Button for Light, Sensemux-Diagram, Activity (TV, Musik, Solder, Off), Miniminutnik
41 7 Maximilian Seesslen
** Header with Clock
42 8 Maximilian Seesslen
* Light-Screen
43
** Power-Widget
44
** Ok-Button
45 7 Maximilian Seesslen
* Clock-Screen (Screen saver)
46 9 Maximilian Seesslen
** Clock, Date, Temperature, Quick-Access-Buttons
47 18 Maximilian Seesslen
48
h2. Pointers
49
50
Like in Qt an widget has an parent.
51
52
h2. Single App class vs. Screens
53
54 27 Maximilian Seesslen
Having everything in an single class may be confusing. It should be splited to per-Screen-classes. The screens have access to the app.
55 19 Maximilian Seesslen
<pre><code class="cpp">
56 18 Maximilian Seesslen
57 25 Maximilian Seesslen
class OWidget
58
{
59
   static GDisplay *m_display;
60
   public:
61
   CSignal signalClicked();
62
63
   virtual pressed(int x, int y);
64
   virtual released(int x, int y);
65
   virtual clicked(int x, int y);
66
}
67
68
OWidget::m_display=nullptr;
69
70 24 Maximilian Seesslen
class OScreen
71
{
72
      CColor background;
73 25 Maximilian Seesslen
      CList <OWidget *>m_widgets;
74 1 Maximilian Seesslen
   public:
75 25 Maximilian Seesslen
      virtual clicked(int x,int y)
76
      {
77
         OWidget *widget=getWidget(x,y);
78
         if(widget)
79
             widget->clicked( x, y);
80
      }
81 22 Maximilian Seesslen
}
82
83
class Ocelli
84
{
85 26 Maximilian Seesslen
   private:
86 22 Maximilian Seesslen
      OScreen *currentScreen;
87
      OScreen *previousScreen;
88 26 Maximilian Seesslen
      bool m_darkened=false;
89
90 1 Maximilian Seesslen
   public:
91 25 Maximilian Seesslen
      Ocelli(CGDisplay &display, CTouch &touch)
92
      {
93
         OWidget::m_pDisplay=&display;
94 27 Maximilian Seesslen
         touch.signalClicked.connect( this, Ocelli::clicked );
95 25 Maximilian Seesslen
      }
96 18 Maximilian Seesslen
      setCurrentScreen(OScreen *screen);
97 1 Maximilian Seesslen
      setPreviousScreen();
98 25 Maximilian Seesslen
      clicked( int x, int y)
99
      {
100
         if(currentScreen)
101
         {
102
            currentScreen->clicked( x, y);
103
         }
104
      }
105 1 Maximilian Seesslen
      eventLoop()
106
      {
107 27 Maximilian Seesslen
         if(currentScreen)
108
         {
109
            currentScreen->eventLoop();
110
         }
111 26 Maximilian Seesslen
      }
112 22 Maximilian Seesslen
}
113 24 Maximilian Seesslen
114 1 Maximilian Seesslen
class CApp: Ocelli
115 24 Maximilian Seesslen
{
116 1 Maximilian Seesslen
   public:
117
118 25 Maximilian Seesslen
      CScreenMain *screenMain;
119
      CScreenAlarm *screenAlarm;
120 21 Maximilian Seesslen
      CApp()
121 24 Maximilian Seesslen
      {
122 25 Maximilian Seesslen
         addScreen( screenMain = new CScreenMain() );
123 21 Maximilian Seesslen
      }
124 1 Maximilian Seesslen
}
125
126 25 Maximilian Seesslen
class CScreenClock: public OScreen
127 1 Maximilian Seesslen
{
128 23 Maximilian Seesslen
      CApp &app;
129 18 Maximilian Seesslen
      OButton buttonAddTimer;
130 25 Maximilian Seesslen
      OLabel labelTime;
131 26 Maximilian Seesslen
      OLabel labelDate;
132 24 Maximilian Seesslen
      lrtimer_t clickTimer;
133 1 Maximilian Seesslen
134 20 Maximilian Seesslen
   public:
135
136 1 Maximilian Seesslen
      CScreenMain()
137 27 Maximilian Seesslen
         :buttonAddTimer(this)
138 1 Maximilian Seesslen
      {
139
      }
140 25 Maximilian Seesslen
      virtual clicked(int x,int y)
141
      {
142 26 Maximilian Seesslen
         clickTimer=ltNow();
143 25 Maximilian Seesslen
         app.m_pwmBacklight.setPwmValue(800);
144
      }
145
      void eventLoop()
146
      {
147
         app.m_pwmBacklight.setPwmValue(100);
148
      }
149 18 Maximilian Seesslen
      addItemPressed()
150 1 Maximilian Seesslen
      {
151
         app.switchScreen( eDesktopItems );
152 18 Maximilian Seesslen
      }
153 24 Maximilian Seesslen
}
154 23 Maximilian Seesslen
155 1 Maximilian Seesslen
class CScreenMain: public OScreen
156
{
157 24 Maximilian Seesslen
      CApp &app;
158
159
   public:
160
161
      virtual clicked(int x,int y);
162
}
163
164
class CScreenAlarm: public OScreen
165
{
166
      CApp &app;
167 1 Maximilian Seesslen
      OLabel alarmText;
168 24 Maximilian Seesslen
      lrtimer_t activationTimer;
169
170
   public:
171
      CScreenAlarm()
172 27 Maximilian Seesslen
         :alarmText( centerX, centerY-200, "-")
173 24 Maximilian Seesslen
      {
174
      }
175
      virtual avctivate() override
176 1 Maximilian Seesslen
      {
177
         app.m_buzzer.setBeepMode(alarm);
178
         activationTimer=lrNow();
179 24 Maximilian Seesslen
      }
180
      virtual clicked(int x,int y) override
181
      {
182 27 Maximilian Seesslen
         // Dont allow to quit alarm immediately by accident 
183
         // when playing with the device; 500ms must elapse
184
         if( ! lrElapsed(activationTimer, MSECS_PER_SEC / 2 ) )
185 24 Maximilian Seesslen
         {
186
            return;
187
         }
188
         app.m_buzzer.setBeepMode(nullptr);
189 27 Maximilian Seesslen
         app.activatePreviousScreen();
190 24 Maximilian Seesslen
      }
191 18 Maximilian Seesslen
}
192 19 Maximilian Seesslen
</code></pre>