Console.h
Go to the documentation of this file.
1 /****
2  * Console.h
3  *
4  * Copyright 2021 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the Sming-Graphics Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  * @author: October 2021 - mikee47 <mike@sillyhouse.net>
19  *
20  ****/
21 
22 #pragma once
23 
24 #include "AbstractDisplay.h"
25 #include "RenderQueue.h"
26 #include <memory>
27 
28 namespace Graphics
29 {
30 class Console : public Print
31 {
32 public:
38  Console(AbstractDisplay& display, RenderQueue& renderQueue) : display(display), renderQueue(renderQueue)
39  {
40  }
41 
46  void systemDebugOutput(bool enable);
47 
54  void pause(bool state);
55 
59  bool isPaused() const
60  {
61  return paused;
62  }
63 
64  /* Print methods */
65 
66  size_t write(const uint8_t* data, size_t size) override;
67 
68  size_t write(uint8_t c) override
69  {
70  return write(&c, 1);
71  }
72 
73 private:
74  void update();
75 
76  AbstractDisplay& display;
77  RenderQueue& renderQueue;
78  String buffer;
79  String pauseBuffer;
80  std::unique_ptr<SceneObject> scene;
81  Point cursor{};
82  bool paused{false};
83 };
84 
85 } // namespace Graphics
void pause(bool state)
Suspend/resume output to display.
The String class.
Definition: WString.h:136
bool isPaused() const
Determine if output is paused.
Definition: Console.h:97
Console(AbstractDisplay &display, RenderQueue &renderQueue)
Console constructor.
Definition: Console.h:76
size_t write(const uint8_t *data, size_t size) override
Writes characters from a buffer to output stream.
Definition: Virtual.h:30
Top-level manager to queue objects for rendering to a specific target.
Definition: RenderQueue.h:53
Provides formatted output to stream.
Definition: Print.h:36
void enable(Handler &commandHandler, HardwareSerial &serial)
void systemDebugOutput(bool enable)
Use console for debug output.
Definition: AbstractDisplay.h:48