23 #include "SensorManager.h" 24 #include "TextBoxNumber.h" 25 #include "TextBoxString.h" 26 #include "ChartWindow.h" 27 #include "ViewModusWindow.h" 28 #include "ISensorHasDataEventReceiver.h" 31 extern uint8_t ArialNumFontPlus[];
32 extern uint8_t BigFont[];
33 extern uint8_t SmallFont[];
39 static const int Margin=10;
40 static const int BigWindowHeight=70+Margin*2;
41 static const int SmallWindowHeight=BigWindowHeight/2-Margin/4;
42 static const int BigWindowWidth=135+Margin*2;
43 static const int SmallWindowWidth=BigWindowWidth/2-Margin/4;
60 SensorManager *_sensorManager;
76 SensorWindow(
const __FlashStringHelper * name,SensorManager *sensorManager,
int left,
int top,WindowSize size=Big):
Window(name,left,top,size == Big?BigWindowWidth:SmallWindowWidth,size == Big?BigWindowHeight:SmallWindowHeight)
78 Initialize(name,sensorManager,size,
Width());
80 SensorWindow(
const __FlashStringHelper * name,SensorManager *sensorManager,
int left,
int top,
int width,
int height):
Window(name,left,top,width,height)
82 Initialize(name,sensorManager,User,BigWindowWidth);
85 void Initialize(
const __FlashStringHelper * name,SensorManager *sensorManager,WindowSize size,
int textBoxWidth)
87 _sensorManager = sensorManager;
88 _sensorManager->RegisterHasDataEventReceiver(
this);
90 int offset = size != Small?Margin:Margin/2;
91 int first_font_height=size != Small?70:30;
94 _textValue =
new TextBoxNumber(offset,offset,textBoxWidth-offset,first_font_height-offset,_sensorManager->Sensor()->Precission());
95 _textValue->
SetFont(size != Small?ArialNumFontPlus:BigFont);
96 _textValue->SetStatus(
false);
98 _textName =
new TextBoxFString(offset,first_font_height,textBoxWidth,1,name);
99 _textName->
SetFont(size != Small?BigFont:SmallFont);
101 int chart_height=
Height()-15;
103 _textChartAxis->
SetFont(size != Small?BigFont:SmallFont);
104 int chart_offset_x=0;
105 _chartWnd =
new ChartWindow(NULL,NULL,chart_offset_x,0,
Width()-chart_offset_x,chart_height);
130 if(_mode == ChartHowr)
138 else if(_mode == Text)
144 _chartWnd->
SetBuffer(_sensorManager->SecBuffer());
145 _textChartAxis->
SetText(F(
"sec"));
148 else if(_mode == ChartSec)
150 _chartWnd->
SetBuffer(_sensorManager->MinBuffer());
151 _textChartAxis->
SetText(F(
"min"));
154 else if(_mode == ChartMin)
156 _chartWnd->
SetBuffer(_sensorManager->HowrsBuffer());
157 _textChartAxis->
SetText(F(
"howr"));
167 _textValue->SetStatus(_sensorManager->Status()!=Error);
168 float value=_sensorManager->GetData();
169 if(_sensorManager->Status()!=Error)
173 if(_sensorManager->Status() == ApplicationAlarm)
184 if(_sensorManager->Status()!=Error && _textValue->GetNumber()!=value)
189 else if(_sensorManager->Status()!=Error && _mode == ChartSec)
virtual bool OnTouch(int x, int y)
Process touch event.
Definition: SensorWindow.h:128
DecoratorList * GetDecorators()
Returns window decorators list.
Definition: Window.h:81
Base class for all window objects. Provides basic window functionality.
Definition: Window.h:34
void SetText(T *text)
Initialize window with text.
Definition: TextBoxString.h:64
void SetFont(uint8_t *font)
Sets font.
Definition: TextBox.h:64
Main window that controls child window appearance (day/night/alarm) for windows like sensor window...
Definition: ViewModusWindow.h:27
Window * Parent()
Returns Parent window.
Definition: Window.h:200
Text box for numbers.
Definition: TextBoxNumber.h:24
Chart window implement XY plots.
Definition: ChartWindow.h:30
int Height()
Returns window height.
Definition: Window.h:189
void Invalidate()
If function is called than the window manager updates the window.
Definition: Window.h:157
bool IsAwaitTouch()
Returns true if window await touch action (like button) or false if touch manager should ignore this ...
Definition: SensorWindow.h:114
Window(const __FlashStringHelper *name, int left, int top, int width, int height)
Constructor.
Definition: Window.h:60
void NotifySensorHasData(SensorManager *sensorManager)
If sensor data was changed this notification is call.
Definition: SensorWindow.h:165
bool IsVisible()
Returns true if window visible and false is hidden.
Definition: Window.h:211
void AddChild(Window *window)
Adds window child window.
Definition: Window.h:194
void SetBuffer(IDataBuffer *buffer)
Sets data buffer.
Definition: ChartWindow.h:54
Window that visualizes data from sensor in from from text or chart with different time scala (See exa...
Definition: SensorWindow.h:36
void SetNumber(float number)
Initialize window with number.
Definition: TextBoxNumber.h:74
void SetVisible(bool isVisible)
Sets window visibility status.
Definition: Window.h:205
virtual void SetDecorators(DecoratorList *decorators)
Sets window decorators list.
Definition: Window.h:76
void SetDecorators(DecoratorList *decorators)
Sets appearance settings.
Definition: SensorWindow.h:119
int Width()
Returns window width.
Definition: Window.h:184
SensorWindow(const __FlashStringHelper *name, SensorManager *sensorManager, int left, int top, WindowSize size=Big)
Constructor.
Definition: SensorWindow.h:76