From 6dff81fb75d39a4b063b6c8a1cb98a9aff0c3669 Mon Sep 17 00:00:00 2001 From: devfix Date: Thu, 4 Jul 2019 11:31:30 +0200 Subject: [PATCH] commit hash fixed --- control/src/Makefile | 2 +- control/src/drv/b15f.h | 2 +- control/src/drv/commit_hash.h | 4 + docs/html/annotated.html | 2 +- docs/html/b15f_8cpp_source.html | 2 +- docs/html/b15f_8h_source.html | 4 +- docs/html/classB15F-members.html | 2 +- docs/html/classB15F.html | 2 +- docs/html/classDot-members.html | 2 +- docs/html/classDot.html | 8 +- 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 | 2 +- docs/html/classViewMonitor.html | 2 +- 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 | 4 +- docs/html/driverexception_8h_source.html | 2 +- docs/html/drv_2commit__hash_8h_source.html | 81 +++++++++++++++++++ docs/html/files.html | 53 ++++++------ docs/html/functions.html | 2 +- docs/html/functions_func.html | 2 +- docs/html/functions_vars.html | 2 +- docs/html/hierarchy.html | 2 +- docs/html/index.html | 2 +- docs/html/plottyfile_8cpp_source.html | 2 +- docs/html/plottyfile_8h_source.html | 4 +- docs/html/requests_8h_source.html | 2 +- docs/html/timeoutexception_8h_source.html | 2 +- docs/html/ui_8cpp_source.html | 2 +- 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 | 2 +- docs/html/view__monitor_8h_source.html | 2 +- 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 +- 64 files changed, 180 insertions(+), 94 deletions(-) create mode 100644 control/src/drv/commit_hash.h create mode 100644 docs/html/drv_2commit__hash_8h_source.html diff --git a/control/src/Makefile b/control/src/Makefile index 2aabfc2..2b782de 100644 --- a/control/src/Makefile +++ b/control/src/Makefile @@ -94,7 +94,7 @@ clean: commit_hash: @echo "Updating commit hash..." - @bash -c 'echo -e "#ifndef COMMIT_HASH_H\n#define COMMIT_HASH_H\nconst char COMMIT_HASH[] = \"`git log --pretty=format:'%H' -n 1`\";\n#endif // COMMIT_HASH_H" > commit_hash.h' + @bash -c 'echo -e "#ifndef COMMIT_HASH_H\n#define COMMIT_HASH_H\nconst char COMMIT_HASH[] = \"`git log --pretty=format:'%H' -n 1`\";\n#endif // COMMIT_HASH_H" > drv/commit_hash.h' .cpp.o: $(PATH_COMPILER) $(CFLAGS) -c $< -o $@ diff --git a/control/src/drv/b15f.h b/control/src/drv/b15f.h index 978987f..f1dc177 100644 --- a/control/src/drv/b15f.h +++ b/control/src/drv/b15f.h @@ -15,7 +15,7 @@ #include #include -#include "../commit_hash.h" +#include "commit_hash.h" #include "requests.h" #include "usart.h" #include "driverexception.h" diff --git a/control/src/drv/commit_hash.h b/control/src/drv/commit_hash.h new file mode 100644 index 0000000..f0106a0 --- /dev/null +++ b/control/src/drv/commit_hash.h @@ -0,0 +1,4 @@ +#ifndef COMMIT_HASH_H +#define COMMIT_HASH_H +const char COMMIT_HASH[] = "018bd1057deef81d8a44a808b7c68fb29abc3be6"; +#endif // COMMIT_HASH_H diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 2e2599b..d0cc50d 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 d0ebb36..fff65bb 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 97f2b50..72c751e 100644 --- a/docs/html/b15f_8h_source.html +++ b/docs/html/b15f_8h_source.html @@ -70,7 +70,7 @@ $(function() {
b15f.h
-
1 #ifndef B15F_H
2 #define B15F_H
3 
4 #include <iostream>
5 #include <bits/stdc++.h>
6 #include <string>
7 #include <fstream>
8 #include <cstdlib>
9 #include <chrono>
10 #include <cstdint>
11 #include <vector>
12 
13 #include <unistd.h>
14 #include <fcntl.h>
15 #include <sys/ioctl.h>
16 #include <termios.h>
17 
18 #include "../commit_hash.h"
19 #include "requests.h"
20 #include "usart.h"
21 #include "driverexception.h"
22 #include "timeoutexception.h"
23 
24 // wichtig für die Register-Zugriffe
25 #define _AVR_IO_H_ 1 // Erzwinge die Inklusion
26 #include "/usr/lib/avr/include/avr/sfr_defs.h"
27 #include "/usr/lib/avr/include/avr/iom1284p.h"
28 
29 typedef std::function<void(std::exception&)> errorhandler_t;
30 
31 // Wrapper für Codeposition-Ersetzung
32 #define assertCode(code, expectation) assertCodeFunc(code, expectation, &__FUNCTION__[0], &__FILE__[0], __LINE__)
33 #define assertRequestLength(rq, rq_num) assertRequestLengthFunc(rq, rq_num,& __FUNCTION__[0], &__FILE__[0], __LINE__)
34 
35 
38 class B15F
39 {
40 public:
41 
42  /*************************************
43  * Grundfunktionen des B15F Treibers *
44  *************************************/
45 
50  static B15F& getInstance(void);
51 
56  void reconnect(void);
57 
62  void discard(void);
63 
68  void testConnection(void);
69 
74  void testIntConv(void);
75 
80  std::vector<std::string> getBoardInfo(void);
81 
86  void delay_ms(uint16_t ms);
87 
92  void delay_us(uint16_t us);
93 
99  void reverse(uint8_t& b);
100 
105  static std::string exec(std::string cmd);
106 
111  static void abort(std::string msg);
112 
117  static void abort(std::exception& ex);
118 
123  static void setAbortHandler(errorhandler_t func);
124 
125  /*************************************/
126 
127 
128 
129  /*************************
130  * Steuerbefehle für B15 *
131  *************************/
132 
138  void activateSelfTestMode(void);
139 
145  void digitalWrite0(uint8_t);
146 
152  void digitalWrite1(uint8_t);
153 
159  uint8_t digitalRead0(void);
160 
166  uint8_t digitalRead1(void);
167 
173  uint8_t readDipSwitch(void);
174 
180  void analogWrite0(uint16_t port);
181 
187  void analogWrite1(uint16_t port);
188 
194  uint16_t analogRead(uint8_t channel);
195 
211  void analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count);
212 
222  uint8_t pwmSetFrequency(uint32_t freq);
223 
229  void pwmSetValue(uint8_t value);
230 
239  void setMem8(volatile uint8_t* adr, uint8_t val);
240 
247  uint8_t getMem8(volatile uint8_t* adr);
248 
257  void setMem16(volatile uint16_t* adr, uint16_t val);
258 
265  uint16_t getMem16(volatile uint16_t* adr);
266 
274  void setRegister(volatile uint8_t* adr, uint8_t val);
275 
281  uint8_t getRegister(volatile uint8_t* adr);
282 
287  uint16_t* getInterruptCounterOffset(void);
288 
293  void setServoEnabled(void);
294 
299  void setServoDisabled(void);
300 
306  void setServoPosition(uint16_t pos);
307 
308  /*************************/
309 
310 
311  // CONSTANTS
312  const std::string PRE = "[B15F] ";
313  constexpr static uint8_t MSG_OK = 0xFF;
314  constexpr static uint8_t MSG_FAIL = 0xFE;
315  constexpr static uint16_t RECONNECT_TIMEOUT = 64;
316  constexpr static uint16_t WDT_TIMEOUT = 15;
317  constexpr static uint8_t RECONNECT_TRIES = 3;
318  constexpr static uint32_t BAUDRATE = 57600;
319 
320 private:
321 
325  B15F(void);
326 
331  void init(void);
332 
337  template<typename CodeType, typename ExpectationType>
338  void assertCodeFunc(CodeType& code, ExpectationType expectation, const char* func, const char* file, int line) const
339  {
340  if(code != static_cast<CodeType>(expectation))
341  throw DriverException("Ungültige Antwort erhalten: " + std::to_string((int) code) + " (erwartet: " + std::to_string((int) expectation) + ") in " + std::string(func) + ": " + std::string(file) + "#" + std::to_string(line));
342  }
343 
348  template<size_t RequestLength>
349  void assertRequestLengthFunc(uint8_t (&)[RequestLength], uint8_t rq_num, const char* func, const char* file, int line)
350  {
351  if(RequestLength != rq_len[rq_num])
352  throw DriverException("Ungültige Request Länge: " + std::to_string(RequestLength) + " (erwartet: " + std::to_string(rq_len[rq_num]) + ") in " + std::string(func) + ": " + std::string(file) + "#" + std::to_string(line));
353  }
354 
355  USART usart;
356  static B15F* instance;
357  static errorhandler_t errorhandler;
358 };
359 
360 #endif // B15F_H
+
1 #ifndef B15F_H
2 #define B15F_H
3 
4 #include <iostream>
5 #include <bits/stdc++.h>
6 #include <string>
7 #include <fstream>
8 #include <cstdlib>
9 #include <chrono>
10 #include <cstdint>
11 #include <vector>
12 
13 #include <unistd.h>
14 #include <fcntl.h>
15 #include <sys/ioctl.h>
16 #include <termios.h>
17 
18 #include "commit_hash.h"
19 #include "requests.h"
20 #include "usart.h"
21 #include "driverexception.h"
22 #include "timeoutexception.h"
23 
24 // wichtig für die Register-Zugriffe
25 #define _AVR_IO_H_ 1 // Erzwinge die Inklusion
26 #include "/usr/lib/avr/include/avr/sfr_defs.h"
27 #include "/usr/lib/avr/include/avr/iom1284p.h"
28 
29 typedef std::function<void(std::exception&)> errorhandler_t;
30 
31 // Wrapper für Codeposition-Ersetzung
32 #define assertCode(code, expectation) assertCodeFunc(code, expectation, &__FUNCTION__[0], &__FILE__[0], __LINE__)
33 #define assertRequestLength(rq, rq_num) assertRequestLengthFunc(rq, rq_num,& __FUNCTION__[0], &__FILE__[0], __LINE__)
34 
35 
38 class B15F
39 {
40 public:
41 
42  /*************************************
43  * Grundfunktionen des B15F Treibers *
44  *************************************/
45 
50  static B15F& getInstance(void);
51 
56  void reconnect(void);
57 
62  void discard(void);
63 
68  void testConnection(void);
69 
74  void testIntConv(void);
75 
80  std::vector<std::string> getBoardInfo(void);
81 
86  void delay_ms(uint16_t ms);
87 
92  void delay_us(uint16_t us);
93 
99  void reverse(uint8_t& b);
100 
105  static std::string exec(std::string cmd);
106 
111  static void abort(std::string msg);
112 
117  static void abort(std::exception& ex);
118 
123  static void setAbortHandler(errorhandler_t func);
124 
125  /*************************************/
126 
127 
128 
129  /*************************
130  * Steuerbefehle für B15 *
131  *************************/
132 
138  void activateSelfTestMode(void);
139 
145  void digitalWrite0(uint8_t);
146 
152  void digitalWrite1(uint8_t);
153 
159  uint8_t digitalRead0(void);
160 
166  uint8_t digitalRead1(void);
167 
173  uint8_t readDipSwitch(void);
174 
180  void analogWrite0(uint16_t port);
181 
187  void analogWrite1(uint16_t port);
188 
194  uint16_t analogRead(uint8_t channel);
195 
211  void analogSequence(uint8_t channel_a, uint16_t* buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t* buffer_b, uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count);
212 
222  uint8_t pwmSetFrequency(uint32_t freq);
223 
229  void pwmSetValue(uint8_t value);
230 
239  void setMem8(volatile uint8_t* adr, uint8_t val);
240 
247  uint8_t getMem8(volatile uint8_t* adr);
248 
257  void setMem16(volatile uint16_t* adr, uint16_t val);
258 
265  uint16_t getMem16(volatile uint16_t* adr);
266 
274  void setRegister(volatile uint8_t* adr, uint8_t val);
275 
281  uint8_t getRegister(volatile uint8_t* adr);
282 
287  uint16_t* getInterruptCounterOffset(void);
288 
293  void setServoEnabled(void);
294 
299  void setServoDisabled(void);
300 
306  void setServoPosition(uint16_t pos);
307 
308  /*************************/
309 
310 
311  // CONSTANTS
312  const std::string PRE = "[B15F] ";
313  constexpr static uint8_t MSG_OK = 0xFF;
314  constexpr static uint8_t MSG_FAIL = 0xFE;
315  constexpr static uint16_t RECONNECT_TIMEOUT = 64;
316  constexpr static uint16_t WDT_TIMEOUT = 15;
317  constexpr static uint8_t RECONNECT_TRIES = 3;
318  constexpr static uint32_t BAUDRATE = 57600;
319 
320 private:
321 
325  B15F(void);
326 
331  void init(void);
332 
338  template<typename CodeType, typename ExpectationType>
339  void assertCodeFunc(CodeType& code, ExpectationType expectation, const char* func, const char* file, int line) const
340  {
341  if(code != static_cast<CodeType>(expectation))
342  throw DriverException("Ungültige Antwort erhalten: " + std::to_string((int) code) + " (erwartet: " + std::to_string((int) expectation) + ") in " + std::string(func) + ": " + std::string(file) + "#" + std::to_string(line));
343  }
344 
350  template<size_t RequestLength>
351  void assertRequestLengthFunc(uint8_t (&)[RequestLength], uint8_t rq_num, const char* func, const char* file, int line)
352  {
353  if(RequestLength != rq_len[rq_num])
354  throw DriverException("Ungültige Request Länge: " + std::to_string(RequestLength) + " (erwartet: " + std::to_string(rq_len[rq_num]) + ") in " + std::string(func) + ": " + std::string(file) + "#" + std::to_string(line));
355  }
356 
357  USART usart;
358  static B15F* instance;
359  static errorhandler_t errorhandler;
360 };
361 
362 #endif // B15F_H
void testIntConv(void)
Definition: b15f.cpp:83
void pwmSetValue(uint8_t value)
Definition: b15f.cpp:431
static std::string exec(std::string cmd)
Definition: b15f.cpp:153
@@ -117,7 +117,7 @@ $(function() { diff --git a/docs/html/classB15F-members.html b/docs/html/classB15F-members.html index 7c59b52..9664079 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 73d98d9..2fea9d4 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 e09bb55..4786d83 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 140f604..65612a5 100644 --- a/docs/html/classDot.html +++ b/docs/html/classDot.html @@ -141,7 +141,7 @@ Public Member Functions
-

Returns the curve index.

+
Returns
the curve index

Definition at line 19 of file dot.cpp.

@@ -162,7 +162,7 @@ Public Member Functions
-

Returns the x coordinate.

+
Returns
the x coordinate

Definition at line 9 of file dot.cpp.

@@ -183,7 +183,7 @@ Public Member Functions
-

Returns the y coordinate.

+
Returns
the y coordinate

Definition at line 14 of file dot.cpp.

@@ -196,7 +196,7 @@ Public Member Functions
diff --git a/docs/html/classDriverException-members.html b/docs/html/classDriverException-members.html index ab6a4d0..10c1b75 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 10efeee..a9fefb8 100644 --- a/docs/html/classDriverException.html +++ b/docs/html/classDriverException.html @@ -109,7 +109,7 @@ std::string msg_< diff --git a/docs/html/classPlottyFile-members.html b/docs/html/classPlottyFile-members.html index 56c067a..9b4d8d7 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 391905c..6cd1eac 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 7d41c44..7836524 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 c44c5fb..3f0d010 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 bb63e2c..e4ff867 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 cc60ce6..01f7ce6 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 dd8cf07..5b1c786 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 96f79f5..9fa1175 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 ede3450..9ba325e 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 ccf46bf..8ecc82e 100644 --- a/docs/html/classView.html +++ b/docs/html/classView.html @@ -157,7 +157,7 @@ constexpr static int KEY_E diff --git a/docs/html/classViewInfo-members.html b/docs/html/classViewInfo-members.html index d189fea..88d6156 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 e032699..5b8d953 100644 --- a/docs/html/classViewInfo.html +++ b/docs/html/classViewInfo.html @@ -185,7 +185,7 @@ static std::vector< std::string >  diff --git a/docs/html/classViewMonitor-members.html b/docs/html/classViewMonitor-members.html index 413942d..35087e1 100644 --- a/docs/html/classViewMonitor-members.html +++ b/docs/html/classViewMonitor-members.html @@ -103,7 +103,7 @@ $(function() { diff --git a/docs/html/classViewMonitor.html b/docs/html/classViewMonitor.html index 745b1ad..6540876 100644 --- a/docs/html/classViewMonitor.html +++ b/docs/html/classViewMonitor.html @@ -197,7 +197,7 @@ constexpr static int KEY_E diff --git a/docs/html/classViewPromt-members.html b/docs/html/classViewPromt-members.html index f37af8d..6c8b55b 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 f33556c..d3b4acb 100644 --- a/docs/html/classViewPromt.html +++ b/docs/html/classViewPromt.html @@ -205,7 +205,7 @@ static std::vector< std::string >  diff --git a/docs/html/classViewSelection-members.html b/docs/html/classViewSelection-members.html index 259bbb9..cb4eeae 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 4a9761e..b3c1ddf 100644 --- a/docs/html/classViewSelection.html +++ b/docs/html/classViewSelection.html @@ -172,7 +172,7 @@ static std::vector< std::string >  diff --git a/docs/html/classes.html b/docs/html/classes.html index dc629f4..3e7be3a 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 5b2f357..c96199c 100644 --- a/docs/html/cli_8cpp_source.html +++ b/docs/html/cli_8cpp_source.html @@ -72,7 +72,7 @@ $(function() {
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:186
diff --git a/docs/html/commit__hash_8h_source.html b/docs/html/commit__hash_8h_source.html index 0f1b89c..7bb89be 100644 --- a/docs/html/commit__hash_8h_source.html +++ b/docs/html/commit__hash_8h_source.html @@ -66,10 +66,10 @@ $(function() {
commit_hash.h
-
1 #ifndef COMMIT_HASH_H
2 #define COMMIT_HASH_H
3 const char COMMIT_HASH[] = "e016a52459314099549511bb1fed60b3e8f58fa3";
4 #endif // COMMIT_HASH_H
+
1 #ifndef COMMIT_HASH_H
2 #define COMMIT_HASH_H
3 const char COMMIT_HASH[] = "a43c1610917fa01cb5fb07edbb2090d01fb846f7";
4 #endif // COMMIT_HASH_H
diff --git a/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html b/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html index f893d43..b724d94 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 e80d344..72ac5bc 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 78aee45..6e9771e 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 d3327c3..3750aa8 100644 --- a/docs/html/dot_8h_source.html +++ b/docs/html/dot_8h_source.html @@ -70,7 +70,7 @@ $(function() {
dot.h
-
1 #ifndef DOT_H
2 #define DOT_H
3 
4 #include <cstdint>
5 #include <stdexcept>
6 
12 class Dot
13 {
14 public:
18  Dot(uint16_t x, uint16_t y, uint8_t curve);
19 
23  uint16_t getX(void) const;
24 
28  uint16_t getY(void) const;
29 
33  uint8_t getCurve(void) const;
34 
35 private:
36  uint16_t x, y;
37  uint8_t curve;
38 };
39 
40 
41 #endif // DOT_H
+
1 #ifndef DOT_H
2 #define DOT_H
3 
4 #include <cstdint>
5 #include <stdexcept>
6 
12 class Dot
13 {
14 public:
18  Dot(uint16_t x, uint16_t y, uint8_t curve);
19 
23  uint16_t getX(void) const;
24 
28  uint16_t getY(void) const;
29 
33  uint8_t getCurve(void) const;
34 
35 private:
36  const uint16_t x, y;
37  const uint8_t curve;
38 };
39 
40 
41 #endif // DOT_H
uint16_t getX(void) const
Definition: dot.cpp:9
Definition: dot.h:12
uint16_t getY(void) const
Definition: dot.cpp:14
@@ -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 f00933c..1eec841 100644 --- a/docs/html/driverexception_8h_source.html +++ b/docs/html/driverexception_8h_source.html @@ -74,7 +74,7 @@ $(function() { diff --git a/docs/html/drv_2commit__hash_8h_source.html b/docs/html/drv_2commit__hash_8h_source.html new file mode 100644 index 0000000..044f9af --- /dev/null +++ b/docs/html/drv_2commit__hash_8h_source.html @@ -0,0 +1,81 @@ + + + + + + + +B15F: drv/commit_hash.h Source File + + + + + + + + + +
+
+ + + + + + +
+
B15F +
+
Board 15 Famulus Edition
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
commit_hash.h
+
+
+
1 #ifndef COMMIT_HASH_H
2 #define COMMIT_HASH_H
3 const char COMMIT_HASH[] = "018bd1057deef81d8a44a808b7c68fb29abc3be6";
4 #endif // COMMIT_HASH_H
+ + + + diff --git a/docs/html/files.html b/docs/html/files.html index 6849071..833f4f7 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -71,37 +71,38 @@ $(function() {   drv  b15f.cpp  b15f.h - dot.cpp - dot.h - driverexception.h - plottyfile.cpp - plottyfile.h - requests.h - timeoutexception.h - usart.cpp - usart.h - usartexception.h -  ui - ui.cpp - ui.h - view.cpp - view.h - view_info.cpp - view_info.h - view_monitor.cpp - view_monitor.h - view_promt.cpp - view_promt.h - view_selection.cpp - view_selection.h - cli.cpp - commit_hash.h + commit_hash.h + dot.cpp + dot.h + driverexception.h + plottyfile.cpp + plottyfile.h + requests.h + timeoutexception.h + usart.cpp + usart.h + usartexception.h +  ui + ui.cpp + ui.h + view.cpp + view.h + view_info.cpp + view_info.h + view_monitor.cpp + view_monitor.h + view_promt.cpp + view_promt.h + view_selection.cpp + view_selection.h + cli.cpp + commit_hash.h diff --git a/docs/html/functions.html b/docs/html/functions.html index a7034e6..3d33420 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -407,7 +407,7 @@ $(function() { diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index 5a9e274..d2cad70 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html @@ -374,7 +374,7 @@ $(function() { diff --git a/docs/html/functions_vars.html b/docs/html/functions_vars.html index 1574167..7e07809 100644 --- a/docs/html/functions_vars.html +++ b/docs/html/functions_vars.html @@ -92,7 +92,7 @@ $(function() { diff --git a/docs/html/hierarchy.html b/docs/html/hierarchy.html index 6b3eab2..6244661 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 b8d05cd..1cd5d8b 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -170,7 +170,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 3b36ddd..bce966e 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 e755045..e954852 100644 --- a/docs/html/plottyfile_8h_source.html +++ b/docs/html/plottyfile_8h_source.html @@ -70,7 +70,7 @@ $(function() {
plottyfile.h
-
1 #ifndef PLOTTYFILE_H
2 #define PLOTTYFILE_H
3 
4 #include <iostream>
5 #include <fstream>
6 #include <exception>
7 #include <vector>
8 #include <stdexcept>
9 #include "dot.h"
10 
11 enum FunctionType
12 {
13  CurveFamily = 'S',
14  Curve = 'C',
15  Level = 'P'
16 };
17 
21 {
22 public:
27  void addDot(Dot& dot);
28 
33  void addDot(Dot dot);
34 
39  void setFunctionType(FunctionType function_type);
40 
45  void setQuadrant(uint8_t quadrant);
46 
51  void setRefX(uint16_t ref_x);
52 
57  void setRefY(uint16_t ref_y);
58 
64  void setParaFirstCurve(uint16_t para_first);
65 
70  void setParaStepWidth(uint16_t para_stepwidth);
71 
76  void setUnitX(std::string unit_x);
77 
82  void setDescX(std::string desc_x);
83 
88  void setUnitY(std::string unit_y);
89 
94  void setDescY(std::string desc_y);
95 
100  void setUnitPara(std::string unit_para);
105  void setDescPara(std::string desc_para);
106 
107 
108 
112  FunctionType getFunctionType(void) const;
113 
117  uint8_t getQuadrant(void) const;
118 
122  uint16_t getRefX(void) const;
123 
127  uint16_t getRefY(void) const;
128 
132  uint16_t getParaFirstCurve(void) const;
133 
137  uint16_t getParaStepWidth(void) const;
138 
142  std::string getUnitX(void) const;
143 
147  std::string getDescX(void) const;
148 
152  std::string getUnitY(void) const;
153 
157  std::string getDescY(void) const;
158 
162  std::string getUnitPara(void) const;
163 
167  std::string getDescPara(void) const;
168 
169 
174  void writeToFile(std::string filename);
175 
180  void startPlotty(std::string filename);
181 private:
182  void prepStr(std::string& str, uint8_t len);
183 
184  std::vector<Dot> dots;
185 
186  int8_t command = 0x1D;
187  const std::string head = "HTWK-HWLab";
188  const std::string filetype = "MD";
189  int16_t version = 1;
190  int16_t subversion = 0;
191  FunctionType function_type = FunctionType::Curve;
192  uint8_t quadrant = 1;
193  uint16_t ref_x = 1023;
194  uint16_t ref_y = 1023;
195  uint16_t para_first = 1;
196  uint16_t para_stepwidth = 1;
197  std::string unit_x;
198  std::string desc_x;
199  std::string unit_y;
200  std::string desc_y;
201  std::string unit_para;
202  std::string desc_para;
203  const uint8_t eof = 0xD;
204 
205  constexpr static uint8_t STR_LEN_SHORT = 10;
206  constexpr static uint8_t STR_LEN_LARGE = 20;
207 };
208 
209 #endif // PLOTTYFILE_H
+
1 #ifndef PLOTTYFILE_H
2 #define PLOTTYFILE_H
3 
4 #include <iostream>
5 #include <fstream>
6 #include <exception>
7 #include <vector>
8 #include <stdexcept>
9 #include "dot.h"
10 
11 enum FunctionType
12 {
13  CurveFamily = 'S',
14  Curve = 'C',
15  Level = 'P'
16 };
17 
21 {
22 public:
27  void addDot(Dot& dot);
28 
33  void addDot(Dot dot);
34 
39  void setFunctionType(FunctionType function_type);
40 
45  void setQuadrant(uint8_t quadrant);
46 
51  void setRefX(uint16_t ref_x);
52 
57  void setRefY(uint16_t ref_y);
58 
64  void setParaFirstCurve(uint16_t para_first);
65 
70  void setParaStepWidth(uint16_t para_stepwidth);
71 
76  void setUnitX(std::string unit_x);
77 
82  void setDescX(std::string desc_x);
83 
88  void setUnitY(std::string unit_y);
89 
94  void setDescY(std::string desc_y);
95 
100  void setUnitPara(std::string unit_para);
105  void setDescPara(std::string desc_para);
106 
107 
108 
112  FunctionType getFunctionType(void) const;
113 
117  uint8_t getQuadrant(void) const;
118 
122  uint16_t getRefX(void) const;
123 
127  uint16_t getRefY(void) const;
128 
132  uint16_t getParaFirstCurve(void) const;
133 
137  uint16_t getParaStepWidth(void) const;
138 
142  std::string getUnitX(void) const;
143 
147  std::string getDescX(void) const;
148 
152  std::string getUnitY(void) const;
153 
157  std::string getDescY(void) const;
158 
162  std::string getUnitPara(void) const;
163 
167  std::string getDescPara(void) const;
168 
169 
174  void writeToFile(std::string filename);
175 
180  void startPlotty(std::string filename);
181 private:
182  void prepStr(std::string& str, uint8_t len);
183 
184  std::vector<Dot> dots;
185 
186  int8_t command = 0x1D;
187  const std::string head = "HTWK-HWLab";
188  const std::string filetype = "MD";
189  int16_t version = 1;
190  int16_t subversion = 0;
191  FunctionType function_type = FunctionType::Curve;
192  uint8_t quadrant = 1;
193  uint16_t ref_x = 1023;
194  uint16_t ref_y = 1023;
195  uint16_t para_first = 1;
196  uint16_t para_stepwidth = 1;
197  std::string unit_x;
198  std::string desc_x;
199  std::string unit_y;
200  std::string desc_y;
201  std::string unit_para;
202  std::string desc_para;
203  const uint8_t eof = 0xD;
204 
205  constexpr static uint8_t STR_LEN_SHORT = 10;
206  constexpr static uint8_t STR_LEN_LARGE = 20;
207 };
208 
209 #endif // PLOTTYFILE_H
void setParaStepWidth(uint16_t para_stepwidth)
Definition: plottyfile.cpp:40
uint8_t getQuadrant(void) const
Definition: plottyfile.cpp:80
void startPlotty(std::string filename)
Definition: plottyfile.cpp:196
@@ -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 20a6fea..10910fb 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/timeoutexception_8h_source.html b/docs/html/timeoutexception_8h_source.html index 0349eef..eb6425e 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 3204b2b..126d3c4 100644 --- a/docs/html/ui_8cpp_source.html +++ b/docs/html/ui_8cpp_source.html @@ -88,7 +88,7 @@ $(function() {
void digitalWrite1(uint8_t)
Definition: b15f.cpp:229
diff --git a/docs/html/ui_8h_source.html b/docs/html/ui_8h_source.html index db430de..f45635b 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 84a9ebc..f3f564a 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 470bafe..e3b56c6 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 1e52fce..181fe28 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 c8d208d..53a6ab6 100644 --- a/docs/html/view_8cpp_source.html +++ b/docs/html/view_8cpp_source.html @@ -74,7 +74,7 @@ $(function() {
static void abort(std::string msg)
Definition: b15f.cpp:169
diff --git a/docs/html/view_8h_source.html b/docs/html/view_8h_source.html index 8e45e1a..35ac2a9 100644 --- a/docs/html/view_8h_source.html +++ b/docs/html/view_8h_source.html @@ -74,7 +74,7 @@ $(function() {
Definition: view.h:19
diff --git a/docs/html/view__info_8cpp_source.html b/docs/html/view__info_8cpp_source.html index 67d7aee..fb227d5 100644 --- a/docs/html/view__info_8cpp_source.html +++ b/docs/html/view__info_8cpp_source.html @@ -73,7 +73,7 @@ $(function() {
1 #include "view_info.h"
2 
3 ViewInfo::ViewInfo()
4 {
5  calls.push_back(nullptr);
6 }
7 
8 void ViewInfo::setText(std::string text)
9 {
10  this->text = text;
11 }
12 
13 void ViewInfo::setLabelClose(std::string label)
14 {
15  this->label_close = label;
16 }
17 
18 void ViewInfo::setCall(call_t call)
19 {
20  calls[0] = call;
21 }
22 
23 void ViewInfo::draw()
24 {
25  int li = 0;
26  for(std::string line : str_split(text, "\n"))
27  mvwprintw(win, text_offset_y + li++, text_offset_x, "%s", line.c_str());
28 
29  close_offset_x = (width - label_close.length()) / 2;
30  close_offset_y = height - 2;
31 
32  wattron(win, A_REVERSE);
33  mvwprintw(win, close_offset_y, close_offset_x, "%s", label_close.c_str());
34  wattroff(win, A_REVERSE);
35 }
36 
37 call_t ViewInfo::keypress(int& key)
38 {
39  switch(key)
40  {
41 
42  case KEY_MOUSE:
43  {
44  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
45  MEVENT event;
46  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
47  {
48  size_t column = start_x + close_offset_x;
49  size_t row = start_y + close_offset_y;
50  size_t mouse_x = event.x, mouse_y = event.y;
51  if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length())
52  key = -1; // do return from view
53  }
54  break;
55  }
56  case KEY_ENT:
57  key = -1; // do return from view
58  break;
59  default:
60  break;
61  }
62  return calls[0];
63 }
diff --git a/docs/html/view__info_8h_source.html b/docs/html/view__info_8h_source.html index 54e3d6d..ee4401a 100644 --- a/docs/html/view__info_8h_source.html +++ b/docs/html/view__info_8h_source.html @@ -75,7 +75,7 @@ $(function() {
Definition: view.h:19
diff --git a/docs/html/view__monitor_8cpp_source.html b/docs/html/view__monitor_8cpp_source.html index 211cb88..3ab8372 100644 --- a/docs/html/view__monitor_8cpp_source.html +++ b/docs/html/view__monitor_8cpp_source.html @@ -84,7 +84,7 @@ $(function() { diff --git a/docs/html/view__monitor_8h_source.html b/docs/html/view__monitor_8h_source.html index ecbeb60..2e8baa4 100644 --- a/docs/html/view__monitor_8h_source.html +++ b/docs/html/view__monitor_8h_source.html @@ -75,7 +75,7 @@ $(function() { diff --git a/docs/html/view__promt_8cpp_source.html b/docs/html/view__promt_8cpp_source.html index 39b3a77..754ceab 100644 --- a/docs/html/view__promt_8cpp_source.html +++ b/docs/html/view__promt_8cpp_source.html @@ -73,7 +73,7 @@ $(function() {
1 #include "view_promt.h"
2 
3 void ViewPromt::draw()
4 {
5  curs_set(1); // show cursor
6 
7  int li = text_offset_y;
8  int ci = 0;
9  for(std::string line : str_split(message + input, "\n"))
10  {
11  mvwprintw(win, ++li, text_offset_x, "%s", line.c_str());
12  ci = line.length() + text_offset_x;
13  }
14 
15  button_offset_x = (width - label_cancel.length() - sep.length() - label_confirm.length()) / 2;
16  button_offset_y = height - text_offset_y;
17 
18  if(selection == 0)
19  {
20  wattron(win, A_REVERSE);
21  mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str());
22  wattroff(win, A_REVERSE);
23  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str());
24  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str());
25  }
26  else
27  {
28  mvwprintw(win, button_offset_y, button_offset_x, "%s", label_cancel.c_str());
29  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length(), "%s", sep.c_str());
30  wattron(win, A_REVERSE);
31  mvwprintw(win, button_offset_y, button_offset_x + label_cancel.length() + sep.length(), "%s", label_confirm.c_str());
32  wattroff(win, A_REVERSE);
33  }
34  wmove(win, li, ci);
35 }
36 
37 void ViewPromt::setMessage(std::string message)
38 {
39  this->message = message;
40 }
41 
42 void ViewPromt::setConfirm(std::string name, std::function<void(int)> call)
43 {
44  label_confirm = name;
45  call_confirm = call;
46 }
47 
48 void ViewPromt::setCancel(std::string name, bool cancelable)
49 {
50  label_cancel = name;
51  this->cancelable = cancelable;
52 }
53 
54 std::string ViewPromt::getInput()
55 {
56  return input;
57 }
58 
59 std::function<void(int)> ViewPromt::keypress(int& key)
60 {
61  std::function<void(int)> ret = nullptr;
62  switch(key)
63  {
64  case KEY_BACKSPACE:
65  if(input.length())
66  input.pop_back();
67  break;
68  case '\t':
69  case KEY_LEFT:
70  case KEY_RIGHT:
71  selection = (selection + 1 ) % 2;
72  break;
73  case KEY_MOUSE:
74  {
75  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
76  MEVENT event;
77  bool hit = false;
78  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
79  {
80  size_t column_start = start_x + button_offset_x;
81  size_t row_start = start_y + button_offset_y;
82  size_t mouse_x = event.x, mouse_y = event.y;
83  if(mouse_y == row_start)
84  {
85  if(cancelable && mouse_x >= column_start && mouse_x < column_start + label_cancel.length())
86  {
87  if(selection == 0 || event.bstate & BUTTON1_DOUBLE_CLICKED)
88  hit = true;
89  selection = 0;
90  }
91  if(mouse_x >= column_start + label_cancel.length() + sep.length() && mouse_x < column_start + label_cancel.length() + sep.length() + label_confirm.length())
92  {
93  if(selection == 1 || event.bstate & BUTTON1_DOUBLE_CLICKED)
94  hit = true;
95  selection = 1;
96  }
97  }
98  }
99  if(!hit)
100  break;
101 
102  // fall through to next case
103  [[fallthrough]];
104  }
105  case KEY_ENT:
106  if(selection == 0) // exit
107  key = -1; // do return from view
108  else
109  ret = call_confirm;
110  break;
111  default:
112  break;
113  }
114 
115  if(key >= ' ' && key <= '~')
116  input += (char) key;
117 
118  if(key != KEY_ENT)
119  repaint();
120  return ret;
121 }
diff --git a/docs/html/view__promt_8h_source.html b/docs/html/view__promt_8h_source.html index b4be3bc..699fbf8 100644 --- a/docs/html/view__promt_8h_source.html +++ b/docs/html/view__promt_8h_source.html @@ -75,7 +75,7 @@ $(function() { diff --git a/docs/html/view__selection_8cpp_source.html b/docs/html/view__selection_8cpp_source.html index afffd90..5c581b6 100644 --- a/docs/html/view__selection_8cpp_source.html +++ b/docs/html/view__selection_8cpp_source.html @@ -73,7 +73,7 @@ $(function() {
1 #include "view_selection.h"
2 
3 void ViewSelection::draw()
4 {
5  //curs_set(0); // hide cursor
6  for(size_t i = 0; i < choices.size(); i++)
7  {
8  if(selection == i)
9  wattron(win, A_REVERSE);
10  mvwprintw(win, i + choice_offset_y, choice_offset_x, "%s", choices[i].c_str());
11  if(selection == i)
12  wattroff(win, A_REVERSE);
13  }
14 }
15 
16 void ViewSelection::addChoice(std::string name, call_t call)
17 {
18  choices.push_back(name);
19  calls.push_back(call);
20 }
21 
22 call_t ViewSelection::keypress(int& key)
23 {
24  call_t ret = nullptr;
25  switch(key)
26  {
27  case KEY_UP:
28  do
29  selection = (selection - 1 + choices.size()) % choices.size();
30  while(!choices[selection].length() && choices.size());
31  break;
32 
33  case '\t':
34  case KEY_DOWN:
35  do
36  selection = (selection + 1) % choices.size();
37  while(!choices[selection].length() && choices.size());
38  break;
39 
40  case KEY_MOUSE:
41  {
42  // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
43  MEVENT event;
44  bool hit = false;
45  if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
46  {
47  size_t column_start = start_x + choice_offset_x;
48  size_t row_start = start_y + choice_offset_y;
49  size_t mouse_x = event.x, mouse_y = event.y;
50  for(size_t i = 0; i < choices.size(); i++)
51  if(choices[i].length() && mouse_y == row_start + i && mouse_x >= column_start && mouse_x < column_start + choices[i].length())
52  {
53  if(selection == i || event.bstate & BUTTON1_DOUBLE_CLICKED)
54  hit = true;
55  selection = i;
56  }
57  }
58  if(!hit)
59  break;
60 
61  // fall through to next case
62  [[fallthrough]];
63  }
64 
65  case KEY_ENT:
66  if(selection == choices.size() - 1) // exit
67  key = -1; // do return from view
68  else
69  ret = calls[selection];
70  break;
71  default:
72  break;
73  }
74  repaint();
75  return ret;
76 }
diff --git a/docs/html/view__selection_8h_source.html b/docs/html/view__selection_8h_source.html index 4cb65b9..0e73ba7 100644 --- a/docs/html/view__selection_8h_source.html +++ b/docs/html/view__selection_8h_source.html @@ -75,7 +75,7 @@ $(function() {