B15F
Board 15 Famulus Edition
|
1 #include "view_monitor.h" 17 if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
21 size_t mouse_x =
event.x, mouse_y =
event.y;
22 if(mouse_y == row && mouse_x >= column && mouse_x < column +
label_close.length())
44 std::string ViewMonitor::fancyDigitalString(uint8_t& b)
46 std::string bitstring(std::bitset<8>(b).to_string());
49 std::stringstream str;
52 str <<
"0x" << std::setfill (
'0') << std::setw(2) << std::hex << (int) b << std::dec;
56 std::string ViewMonitor::fancyAnalogString(uint16_t& v)
58 std::stringstream str;
59 double volt = round(v * 100.0 * 5.0 / 1023.0) / 100.0;
61 str << std::setfill (
'0') << std::setw(4) << (int) v <<
" " << std::fixed << std::setprecision(2) << volt <<
" V ";
64 uint8_t p = round(v * 40.0 / 1023.0);
65 for(uint8_t i = 0; i < p; i++)
67 for(uint8_t i = 0; i < 40 - p; i++)
69 str <<
"]" << std::endl;
84 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
87 std::this_thread::sleep_for(std::chrono::milliseconds(100));
94 for(uint8_t i = 0; i <
sizeof(adc) /
sizeof(adc[0]); i++)
98 std::stringstream str;
108 str <<
"Digitale Enigaenge:" << std::endl;
109 str <<
"Binaere Eingabe 0: " << fancyDigitalString(be0) << std::endl;
110 str <<
"Binaere Eingabe 1: " << fancyDigitalString(be1) << std::endl;
111 str <<
"Dip Schalter (S7): " << fancyDigitalString(dsw) << std::endl;
121 str <<
"Analoge Eingaenge:" << std::endl;
122 for(uint8_t i = 0; i <
sizeof(adc) /
sizeof(adc[0]); i++)
124 str <<
"Kanal " << std::to_string((
int) i) <<
": ";
125 str << fancyAnalogString(adc[i]) << std::endl;
133 std::cout <<
"DriverException: " << ex.
what() << std::endl;
144 B15F::abort(
"Die Verbindung ist unterbrochen worden. Wurde ein Stecker gezogen? :D");
virtual call_t keypress(int &key) override
constexpr static int text_offset_x
Relativer Abstand des Textes zum linken Rahmen.
int width
width of view in terminal characters
uint8_t digitalRead0(void)
virtual const char * what() const
uint8_t readDipSwitch(void)
void delay_ms(uint16_t ms)
std::vector< call_t > calls
calls (function pointers) for different button actions in the view (if any)
static B15F & getInstance(void)
static void abort(std::string msg)
static WINDOW * win
static window contexts for all views
int close_offset_x
Relative X Koordinate des Buttons zum Schließen im Window.
std::string label_close
Beschriftung für Button zum Schließen.
uint16_t analogRead(uint8_t channel)
virtual void repaint(void)
volatile bool run_worker
Legt fest, ob die Schleife im worker() weiterhin fortgeführt werden soll. Bei false bricht die Schlei...
virtual void worker(void)
Funktion, die vom Worker-Thread ausgeführt, um die Anzeige zu aktualisieren.
int close_offset_y
Relative Y Koordinate des Buttons zum Schließen im Window.
uint8_t digitalRead1(void)
int start_x
x offset (characters) in the terminal, used to center the window on repaint()
std::string text
Benachrichtigungstext dieser View.
int start_y
y offset (characters) in the terminal, used to center the window on repaint()
std::thread t_worker
Worker-Thread.
constexpr static int KEY_ENT
Key value for the Enter key.