From 3cf9eeabf7019d3262d9e6096341268eb6a8d997 Mon Sep 17 00:00:00 2001 From: Tristan Krause Date: Wed, 31 Jul 2019 16:08:45 +0200 Subject: [PATCH] view monitor kommentiert --- control/src/drv/commit_hash.h | 2 +- control/src/ui/view_monitor.h | 29 +++++++++++-- docs/html/annotated.html | 2 +- docs/html/b15f_8cpp_source.html | 2 +- docs/html/b15f_8h_source.html | 2 +- docs/html/classB15F-members.html | 2 +- docs/html/classB15F.html | 2 +- docs/html/classDot-members.html | 2 +- docs/html/classDot.html | 2 +- docs/html/classDriverException-members.html | 2 +- docs/html/classDriverException.html | 2 +- docs/html/classPlottyFile-members.html | 2 +- docs/html/classPlottyFile.html | 2 +- docs/html/classTimeoutException-members.html | 2 +- docs/html/classTimeoutException.html | 2 +- docs/html/classUSART-members.html | 2 +- docs/html/classUSART.html | 2 +- docs/html/classUSARTException-members.html | 2 +- docs/html/classUSARTException.html | 2 +- docs/html/classView-members.html | 2 +- docs/html/classView.html | 2 +- docs/html/classViewInfo-members.html | 2 +- docs/html/classViewInfo.html | 2 +- docs/html/classViewMonitor-members.html | 10 ++--- docs/html/classViewMonitor.html | 41 +++++++++++++++---- docs/html/classViewPromt-members.html | 2 +- docs/html/classViewPromt.html | 2 +- docs/html/classViewSelection-members.html | 2 +- docs/html/classViewSelection.html | 2 +- docs/html/classes.html | 2 +- docs/html/cli_8cpp_source.html | 2 +- docs/html/commit__hash_8h_source.html | 4 +- .../dir_1788f8309b1a812dcb800a185471cf6c.html | 2 +- .../dir_587c94d866dbb2f408f78cf41f9b2f8d.html | 2 +- docs/html/dot_8cpp_source.html | 2 +- docs/html/dot_8h_source.html | 2 +- docs/html/driverexception_8h_source.html | 2 +- docs/html/files.html | 2 +- docs/html/functions.html | 14 ++++++- docs/html/functions_func.html | 8 +++- docs/html/functions_vars.html | 8 +++- docs/html/hierarchy.html | 2 +- docs/html/index.html | 2 +- docs/html/plottyfile_8cpp_source.html | 2 +- docs/html/plottyfile_8h_source.html | 2 +- docs/html/requests_8h_source.html | 2 +- docs/html/search/all_11.js | 2 +- docs/html/search/all_12.js | 1 + docs/html/search/all_d.js | 3 +- docs/html/search/all_f.js | 1 + docs/html/search/functions_d.js | 3 +- docs/html/search/functions_e.js | 1 + docs/html/search/variables_7.js | 3 +- docs/html/search/variables_9.js | 1 + docs/html/timeoutexception_8h_source.html | 2 +- docs/html/ui_8cpp_source.html | 4 +- docs/html/ui_8h_source.html | 2 +- docs/html/usart_8cpp_source.html | 2 +- docs/html/usart_8h_source.html | 2 +- docs/html/usartexception_8h_source.html | 2 +- docs/html/view_8cpp_source.html | 2 +- docs/html/view_8h_source.html | 2 +- docs/html/view__info_8cpp_source.html | 2 +- docs/html/view__info_8h_source.html | 2 +- docs/html/view__monitor_8cpp_source.html | 10 +++-- docs/html/view__monitor_8h_source.html | 10 +++-- docs/html/view__promt_8cpp_source.html | 2 +- docs/html/view__promt_8h_source.html | 2 +- docs/html/view__selection_8cpp_source.html | 2 +- docs/html/view__selection_8h_source.html | 2 +- 70 files changed, 172 insertions(+), 85 deletions(-) diff --git a/control/src/drv/commit_hash.h b/control/src/drv/commit_hash.h index 904524a..dbe2c7d 100644 --- a/control/src/drv/commit_hash.h +++ b/control/src/drv/commit_hash.h @@ -1,4 +1,4 @@ #ifndef COMMIT_HASH_H #define COMMIT_HASH_H -const char COMMIT_HASH[] = "be3545fcbb7c7a41ec40d489efc952369f81bf5a"; +const char COMMIT_HASH[] = "69e02c20c2eef57a31b513144c7379d63701f01f"; #endif // COMMIT_HASH_H diff --git a/control/src/ui/view_monitor.h b/control/src/ui/view_monitor.h index 9ab39b5..457e161 100644 --- a/control/src/ui/view_monitor.h +++ b/control/src/ui/view_monitor.h @@ -8,23 +8,44 @@ #include "view_info.h" #include "../drv/b15f.h" -/*! View to display all B15 inputs. */ +/** + * Klasse für die Anzeige aller analogen & digitalen Eingänge des B15. + */ class ViewMonitor : public ViewInfo { public: + /** + * Standard-Konstruktor ohne Argumente + */ ViewMonitor(void); + + /** + * Verarbeitet einen Tastendruck, z.B. Enter = Button angewählt. + * \param key gedrückte Taste + * \return Call, der nach dem keypress ausgeführt werden soll + */ virtual call_t keypress(int& key) override; private: + /** + * Formatiert einen eingelesen Port-Wert in einen Bitstring und Hexadezimalzahlen. + * \param b Port-Wert + * \return formatierter String + */ std::string fancyDigitalString(uint8_t& b); + /** + * Formatiert einen eingelesen ADC-Wert und zeigt eine Prozentleiste. + * \param b analoger Wert + * \return formatierter String + */ std::string fancyAnalogString(uint16_t& v); protected: - virtual void worker(void); - volatile bool run_worker = true; - std::thread t_worker; + virtual void worker(void); //!< Funktion, die vom Worker-Thread ausgeführt, um die Anzeige zu aktualisieren. + volatile bool run_worker = true; //!< Legt fest, ob die Schleife im worker() weiterhin fortgeführt werden soll. Bei false bricht die Schleife ab. + std::thread t_worker; //!< Worker-Thread }; diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 42e0e7e..97f1d2e 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -85,7 +85,7 @@ $(function() { diff --git a/docs/html/b15f_8cpp_source.html b/docs/html/b15f_8cpp_source.html index 3df8b32..533c326 100644 --- a/docs/html/b15f_8cpp_source.html +++ b/docs/html/b15f_8cpp_source.html @@ -121,7 +121,7 @@ $(function() {
diff --git a/docs/html/b15f_8h_source.html b/docs/html/b15f_8h_source.html index 18c842a..8f0c15a 100644 --- a/docs/html/b15f_8h_source.html +++ b/docs/html/b15f_8h_source.html @@ -117,7 +117,7 @@ $(function() {
diff --git a/docs/html/classB15F-members.html b/docs/html/classB15F-members.html index 9546393..c2f135d 100644 --- a/docs/html/classB15F-members.html +++ b/docs/html/classB15F-members.html @@ -114,7 +114,7 @@ $(function() { diff --git a/docs/html/classB15F.html b/docs/html/classB15F.html index c82b4b2..76bf09a 100644 --- a/docs/html/classB15F.html +++ b/docs/html/classB15F.html @@ -1309,7 +1309,7 @@ constexpr static uint32_t  diff --git a/docs/html/classDot-members.html b/docs/html/classDot-members.html index 8a9f3c5..1814208 100644 --- a/docs/html/classDot-members.html +++ b/docs/html/classDot-members.html @@ -76,7 +76,7 @@ $(function() { diff --git a/docs/html/classDot.html b/docs/html/classDot.html index f04fbd9..71ff64f 100644 --- a/docs/html/classDot.html +++ b/docs/html/classDot.html @@ -196,7 +196,7 @@ Public Member Functions diff --git a/docs/html/classDriverException-members.html b/docs/html/classDriverException-members.html index 835b92d..e19a66d 100644 --- a/docs/html/classDriverException-members.html +++ b/docs/html/classDriverException-members.html @@ -77,7 +77,7 @@ $(function() { diff --git a/docs/html/classDriverException.html b/docs/html/classDriverException.html index 129358d..d15d305 100644 --- a/docs/html/classDriverException.html +++ b/docs/html/classDriverException.html @@ -247,7 +247,7 @@ std::string  diff --git a/docs/html/classPlottyFile-members.html b/docs/html/classPlottyFile-members.html index 7344642..11df990 100644 --- a/docs/html/classPlottyFile-members.html +++ b/docs/html/classPlottyFile-members.html @@ -100,7 +100,7 @@ $(function() { diff --git a/docs/html/classPlottyFile.html b/docs/html/classPlottyFile.html index ca14873..dfada5a 100644 --- a/docs/html/classPlottyFile.html +++ b/docs/html/classPlottyFile.html @@ -811,7 +811,7 @@ Public Member Functions diff --git a/docs/html/classTimeoutException-members.html b/docs/html/classTimeoutException-members.html index ed75098..fff51f5 100644 --- a/docs/html/classTimeoutException-members.html +++ b/docs/html/classTimeoutException-members.html @@ -77,7 +77,7 @@ $(function() { diff --git a/docs/html/classTimeoutException.html b/docs/html/classTimeoutException.html index 4794db7..811778f 100644 --- a/docs/html/classTimeoutException.html +++ b/docs/html/classTimeoutException.html @@ -239,7 +239,7 @@ std::string  diff --git a/docs/html/classUSART-members.html b/docs/html/classUSART-members.html index fd40572..ac90f6e 100644 --- a/docs/html/classUSART-members.html +++ b/docs/html/classUSART-members.html @@ -86,7 +86,7 @@ $(function() { diff --git a/docs/html/classUSART.html b/docs/html/classUSART.html index 452cae6..87adf51 100644 --- a/docs/html/classUSART.html +++ b/docs/html/classUSART.html @@ -523,7 +523,7 @@ Public Member Functions diff --git a/docs/html/classUSARTException-members.html b/docs/html/classUSARTException-members.html index 177d5c4..952ab9b 100644 --- a/docs/html/classUSARTException-members.html +++ b/docs/html/classUSARTException-members.html @@ -77,7 +77,7 @@ $(function() { diff --git a/docs/html/classUSARTException.html b/docs/html/classUSARTException.html index 804be23..71a7332 100644 --- a/docs/html/classUSARTException.html +++ b/docs/html/classUSARTException.html @@ -239,7 +239,7 @@ std::string  diff --git a/docs/html/classView-members.html b/docs/html/classView-members.html index b8890ee..bfa73bf 100644 --- a/docs/html/classView-members.html +++ b/docs/html/classView-members.html @@ -89,7 +89,7 @@ $(function() { diff --git a/docs/html/classView.html b/docs/html/classView.html index 6299c49..90b9a5e 100644 --- a/docs/html/classView.html +++ b/docs/html/classView.html @@ -444,7 +444,7 @@ constexpr static int  diff --git a/docs/html/classViewInfo-members.html b/docs/html/classViewInfo-members.html index bdbd8a1..0f612af 100644 --- a/docs/html/classViewInfo-members.html +++ b/docs/html/classViewInfo-members.html @@ -99,7 +99,7 @@ $(function() { diff --git a/docs/html/classViewInfo.html b/docs/html/classViewInfo.html index eebd3a2..4e3fb1c 100644 --- a/docs/html/classViewInfo.html +++ b/docs/html/classViewInfo.html @@ -390,7 +390,7 @@ Additional Inherited Members diff --git a/docs/html/classViewMonitor-members.html b/docs/html/classViewMonitor-members.html index 11c3acb..fe0d240 100644 --- a/docs/html/classViewMonitor-members.html +++ b/docs/html/classViewMonitor-members.html @@ -79,7 +79,7 @@ $(function() { keypress(int &key) overrideViewMonitorvirtual label_closeViewInfoprotected repaint(void)Viewvirtual - run_worker (defined in ViewMonitor)ViewMonitorprotected + run_workerViewMonitorprotected setCall(call_t call)ViewInfovirtual setLabelClose(std::string label)ViewInfovirtual setText(std::string text)ViewInfovirtual @@ -88,22 +88,22 @@ $(function() { start_xViewprotected start_yViewprotected str_split(const std::string &str, const std::string delim)Viewstatic - t_worker (defined in ViewMonitor)ViewMonitorprotected + t_workerViewMonitorprotected textViewInfoprotected text_offset_xViewInfoprotectedstatic text_offset_yViewInfoprotectedstatic titleViewprotected View(void)View ViewInfo(void)ViewInfo - ViewMonitor(void) (defined in ViewMonitor)ViewMonitor + ViewMonitor(void)ViewMonitor widthViewprotected winViewprotectedstatic - worker(void) (defined in ViewMonitor)ViewMonitorprotectedvirtual + worker(void)ViewMonitorprotectedvirtual ~View(void)Viewvirtual diff --git a/docs/html/classViewMonitor.html b/docs/html/classViewMonitor.html index e816603..3efcd70 100644 --- a/docs/html/classViewMonitor.html +++ b/docs/html/classViewMonitor.html @@ -88,6 +88,8 @@ $(function() { + + @@ -114,16 +116,19 @@ Public Member Functions +virtual void  +

Public Member Functions

 ViewMonitor (void)
 
virtual call_t keypress (int &key) override
 
- Public Member Functions inherited from ViewInfo

Protected Member Functions

-virtual void worker (void)
worker (void)
 Funktion, die vom Worker-Thread ausgeführt, um die Anzeige zu aktualisieren.
 
+volatile bool  + +std::thread  +

Protected Attributes

-volatile bool run_worker = true
run_worker = true
 Legt fest, ob die Schleife im worker() weiterhin fortgeführt werden soll. Bei false bricht die Schleife ab.
 
-std::thread t_worker
t_worker
 Worker-Thread.
 
- Protected Attributes inherited from ViewInfo
@@ -197,10 +202,32 @@ constexpr static int  

Detailed Description

-

View to display all B15 inputs.

+

Klasse für die Anzeige aller analogen & digitalen Eingänge des B15.

-

Definition at line 13 of file view_monitor.h.

-

Member Function Documentation

+

Definition at line 15 of file view_monitor.h.

+

Constructor & Destructor Documentation

+ +

◆ ViewMonitor()

+ +
+
+ + + + + + + + +
ViewMonitor::ViewMonitor (void )
+
+

Standard-Konstruktor ohne Argumente

+ +

Definition at line 3 of file view_monitor.cpp.

+ +
+
+

Member Function Documentation

◆ keypress()

@@ -245,7 +272,7 @@ constexpr static int  diff --git a/docs/html/classViewPromt-members.html b/docs/html/classViewPromt-members.html index ba2a693..adf815b 100644 --- a/docs/html/classViewPromt-members.html +++ b/docs/html/classViewPromt-members.html @@ -105,7 +105,7 @@ $(function() { diff --git a/docs/html/classViewPromt.html b/docs/html/classViewPromt.html index e59d998..accff7f 100644 --- a/docs/html/classViewPromt.html +++ b/docs/html/classViewPromt.html @@ -273,7 +273,7 @@ Additional Inherited Members diff --git a/docs/html/classViewSelection-members.html b/docs/html/classViewSelection-members.html index 6698c65..b70becc 100644 --- a/docs/html/classViewSelection-members.html +++ b/docs/html/classViewSelection-members.html @@ -94,7 +94,7 @@ $(function() { diff --git a/docs/html/classViewSelection.html b/docs/html/classViewSelection.html index f702445..4ff0481 100644 --- a/docs/html/classViewSelection.html +++ b/docs/html/classViewSelection.html @@ -240,7 +240,7 @@ Additional Inherited Members diff --git a/docs/html/classes.html b/docs/html/classes.html index c87e7d8..3836c8c 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -105,7 +105,7 @@ $(function() { diff --git a/docs/html/cli_8cpp_source.html b/docs/html/cli_8cpp_source.html index abda5ea..9978cb0 100644 --- a/docs/html/cli_8cpp_source.html +++ b/docs/html/cli_8cpp_source.html @@ -77,7 +77,7 @@ $(function() {
virtual void setTitle(std::string title)
Definition: view.cpp:47
diff --git a/docs/html/commit__hash_8h_source.html b/docs/html/commit__hash_8h_source.html index 6662c85..0a7d187 100644 --- a/docs/html/commit__hash_8h_source.html +++ b/docs/html/commit__hash_8h_source.html @@ -70,10 +70,10 @@ $(function() {
commit_hash.h
-
1 #ifndef COMMIT_HASH_H
2 #define COMMIT_HASH_H
3 const char COMMIT_HASH[] = "be3545fcbb7c7a41ec40d489efc952369f81bf5a";
4 #endif // COMMIT_HASH_H
+
1 #ifndef COMMIT_HASH_H
2 #define COMMIT_HASH_H
3 const char COMMIT_HASH[] = "69e02c20c2eef57a31b513144c7379d63701f01f";
4 #endif // COMMIT_HASH_H
diff --git a/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html b/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html index b5c9a3f..f9d9c02 100644 --- a/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html +++ b/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html @@ -73,7 +73,7 @@ $(function() { diff --git a/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html b/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html index ee26b78..4dea88d 100644 --- a/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html +++ b/docs/html/dir_587c94d866dbb2f408f78cf41f9b2f8d.html @@ -73,7 +73,7 @@ $(function() { diff --git a/docs/html/dot_8cpp_source.html b/docs/html/dot_8cpp_source.html index d225d50..0f28596 100644 --- a/docs/html/dot_8cpp_source.html +++ b/docs/html/dot_8cpp_source.html @@ -77,7 +77,7 @@ $(function() {
Dot(uint16_t x, uint16_t y, uint8_t curve)
Definition: dot.cpp:3
diff --git a/docs/html/dot_8h_source.html b/docs/html/dot_8h_source.html index 57910da..708b1b9 100644 --- a/docs/html/dot_8h_source.html +++ b/docs/html/dot_8h_source.html @@ -78,7 +78,7 @@ $(function() {
Dot(uint16_t x, uint16_t y, uint8_t curve)
Definition: dot.cpp:3
diff --git a/docs/html/driverexception_8h_source.html b/docs/html/driverexception_8h_source.html index 09a9de3..958fa61 100644 --- a/docs/html/driverexception_8h_source.html +++ b/docs/html/driverexception_8h_source.html @@ -79,7 +79,7 @@ $(function() {
diff --git a/docs/html/files.html b/docs/html/files.html index 6cbc2b6..b82f7ed 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -101,7 +101,7 @@ $(function() { diff --git a/docs/html/functions.html b/docs/html/functions.html index 3a2ff65..a663310 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -335,6 +335,9 @@ $(function() {
  • reverse() : B15F
  • +
  • run_worker +: ViewMonitor +
  • @@ -433,6 +436,9 @@ $(function() {

    - t -

    @@ -495,6 +504,9 @@ $(function() {
  • win : View
  • +
  • worker() +: ViewMonitor +
  • writeToFile() : PlottyFile
  • @@ -521,7 +533,7 @@ $(function() { diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index 63ae921..dd48d42 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html @@ -400,6 +400,9 @@ $(function() {
  • ViewInfo() : ViewInfo
  • +
  • ViewMonitor() +: ViewMonitor +
  • @@ -409,6 +412,9 @@ $(function() { , TimeoutException , USARTException +
  • worker() +: ViewMonitor +
  • writeToFile() : PlottyFile
  • @@ -435,7 +441,7 @@ $(function() { diff --git a/docs/html/functions_vars.html b/docs/html/functions_vars.html index 2151bdd..88ece39 100644 --- a/docs/html/functions_vars.html +++ b/docs/html/functions_vars.html @@ -106,12 +106,18 @@ $(function() {
  • RECONNECT_TRIES : B15F
  • +
  • run_worker +: ViewMonitor +
  • start_x : View
  • start_y : View
  • +
  • t_worker +: ViewMonitor +
  • text : ViewInfo
  • @@ -137,7 +143,7 @@ $(function() { diff --git a/docs/html/hierarchy.html b/docs/html/hierarchy.html index 1a89836..b97c6ef 100644 --- a/docs/html/hierarchy.html +++ b/docs/html/hierarchy.html @@ -86,7 +86,7 @@ $(function() { diff --git a/docs/html/index.html b/docs/html/index.html index 0d38f71..3cdd4b4 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -175,7 +175,7 @@ Dabei gehören Punkte mit dem gleichen Index für curve (uint8_ diff --git a/docs/html/plottyfile_8cpp_source.html b/docs/html/plottyfile_8cpp_source.html index baa0b4b..6446299 100644 --- a/docs/html/plottyfile_8cpp_source.html +++ b/docs/html/plottyfile_8cpp_source.html @@ -101,7 +101,7 @@ $(function() {
    std::string getUnitX(void) const
    Definition: plottyfile.cpp:105
    diff --git a/docs/html/plottyfile_8h_source.html b/docs/html/plottyfile_8h_source.html index 62ac267..50407c9 100644 --- a/docs/html/plottyfile_8h_source.html +++ b/docs/html/plottyfile_8h_source.html @@ -102,7 +102,7 @@ $(function() {
    std::string getUnitX(void) const
    Definition: plottyfile.cpp:105
    diff --git a/docs/html/requests_8h_source.html b/docs/html/requests_8h_source.html index eff5feb..7a54f2a 100644 --- a/docs/html/requests_8h_source.html +++ b/docs/html/requests_8h_source.html @@ -73,7 +73,7 @@ $(function() {
    1 #ifndef REQUESTS_H
    2 #define REQUESTS_H
    3 
    4 constexpr static uint8_t RQ_DISCARD = 0;
    5 constexpr static uint8_t RQ_TEST = 1;
    6 constexpr static uint8_t RQ_INFO = 2;
    7 constexpr static uint8_t RQ_INT_TEST = 3;
    8 constexpr static uint8_t RQ_SELF_TEST = 4;
    9 constexpr static uint8_t RQ_DIGITAL_WRITE_0 = 5;
    10 constexpr static uint8_t RQ_DIGITAL_WRITE_1 = 6;
    11 constexpr static uint8_t RQ_DIGITAL_READ_0 = 7;
    12 constexpr static uint8_t RQ_DIGITAL_READ_1 = 8;
    13 constexpr static uint8_t RQ_READ_DIP_SWITCH = 9;
    14 constexpr static uint8_t RQ_ANALOG_WRITE_0 = 10;
    15 constexpr static uint8_t RQ_ANALOG_WRITE_1 = 11;
    16 constexpr static uint8_t RQ_ANALOG_READ = 12;
    17 constexpr static uint8_t RQ_ADC_DAC_STROKE = 13;
    18 constexpr static uint8_t RQ_PWM_SET_FREQ = 14;
    19 constexpr static uint8_t RQ_PWM_SET_VALUE = 15;
    20 constexpr static uint8_t RQ_SET_MEM_8 = 16;
    21 constexpr static uint8_t RQ_GET_MEM_8 = 17;
    22 constexpr static uint8_t RQ_SET_MEM_16 = 18;
    23 constexpr static uint8_t RQ_GET_MEM_16 = 19;
    24 constexpr static uint8_t RQ_COUNTER_OFFSET = 20;
    25 constexpr static uint8_t RQ_SERVO_ENABLE = 21;
    26 constexpr static uint8_t RQ_SERVO_DISABLE = 22;
    27 constexpr static uint8_t RQ_SERVO_SET_POS = 23;
    28 
    29 uint8_t const rq_len[] =
    30 {
    31  1 /* RQ_DISCARD */,
    32  1 /* RQ_TEST */ + 1 /* test byte */,
    33  1 /* RQ_INFO */,
    34  1 /* RQ_INT_TEST */ + 1 /* test int high low */ + 1 /* test int high high */,
    35  1 /* RQ_SELF_TEST */,
    36  1 /* RQ_DIGITAL_WRITE_0 */ + 1 /* port value */,
    37  1 /* RQ_DIGITAL_WRITE_1 */ + 1 /* port value */,
    38  1 /* RQ_DIGITAL_READ_0 */,
    39  1 /* RQ_DIGITAL_READ_1 */,
    40  1 /* RQ_READ_DIP_SWITCH */,
    41  1 /* RQ_ANALOG_WRITE_0 */ + 1 /* test int high low */ + 1 /* test int high high */,
    42  1 /* RQ_ANALOG_WRITE_1 */ + 1 /* test int high low */ + 1 /* test int high high */,
    43  1 /* RQ_ANALOG_READ */ + 1 /* adc channel */,
    44  1 /* RQ_ADC_DAC_STROKE */ + 1 /* channel a */ + 1 /* channel b */ + 1 /* start low */ + 1 /* start high */ + 1 /* delta low */ + 1 /* delta high */ + 1 /* count low */ + 1 /* count high */,
    45  1 /* RQ_PWM_SET_FREQ */ + 1 /* freq low low */ + 1 /* freq low high */ + 1 /* freq high low */ + 1 /* freq high high */,
    46  1 /* RQ_PWM_SET_VALUE */ + 1 /* pwm value */,
    47  1 /* RQ_SET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value (8-bit) */,
    48  1 /* RQ_GET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */,
    49  1 /* RQ_SET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value low */ + 1 /* memory value high */,
    50  1 /* RQ_GET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */,
    51  1 /* RQ_COUNTER_OFFSET */,
    52  1 /* RQ_SERVO_ENABLE */,
    53  1 /* RQ_SERVO_DISABLE */,
    54  1 /* RQ_SERVO_SET_POS */ + 1 /* pulse length low */ + 1 /* pulse length high */,
    55 };
    56 
    57 #endif // REQUESTS_H
    diff --git a/docs/html/search/all_11.js b/docs/html/search/all_11.js index 7f009ca..9f76639 100644 --- a/docs/html/search/all_11.js +++ b/docs/html/search/all_11.js @@ -2,7 +2,7 @@ var searchData= [ ['view',['View',['../classView.html',1,'View'],['../classView.html#a0a9be6e5fb588412aab31cacf5e43b04',1,'View::View()']]], ['viewinfo',['ViewInfo',['../classViewInfo.html',1,'ViewInfo'],['../classViewInfo.html#a95a3a81de65ef42615bbe5a843e8d5f6',1,'ViewInfo::ViewInfo()']]], - ['viewmonitor',['ViewMonitor',['../classViewMonitor.html',1,'']]], + ['viewmonitor',['ViewMonitor',['../classViewMonitor.html',1,'ViewMonitor'],['../classViewMonitor.html#a080526967fac26eeaa5b73468fdac26d',1,'ViewMonitor::ViewMonitor()']]], ['viewpromt',['ViewPromt',['../classViewPromt.html',1,'']]], ['viewselection',['ViewSelection',['../classViewSelection.html',1,'']]] ]; diff --git a/docs/html/search/all_12.js b/docs/html/search/all_12.js index 4f5cf1d..ffd40a7 100644 --- a/docs/html/search/all_12.js +++ b/docs/html/search/all_12.js @@ -4,5 +4,6 @@ var searchData= ['what',['what',['../classDriverException.html#a781362760bcd75b1bd5448629df58446',1,'DriverException::what()'],['../classTimeoutException.html#a97eaf01fc39ddb94b060020b42fefd6e',1,'TimeoutException::what()'],['../classUSARTException.html#a2af5e3c00cd0585c7427c2e0420a8f15',1,'USARTException::what()']]], ['width',['width',['../classView.html#ae039aa744b085db819ae149705b2c32b',1,'View']]], ['win',['win',['../classView.html#a5ddee2bf0b26dbcfa7780be17ff33dd7',1,'View']]], + ['worker',['worker',['../classViewMonitor.html#a245a1dc3cc43a84f63e1175a195581a2',1,'ViewMonitor']]], ['writetofile',['writeToFile',['../classPlottyFile.html#a82c348e7fade2edcbc907e7c2bc2e305',1,'PlottyFile']]] ]; diff --git a/docs/html/search/all_d.js b/docs/html/search/all_d.js index 2c0fc33..d079e8d 100644 --- a/docs/html/search/all_d.js +++ b/docs/html/search/all_d.js @@ -6,5 +6,6 @@ var searchData= ['reconnect_5ftimeout',['RECONNECT_TIMEOUT',['../classB15F.html#a040951746fbfd632e12bd1ad14578816',1,'B15F']]], ['reconnect_5ftries',['RECONNECT_TRIES',['../classB15F.html#a6c4895bdbcd71ff6743becf97985c2dc',1,'B15F']]], ['repaint',['repaint',['../classView.html#aa7b1f1179e3c4f06bef1e99355d0d592',1,'View']]], - ['reverse',['reverse',['../classB15F.html#a2937f22f1cfc9b533f4b5bf4db726a68',1,'B15F']]] + ['reverse',['reverse',['../classB15F.html#a2937f22f1cfc9b533f4b5bf4db726a68',1,'B15F']]], + ['run_5fworker',['run_worker',['../classViewMonitor.html#a79a68894c0a05422b5707202d28a6db0',1,'ViewMonitor']]] ]; diff --git a/docs/html/search/all_f.js b/docs/html/search/all_f.js index 5d93e26..e998cfa 100644 --- a/docs/html/search/all_f.js +++ b/docs/html/search/all_f.js @@ -1,5 +1,6 @@ var searchData= [ + ['t_5fworker',['t_worker',['../classViewMonitor.html#a377eb8deab3061aa4e084be9b791c056',1,'ViewMonitor']]], ['testconnection',['testConnection',['../classB15F.html#a6b8c7da1fb9b619543844e0ce7597d83',1,'B15F']]], ['testintconv',['testIntConv',['../classB15F.html#ac2c7b6d84da5239ee7cc3d44e689d9db',1,'B15F']]], ['text',['text',['../classViewInfo.html#ac392a569ef16af3dc11ee659f3fa1eb4',1,'ViewInfo']]], diff --git a/docs/html/search/functions_d.js b/docs/html/search/functions_d.js index fcaf074..8200514 100644 --- a/docs/html/search/functions_d.js +++ b/docs/html/search/functions_d.js @@ -1,5 +1,6 @@ var searchData= [ ['view',['View',['../classView.html#a0a9be6e5fb588412aab31cacf5e43b04',1,'View']]], - ['viewinfo',['ViewInfo',['../classViewInfo.html#a95a3a81de65ef42615bbe5a843e8d5f6',1,'ViewInfo']]] + ['viewinfo',['ViewInfo',['../classViewInfo.html#a95a3a81de65ef42615bbe5a843e8d5f6',1,'ViewInfo']]], + ['viewmonitor',['ViewMonitor',['../classViewMonitor.html#a080526967fac26eeaa5b73468fdac26d',1,'ViewMonitor']]] ]; diff --git a/docs/html/search/functions_e.js b/docs/html/search/functions_e.js index 6335f37..773bb5d 100644 --- a/docs/html/search/functions_e.js +++ b/docs/html/search/functions_e.js @@ -1,5 +1,6 @@ var searchData= [ ['what',['what',['../classDriverException.html#a781362760bcd75b1bd5448629df58446',1,'DriverException::what()'],['../classTimeoutException.html#a97eaf01fc39ddb94b060020b42fefd6e',1,'TimeoutException::what()'],['../classUSARTException.html#a2af5e3c00cd0585c7427c2e0420a8f15',1,'USARTException::what()']]], + ['worker',['worker',['../classViewMonitor.html#a245a1dc3cc43a84f63e1175a195581a2',1,'ViewMonitor']]], ['writetofile',['writeToFile',['../classPlottyFile.html#a82c348e7fade2edcbc907e7c2bc2e305',1,'PlottyFile']]] ]; diff --git a/docs/html/search/variables_7.js b/docs/html/search/variables_7.js index fbf0a47..d75da1d 100644 --- a/docs/html/search/variables_7.js +++ b/docs/html/search/variables_7.js @@ -1,5 +1,6 @@ var searchData= [ ['reconnect_5ftimeout',['RECONNECT_TIMEOUT',['../classB15F.html#a040951746fbfd632e12bd1ad14578816',1,'B15F']]], - ['reconnect_5ftries',['RECONNECT_TRIES',['../classB15F.html#a6c4895bdbcd71ff6743becf97985c2dc',1,'B15F']]] + ['reconnect_5ftries',['RECONNECT_TRIES',['../classB15F.html#a6c4895bdbcd71ff6743becf97985c2dc',1,'B15F']]], + ['run_5fworker',['run_worker',['../classViewMonitor.html#a79a68894c0a05422b5707202d28a6db0',1,'ViewMonitor']]] ]; diff --git a/docs/html/search/variables_9.js b/docs/html/search/variables_9.js index ce82adb..f24859e 100644 --- a/docs/html/search/variables_9.js +++ b/docs/html/search/variables_9.js @@ -1,5 +1,6 @@ var searchData= [ + ['t_5fworker',['t_worker',['../classViewMonitor.html#a377eb8deab3061aa4e084be9b791c056',1,'ViewMonitor']]], ['text',['text',['../classViewInfo.html#ac392a569ef16af3dc11ee659f3fa1eb4',1,'ViewInfo']]], ['text_5foffset_5fx',['text_offset_x',['../classViewInfo.html#a4681a8138f17ea229aca02e6db7357cd',1,'ViewInfo']]], ['text_5foffset_5fy',['text_offset_y',['../classViewInfo.html#a34a9239c8954a0c27a22cf44d112f5b8',1,'ViewInfo']]], diff --git a/docs/html/timeoutexception_8h_source.html b/docs/html/timeoutexception_8h_source.html index 727164e..edb008d 100644 --- a/docs/html/timeoutexception_8h_source.html +++ b/docs/html/timeoutexception_8h_source.html @@ -79,7 +79,7 @@ $(function() {
    TimeoutException(const std::string &message)
    diff --git a/docs/html/ui_8cpp_source.html b/docs/html/ui_8cpp_source.html index 9e932c4..8e57797 100644 --- a/docs/html/ui_8cpp_source.html +++ b/docs/html/ui_8cpp_source.html @@ -71,7 +71,7 @@ $(function() {
    1 #include "ui.h"
    2 #include "../drv/b15f.h"
    3 
    4 std::vector<View*> win_stack;
    5 std::thread t_refresh;
    6 
    7 void show_main(int)
    8 {
    9  ViewSelection* view = new ViewSelection();
    10  view->setTitle("B15F - Command Line Interface");
    11  view->addChoice("[ Monitor - Eingaben beobachten ]", &show_monitor);
    12  view->addChoice("[ Digitale Ausgabe BA0 ]", &show_digital_output0);
    13  view->addChoice("[ Digitale Ausgabe BA1 ]", &show_digital_output1);
    14  view->addChoice("[ Analoge Ausgabe AA0 ]", &show_analog_output0);
    15  view->addChoice("[ Analoge Ausgabe AA1 ]", &show_analog_output1);
    16  view->addChoice("[ Selbsttest des B15 ]", &show_selftest_info);
    17  view->addChoice("[ Informationen ]", &show_info);
    18  view->addChoice("", nullptr);
    19  view->addChoice("[ Beenden ]", &finish);
    20  view->repaint();
    21 
    22  win_stack.push_back(view);
    23  input(0);
    24 }
    25 
    26 void input(int)
    27 {
    28  call_t nextCall;
    29  int key;
    30  do
    31  {
    32  key = wgetch(View::getWinContext());
    33  win_stack.back()->repaint();
    34  nextCall = win_stack.back()->keypress(key);
    35 
    36  if(key == -1)
    37  view_back(key);
    38 
    39  if(nextCall)
    40  nextCall(key);
    41  }
    42  while(win_stack.size());
    43 }
    44 
    45 void view_back(int)
    46 {
    47  if(win_stack.size())
    48  {
    49  delete win_stack.back();
    50  win_stack.pop_back();
    51  }
    52  if(win_stack.size())
    53  win_stack.back()->repaint();
    54 }
    55 
    56 void finish(int)
    57 {
    58  cleanup();
    59  exit(EXIT_SUCCESS);
    60 }
    61 
    62 void cleanup()
    63 {
    64  if(t_refresh.joinable())
    65  t_refresh.join();
    66  clrtoeol();
    67  refresh();
    68  endwin();
    69 }
    70 
    71 void show_info(int)
    72 {
    73  ViewInfo* view = new ViewInfo();
    74  view->setTitle("Info");
    75  view->setText("Informationen zu Board 15 Famulus Edition\n \nProjektseite: https://github.com/devfix/b15f/\nDokumentation: https://devfix.github.io/b15f/\n \nB15F Software entwickelt von Tristan Krause für das Hardware-Labor.\nKontakt: tristan.krause@stud.htwk-leipzig.de");
    76  view->setLabelClose("[ Zurueck ]");
    77  view->repaint();
    78 
    79  win_stack.push_back(view);
    80  input(0);
    81 }
    82 
    83 void show_monitor(int)
    84 {
    85  ViewMonitor* view = new ViewMonitor();
    86  view->setTitle("Monitor");
    87  view->setText("\nErfasse Messwerte...");
    88  view->setLabelClose("[ Zurueck ]");
    89  view->repaint();
    90 
    91  win_stack.push_back(view);
    92  input(0);
    93 }
    94 
    95 void show_invalid_port_input(int)
    96 {
    97  ViewInfo* view = new ViewInfo();
    98  view->setTitle("Falsche Eingabe");
    99  view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, FF] an.");
    100  view->setLabelClose("[ Schliessen ]");
    101  view->repaint();
    102 
    103  win_stack.push_back(view);
    104  input(0);
    105 }
    106 
    107 void show_invalid_dac_input(int)
    108 {
    109  ViewInfo* view = new ViewInfo();
    110  view->setTitle("Falsche Eingabe");
    111  view->setText("Bitte geben Sie einen Wert aus dem Intervall [0, 1023] an.");
    112  view->setLabelClose("[ Schliessen ]");
    113  view->repaint();
    114 
    115  win_stack.push_back(view);
    116  input(0);
    117 }
    118 
    119 void write_digital_output0(int)
    120 {
    121  try
    122  {
    123  int d = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput(), 0, 16);
    124  if(d > 255 || 0 > d)
    125  throw std::invalid_argument("bad value");
    126  uint8_t port = static_cast<uint8_t>(d);
    127 
    128  B15F& drv = B15F::getInstance();
    129  drv.digitalWrite0(port);
    130  view_back(0);
    131  }
    132  catch(std::invalid_argument& ex)
    133  {
    134  show_invalid_port_input(0);
    135  }
    136 }
    137 
    138 void write_digital_output1(int)
    139 {
    140  try
    141  {
    142  int d = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput(), 0, 16);
    143  if(d > 255 || 0 > d)
    144  throw std::invalid_argument("bad value");
    145  uint8_t port = static_cast<uint8_t>(d);
    146 
    147  B15F& drv = B15F::getInstance();
    148  drv.digitalWrite1(port);
    149  view_back(0);
    150  }
    151  catch(std::invalid_argument& ex)
    152  {
    153  show_invalid_port_input(0);
    154  }
    155 }
    156 
    157 void write_analog_output0(int)
    158 {
    159  try
    160  {
    161  uint16_t port = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput());
    162  if(port > 1023)
    163  throw std::invalid_argument("bad value");
    164 
    165  B15F& drv = B15F::getInstance();
    166  drv.analogWrite0(port);
    167  view_back(0);
    168  }
    169  catch(std::invalid_argument& ex)
    170  {
    171  show_invalid_dac_input(0);
    172  }
    173 }
    174 
    175 void write_analog_output1(int)
    176 {
    177  try
    178  {
    179  uint16_t port = std::stoi(static_cast<ViewPromt*>(win_stack.back())->getInput());
    180  if(port > 1023)
    181  throw std::invalid_argument("bad value");
    182 
    183  B15F& drv = B15F::getInstance();
    184  drv.analogWrite1(port);
    185  view_back(0);
    186  }
    187  catch(std::invalid_argument& ex)
    188  {
    189  show_invalid_dac_input(0);
    190  }
    191 }
    192 
    193 void show_digital_output0(int)
    194 {
    195  ViewPromt* view = new ViewPromt();
    196  view->setTitle("Digitale Ausgabe BE0");
    197  view->setMessage("\nAusgabe Port-Wert (hex): 0x");
    198  view->setCancel("[ Zurueck ]", true);
    199  view->setConfirm("[ OK ]", &write_digital_output0);
    200  view->repaint();
    201 
    202  win_stack.push_back(view);
    203  input(0);
    204 }
    205 
    206 void show_digital_output1(int)
    207 {
    208  ViewPromt* view = new ViewPromt();
    209  view->setTitle("Digitale Ausgabe BE1");
    210  view->setMessage("\nAusgabe Port-Wert (hex): 0x");
    211  view->setCancel("[ Zurueck ]", true);
    212  view->setConfirm("[ OK ]", &write_digital_output1);
    213  view->repaint();
    214 
    215  win_stack.push_back(view);
    216  input(0);
    217 }
    218 
    219 void show_analog_output0(int)
    220 {
    221  ViewPromt* view = new ViewPromt();
    222  view->setTitle("Analoge Ausgabe AA0");
    223  view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): ");
    224  view->setCancel("[ Zurueck ]", true);
    225  view->setConfirm("[ OK ]", &write_analog_output0);
    226  view->repaint();
    227 
    228  win_stack.push_back(view);
    229  input(0);
    230 }
    231 
    232 void show_analog_output1(int)
    233 {
    234  ViewPromt* view = new ViewPromt();
    235  view->setTitle("Analoge Ausgabe AA1");
    236  view->setMessage("\nAusgabe 10-Bit-Wert (0...1023): ");
    237  view->setCancel("[ Zurueck ]", true);
    238  view->setConfirm("[ OK ]", &write_analog_output1);
    239  view->repaint();
    240 
    241  win_stack.push_back(view);
    242  input(0);
    243 }
    244 
    245 void start_selftest(int)
    246 {
    247  B15F& drv = B15F::getInstance();
    248  drv.activateSelfTestMode();
    249 
    250  ViewInfo* view = new ViewInfo();
    251  view->setTitle("Selbsttest aktiv");
    252  view->setText("Das B15 befindet sich jetzt im Selbsttestmodus.\n \nSelbsttest:\nZu Beginn geht der Reihe nach jede LED von BA0 bis BA1 an.\nDanach leuchten die LEDs an AA0 und AA1 kurz auf.\nZum Schluss spiegelt in einer Endlosschleife:\n* BA0 Port BE0\n* BA1 die DIP-Schalter S7\n* AA0 ADC0\n* AA1 ADC1");
    253  view->setLabelClose("[ Selbsttest Beenden ]");
    254  view->setCall(&stop_selftest);
    255  view->repaint();
    256 
    257  win_stack.push_back(view);
    258  input(0);
    259 }
    260 
    261 void stop_selftest(int)
    262 {
    263  B15F& drv = B15F::getInstance();
    264  drv.discard();
    266  drv.reconnect();
    267  drv.digitalWrite0(0);
    268  drv.digitalWrite1(0);
    269 }
    270 
    271 void show_selftest_info(int)
    272 {
    273  ViewInfo* view = new ViewInfo();
    274  view->setTitle("Selbsttest");
    275  view->setText("Bitte entfernen Sie jetzt alle Draehte von den Anschlussklemmen und\nbestätigen mit Enter.");
    276  view->setLabelClose("[ Weiter ]");
    277  view->setCall(&start_selftest);
    278  view->repaint();
    279 
    280  win_stack.push_back(view);
    281  input(0);
    282 }
    - +
    void analogWrite0(uint16_t port)
    Definition: b15f.cpp:312
    void analogWrite1(uint16_t port)
    Definition: b15f.cpp:329
    void digitalWrite0(uint8_t)
    Definition: b15f.cpp:219
    @@ -94,7 +94,7 @@ $(function() {
    void digitalWrite1(uint8_t)
    Definition: b15f.cpp:237
    diff --git a/docs/html/ui_8h_source.html b/docs/html/ui_8h_source.html index 71ae0b6..6e0faf6 100644 --- a/docs/html/ui_8h_source.html +++ b/docs/html/ui_8h_source.html @@ -73,7 +73,7 @@ $(function() {
    1 #ifndef UI_H
    2 #define UI_H
    3 
    4 #include <vector>
    5 #include "view_selection.h"
    6 #include "view_info.h"
    7 #include "view_monitor.h"
    8 #include "view_promt.h"
    9 
    10 void show_main(int);
    11 void input(int);
    12 void view_back(int);
    13 void finish(int);
    14 void cleanup();
    15 
    16 void show_info(int);
    17 void show_monitor(int);
    18 void show_invalid_port_input(int);
    19 void show_invalid_dac_input(int);
    20 void write_digital_output0(int);
    21 void write_digital_output1(int);
    22 void write_analog_output0(int);
    23 void write_analog_output1(int);
    24 void show_digital_output0(int);
    25 void show_digital_output1(int);
    26 void show_analog_output0(int);
    27 void show_analog_output1(int);
    28 
    29 // selftest group
    30 void show_selftest_info(int);
    31 void start_selftest(int);
    32 void stop_selftest(int);
    33 
    34 
    35 extern std::vector<View*> win_stack;
    36 extern std::thread t_refresh;
    37 
    38 #endif // UI_H
    diff --git a/docs/html/usart_8cpp_source.html b/docs/html/usart_8cpp_source.html index 67e7ceb..cadc1f6 100644 --- a/docs/html/usart_8cpp_source.html +++ b/docs/html/usart_8cpp_source.html @@ -88,7 +88,7 @@ $(function() { diff --git a/docs/html/usart_8h_source.html b/docs/html/usart_8h_source.html index eaf2eb7..4ebd986 100644 --- a/docs/html/usart_8h_source.html +++ b/docs/html/usart_8h_source.html @@ -88,7 +88,7 @@ $(function() {
    void flushOutputBuffer(void)
    Definition: usart.cpp:68
    diff --git a/docs/html/usartexception_8h_source.html b/docs/html/usartexception_8h_source.html index ca27f65..95dbb21 100644 --- a/docs/html/usartexception_8h_source.html +++ b/docs/html/usartexception_8h_source.html @@ -79,7 +79,7 @@ $(function() {
    virtual ~USARTException()=default
    diff --git a/docs/html/view_8cpp_source.html b/docs/html/view_8cpp_source.html index f2e3888..3004ac5 100644 --- a/docs/html/view_8cpp_source.html +++ b/docs/html/view_8cpp_source.html @@ -88,7 +88,7 @@ $(function() {
    virtual void draw(void)=0
    diff --git a/docs/html/view_8h_source.html b/docs/html/view_8h_source.html index 920047c..c8948a3 100644 --- a/docs/html/view_8h_source.html +++ b/docs/html/view_8h_source.html @@ -91,7 +91,7 @@ $(function() {
    constexpr static int KEY_ENT
    Key value for the Enter key.
    Definition: view.h:87
    diff --git a/docs/html/view__info_8cpp_source.html b/docs/html/view__info_8cpp_source.html index 71a96b6..9261c88 100644 --- a/docs/html/view__info_8cpp_source.html +++ b/docs/html/view__info_8cpp_source.html @@ -93,7 +93,7 @@ $(function() {
    constexpr static int KEY_ENT
    Key value for the Enter key.
    Definition: view.h:87
    diff --git a/docs/html/view__info_8h_source.html b/docs/html/view__info_8h_source.html index d5bf10e..24ae3f4 100644 --- a/docs/html/view__info_8h_source.html +++ b/docs/html/view__info_8h_source.html @@ -87,7 +87,7 @@ $(function() {
    virtual void draw(void) override
    Definition: view_info.cpp:23
    diff --git a/docs/html/view__monitor_8cpp_source.html b/docs/html/view__monitor_8cpp_source.html index df59651..fcd6f9a 100644 --- a/docs/html/view__monitor_8cpp_source.html +++ b/docs/html/view__monitor_8cpp_source.html @@ -70,14 +70,15 @@ $(function() {
    view_monitor.cpp
    -
    1 #include "view_monitor.h"
    2 
    3 ViewMonitor::ViewMonitor() : t_worker(&ViewMonitor::worker, this)
    4 {
    5 }
    6 
    7 call_t ViewMonitor::keypress(int& key)
    8 {
    9  switch(key)
    10  {
    11 
    12  case KEY_MOUSE:
    13  {
    14  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    15  MEVENT event;
    16  bool hit = false;
    17  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    18  {
    19  size_t column = start_x + close_offset_x;
    20  size_t row = start_y + close_offset_y;
    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())
    23  hit = true;
    24  }
    25  if(!hit)
    26  break;
    27 
    28  // fall through to next case
    29  [[fallthrough]];
    30  }
    31  case KEY_ENT:
    32  run_worker = false;
    33  key = -1; // do return from view
    34  wclear(win);
    35  wrefresh(win);
    36  t_worker.join();
    37  break;
    38  default:
    39  break;
    40  }
    41  return calls[0];
    42 }
    43 
    44 std::string ViewMonitor::fancyDigitalString(uint8_t& b)
    45 {
    46  std::string bitstring(std::bitset<8>(b).to_string());
    47  // std::reverse(bitstring.begin(), bitstring.end()); nicht mehr notwendig, B15F invertiert automatisch den port
    48 
    49  std::stringstream str;
    50  str << bitstring;
    51  str << " ";
    52  str << "0x" << std::setfill ('0') << std::setw(2) << std::hex << (int) b << std::dec;
    53  return str.str();
    54 }
    55 
    56 std::string ViewMonitor::fancyAnalogString(uint16_t& v)
    57 {
    58  std::stringstream str;
    59  double volt = round(v * 100.0 * 5.0 / 1023.0) / 100.0;
    60 
    61  str << std::setfill ('0') << std::setw(4) << (int) v << " " << std::fixed << std::setprecision(2) << volt << " V ";
    62 
    63  str << "[";
    64  uint8_t p = round(v * 40.0 / 1023.0);
    65  for(uint8_t i = 0; i < p; i++)
    66  str << "X";
    67  for(uint8_t i = 0; i < 40 - p; i++)
    68  str << " ";
    69  str << "]" << std::endl;
    70 
    71  return str.str();
    72 }
    73 
    74 void ViewMonitor::worker()
    75 {
    76  B15F& drv = B15F::getInstance();
    77  while(run_worker)
    78  {
    79  try
    80  {
    81 
    82 #ifdef __arm__
    83  // Raspberry Pi is much slower
    84  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    85 #else
    86  // normal PC is faster
    87  std::this_thread::sleep_for(std::chrono::milliseconds(100));
    88 #endif
    89 
    90  uint8_t be0 = drv.digitalRead0();
    91  uint8_t be1 = drv.digitalRead1();
    92  uint8_t dsw = drv.readDipSwitch();
    93  uint16_t adc[8];
    94  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    95  adc[i] = drv.analogRead(i);
    96 
    97 
    98  std::stringstream str;
    99 
    100  // hline
    101  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    102  if(i % 2 == 0)
    103  str << "-";
    104  else
    105  str << " ";
    106  str << std::endl;
    107 
    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;
    112 
    113  // hline
    114  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    115  if(i % 2 == 0)
    116  str << "-";
    117  else
    118  str << " ";
    119  str << std::endl;
    120 
    121  str << "Analoge Eingaenge:" << std::endl;
    122  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    123  {
    124  str << "Kanal " << std::to_string((int) i) << ": ";
    125  str << fancyAnalogString(adc[i]) << std::endl;
    126  }
    127 
    128  text = str.str();
    129  repaint();
    130  }
    131  catch(DriverException& ex)
    132  {
    133  std::cout << "DriverException: " << ex.what() << std::endl;
    134  drv.delay_ms(1000);
    135  }
    136  catch(...)
    137  {
    138  try
    139  {
    140  drv.reconnect();
    141  }
    142  catch(...)
    143  {
    144  B15F::abort("Die Verbindung ist unterbrochen worden. Wurde ein Stecker gezogen? :D");
    145  return;
    146  }
    147  }
    148  }
    149 }
    +
    1 #include "view_monitor.h"
    2 
    3 ViewMonitor::ViewMonitor() : t_worker(&ViewMonitor::worker, this)
    4 {
    5 }
    6 
    7 call_t ViewMonitor::keypress(int& key)
    8 {
    9  switch(key)
    10  {
    11 
    12  case KEY_MOUSE:
    13  {
    14  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
    15  MEVENT event;
    16  bool hit = false;
    17  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
    18  {
    19  size_t column = start_x + close_offset_x;
    20  size_t row = start_y + close_offset_y;
    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())
    23  hit = true;
    24  }
    25  if(!hit)
    26  break;
    27 
    28  // fall through to next case
    29  [[fallthrough]];
    30  }
    31  case KEY_ENT:
    32  run_worker = false;
    33  key = -1; // do return from view
    34  wclear(win);
    35  wrefresh(win);
    36  t_worker.join();
    37  break;
    38  default:
    39  break;
    40  }
    41  return calls[0];
    42 }
    43 
    44 std::string ViewMonitor::fancyDigitalString(uint8_t& b)
    45 {
    46  std::string bitstring(std::bitset<8>(b).to_string());
    47  // std::reverse(bitstring.begin(), bitstring.end()); nicht mehr notwendig, B15F invertiert automatisch den port
    48 
    49  std::stringstream str;
    50  str << bitstring;
    51  str << " ";
    52  str << "0x" << std::setfill ('0') << std::setw(2) << std::hex << (int) b << std::dec;
    53  return str.str();
    54 }
    55 
    56 std::string ViewMonitor::fancyAnalogString(uint16_t& v)
    57 {
    58  std::stringstream str;
    59  double volt = round(v * 100.0 * 5.0 / 1023.0) / 100.0;
    60 
    61  str << std::setfill ('0') << std::setw(4) << (int) v << " " << std::fixed << std::setprecision(2) << volt << " V ";
    62 
    63  str << "[";
    64  uint8_t p = round(v * 40.0 / 1023.0);
    65  for(uint8_t i = 0; i < p; i++)
    66  str << "X";
    67  for(uint8_t i = 0; i < 40 - p; i++)
    68  str << " ";
    69  str << "]" << std::endl;
    70 
    71  return str.str();
    72 }
    73 
    75 {
    76  B15F& drv = B15F::getInstance();
    77  while(run_worker)
    78  {
    79  try
    80  {
    81 
    82 #ifdef __arm__
    83  // Raspberry Pi is much slower
    84  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    85 #else
    86  // normal PC is faster
    87  std::this_thread::sleep_for(std::chrono::milliseconds(100));
    88 #endif
    89 
    90  uint8_t be0 = drv.digitalRead0();
    91  uint8_t be1 = drv.digitalRead1();
    92  uint8_t dsw = drv.readDipSwitch();
    93  uint16_t adc[8];
    94  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    95  adc[i] = drv.analogRead(i);
    96 
    97 
    98  std::stringstream str;
    99 
    100  // hline
    101  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    102  if(i % 2 == 0)
    103  str << "-";
    104  else
    105  str << " ";
    106  str << std::endl;
    107 
    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;
    112 
    113  // hline
    114  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    115  if(i % 2 == 0)
    116  str << "-";
    117  else
    118  str << " ";
    119  str << std::endl;
    120 
    121  str << "Analoge Eingaenge:" << std::endl;
    122  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    123  {
    124  str << "Kanal " << std::to_string((int) i) << ": ";
    125  str << fancyAnalogString(adc[i]) << std::endl;
    126  }
    127 
    128  text = str.str();
    129  repaint();
    130  }
    131  catch(DriverException& ex)
    132  {
    133  std::cout << "DriverException: " << ex.what() << std::endl;
    134  drv.delay_ms(1000);
    135  }
    136  catch(...)
    137  {
    138  try
    139  {
    140  drv.reconnect();
    141  }
    142  catch(...)
    143  {
    144  B15F::abort("Die Verbindung ist unterbrochen worden. Wurde ein Stecker gezogen? :D");
    145  return;
    146  }
    147  }
    148  }
    149 }
    virtual call_t keypress(int &key) override
    Definition: view_monitor.cpp:7
    - +
    constexpr static int text_offset_x
    Relativer Abstand des Textes zum linken Rahmen.
    Definition: view_info.h:55
    int width
    width of view in terminal characters
    Definition: view.h:79
    uint8_t digitalRead0(void)
    Definition: b15f.cpp:255
    virtual const char * what() const
    uint8_t readDipSwitch(void)
    Definition: b15f.cpp:293
    +
    ViewMonitor(void)
    Definition: view_monitor.cpp:3
    void delay_ms(uint16_t ms)
    Definition: b15f.cpp:141
    std::vector< call_t > calls
    calls (function pointers) for different button actions in the view (if any)
    Definition: view.h:84
    static B15F & getInstance(void)
    Definition: b15f.cpp:10
    @@ -88,17 +89,20 @@ $(function() {
    std::string label_close
    Beschriftung für Button zum Schließen.
    Definition: view_info.h:52
    uint16_t analogRead(uint8_t channel)
    Definition: b15f.cpp:346
    virtual void repaint(void)
    Definition: view.cpp:52
    +
    volatile bool run_worker
    Legt fest, ob die Schleife im worker() weiterhin fortgeführt werden soll. Bei false bricht die Schlei...
    Definition: view_monitor.h:47
    +
    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.
    Definition: view_info.h:54
    uint8_t digitalRead1(void)
    Definition: b15f.cpp:274
    void reconnect(void)
    Definition: b15f.cpp:18
    int start_x
    x offset (characters) in the terminal, used to center the window on repaint()
    Definition: view.h:81
    std::string text
    Benachrichtigungstext dieser View.
    Definition: view_info.h:51
    int start_y
    y offset (characters) in the terminal, used to center the window on repaint()
    Definition: view.h:82
    +
    std::thread t_worker
    Worker-Thread.
    Definition: view_monitor.h:48
    constexpr static int KEY_ENT
    Key value for the Enter key.
    Definition: view.h:87
    diff --git a/docs/html/view__monitor_8h_source.html b/docs/html/view__monitor_8h_source.html index 9f22b05..624d78e 100644 --- a/docs/html/view__monitor_8h_source.html +++ b/docs/html/view__monitor_8h_source.html @@ -70,13 +70,17 @@ $(function() {
    view_monitor.h
    -
    1 #ifndef VIEW_MONITOR_H
    2 #define VIEW_MONITOR_H
    3 
    4 #include <thread>
    5 #include <chrono>
    6 #include <sstream>
    7 #include <bitset>
    8 #include "view_info.h"
    9 #include "../drv/b15f.h"
    10 
    13 class ViewMonitor : public ViewInfo
    14 {
    15 
    16 public:
    17  ViewMonitor(void);
    18  virtual call_t keypress(int& key) override;
    19 
    20 private:
    21  std::string fancyDigitalString(uint8_t& b);
    22  std::string fancyAnalogString(uint16_t& v);
    23 
    24 protected:
    25  virtual void worker(void);
    26  volatile bool run_worker = true;
    27  std::thread t_worker;
    28 
    29 };
    30 
    31 #endif // VIEW_MONITOR_H
    +
    1 #ifndef VIEW_MONITOR_H
    2 #define VIEW_MONITOR_H
    3 
    4 #include <thread>
    5 #include <chrono>
    6 #include <sstream>
    7 #include <bitset>
    8 #include "view_info.h"
    9 #include "../drv/b15f.h"
    10 
    15 class ViewMonitor : public ViewInfo
    16 {
    17 
    18 public:
    22  ViewMonitor(void);
    23 
    29  virtual call_t keypress(int& key) override;
    30 
    31 private:
    37  std::string fancyDigitalString(uint8_t& b);
    43  std::string fancyAnalogString(uint16_t& v);
    44 
    45 protected:
    46  virtual void worker(void);
    47  volatile bool run_worker = true;
    48  std::thread t_worker;
    49 
    50 };
    51 
    52 #endif // VIEW_MONITOR_H
    virtual call_t keypress(int &key) override
    Definition: view_monitor.cpp:7
    - + +
    ViewMonitor(void)
    Definition: view_monitor.cpp:3
    +
    volatile bool run_worker
    Legt fest, ob die Schleife im worker() weiterhin fortgeführt werden soll. Bei false bricht die Schlei...
    Definition: view_monitor.h:47
    +
    virtual void worker(void)
    Funktion, die vom Worker-Thread ausgeführt, um die Anzeige zu aktualisieren.
    +
    std::thread t_worker
    Worker-Thread.
    Definition: view_monitor.h:48
    diff --git a/docs/html/view__promt_8cpp_source.html b/docs/html/view__promt_8cpp_source.html index d838c02..302a6d4 100644 --- a/docs/html/view__promt_8cpp_source.html +++ b/docs/html/view__promt_8cpp_source.html @@ -83,7 +83,7 @@ $(function() {
    constexpr static int KEY_ENT
    Key value for the Enter key.
    Definition: view.h:87
    diff --git a/docs/html/view__promt_8h_source.html b/docs/html/view__promt_8h_source.html index c67bb83..f464d3a 100644 --- a/docs/html/view__promt_8h_source.html +++ b/docs/html/view__promt_8h_source.html @@ -77,7 +77,7 @@ $(function() {
    virtual call_t keypress(int &key) override
    Definition: view_promt.cpp:59
    diff --git a/docs/html/view__selection_8cpp_source.html b/docs/html/view__selection_8cpp_source.html index b953db6..74092ac 100644 --- a/docs/html/view__selection_8cpp_source.html +++ b/docs/html/view__selection_8cpp_source.html @@ -81,7 +81,7 @@ $(function() {
    constexpr static int KEY_ENT
    Key value for the Enter key.
    Definition: view.h:87
    diff --git a/docs/html/view__selection_8h_source.html b/docs/html/view__selection_8h_source.html index 06965d3..f6908e6 100644 --- a/docs/html/view__selection_8h_source.html +++ b/docs/html/view__selection_8h_source.html @@ -77,7 +77,7 @@ $(function() {
    virtual void draw(void) override