AWind
TabTemperature.h
1 /*
2  AWind.h - Arduino window library support for Color TFT LCD Boards
3  Copyright (C)2014 Andrei Degtiarev. All right reserved
4 
5  You can find the latest version of the library at
6  https://github.com/AndreiDegtiarev/AWind
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the CC BY-NC-SA 3.0 license.
10  Please see the included documents for further information.
11 
12  Commercial use of this library requires you to buy a license that
13  will allow commercial use. This includes using the library,
14  modified or not, as a tool to sell products.
15 
16  The license applies to all part of the library including the
17  examples and tools supplied with the library.
18 */
19 #pragma once
20 #include <Window.h>
21 #include "TimeSerieBuffer.h"
22 #include <ChartWindow.h>
24 class TabTemperature : public Window
25 {
26 
27  TimeSerieBuffer *_dataBuffer;
28  ChartWindow *_chartWnd;
29  DecoratorAxis *_chartYAxis;
30 
31 public:
32  TabTemperature(const __FlashStringHelper * name,int left,int top,int width,int height):Window(name,left,top,width,height)
33  {
34  SetDecorators(Environment::Get()->FindDecorators(F("Window")));
35 
36  _dataBuffer = new TimeSerieBuffer(1, 1, 1000, 1000);
37 
38  }
39  void Initialize()
40  {
41  int cy = Height();
42  int axis_y_margins = 2;
43 
44  DecoratorAxis *chartYAxis = new DecoratorAxis(DecoratorAxis::VerticalLeft, SmallFont, cy - axis_y_margins * 2, 0, 120, 5);
45  chartYAxis->SetOffset(4, axis_y_margins);
46  _chartWnd = new ChartWindow(NULL, chartYAxis, 1, 1, Width() - 2, cy);
47  //Chart decorators
48  _chartWnd->AddDecorator(new Decorator3DRect(Color::White, Color::Gray));
49  _chartWnd->AddDecorator(new DecoratorColor(Color::Black));
50  _chartWnd->AddDecorator(chartYAxis);
51  _chartWnd->SetBuffer(_dataBuffer);
52  AddChild(_chartWnd);
53  }
54 };
Buffer for sensor data. It is used by chart control.
Definition: TimeSerieBuffer.h:27
Base class for all window objects. Provides basic window functionality.
Definition: Window.h:34
static Environment * Get()
Returns singltone instance of environment.
Definition: Environment.h:44
Vertcal axis with the labels left to the axis.
Definition: DecoratorPrimitives.h:152
void SetOffset(int offsetX, int offsetY)
Sets decorator offset in the parent window coordinate system.
Definition: DecoratorPrimitives.h:188
Tab with chart for temperature logging.
Definition: TabTemperature.h:24
Axis decorator primitive. It is shared between gauge and chart objects. Overriden members description...
Definition: DecoratorPrimitives.h:145
Chart window implement XY plots.
Definition: ChartWindow.h:30
int Height()
Returns window height.
Definition: Window.h:189
Decorator primitive for 3D rectangle. Overriden members description see Decorator class documentation...
Definition: DecoratorPrimitives.h:130
Decorator primitive that sets current color. Overriden members description see Decorator class docume...
Definition: DecoratorPrimitives.h:24
Window(const __FlashStringHelper *name, int left, int top, int width, int height)
Constructor.
Definition: Window.h:60
void AddChild(Window *window)
Adds window child window.
Definition: Window.h:194
void SetBuffer(IDataBuffer *buffer)
Sets data buffer.
Definition: ChartWindow.h:54
void AddDecorator(Decorator *decorator)
Adds decorator to the decaorator list.
Definition: Window.h:86
virtual void SetDecorators(DecoratorList *decorators)
Sets window decorators list.
Definition: Window.h:76
int Width()
Returns window width.
Definition: Window.h:184