From 7b2e5aa1ef84def23fa48595ad4ceef46026152d Mon Sep 17 00:00:00 2001 From: Tristan Krause Date: Tue, 25 Jun 2019 11:07:06 +0200 Subject: [PATCH] docu --- control/src/drv/b15f.cpp | 10 +- control/src/drv/b15f.cpp.orig | 584 ++++++++++++++++++ control/src/drv/b15f.h | 8 +- control/src/drv/b15f.h.orig | 313 ++++++++++ control/src/drv/requests.h | 45 +- control/src/drv/requests.h.orig | 50 ++ control/src/ui/view_monitor.cpp | 2 +- control/src/ui/view_monitor.cpp.orig | 142 +++++ docs/html/annotated.html | 2 +- docs/html/b15f_8cpp_source.html | 19 +- docs/html/b15f_8h_source.html | 23 +- docs/html/classB15F-members.html | 43 +- docs/html/classB15F.html | 85 ++- 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 | 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 +- .../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 | 9 +- docs/html/functions_func.html | 9 +- 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 | 2 +- docs/html/requests_8h_source.html | 4 +- docs/html/search/all_6.js | 3 +- docs/html/search/all_b.js | 2 +- docs/html/search/functions_5.js | 3 +- docs/html/search/functions_9.js | 2 +- 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 | 4 +- 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 +- 71 files changed, 1276 insertions(+), 188 deletions(-) create mode 100644 control/src/drv/b15f.cpp.orig create mode 100644 control/src/drv/b15f.h.orig create mode 100644 control/src/drv/requests.h.orig create mode 100644 control/src/ui/view_monitor.cpp.orig diff --git a/control/src/drv/b15f.cpp b/control/src/drv/b15f.cpp index a4f522d..505b26f 100644 --- a/control/src/drv/b15f.cpp +++ b/control/src/drv/b15f.cpp @@ -7,7 +7,7 @@ errorhandler_t B15F::errorhandler = nullptr; /************************************* * Grundfunktionen des B15F Treibers * *************************************/ - + B15F &B15F::getInstance(void) { if (!instance) @@ -204,7 +204,7 @@ bool B15F::activateSelfTestMode() } bool B15F::digitalWrite0(uint8_t port) -{ +{ uint8_t rq[] = { RQ_DIGITAL_WRITE_0, @@ -270,9 +270,9 @@ uint8_t B15F::readDipSwitch() uint8_t aw; usart.receive(&aw, 0, sizeof(aw)); - + reverse(aw); // DIP Schalter muss invertiert werden! - + return aw; } @@ -528,7 +528,7 @@ uint16_t* B15F::getInterruptCounterOffset() /********************** - * Private Funktionen * + * Private Funktionen * **********************/ B15F::B15F() diff --git a/control/src/drv/b15f.cpp.orig b/control/src/drv/b15f.cpp.orig new file mode 100644 index 0000000..a4f522d --- /dev/null +++ b/control/src/drv/b15f.cpp.orig @@ -0,0 +1,584 @@ +#include "b15f.h" + +B15F *B15F::instance = nullptr; +errorhandler_t B15F::errorhandler = nullptr; + + +/************************************* + * Grundfunktionen des B15F Treibers * + *************************************/ + +B15F &B15F::getInstance(void) +{ + if (!instance) + instance = new B15F(); + + return *instance; +} + +void B15F::reconnect() +{ + uint8_t tries = RECONNECT_TRIES; + while (tries--) + { + delay_ms(RECONNECT_TIMEOUT); + discard(); + + if (testConnection()) + return; + } + + abort("Verbindung kann nicht repariert werden"); +} + +void B15F::discard(void) +{ + try + { + uint8_t rq[] = + { + RQ_DISCARD + }; + + usart.clearOutputBuffer(); + for (uint8_t i = 0; i < 16; i++) + { + usart.transmit(&rq[0], 0, sizeof(rq)); // sende discard Befehl (verwerfe input) + delay_ms(4); + } + usart.clearInputBuffer(); + } + catch (std::exception &ex) + { + abort(ex); + } +} + +bool B15F::testConnection() +{ + // erzeuge zufälliges Byte + srand(time(NULL)); + uint8_t dummy = rand() % 256; + + uint8_t rq[] = + { + RQ_TEST, + dummy + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw[2]; + usart.receive(&aw[0], 0, sizeof(aw)); + + return aw[0] == MSG_OK && aw[1] == dummy; +} + +bool B15F::testIntConv() +{ + srand(time(NULL)); + uint16_t dummy = rand() % (0xFFFF / 3); + + uint8_t rq[] = + { + RQ_INT_TEST, + static_cast(dummy & 0xFF), + static_cast(dummy >> 8) + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint16_t aw; + usart.receive(reinterpret_cast(&aw), 0, sizeof(aw)); + + return aw == dummy * 3; +} + + +std::vector B15F::getBoardInfo(void) +{ + std::vector info; + + uint8_t rq[] = + { + RQ_INFO + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t n; + usart.receive(&n, 0, sizeof(n)); + while (n--) + { + uint8_t len; + usart.receive(&len, 0, sizeof(len)); + + char str[len + 1]; + str[len] = '\0'; + usart.receive(reinterpret_cast(&str[0]), 0, len); + + info.push_back(std::string(str)); + } + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + if (aw != MSG_OK) + abort("Board Info fehlerhalft: code " + std::to_string((int) aw)); + + return info; +} + +void B15F::delay_ms(uint16_t ms) +{ + std::this_thread::sleep_for(std::chrono::milliseconds(ms)); +} + +void B15F::delay_us(uint16_t us) +{ + std::this_thread::sleep_for(std::chrono::microseconds(us)); +} + +void B15F::reverse(uint8_t& b) +{ + b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; + b = (b & 0xCC) >> 2 | (b & 0x33) << 2; + b = (b & 0xAA) >> 1 | (b & 0x55) << 1; +} + +// https://stackoverflow.com/a/478960 +std::string B15F::exec(std::string cmd) +{ + std::array buffer; + std::string result; + std::unique_ptr pipe(popen(cmd.c_str(), "r"), pclose); + if (!pipe) + { + throw std::runtime_error("popen() failed!"); + } + while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) + { + result += buffer.data(); + } + return result; +} + +void B15F::abort(std::string msg) +{ + DriverException ex(msg); + abort(ex); +} + +void B15F::abort(std::exception &ex) +{ + if (errorhandler) + errorhandler(ex); + else + { + std::cerr << "NOTICE: B15F::errorhandler not set" << std::endl; + std::cout << ex.what() << std::endl; + throw DriverException(ex.what()); + } +} + +void B15F::setAbortHandler(errorhandler_t func) +{ + errorhandler = func; +} + +/*************************************/ + + + +/************************* + * Steuerbefehle für B15 * + *************************/ + +bool B15F::activateSelfTestMode() +{ + uint8_t rq[] = + { + RQ_SELF_TEST + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; +} + +bool B15F::digitalWrite0(uint8_t port) +{ + uint8_t rq[] = + { + RQ_DIGITAL_WRITE_0, + port + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; +} + +bool B15F::digitalWrite1(uint8_t port) +{ + uint8_t rq[] = + { + RQ_DIGITAL_WRITE_1, + port + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; +} + +uint8_t B15F::digitalRead0() +{ + usart.clearInputBuffer(); + uint8_t rq[] = + { + RQ_DIGITAL_READ_0 + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw; +} + +uint8_t B15F::digitalRead1() +{ + usart.clearInputBuffer(); + uint8_t rq[] = + { + RQ_DIGITAL_READ_1 + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw; +} + +uint8_t B15F::readDipSwitch() +{ + usart.clearInputBuffer(); + uint8_t rq[] = + { + RQ_READ_DIP_SWITCH + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + + reverse(aw); // DIP Schalter muss invertiert werden! + + return aw; +} + +bool B15F::analogWrite0(uint16_t value) +{ + uint8_t rq[] = + { + RQ_ANALOG_WRITE_0, + static_cast(value & 0xFF), + static_cast(value >> 8) + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; +} + +bool B15F::analogWrite1(uint16_t value) +{ + uint8_t rq[] = + { + RQ_ANALOG_WRITE_1, + static_cast(value & 0xFF), + static_cast(value >> 8) + }; + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; +} + +uint16_t B15F::analogRead(uint8_t channel) +{ + usart.clearInputBuffer(); + if (channel > 7) + abort("Bad ADC channel: " + std::to_string(channel)); + + uint8_t rq[] = + { + RQ_ANALOG_READ, + channel + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint16_t aw; + usart.receive(reinterpret_cast(&aw), 0, sizeof(aw)); + + if (aw > 1023) + abort("Bad ADC data detected (1)"); + return aw; +} + +void +B15F::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) +{ + // prepare pointers + buffer_a += offset_a; + buffer_b += offset_b; + + + usart.clearInputBuffer(); + uint8_t rq[] = + { + RQ_ADC_DAC_STROKE, + channel_a, + channel_b, + static_cast(start & 0xFF), + static_cast(start >> 8), + static_cast(delta & 0xFF), + static_cast(delta >> 8), + static_cast(count & 0xFF), + static_cast(count >> 8) + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + for (uint16_t i = 0; i < count; i++) + { + if (buffer_a) + { + usart.receive(reinterpret_cast(&buffer_a[i]), 0, 2); + + if (buffer_a[i] > 1023) // check for broken usart connection + abort("Bad ADC data detected (2)"); + } + else + { + usart.drop(2); + } + + if (buffer_b) + { + usart.receive(reinterpret_cast(&buffer_b[i]), 0, 2); + + if (buffer_b[i] > 1023) // check for broken usart connection + abort("Bad ADC data detected (3)"); + } + else + { + usart.drop(2); + } + } + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + if(aw != MSG_OK) + abort("Sequenz unterbrochen"); +} + +uint8_t B15F::pwmSetFrequency(uint32_t freq) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_PWM_SET_FREQ, + static_cast((freq >> 0) & 0xFF), + static_cast((freq >> 8) & 0xFF), + static_cast((freq >> 16) & 0xFF), + static_cast((freq >> 24) & 0xFF) + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw; +} + +bool B15F::pwmSetValue(uint8_t value) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_PWM_SET_VALUE, + value + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == MSG_OK; +} + +bool B15F::setMem8(volatile uint8_t* adr, uint8_t val) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_SET_MEM_8, + static_cast(reinterpret_cast(adr) & 0xFF), + static_cast(reinterpret_cast(adr) >> 8), + val + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw == val; +} + +uint8_t B15F::getMem8(volatile uint8_t* adr) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_GET_MEM_8, + static_cast(reinterpret_cast(adr) & 0xFF), + static_cast(reinterpret_cast(adr) >> 8) + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint8_t aw; + usart.receive(&aw, 0, sizeof(aw)); + return aw; +} + +bool B15F::setMem16(volatile uint16_t* adr, uint16_t val) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_SET_MEM_16, + static_cast(reinterpret_cast(adr) & 0xFF), + static_cast(reinterpret_cast(adr) >> 8), + static_cast(val & 0xFF), + static_cast(val >> 8) + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint16_t aw; + usart.receive(reinterpret_cast(&aw), 0, sizeof(aw)); + return aw == val; +} + +uint16_t B15F::getMem16(volatile uint16_t* adr) +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_GET_MEM_16, + static_cast(reinterpret_cast(adr) & 0xFF), + static_cast(reinterpret_cast(adr) >> 8) + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint16_t aw; + usart.receive(reinterpret_cast(&aw), 0, sizeof(aw)); + return aw; +} + +bool B15F::setRegister(volatile uint8_t* adr, uint8_t val) +{ + return setMem8(adr, val); +} + +uint8_t B15F::getRegister(volatile uint8_t* adr) +{ + return getMem8(adr); +} + +uint16_t* B15F::getInterruptCounterOffset() +{ + usart.clearInputBuffer(); + + uint8_t rq[] = + { + RQ_COUNTER_OFFSET + }; + + usart.transmit(&rq[0], 0, sizeof(rq)); + + uint16_t aw; + usart.receive(reinterpret_cast(&aw), 0, sizeof(aw)); + return reinterpret_cast(aw); +} + +/*************************/ + + +/********************** + * Private Funktionen * + **********************/ + +B15F::B15F() +{ + init(); +} + + +void B15F::init() +{ + + std::string device = exec("bash -c 'ls /dev/ttyUSB*'"); + while (device.find(' ') != std::string::npos || device.find('\n') != std::string::npos || + device.find('\t') != std::string::npos) + device.pop_back(); + + if (device.length() == 0) + abort("Adapter nicht gefunden"); + + std::cout << PRE << "Verwende Adapter: " << device << std::endl; + + + std::cout << PRE << "Stelle Verbindung mit Adapter her... " << std::flush; + usart.setBaudrate(BAUDRATE); + usart.openDevice(device); + std::cout << "OK" << std::endl; + + + std::cout << PRE << "Teste Verbindung... " << std::flush; + uint8_t tries = 3; + while (tries--) + { + // verwerfe Daten, die µC noch hat + //discard(); + + if (!testConnection()) + continue; + + if (!testIntConv()) + continue; + + break; + } + if (tries == 0) + abort("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?"); + std::cout << "OK" << std::endl; + + + // Gib board info aus + std::vector info = getBoardInfo(); + std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")" + << std::endl; +} diff --git a/control/src/drv/b15f.h b/control/src/drv/b15f.h index 1a03701..4904fee 100644 --- a/control/src/drv/b15f.h +++ b/control/src/drv/b15f.h @@ -43,7 +43,7 @@ public: * @throws DriverException */ static B15F& getInstance(void); - + /** * Versucht die Verbindung zum B15 wiederherzustellen * \throws DriverException @@ -85,7 +85,7 @@ public: * \param us Verzögerung in Microsekunden */ void delay_us(uint16_t us); - + /** * Invertiert das Bitmuster eines Bytes * z.B.: 10100001 --> 10000101 @@ -273,7 +273,7 @@ public: * \return Wert des Registers */ uint8_t getRegister(volatile uint8_t* adr); - + /** * Liefert die Adresse des ersten Interrupt Counters (BASISR). * \return Adresse (in der MCU) @@ -298,7 +298,7 @@ private: * Privater Konstruktor */ B15F(void); - + /** * Initialisiert und testet die Verbindung zum B15 * \throws DriverException diff --git a/control/src/drv/b15f.h.orig b/control/src/drv/b15f.h.orig new file mode 100644 index 0000000..1a03701 --- /dev/null +++ b/control/src/drv/b15f.h.orig @@ -0,0 +1,313 @@ +#ifndef B15F_H +#define B15F_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "requests.h" +#include "usart.h" +#include "driverexception.h" +#include "timeoutexception.h" + +// wichtig für die Register-Zugriffe +#define _AVR_IO_H_ 1 // Erzwinge die Inklusion +#include "/usr/lib/avr/include/avr/sfr_defs.h" +#include "/usr/lib/avr/include/avr/iom1284p.h" + +typedef std::function errorhandler_t; + + +/*! main driver class */ + +class B15F +{ +public: + + /************************************* + * Grundfunktionen des B15F Treibers * + *************************************/ + + /** + * Liefert eine Referenz zur aktuellen Treiber-Instanz, die Verbindung wird gegebenenfalls automatisch hergestellt. + * @throws DriverException + */ + static B15F& getInstance(void); + + /** + * Versucht die Verbindung zum B15 wiederherzustellen + * \throws DriverException + */ + void reconnect(void); + + /** + * Verwirft Daten im USART Puffer auf dieser Maschine und B15 + * \throws DriverException + */ + void discard(void); + + /** + * Testet die USART Verbindung auf Funktion + * \throws DriverException + */ + bool testConnection(void); + + /** + * Testet die Integer Konvertierung der USART Verbindung + * \throws DriverException + */ + bool testIntConv(void); + + /** + * Liefert Informationen zur aktuellen Firmware des B15 + * \throws DriverException + */ + std::vector getBoardInfo(void); + + /** + * Lässt den Treiber für eine angegebene Zeit pausieren + * \param ms Verzögerung in Millisekunden + */ + void delay_ms(uint16_t ms); + + /** + * Lässt den Treiber für eine angegebene Zeit pausieren + * \param us Verzögerung in Microsekunden + */ + void delay_us(uint16_t us); + + /** + * Invertiert das Bitmuster eines Bytes + * z.B.: 10100001 --> 10000101 + * \param b Byte, das invertiert wird + */ + void reverse(uint8_t& b); + + /** + * Führt ein Befehl auf dieser Maschine aus und liefert stdout zurück + * \param cmd Der Befehl + */ + static std::string exec(std::string cmd); + + /** + * Multithread sicherer Abbruch des B15F-Treibers + * \param msg Beschreibung der Abbruchursache + */ + static void abort(std::string msg); + + /** + * Multithread sicherer Abbruch des B15F-Treibers + * \param ex Exception als Abbruchursache + */ + static void abort(std::exception& ex); + + /** + * Setzt eine Fehlerbehandlungsroutine für den Treiberabbruch (abort) + * \param func Funktion, die Exception als Parameter bekommt + */ + static void setAbortHandler(errorhandler_t func); + + /*************************************/ + + + + /************************* + * Steuerbefehle für B15 * + *************************/ + + /** + * Versetzt das Board in den Selbsttest-Modus + * WICHTIG: Es darf dabei nichts an den Klemmen angeschlossen sein! + * \throws DriverException + */ + bool activateSelfTestMode(void); + + /** + * Setzt den Wert des digitalen Ausgabeports 0 + * \param port Wert für gesamten Port + * \throws DriverException + */ + bool digitalWrite0(uint8_t); + + /** + * Setzt den Wert des digitalen Ausgabeports 1 + * \param port Wert für gesamten Port + * \throws DriverException + */ + bool digitalWrite1(uint8_t); + + /** + * Liest den Wert des digitalen Eingabeports 0 + * \return Wert für gesamten Port + * \throws DriverException + */ + uint8_t digitalRead0(void); + + /** + * Liest den Wert des digitalen Eingabeports 1 + * \return Wert für gesamten Port + * \throws DriverException + */ + uint8_t digitalRead1(void); + + /** + * Liest den Wert des digitalen Eingabeports, an dem der DIP-switch angeschlossen ist (S7) + * \return Wert für gesamten Port + * \throws DriverException + */ + uint8_t readDipSwitch(void); + + /** + * Setzt den Wert des Digital-Analog-Converters (DAC / DAU) 0 + * \param port 10-Bit Wert + * \throws DriverException + */ + bool analogWrite0(uint16_t port); + + /** + * Setzt den Wert des Digital-Analog-Converters (DAC / DAU) 1 + * \param port 10-Bit Wert + * \throws DriverException + */ + bool analogWrite1(uint16_t port); + + /** + * Liest den Wert des Analog-Digital-Converters (ADC / ADU) + * \param channel Kanalwahl von 0 - 7 + * \throws DriverException + */ + uint16_t analogRead(uint8_t channel); + + /** + * DAC 0 wird auf den Startwert gesetzt und dann schrittweise um Delta inkrementiert. + * Für jeden eingestelleten DAC-Wert werden zwei ADCs (channel_a und channel_b) angesprochen und die Werte übermittelt. + * Die Werte werden in buffer_a für Kanal a und buffer_b für Kanal b gespeichert. + * \param channel_a Auswahl des ADC a, von 0 - 7 + * \param buffer_a Speichertort für Werte des Kanals a + * \param offset_a Anzahl an Werten des Kanals a, die im Speicher übersprungen werden sollen + * \param channel_b Auswahl des ADC b, von 0 - 7 + * \param buffer_b Speichertort für Werte des Kanals b + * \param offset_b Anzahl an Werten des Kanals b, die im Speicher übersprungen werden + * \param start Startwert des DACs + * \param delta Schrittweite, mit welcher der DAC inkrementiert wird + * \param count Anzahl an Inkrementierungen + * \throws DriverException + */ + 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); + + /** + * Setzt die Register so, dass näherungsweise die gewünschte Frequenz erzeugt wird. + * Ist freq == 0 wird PWM deaktiviert. + * Standardfrequenz: 31300 (empfohlen, da dann TOP == 255) + * \param freq PWM Frequenz + * \return Top Wert des PWM Value für die gesetzte Frequenz + * \throws DriverException + */ + uint8_t pwmSetFrequency(uint32_t freq); + + /** + * Setzt den PWM Wert. + * \param value PWM Wert [0..0xFF] + * \throws DriverException + */ + bool pwmSetValue(uint8_t value); + + /** + * Setzt direkt den Wert einer MCU Speicherzelle der Größe 8 Bit. + * Diese kann ein Register oder RAM-Daten sein. + * *Wichtig:* bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen! + * \param adr Speicheradresse + * \param val Neuer Wert für die Zelle + * \return true, falls Vorgang erfolgreich + */ + bool setMem8(volatile uint8_t* adr, uint8_t val); + + /** + * Liefert den Wert einer MCU Speicherzelle der Größe 8 Bit. + * Diese kann ein Register oder RAM-Daten sein. + * \param adr Speicheradresse + * \return Wert der Speicherzelle + */ + uint8_t getMem8(volatile uint8_t* adr); + + /** + * Setzt direkt den Wert einer MCU Speicherzelle der Größe 16 Bit. + * Diese kann ein Register oder RAM-Daten sein. + * *Wichtig:* bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen! + * \param adr Speicheradresse + * \param val Neuer Wert für die Zelle + * \return true, falls Vorgang erfolgreich + */ + bool setMem16(volatile uint16_t* adr, uint16_t val); + + /** + * Liefert den Wert einer MCU Speicherzelle der Größe 16 Bit. + * Diese kann ein Register oder RAM-Daten sein. + * \param adr Speicheradresse + * \return Wert der Speicherzelle + */ + uint16_t getMem16(volatile uint16_t* adr); + + /** + * Diese Funktion ist ein Alias für setMem8(). + * *Wichtig:* bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen! + * \param adr Speicheradresse + * \param val Neuer Wert für das Register + * \return true, falls Vorgang erfolgreich + */ + bool setRegister(volatile uint8_t* adr, uint8_t val); + + /** + * Diese Funktion ist ein Alias für getMem8(). + * \param adr Speicheradresse + * \return Wert des Registers + */ + uint8_t getRegister(volatile uint8_t* adr); + + /** + * Liefert die Adresse des ersten Interrupt Counters (BASISR). + * \return Adresse (in der MCU) + */ + uint16_t* getInterruptCounterOffset(void); + + /*************************/ + + + // CONSTANTS + const std::string PRE = "[B15F] "; //!< B15F stdout prefix + constexpr static uint8_t MSG_OK = 0xFF; //!< Value to acknowledge a received command + constexpr static uint8_t MSG_FAIL = 0xFE; //!< Value to reject a received command + constexpr static uint16_t RECONNECT_TIMEOUT = 64; //!< Time in ms after which a reconnect attempt aborts + constexpr static uint16_t WDT_TIMEOUT = 15; //!< Time in ms after which the watch dog timer resets the MCU + constexpr static uint8_t RECONNECT_TRIES = 3; //!< Maximum count of reconnect attempts after which the driver stops + constexpr static uint32_t BAUDRATE = 57600; //!< USART baudrate for communication with the MCU + +private: + + /** + * Privater Konstruktor + */ + B15F(void); + + /** + * Initialisiert und testet die Verbindung zum B15 + * \throws DriverException + */ + void init(void); + + USART usart; + static B15F* instance; + static errorhandler_t errorhandler; +}; + +#endif // B15F_H diff --git a/control/src/drv/requests.h b/control/src/drv/requests.h index 24a2dc4..5ef0f9c 100644 --- a/control/src/drv/requests.h +++ b/control/src/drv/requests.h @@ -23,28 +23,29 @@ constexpr static uint8_t RQ_SET_MEM_16 = 18; constexpr static uint8_t RQ_GET_MEM_16 = 19; constexpr static uint8_t RQ_COUNTER_OFFSET = 20; -uint8_t const rq_len[] = { - 1 /* RQ_DISCARD */, - 1 /* RQ_TEST */ + 1 /* test byte */, - 1 /* RQ_INFO */, - 1 /* RQ_INT_TEST */ + 1 /* test int high low */ + 1 /* test int high high */, - 1 /* RQ_SELF_TEST */, - 1 /* RQ_DIGITAL_WRITE_0 */ + 1 /* port value */, - 1 /* RQ_DIGITAL_WRITE_1 */ + 1 /* port value */, - 1 /* RQ_DIGITAL_READ_0 */, - 1 /* RQ_DIGITAL_READ_1 */, - 1 /* RQ_READ_DIP_SWITCH */, - 1 /* RQ_ANALOG_WRITE_0 */ + 1 /* test int high low */ + 1 /* test int high high */, - 1 /* RQ_ANALOG_WRITE_1 */ + 1 /* test int high low */ + 1 /* test int high high */, - 1 /* RQ_ANALOG_READ */ + 1 /* adc channel */, - 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 */, - 1 /* RQ_PWM_SET_FREQ */ + 1 /* freq low low */ + 1 /* freq low high */ + 1 /* freq high low */ + 1 /* freq high high */, - 1 /* RQ_PWM_SET_VALUE */ + 1 /* pwm value */, - 1 /* RQ_SET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value (8-bit) */, - 1 /* RQ_GET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */, - 1 /* RQ_SET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value low */ + 1 /* memory value high */, - 1 /* RQ_GET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */, - 1 /* RQ_COUNTER_OFFSET */, +uint8_t const rq_len[] = +{ + 1 /* RQ_DISCARD */, + 1 /* RQ_TEST */ + 1 /* test byte */, + 1 /* RQ_INFO */, + 1 /* RQ_INT_TEST */ + 1 /* test int high low */ + 1 /* test int high high */, + 1 /* RQ_SELF_TEST */, + 1 /* RQ_DIGITAL_WRITE_0 */ + 1 /* port value */, + 1 /* RQ_DIGITAL_WRITE_1 */ + 1 /* port value */, + 1 /* RQ_DIGITAL_READ_0 */, + 1 /* RQ_DIGITAL_READ_1 */, + 1 /* RQ_READ_DIP_SWITCH */, + 1 /* RQ_ANALOG_WRITE_0 */ + 1 /* test int high low */ + 1 /* test int high high */, + 1 /* RQ_ANALOG_WRITE_1 */ + 1 /* test int high low */ + 1 /* test int high high */, + 1 /* RQ_ANALOG_READ */ + 1 /* adc channel */, + 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 */, + 1 /* RQ_PWM_SET_FREQ */ + 1 /* freq low low */ + 1 /* freq low high */ + 1 /* freq high low */ + 1 /* freq high high */, + 1 /* RQ_PWM_SET_VALUE */ + 1 /* pwm value */, + 1 /* RQ_SET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value (8-bit) */, + 1 /* RQ_GET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */, + 1 /* RQ_SET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value low */ + 1 /* memory value high */, + 1 /* RQ_GET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */, + 1 /* RQ_COUNTER_OFFSET */, }; #endif // REQUESTS_H diff --git a/control/src/drv/requests.h.orig b/control/src/drv/requests.h.orig new file mode 100644 index 0000000..24a2dc4 --- /dev/null +++ b/control/src/drv/requests.h.orig @@ -0,0 +1,50 @@ +#ifndef REQUESTS_H +#define REQUESTS_H + +constexpr static uint8_t RQ_DISCARD = 0; +constexpr static uint8_t RQ_TEST = 1; +constexpr static uint8_t RQ_INFO = 2; +constexpr static uint8_t RQ_INT_TEST = 3; +constexpr static uint8_t RQ_SELF_TEST = 4; +constexpr static uint8_t RQ_DIGITAL_WRITE_0 = 5; +constexpr static uint8_t RQ_DIGITAL_WRITE_1 = 6; +constexpr static uint8_t RQ_DIGITAL_READ_0 = 7; +constexpr static uint8_t RQ_DIGITAL_READ_1 = 8; +constexpr static uint8_t RQ_READ_DIP_SWITCH = 9; +constexpr static uint8_t RQ_ANALOG_WRITE_0 = 10; +constexpr static uint8_t RQ_ANALOG_WRITE_1 = 11; +constexpr static uint8_t RQ_ANALOG_READ = 12; +constexpr static uint8_t RQ_ADC_DAC_STROKE = 13; +constexpr static uint8_t RQ_PWM_SET_FREQ = 14; +constexpr static uint8_t RQ_PWM_SET_VALUE = 15; +constexpr static uint8_t RQ_SET_MEM_8 = 16; +constexpr static uint8_t RQ_GET_MEM_8 = 17; +constexpr static uint8_t RQ_SET_MEM_16 = 18; +constexpr static uint8_t RQ_GET_MEM_16 = 19; +constexpr static uint8_t RQ_COUNTER_OFFSET = 20; + +uint8_t const rq_len[] = { + 1 /* RQ_DISCARD */, + 1 /* RQ_TEST */ + 1 /* test byte */, + 1 /* RQ_INFO */, + 1 /* RQ_INT_TEST */ + 1 /* test int high low */ + 1 /* test int high high */, + 1 /* RQ_SELF_TEST */, + 1 /* RQ_DIGITAL_WRITE_0 */ + 1 /* port value */, + 1 /* RQ_DIGITAL_WRITE_1 */ + 1 /* port value */, + 1 /* RQ_DIGITAL_READ_0 */, + 1 /* RQ_DIGITAL_READ_1 */, + 1 /* RQ_READ_DIP_SWITCH */, + 1 /* RQ_ANALOG_WRITE_0 */ + 1 /* test int high low */ + 1 /* test int high high */, + 1 /* RQ_ANALOG_WRITE_1 */ + 1 /* test int high low */ + 1 /* test int high high */, + 1 /* RQ_ANALOG_READ */ + 1 /* adc channel */, + 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 */, + 1 /* RQ_PWM_SET_FREQ */ + 1 /* freq low low */ + 1 /* freq low high */ + 1 /* freq high low */ + 1 /* freq high high */, + 1 /* RQ_PWM_SET_VALUE */ + 1 /* pwm value */, + 1 /* RQ_SET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value (8-bit) */, + 1 /* RQ_GET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */, + 1 /* RQ_SET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value low */ + 1 /* memory value high */, + 1 /* RQ_GET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */, + 1 /* RQ_COUNTER_OFFSET */, +}; + +#endif // REQUESTS_H diff --git a/control/src/ui/view_monitor.cpp b/control/src/ui/view_monitor.cpp index 2d354e9..43c9f11 100644 --- a/control/src/ui/view_monitor.cpp +++ b/control/src/ui/view_monitor.cpp @@ -45,7 +45,7 @@ std::string ViewMonitor::fancyDigitalString(uint8_t& b) { std::string bitstring(std::bitset<8>(b).to_string()); std::reverse(bitstring.begin(), bitstring.end()); - + std::stringstream str; str << bitstring; str << " "; diff --git a/control/src/ui/view_monitor.cpp.orig b/control/src/ui/view_monitor.cpp.orig new file mode 100644 index 0000000..2d354e9 --- /dev/null +++ b/control/src/ui/view_monitor.cpp.orig @@ -0,0 +1,142 @@ +#include "view_monitor.h" + +ViewMonitor::ViewMonitor() : t_worker(&ViewMonitor::worker, this) +{ +} + +call_t ViewMonitor::keypress(int& key) +{ + switch(key) + { + + case KEY_MOUSE: + { + // http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml + MEVENT event; + bool hit = false; + if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) + { + size_t column = start_x + close_offset_x; + size_t row = start_y + close_offset_y; + size_t mouse_x = event.x, mouse_y = event.y; + if(mouse_y == row && mouse_x >= column && mouse_x < column + label_close.length()) + hit = true; + } + if(!hit) + break; + + // fall through to next case + [[fallthrough]]; + } + case KEY_ENT: + run_worker = false; + key = -1; // do return from view + wclear(win); + wrefresh(win); + t_worker.join(); + break; + default: + break; + } + return calls[0]; +} + +std::string ViewMonitor::fancyDigitalString(uint8_t& b) +{ + std::string bitstring(std::bitset<8>(b).to_string()); + std::reverse(bitstring.begin(), bitstring.end()); + + std::stringstream str; + str << bitstring; + str << " "; + str << "0x" << std::setfill ('0') << std::setw(2) << std::hex << (int) b << std::dec; + return str.str(); +} + +std::string ViewMonitor::fancyAnalogString(uint16_t& v) +{ + std::stringstream str; + double volt = round(v * 100.0 * 5.0 / 1023.0) / 100.0; + + str << std::setfill ('0') << std::setw(4) << (int) v << " " << std::fixed << std::setprecision(2) << volt << " V "; + + str << "["; + uint8_t p = round(v * 40.0 / 1023.0); + for(uint8_t i = 0; i < p; i++) + str << "X"; + for(uint8_t i = 0; i < 40 - p; i++) + str << " "; + str << "]" << std::endl; + + return str.str(); +} + +void ViewMonitor::worker() +{ + B15F& drv = B15F::getInstance(); + while(run_worker) + { + try + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + uint8_t be0 = drv.digitalRead0(); + uint8_t be1 = drv.digitalRead1(); + uint8_t dsw = drv.readDipSwitch(); + uint16_t adc[8]; + for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++) + adc[i] = drv.analogRead(i); + + + std::stringstream str; + + // hline + for(uint8_t i = 0; i < width - 2 * text_offset_x; i++) + if(i % 2 == 0) + str << "-"; + else + str << " "; + str << std::endl; + + str << "Digitale Enigaenge:" << std::endl; + str << "Binaere Eingabe 0: " << fancyDigitalString(be0) << std::endl; + str << "Binaere Eingabe 1: " << fancyDigitalString(be1) << std::endl; + str << "Dip Schalter (S7): " << fancyDigitalString(dsw) << std::endl; + + // hline + for(uint8_t i = 0; i < width - 2 * text_offset_x; i++) + if(i % 2 == 0) + str << "-"; + else + str << " "; + str << std::endl; + + str << "Analoge Eingaenge:" << std::endl; + for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++) + { + str << "Kanal " << std::to_string((int) i) << ": "; + str << fancyAnalogString(adc[i]) << std::endl; + } + + text = str.str(); + repaint(); + } + catch(DriverException& ex) + { + std::cout << "DriverException: " << ex.what() << std::endl; + drv.delay_ms(1000); + } + catch(...) + { + try + { + drv.reconnect(); + } + catch(...) + { + B15F::abort("Die Verbindung ist unterbrochen worden. Wurde ein Stecker gezogen? :D"); + return; + } + } + } +} diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 2691b30..fbad164 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 a5975dc..5c38dbb 100644 --- a/docs/html/b15f_8cpp_source.html +++ b/docs/html/b15f_8cpp_source.html @@ -70,7 +70,7 @@ $(function() {
b15f.cpp
-
1 #include "b15f.h"
2 
3 B15F *B15F::instance = nullptr;
4 errorhandler_t B15F::errorhandler = nullptr;
5 
6 
7 /*************************************
8  * Grundfunktionen des B15F Treibers *
9  *************************************/
10 
12 {
13  if (!instance)
14  instance = new B15F();
15 
16  return *instance;
17 }
18 
19 void B15F::reconnect()
20 {
21  uint8_t tries = RECONNECT_TRIES;
22  while (tries--)
23  {
25  discard();
26 
27  if (testConnection())
28  return;
29  }
30 
31  abort("Verbindung kann nicht repariert werden");
32 }
33 
34 void B15F::discard(void)
35 {
36  try
37  {
38  uint8_t rq[] =
39  {
40  RQ_DISCARD
41  };
42 
43  usart.clearOutputBuffer();
44  for (uint8_t i = 0; i < 16; i++)
45  {
46  usart.transmit(&rq[0], 0, sizeof(rq)); // sende discard Befehl (verwerfe input)
47  delay_ms(4);
48  }
49  usart.clearInputBuffer();
50  }
51  catch (std::exception &ex)
52  {
53  abort(ex);
54  }
55 }
56 
58 {
59  // erzeuge zufälliges Byte
60  srand(time(NULL));
61  uint8_t dummy = rand() % 256;
62 
63  uint8_t rq[] =
64  {
65  RQ_TEST,
66  dummy
67  };
68  usart.transmit(&rq[0], 0, sizeof(rq));
69 
70  uint8_t aw[2];
71  usart.receive(&aw[0], 0, sizeof(aw));
72 
73  return aw[0] == MSG_OK && aw[1] == dummy;
74 }
75 
76 bool B15F::testIntConv()
77 {
78  srand(time(NULL));
79  uint16_t dummy = rand() % (0xFFFF / 3);
80 
81  uint8_t rq[] =
82  {
83  RQ_INT_TEST,
84  static_cast<uint8_t >(dummy & 0xFF),
85  static_cast<uint8_t >(dummy >> 8)
86  };
87  usart.transmit(&rq[0], 0, sizeof(rq));
88 
89  uint16_t aw;
90  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
91 
92  return aw == dummy * 3;
93 }
94 
95 
96 std::vector<std::string> B15F::getBoardInfo(void)
97 {
98  std::vector<std::string> info;
99 
100  uint8_t rq[] =
101  {
102  RQ_INFO
103  };
104  usart.transmit(&rq[0], 0, sizeof(rq));
105 
106  uint8_t n;
107  usart.receive(&n, 0, sizeof(n));
108  while (n--)
109  {
110  uint8_t len;
111  usart.receive(&len, 0, sizeof(len));
112 
113  char str[len + 1];
114  str[len] = '\0';
115  usart.receive(reinterpret_cast<uint8_t *>(&str[0]), 0, len);
116 
117  info.push_back(std::string(str));
118  }
119 
120  uint8_t aw;
121  usart.receive(&aw, 0, sizeof(aw));
122  if (aw != MSG_OK)
123  abort("Board Info fehlerhalft: code " + std::to_string((int) aw));
124 
125  return info;
126 }
127 
128 void B15F::delay_ms(uint16_t ms)
129 {
130  std::this_thread::sleep_for(std::chrono::milliseconds(ms));
131 }
132 
133 void B15F::delay_us(uint16_t us)
134 {
135  std::this_thread::sleep_for(std::chrono::microseconds(us));
136 }
137 
138 void B15F::reverse(uint8_t& b)
139 {
140  b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
141  b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
142  b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
143 }
144 
145 // https://stackoverflow.com/a/478960
146 std::string B15F::exec(std::string cmd)
147 {
148  std::array<char, 128> buffer;
149  std::string result;
150  std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
151  if (!pipe)
152  {
153  throw std::runtime_error("popen() failed!");
154  }
155  while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
156  {
157  result += buffer.data();
158  }
159  return result;
160 }
161 
162 void B15F::abort(std::string msg)
163 {
164  DriverException ex(msg);
165  abort(ex);
166 }
167 
168 void B15F::abort(std::exception &ex)
169 {
170  if (errorhandler)
171  errorhandler(ex);
172  else
173  {
174  std::cerr << "NOTICE: B15F::errorhandler not set" << std::endl;
175  std::cout << ex.what() << std::endl;
176  throw DriverException(ex.what());
177  }
178 }
179 
180 void B15F::setAbortHandler(errorhandler_t func)
181 {
182  errorhandler = func;
183 }
184 
185 /*************************************/
186 
187 
188 
189 /*************************
190  * Steuerbefehle für B15 *
191  *************************/
192 
194 {
195  uint8_t rq[] =
196  {
197  RQ_SELF_TEST
198  };
199  usart.transmit(&rq[0], 0, sizeof(rq));
200 
201  uint8_t aw;
202  usart.receive(&aw, 0, sizeof(aw));
203  return aw == MSG_OK;
204 }
205 
206 bool B15F::digitalWrite0(uint8_t port)
207 {
208  uint8_t rq[] =
209  {
210  RQ_DIGITAL_WRITE_0,
211  port
212  };
213  usart.transmit(&rq[0], 0, sizeof(rq));
214 
215  uint8_t aw;
216  usart.receive(&aw, 0, sizeof(aw));
217  return aw == MSG_OK;
218 }
219 
220 bool B15F::digitalWrite1(uint8_t port)
221 {
222  uint8_t rq[] =
223  {
224  RQ_DIGITAL_WRITE_1,
225  port
226  };
227  usart.transmit(&rq[0], 0, sizeof(rq));
228 
229  uint8_t aw;
230  usart.receive(&aw, 0, sizeof(aw));
231  return aw == MSG_OK;
232 }
233 
234 uint8_t B15F::digitalRead0()
235 {
236  usart.clearInputBuffer();
237  uint8_t rq[] =
238  {
239  RQ_DIGITAL_READ_0
240  };
241  usart.transmit(&rq[0], 0, sizeof(rq));
242 
243  uint8_t aw;
244  usart.receive(&aw, 0, sizeof(aw));
245  return aw;
246 }
247 
248 uint8_t B15F::digitalRead1()
249 {
250  usart.clearInputBuffer();
251  uint8_t rq[] =
252  {
253  RQ_DIGITAL_READ_1
254  };
255  usart.transmit(&rq[0], 0, sizeof(rq));
256 
257  uint8_t aw;
258  usart.receive(&aw, 0, sizeof(aw));
259  return aw;
260 }
261 
262 uint8_t B15F::readDipSwitch()
263 {
264  usart.clearInputBuffer();
265  uint8_t rq[] =
266  {
267  RQ_READ_DIP_SWITCH
268  };
269  usart.transmit(&rq[0], 0, sizeof(rq));
270 
271  uint8_t aw;
272  usart.receive(&aw, 0, sizeof(aw));
273 
274  reverse(aw); // DIP Schalter muss invertiert werden!
275 
276  return aw;
277 }
278 
279 bool B15F::analogWrite0(uint16_t value)
280 {
281  uint8_t rq[] =
282  {
283  RQ_ANALOG_WRITE_0,
284  static_cast<uint8_t >(value & 0xFF),
285  static_cast<uint8_t >(value >> 8)
286  };
287  usart.transmit(&rq[0], 0, sizeof(rq));
288 
289  uint8_t aw;
290  usart.receive(&aw, 0, sizeof(aw));
291  return aw == MSG_OK;
292 }
293 
294 bool B15F::analogWrite1(uint16_t value)
295 {
296  uint8_t rq[] =
297  {
298  RQ_ANALOG_WRITE_1,
299  static_cast<uint8_t >(value & 0xFF),
300  static_cast<uint8_t >(value >> 8)
301  };
302  usart.transmit(&rq[0], 0, sizeof(rq));
303 
304  uint8_t aw;
305  usart.receive(&aw, 0, sizeof(aw));
306  return aw == MSG_OK;
307 }
308 
309 uint16_t B15F::analogRead(uint8_t channel)
310 {
311  usart.clearInputBuffer();
312  if (channel > 7)
313  abort("Bad ADC channel: " + std::to_string(channel));
314 
315  uint8_t rq[] =
316  {
317  RQ_ANALOG_READ,
318  channel
319  };
320 
321  usart.transmit(&rq[0], 0, sizeof(rq));
322 
323  uint16_t aw;
324  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
325 
326  if (aw > 1023)
327  abort("Bad ADC data detected (1)");
328  return aw;
329 }
330 
331 void
332 B15F::analogSequence(uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b,
333  uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
334 {
335  // prepare pointers
336  buffer_a += offset_a;
337  buffer_b += offset_b;
338 
339 
340  usart.clearInputBuffer();
341  uint8_t rq[] =
342  {
343  RQ_ADC_DAC_STROKE,
344  channel_a,
345  channel_b,
346  static_cast<uint8_t >(start & 0xFF),
347  static_cast<uint8_t >(start >> 8),
348  static_cast<uint8_t >(delta & 0xFF),
349  static_cast<uint8_t >(delta >> 8),
350  static_cast<uint8_t >(count & 0xFF),
351  static_cast<uint8_t >(count >> 8)
352  };
353 
354  usart.transmit(&rq[0], 0, sizeof(rq));
355 
356  for (uint16_t i = 0; i < count; i++)
357  {
358  if (buffer_a)
359  {
360  usart.receive(reinterpret_cast<uint8_t *>(&buffer_a[i]), 0, 2);
361 
362  if (buffer_a[i] > 1023) // check for broken usart connection
363  abort("Bad ADC data detected (2)");
364  }
365  else
366  {
367  usart.drop(2);
368  }
369 
370  if (buffer_b)
371  {
372  usart.receive(reinterpret_cast<uint8_t *>(&buffer_b[i]), 0, 2);
373 
374  if (buffer_b[i] > 1023) // check for broken usart connection
375  abort("Bad ADC data detected (3)");
376  }
377  else
378  {
379  usart.drop(2);
380  }
381  }
382 
383  uint8_t aw;
384  usart.receive(&aw, 0, sizeof(aw));
385  if(aw != MSG_OK)
386  abort("Sequenz unterbrochen");
387 }
388 
389 uint8_t B15F::pwmSetFrequency(uint32_t freq)
390 {
391  usart.clearInputBuffer();
392 
393  uint8_t rq[] =
394  {
395  RQ_PWM_SET_FREQ,
396  static_cast<uint8_t>((freq >> 0) & 0xFF),
397  static_cast<uint8_t>((freq >> 8) & 0xFF),
398  static_cast<uint8_t>((freq >> 16) & 0xFF),
399  static_cast<uint8_t>((freq >> 24) & 0xFF)
400  };
401 
402  usart.transmit(&rq[0], 0, sizeof(rq));
403 
404  uint8_t aw;
405  usart.receive(&aw, 0, sizeof(aw));
406  return aw;
407 }
408 
409 bool B15F::pwmSetValue(uint8_t value)
410 {
411  usart.clearInputBuffer();
412 
413  uint8_t rq[] =
414  {
415  RQ_PWM_SET_VALUE,
416  value
417  };
418 
419  usart.transmit(&rq[0], 0, sizeof(rq));
420 
421  uint8_t aw;
422  usart.receive(&aw, 0, sizeof(aw));
423  return aw == MSG_OK;
424 }
425 
426 bool B15F::setMem8(volatile uint16_t* adr, uint8_t val)
427 {
428  usart.clearInputBuffer();
429 
430  uint8_t rq[] =
431  {
432  RQ_SET_MEM_8,
433  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
434  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8),
435  val
436  };
437 
438  usart.transmit(&rq[0], 0, sizeof(rq));
439 
440  uint8_t aw;
441  usart.receive(&aw, 0, sizeof(aw));
442  return aw == val;
443 }
444 
445 uint8_t B15F::getMem8(volatile uint16_t* adr)
446 {
447  usart.clearInputBuffer();
448 
449  uint8_t rq[] =
450  {
451  RQ_GET_MEM_8,
452  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
453  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8)
454  };
455 
456  usart.transmit(&rq[0], 0, sizeof(rq));
457 
458  uint8_t aw;
459  usart.receive(&aw, 0, sizeof(aw));
460  return aw;
461 }
462 
463 bool B15F::setMem16(volatile uint16_t* adr, uint16_t val)
464 {
465  usart.clearInputBuffer();
466 
467  uint8_t rq[] =
468  {
469  RQ_SET_MEM_16,
470  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
471  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8),
472  static_cast<uint8_t >(val & 0xFF),
473  static_cast<uint8_t >(val >> 8)
474  };
475 
476  usart.transmit(&rq[0], 0, sizeof(rq));
477 
478  uint16_t aw;
479  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
480  return aw == val;
481 }
482 
483 uint16_t B15F::getMem16(volatile uint16_t* adr)
484 {
485  usart.clearInputBuffer();
486 
487  uint8_t rq[] =
488  {
489  RQ_GET_MEM_16,
490  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
491  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8)
492  };
493 
494  usart.transmit(&rq[0], 0, sizeof(rq));
495 
496  uint16_t aw;
497  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
498  return aw;
499 }
500 
501 bool B15F::setRegister(volatile uint8_t* adr, uint8_t val)
502 {
503  return setMem8(reinterpret_cast<volatile uint16_t*>(adr), val);
504 }
505 
506 uint8_t B15F::getRegister(volatile uint8_t* adr)
507 {
508  return getMem8(reinterpret_cast<volatile uint16_t*>(adr));
509 }
510 
511 /*************************/
512 
513 
514 /**********************
515  * Private Funktionen *
516  **********************/
517 
518 B15F::B15F()
519 {
520  init();
521 }
522 
523 
524 void B15F::init()
525 {
526 
527  std::string device = exec("bash -c 'ls /dev/ttyUSB*'");
528  while (device.find(' ') != std::string::npos || device.find('\n') != std::string::npos ||
529  device.find('\t') != std::string::npos)
530  device.pop_back();
531 
532  if (device.length() == 0)
533  abort("Adapter nicht gefunden");
534 
535  std::cout << PRE << "Verwende Adapter: " << device << std::endl;
536 
537 
538  std::cout << PRE << "Stelle Verbindung mit Adapter her... " << std::flush;
539  usart.setBaudrate(BAUDRATE);
540  usart.openDevice(device);
541  std::cout << "OK" << std::endl;
542 
543 
544  std::cout << PRE << "Teste Verbindung... " << std::flush;
545  uint8_t tries = 3;
546  while (tries--)
547  {
548  // verwerfe Daten, die µC noch hat
549  //discard();
550 
551  if (!testConnection())
552  continue;
553 
554  if (!testIntConv())
555  continue;
556 
557  break;
558  }
559  if (tries == 0)
560  abort("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?");
561  std::cout << "OK" << std::endl;
562 
563 
564  // Gib board info aus
565  std::vector<std::string> info = getBoardInfo();
566  std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")"
567  << std::endl;
568 }
+
1 #include "b15f.h"
2 
3 B15F *B15F::instance = nullptr;
4 errorhandler_t B15F::errorhandler = nullptr;
5 
6 
7 /*************************************
8  * Grundfunktionen des B15F Treibers *
9  *************************************/
10 
12 {
13  if (!instance)
14  instance = new B15F();
15 
16  return *instance;
17 }
18 
19 void B15F::reconnect()
20 {
21  uint8_t tries = RECONNECT_TRIES;
22  while (tries--)
23  {
25  discard();
26 
27  if (testConnection())
28  return;
29  }
30 
31  abort("Verbindung kann nicht repariert werden");
32 }
33 
34 void B15F::discard(void)
35 {
36  try
37  {
38  uint8_t rq[] =
39  {
40  RQ_DISCARD
41  };
42 
43  usart.clearOutputBuffer();
44  for (uint8_t i = 0; i < 16; i++)
45  {
46  usart.transmit(&rq[0], 0, sizeof(rq)); // sende discard Befehl (verwerfe input)
47  delay_ms(4);
48  }
49  usart.clearInputBuffer();
50  }
51  catch (std::exception &ex)
52  {
53  abort(ex);
54  }
55 }
56 
58 {
59  // erzeuge zufälliges Byte
60  srand(time(NULL));
61  uint8_t dummy = rand() % 256;
62 
63  uint8_t rq[] =
64  {
65  RQ_TEST,
66  dummy
67  };
68  usart.transmit(&rq[0], 0, sizeof(rq));
69 
70  uint8_t aw[2];
71  usart.receive(&aw[0], 0, sizeof(aw));
72 
73  return aw[0] == MSG_OK && aw[1] == dummy;
74 }
75 
76 bool B15F::testIntConv()
77 {
78  srand(time(NULL));
79  uint16_t dummy = rand() % (0xFFFF / 3);
80 
81  uint8_t rq[] =
82  {
83  RQ_INT_TEST,
84  static_cast<uint8_t >(dummy & 0xFF),
85  static_cast<uint8_t >(dummy >> 8)
86  };
87  usart.transmit(&rq[0], 0, sizeof(rq));
88 
89  uint16_t aw;
90  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
91 
92  return aw == dummy * 3;
93 }
94 
95 
96 std::vector<std::string> B15F::getBoardInfo(void)
97 {
98  std::vector<std::string> info;
99 
100  uint8_t rq[] =
101  {
102  RQ_INFO
103  };
104  usart.transmit(&rq[0], 0, sizeof(rq));
105 
106  uint8_t n;
107  usart.receive(&n, 0, sizeof(n));
108  while (n--)
109  {
110  uint8_t len;
111  usart.receive(&len, 0, sizeof(len));
112 
113  char str[len + 1];
114  str[len] = '\0';
115  usart.receive(reinterpret_cast<uint8_t *>(&str[0]), 0, len);
116 
117  info.push_back(std::string(str));
118  }
119 
120  uint8_t aw;
121  usart.receive(&aw, 0, sizeof(aw));
122  if (aw != MSG_OK)
123  abort("Board Info fehlerhalft: code " + std::to_string((int) aw));
124 
125  return info;
126 }
127 
128 void B15F::delay_ms(uint16_t ms)
129 {
130  std::this_thread::sleep_for(std::chrono::milliseconds(ms));
131 }
132 
133 void B15F::delay_us(uint16_t us)
134 {
135  std::this_thread::sleep_for(std::chrono::microseconds(us));
136 }
137 
138 void B15F::reverse(uint8_t& b)
139 {
140  b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
141  b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
142  b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
143 }
144 
145 // https://stackoverflow.com/a/478960
146 std::string B15F::exec(std::string cmd)
147 {
148  std::array<char, 128> buffer;
149  std::string result;
150  std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
151  if (!pipe)
152  {
153  throw std::runtime_error("popen() failed!");
154  }
155  while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
156  {
157  result += buffer.data();
158  }
159  return result;
160 }
161 
162 void B15F::abort(std::string msg)
163 {
164  DriverException ex(msg);
165  abort(ex);
166 }
167 
168 void B15F::abort(std::exception &ex)
169 {
170  if (errorhandler)
171  errorhandler(ex);
172  else
173  {
174  std::cerr << "NOTICE: B15F::errorhandler not set" << std::endl;
175  std::cout << ex.what() << std::endl;
176  throw DriverException(ex.what());
177  }
178 }
179 
180 void B15F::setAbortHandler(errorhandler_t func)
181 {
182  errorhandler = func;
183 }
184 
185 /*************************************/
186 
187 
188 
189 /*************************
190  * Steuerbefehle für B15 *
191  *************************/
192 
194 {
195  uint8_t rq[] =
196  {
197  RQ_SELF_TEST
198  };
199  usart.transmit(&rq[0], 0, sizeof(rq));
200 
201  uint8_t aw;
202  usart.receive(&aw, 0, sizeof(aw));
203  return aw == MSG_OK;
204 }
205 
206 bool B15F::digitalWrite0(uint8_t port)
207 {
208  uint8_t rq[] =
209  {
210  RQ_DIGITAL_WRITE_0,
211  port
212  };
213  usart.transmit(&rq[0], 0, sizeof(rq));
214 
215  uint8_t aw;
216  usart.receive(&aw, 0, sizeof(aw));
217  return aw == MSG_OK;
218 }
219 
220 bool B15F::digitalWrite1(uint8_t port)
221 {
222  uint8_t rq[] =
223  {
224  RQ_DIGITAL_WRITE_1,
225  port
226  };
227  usart.transmit(&rq[0], 0, sizeof(rq));
228 
229  uint8_t aw;
230  usart.receive(&aw, 0, sizeof(aw));
231  return aw == MSG_OK;
232 }
233 
234 uint8_t B15F::digitalRead0()
235 {
236  usart.clearInputBuffer();
237  uint8_t rq[] =
238  {
239  RQ_DIGITAL_READ_0
240  };
241  usart.transmit(&rq[0], 0, sizeof(rq));
242 
243  uint8_t aw;
244  usart.receive(&aw, 0, sizeof(aw));
245  return aw;
246 }
247 
248 uint8_t B15F::digitalRead1()
249 {
250  usart.clearInputBuffer();
251  uint8_t rq[] =
252  {
253  RQ_DIGITAL_READ_1
254  };
255  usart.transmit(&rq[0], 0, sizeof(rq));
256 
257  uint8_t aw;
258  usart.receive(&aw, 0, sizeof(aw));
259  return aw;
260 }
261 
262 uint8_t B15F::readDipSwitch()
263 {
264  usart.clearInputBuffer();
265  uint8_t rq[] =
266  {
267  RQ_READ_DIP_SWITCH
268  };
269  usart.transmit(&rq[0], 0, sizeof(rq));
270 
271  uint8_t aw;
272  usart.receive(&aw, 0, sizeof(aw));
273 
274  reverse(aw); // DIP Schalter muss invertiert werden!
275 
276  return aw;
277 }
278 
279 bool B15F::analogWrite0(uint16_t value)
280 {
281  uint8_t rq[] =
282  {
283  RQ_ANALOG_WRITE_0,
284  static_cast<uint8_t >(value & 0xFF),
285  static_cast<uint8_t >(value >> 8)
286  };
287  usart.transmit(&rq[0], 0, sizeof(rq));
288 
289  uint8_t aw;
290  usart.receive(&aw, 0, sizeof(aw));
291  return aw == MSG_OK;
292 }
293 
294 bool B15F::analogWrite1(uint16_t value)
295 {
296  uint8_t rq[] =
297  {
298  RQ_ANALOG_WRITE_1,
299  static_cast<uint8_t >(value & 0xFF),
300  static_cast<uint8_t >(value >> 8)
301  };
302  usart.transmit(&rq[0], 0, sizeof(rq));
303 
304  uint8_t aw;
305  usart.receive(&aw, 0, sizeof(aw));
306  return aw == MSG_OK;
307 }
308 
309 uint16_t B15F::analogRead(uint8_t channel)
310 {
311  usart.clearInputBuffer();
312  if (channel > 7)
313  abort("Bad ADC channel: " + std::to_string(channel));
314 
315  uint8_t rq[] =
316  {
317  RQ_ANALOG_READ,
318  channel
319  };
320 
321  usart.transmit(&rq[0], 0, sizeof(rq));
322 
323  uint16_t aw;
324  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
325 
326  if (aw > 1023)
327  abort("Bad ADC data detected (1)");
328  return aw;
329 }
330 
331 void
332 B15F::analogSequence(uint8_t channel_a, uint16_t *buffer_a, uint32_t offset_a, uint8_t channel_b, uint16_t *buffer_b,
333  uint32_t offset_b, uint16_t start, int16_t delta, uint16_t count)
334 {
335  // prepare pointers
336  buffer_a += offset_a;
337  buffer_b += offset_b;
338 
339 
340  usart.clearInputBuffer();
341  uint8_t rq[] =
342  {
343  RQ_ADC_DAC_STROKE,
344  channel_a,
345  channel_b,
346  static_cast<uint8_t >(start & 0xFF),
347  static_cast<uint8_t >(start >> 8),
348  static_cast<uint8_t >(delta & 0xFF),
349  static_cast<uint8_t >(delta >> 8),
350  static_cast<uint8_t >(count & 0xFF),
351  static_cast<uint8_t >(count >> 8)
352  };
353 
354  usart.transmit(&rq[0], 0, sizeof(rq));
355 
356  for (uint16_t i = 0; i < count; i++)
357  {
358  if (buffer_a)
359  {
360  usart.receive(reinterpret_cast<uint8_t *>(&buffer_a[i]), 0, 2);
361 
362  if (buffer_a[i] > 1023) // check for broken usart connection
363  abort("Bad ADC data detected (2)");
364  }
365  else
366  {
367  usart.drop(2);
368  }
369 
370  if (buffer_b)
371  {
372  usart.receive(reinterpret_cast<uint8_t *>(&buffer_b[i]), 0, 2);
373 
374  if (buffer_b[i] > 1023) // check for broken usart connection
375  abort("Bad ADC data detected (3)");
376  }
377  else
378  {
379  usart.drop(2);
380  }
381  }
382 
383  uint8_t aw;
384  usart.receive(&aw, 0, sizeof(aw));
385  if(aw != MSG_OK)
386  abort("Sequenz unterbrochen");
387 }
388 
389 uint8_t B15F::pwmSetFrequency(uint32_t freq)
390 {
391  usart.clearInputBuffer();
392 
393  uint8_t rq[] =
394  {
395  RQ_PWM_SET_FREQ,
396  static_cast<uint8_t>((freq >> 0) & 0xFF),
397  static_cast<uint8_t>((freq >> 8) & 0xFF),
398  static_cast<uint8_t>((freq >> 16) & 0xFF),
399  static_cast<uint8_t>((freq >> 24) & 0xFF)
400  };
401 
402  usart.transmit(&rq[0], 0, sizeof(rq));
403 
404  uint8_t aw;
405  usart.receive(&aw, 0, sizeof(aw));
406  return aw;
407 }
408 
409 bool B15F::pwmSetValue(uint8_t value)
410 {
411  usart.clearInputBuffer();
412 
413  uint8_t rq[] =
414  {
415  RQ_PWM_SET_VALUE,
416  value
417  };
418 
419  usart.transmit(&rq[0], 0, sizeof(rq));
420 
421  uint8_t aw;
422  usart.receive(&aw, 0, sizeof(aw));
423  return aw == MSG_OK;
424 }
425 
426 bool B15F::setMem8(volatile uint8_t* adr, uint8_t val)
427 {
428  usart.clearInputBuffer();
429 
430  uint8_t rq[] =
431  {
432  RQ_SET_MEM_8,
433  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
434  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8),
435  val
436  };
437 
438  usart.transmit(&rq[0], 0, sizeof(rq));
439 
440  uint8_t aw;
441  usart.receive(&aw, 0, sizeof(aw));
442  return aw == val;
443 }
444 
445 uint8_t B15F::getMem8(volatile uint8_t* adr)
446 {
447  usart.clearInputBuffer();
448 
449  uint8_t rq[] =
450  {
451  RQ_GET_MEM_8,
452  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
453  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8)
454  };
455 
456  usart.transmit(&rq[0], 0, sizeof(rq));
457 
458  uint8_t aw;
459  usart.receive(&aw, 0, sizeof(aw));
460  return aw;
461 }
462 
463 bool B15F::setMem16(volatile uint16_t* adr, uint16_t val)
464 {
465  usart.clearInputBuffer();
466 
467  uint8_t rq[] =
468  {
469  RQ_SET_MEM_16,
470  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
471  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8),
472  static_cast<uint8_t >(val & 0xFF),
473  static_cast<uint8_t >(val >> 8)
474  };
475 
476  usart.transmit(&rq[0], 0, sizeof(rq));
477 
478  uint16_t aw;
479  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
480  return aw == val;
481 }
482 
483 uint16_t B15F::getMem16(volatile uint16_t* adr)
484 {
485  usart.clearInputBuffer();
486 
487  uint8_t rq[] =
488  {
489  RQ_GET_MEM_16,
490  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) & 0xFF),
491  static_cast<uint8_t >(reinterpret_cast<size_t>(adr) >> 8)
492  };
493 
494  usart.transmit(&rq[0], 0, sizeof(rq));
495 
496  uint16_t aw;
497  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
498  return aw;
499 }
500 
501 bool B15F::setRegister(volatile uint8_t* adr, uint8_t val)
502 {
503  return setMem8(adr, val);
504 }
505 
506 uint8_t B15F::getRegister(volatile uint8_t* adr)
507 {
508  return getMem8(adr);
509 }
510 
512 {
513  usart.clearInputBuffer();
514 
515  uint8_t rq[] =
516  {
517  RQ_COUNTER_OFFSET
518  };
519 
520  usart.transmit(&rq[0], 0, sizeof(rq));
521 
522  uint16_t aw;
523  usart.receive(reinterpret_cast<uint8_t *>(&aw), 0, sizeof(aw));
524  return reinterpret_cast<uint16_t*>(aw);
525 }
526 
527 /*************************/
528 
529 
530 /**********************
531  * Private Funktionen *
532  **********************/
533 
534 B15F::B15F()
535 {
536  init();
537 }
538 
539 
540 void B15F::init()
541 {
542 
543  std::string device = exec("bash -c 'ls /dev/ttyUSB*'");
544  while (device.find(' ') != std::string::npos || device.find('\n') != std::string::npos ||
545  device.find('\t') != std::string::npos)
546  device.pop_back();
547 
548  if (device.length() == 0)
549  abort("Adapter nicht gefunden");
550 
551  std::cout << PRE << "Verwende Adapter: " << device << std::endl;
552 
553 
554  std::cout << PRE << "Stelle Verbindung mit Adapter her... " << std::flush;
555  usart.setBaudrate(BAUDRATE);
556  usart.openDevice(device);
557  std::cout << "OK" << std::endl;
558 
559 
560  std::cout << PRE << "Teste Verbindung... " << std::flush;
561  uint8_t tries = 3;
562  while (tries--)
563  {
564  // verwerfe Daten, die µC noch hat
565  //discard();
566 
567  if (!testConnection())
568  continue;
569 
570  if (!testIntConv())
571  continue;
572 
573  break;
574  }
575  if (tries == 0)
576  abort("Verbindungstest fehlgeschlagen. Neueste Version im Einsatz?");
577  std::cout << "OK" << std::endl;
578 
579 
580  // Gib board info aus
581  std::vector<std::string> info = getBoardInfo();
582  std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")"
583  << std::endl;
584 }
static std::string exec(std::string cmd)
Definition: b15f.cpp:145
uint16_t getMem16(volatile uint16_t *adr)
Definition: b15f.cpp:481
void delay_us(uint16_t us)
Definition: b15f.cpp:132
@@ -80,6 +80,7 @@ $(function() {
bool testConnection(void)
Definition: b15f.cpp:56
uint8_t readDipSwitch(void)
Definition: b15f.cpp:260
uint8_t getRegister(volatile uint8_t *adr)
Definition: b15f.cpp:504
+
uint8_t getMem8(volatile uint8_t *adr)
Definition: b15f.cpp:443
void delay_ms(uint16_t ms)
Definition: b15f.cpp:127
static B15F & getInstance(void)
Definition: b15f.cpp:10
Definition: b15f.h:33
@@ -87,37 +88,37 @@ $(function() {
static void abort(std::string msg)
Definition: b15f.cpp:161
void receive(uint8_t *buffer, uint16_t offset, uint8_t len)
Definition: usart.cpp:84
void clearInputBuffer(void)
Definition: usart.cpp:54
+
uint16_t * getInterruptCounterOffset(void)
Definition: b15f.cpp:509
void clearOutputBuffer(void)
Definition: usart.cpp:61
uint16_t analogRead(uint8_t channel)
Definition: b15f.cpp:307
bool digitalWrite0(uint8_t)
Definition: b15f.cpp:204
-
const std::string PRE
B15F stdout prefix.
Definition: b15f.h:287
+
const std::string PRE
B15F stdout prefix.
Definition: b15f.h:285
void reverse(uint8_t &b)
Definition: b15f.cpp:137
void setBaudrate(uint32_t baudrate)
Definition: usart.cpp:131
bool activateSelfTestMode(void)
Definition: b15f.cpp:191
std::vector< std::string > getBoardInfo(void)
Definition: b15f.cpp:95
-
constexpr static uint16_t RECONNECT_TIMEOUT
Time in ms after which a reconnect attempt aborts.
Definition: b15f.h:290
+
constexpr static uint16_t RECONNECT_TIMEOUT
Time in ms after which a reconnect attempt aborts.
Definition: b15f.h:288
bool analogWrite1(uint16_t port)
Definition: b15f.cpp:292
bool setMem16(volatile uint16_t *adr, uint16_t val)
Definition: b15f.cpp:461
bool digitalWrite1(uint8_t)
Definition: b15f.cpp:218
bool pwmSetValue(uint8_t value)
Definition: b15f.cpp:407
void discard(void)
Definition: b15f.cpp:33
bool setRegister(volatile uint8_t *adr, uint8_t val)
Definition: b15f.cpp:499
-
constexpr static uint8_t MSG_OK
Value to acknowledge a received command.
Definition: b15f.h:288
+
constexpr static uint8_t MSG_OK
Value to acknowledge a received command.
Definition: b15f.h:286
void openDevice(std::string device)
Definition: usart.cpp:9
uint8_t digitalRead1(void)
Definition: b15f.cpp:246
-
bool setMem8(volatile uint16_t *adr, uint8_t val)
Definition: b15f.cpp:424
void reconnect(void)
Definition: b15f.cpp:18
-
constexpr static uint32_t BAUDRATE
USART baudrate for communication with the MCU.
Definition: b15f.h:293
+
constexpr static uint32_t BAUDRATE
USART baudrate for communication with the MCU.
Definition: b15f.h:291
+
bool setMem8(volatile uint8_t *adr, uint8_t val)
Definition: b15f.cpp:424
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:179
void drop(uint8_t len)
Definition: usart.cpp:114
-
uint8_t getMem8(volatile uint16_t *adr)
Definition: b15f.cpp:443
bool analogWrite0(uint16_t port)
Definition: b15f.cpp:277
-
constexpr static uint8_t RECONNECT_TRIES
Maximum count of reconnect attempts after which the driver stops.
Definition: b15f.h:292
+
constexpr static uint8_t RECONNECT_TRIES
Maximum count of reconnect attempts after which the driver stops.
Definition: b15f.h:290
bool testIntConv(void)
Definition: b15f.cpp:75
diff --git a/docs/html/b15f_8h_source.html b/docs/html/b15f_8h_source.html index e9abdb8..065537c 100644 --- a/docs/html/b15f_8h_source.html +++ b/docs/html/b15f_8h_source.html @@ -70,9 +70,9 @@ $(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 "requests.h"
19 #include "usart.h"
20 #include "driverexception.h"
21 #include "timeoutexception.h"
22 
23 // wichtig für die Register-Zugriffe
24 #define _AVR_IO_H_ 1 // Erzwinge die Inklusion
25 #include "/usr/lib/avr/include/avr/sfr_defs.h"
26 #include "/usr/lib/avr/include/avr/iom1284p.h"
27 
28 typedef std::function<void(std::exception&)> errorhandler_t;
29 
30 
33 class B15F
34 {
35 public:
36 
37  /*************************************
38  * Grundfunktionen des B15F Treibers *
39  *************************************/
40 
45  static B15F& getInstance(void);
46 
51  void reconnect(void);
52 
57  void discard(void);
58 
63  bool testConnection(void);
64 
69  bool testIntConv(void);
70 
75  std::vector<std::string> getBoardInfo(void);
76 
81  void delay_ms(uint16_t ms);
82 
87  void delay_us(uint16_t us);
88 
94  void reverse(uint8_t& b);
95 
100  static std::string exec(std::string cmd);
101 
106  static void abort(std::string msg);
107 
112  static void abort(std::exception& ex);
113 
118  static void setAbortHandler(errorhandler_t func);
119 
120  /*************************************/
121 
122 
123 
124  /*************************
125  * Steuerbefehle für B15 *
126  *************************/
127 
133  bool activateSelfTestMode(void);
134 
140  bool digitalWrite0(uint8_t);
141 
147  bool digitalWrite1(uint8_t);
148 
154  uint8_t digitalRead0(void);
155 
161  uint8_t digitalRead1(void);
162 
168  uint8_t readDipSwitch(void);
169 
175  bool analogWrite0(uint16_t port);
176 
182  bool analogWrite1(uint16_t port);
183 
189  uint16_t analogRead(uint8_t channel);
190 
206  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);
207 
216  uint8_t pwmSetFrequency(uint32_t freq);
217 
223  bool pwmSetValue(uint8_t value);
224 
234  bool setMem8(volatile uint16_t* adr, uint8_t val);
235 
243  uint8_t getMem8(volatile uint16_t* adr);
244 
254  bool setMem16(volatile uint16_t* adr, uint16_t val);
255 
263  uint16_t getMem16(volatile uint16_t* adr);
264 
274  bool setRegister(volatile uint8_t* adr, uint8_t val);
275 
283  uint8_t getRegister(volatile uint8_t* adr);
284 
285  /*************************/
286 
287 
288  // CONSTANTS
289  const std::string PRE = "[B15F] ";
290  constexpr static uint8_t MSG_OK = 0xFF;
291  constexpr static uint8_t MSG_FAIL = 0xFE;
292  constexpr static uint16_t RECONNECT_TIMEOUT = 64;
293  constexpr static uint16_t WDT_TIMEOUT = 15;
294  constexpr static uint8_t RECONNECT_TRIES = 3;
295  constexpr static uint32_t BAUDRATE = 57600;
296 
297 private:
298 
302  B15F(void);
303 
308  void init(void);
309 
310  USART usart;
311  static B15F* instance;
312  static errorhandler_t errorhandler;
313 };
314 
315 #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 "requests.h"
19 #include "usart.h"
20 #include "driverexception.h"
21 #include "timeoutexception.h"
22 
23 // wichtig für die Register-Zugriffe
24 #define _AVR_IO_H_ 1 // Erzwinge die Inklusion
25 #include "/usr/lib/avr/include/avr/sfr_defs.h"
26 #include "/usr/lib/avr/include/avr/iom1284p.h"
27 
28 typedef std::function<void(std::exception&)> errorhandler_t;
29 
30 
33 class B15F
34 {
35 public:
36 
37  /*************************************
38  * Grundfunktionen des B15F Treibers *
39  *************************************/
40 
45  static B15F& getInstance(void);
46 
51  void reconnect(void);
52 
57  void discard(void);
58 
63  bool testConnection(void);
64 
69  bool testIntConv(void);
70 
75  std::vector<std::string> getBoardInfo(void);
76 
81  void delay_ms(uint16_t ms);
82 
87  void delay_us(uint16_t us);
88 
94  void reverse(uint8_t& b);
95 
100  static std::string exec(std::string cmd);
101 
106  static void abort(std::string msg);
107 
112  static void abort(std::exception& ex);
113 
118  static void setAbortHandler(errorhandler_t func);
119 
120  /*************************************/
121 
122 
123 
124  /*************************
125  * Steuerbefehle für B15 *
126  *************************/
127 
133  bool activateSelfTestMode(void);
134 
140  bool digitalWrite0(uint8_t);
141 
147  bool digitalWrite1(uint8_t);
148 
154  uint8_t digitalRead0(void);
155 
161  uint8_t digitalRead1(void);
162 
168  uint8_t readDipSwitch(void);
169 
175  bool analogWrite0(uint16_t port);
176 
182  bool analogWrite1(uint16_t port);
183 
189  uint16_t analogRead(uint8_t channel);
190 
206  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);
207 
216  uint8_t pwmSetFrequency(uint32_t freq);
217 
223  bool pwmSetValue(uint8_t value);
224 
233  bool setMem8(volatile uint8_t* adr, uint8_t val);
234 
241  uint8_t getMem8(volatile uint8_t* adr);
242 
251  bool setMem16(volatile uint16_t* adr, uint16_t val);
252 
259  uint16_t getMem16(volatile uint16_t* adr);
260 
268  bool setRegister(volatile uint8_t* adr, uint8_t val);
269 
275  uint8_t getRegister(volatile uint8_t* adr);
276 
281  uint16_t* getInterruptCounterOffset(void);
282 
283  /*************************/
284 
285 
286  // CONSTANTS
287  const std::string PRE = "[B15F] ";
288  constexpr static uint8_t MSG_OK = 0xFF;
289  constexpr static uint8_t MSG_FAIL = 0xFE;
290  constexpr static uint16_t RECONNECT_TIMEOUT = 64;
291  constexpr static uint16_t WDT_TIMEOUT = 15;
292  constexpr static uint8_t RECONNECT_TRIES = 3;
293  constexpr static uint32_t BAUDRATE = 57600;
294 
295 private:
296 
300  B15F(void);
301 
306  void init(void);
307 
308  USART usart;
309  static B15F* instance;
310  static errorhandler_t errorhandler;
311 };
312 
313 #endif // B15F_H
static std::string exec(std::string cmd)
Definition: b15f.cpp:145
-
constexpr static uint8_t MSG_FAIL
Value to reject a received command.
Definition: b15f.h:289
+
constexpr static uint8_t MSG_FAIL
Value to reject a received command.
Definition: b15f.h:287
uint16_t getMem16(volatile uint16_t *adr)
Definition: b15f.cpp:481
void delay_us(uint16_t us)
Definition: b15f.cpp:132
uint8_t digitalRead0(void)
Definition: b15f.cpp:232
@@ -81,38 +81,39 @@ $(function() {
bool testConnection(void)
Definition: b15f.cpp:56
uint8_t readDipSwitch(void)
Definition: b15f.cpp:260
uint8_t getRegister(volatile uint8_t *adr)
Definition: b15f.cpp:504
+
uint8_t getMem8(volatile uint8_t *adr)
Definition: b15f.cpp:443
void delay_ms(uint16_t ms)
Definition: b15f.cpp:127
static B15F & getInstance(void)
Definition: b15f.cpp:10
Definition: b15f.h:33
static void abort(std::string msg)
Definition: b15f.cpp:161
+
uint16_t * getInterruptCounterOffset(void)
Definition: b15f.cpp:509
Definition: usart.h:16
uint16_t analogRead(uint8_t channel)
Definition: b15f.cpp:307
bool digitalWrite0(uint8_t)
Definition: b15f.cpp:204
-
const std::string PRE
B15F stdout prefix.
Definition: b15f.h:287
+
const std::string PRE
B15F stdout prefix.
Definition: b15f.h:285
void reverse(uint8_t &b)
Definition: b15f.cpp:137
bool activateSelfTestMode(void)
Definition: b15f.cpp:191
std::vector< std::string > getBoardInfo(void)
Definition: b15f.cpp:95
-
constexpr static uint16_t RECONNECT_TIMEOUT
Time in ms after which a reconnect attempt aborts.
Definition: b15f.h:290
+
constexpr static uint16_t RECONNECT_TIMEOUT
Time in ms after which a reconnect attempt aborts.
Definition: b15f.h:288
bool analogWrite1(uint16_t port)
Definition: b15f.cpp:292
bool setMem16(volatile uint16_t *adr, uint16_t val)
Definition: b15f.cpp:461
bool digitalWrite1(uint8_t)
Definition: b15f.cpp:218
bool pwmSetValue(uint8_t value)
Definition: b15f.cpp:407
void discard(void)
Definition: b15f.cpp:33
bool setRegister(volatile uint8_t *adr, uint8_t val)
Definition: b15f.cpp:499
-
constexpr static uint8_t MSG_OK
Value to acknowledge a received command.
Definition: b15f.h:288
+
constexpr static uint8_t MSG_OK
Value to acknowledge a received command.
Definition: b15f.h:286
uint8_t digitalRead1(void)
Definition: b15f.cpp:246
-
bool setMem8(volatile uint16_t *adr, uint8_t val)
Definition: b15f.cpp:424
-
constexpr static uint16_t WDT_TIMEOUT
Time in ms after which the watch dog timer resets the MCU.
Definition: b15f.h:291
+
constexpr static uint16_t WDT_TIMEOUT
Time in ms after which the watch dog timer resets the MCU.
Definition: b15f.h:289
void reconnect(void)
Definition: b15f.cpp:18
-
constexpr static uint32_t BAUDRATE
USART baudrate for communication with the MCU.
Definition: b15f.h:293
+
constexpr static uint32_t BAUDRATE
USART baudrate for communication with the MCU.
Definition: b15f.h:291
+
bool setMem8(volatile uint8_t *adr, uint8_t val)
Definition: b15f.cpp:424
static void setAbortHandler(errorhandler_t func)
Definition: b15f.cpp:179
-
uint8_t getMem8(volatile uint16_t *adr)
Definition: b15f.cpp:443
bool analogWrite0(uint16_t port)
Definition: b15f.cpp:277
-
constexpr static uint8_t RECONNECT_TRIES
Maximum count of reconnect attempts after which the driver stops.
Definition: b15f.h:292
+
constexpr static uint8_t RECONNECT_TRIES
Maximum count of reconnect attempts after which the driver stops.
Definition: b15f.h:290
bool testIntConv(void)
Definition: b15f.cpp:75
diff --git a/docs/html/classB15F-members.html b/docs/html/classB15F-members.html index 6ed2de5..70162b7 100644 --- a/docs/html/classB15F-members.html +++ b/docs/html/classB15F-members.html @@ -87,30 +87,31 @@ $(function() { exec(std::string cmd)B15Fstatic getBoardInfo(void)B15F getInstance(void)B15Fstatic - getMem16(volatile uint16_t *adr)B15F - getMem8(volatile uint16_t *adr)B15F - getRegister(volatile uint8_t *adr)B15F - MSG_FAILB15Fstatic - MSG_OKB15Fstatic - PREB15F - pwmSetFrequency(uint32_t freq)B15F - pwmSetValue(uint8_t value)B15F - readDipSwitch(void)B15F - reconnect(void)B15F - RECONNECT_TIMEOUTB15Fstatic - RECONNECT_TRIESB15Fstatic - reverse(uint8_t &b)B15F - setAbortHandler(errorhandler_t func)B15Fstatic - setMem16(volatile uint16_t *adr, uint16_t val)B15F - setMem8(volatile uint16_t *adr, uint8_t val)B15F - setRegister(volatile uint8_t *adr, uint8_t val)B15F - testConnection(void)B15F - testIntConv(void)B15F - WDT_TIMEOUTB15Fstatic + getInterruptCounterOffset(void)B15F + getMem16(volatile uint16_t *adr)B15F + getMem8(volatile uint8_t *adr)B15F + getRegister(volatile uint8_t *adr)B15F + MSG_FAILB15Fstatic + MSG_OKB15Fstatic + PREB15F + pwmSetFrequency(uint32_t freq)B15F + pwmSetValue(uint8_t value)B15F + readDipSwitch(void)B15F + reconnect(void)B15F + RECONNECT_TIMEOUTB15Fstatic + RECONNECT_TRIESB15Fstatic + reverse(uint8_t &b)B15F + setAbortHandler(errorhandler_t func)B15Fstatic + setMem16(volatile uint16_t *adr, uint16_t val)B15F + setMem8(volatile uint8_t *adr, uint8_t val)B15F + setRegister(volatile uint8_t *adr, uint8_t val)B15F + testConnection(void)B15F + testIntConv(void)B15F + WDT_TIMEOUTB15Fstatic diff --git a/docs/html/classB15F.html b/docs/html/classB15F.html index 668e644..390df0e 100644 --- a/docs/html/classB15F.html +++ b/docs/html/classB15F.html @@ -117,10 +117,10 @@ Public Member Functions   bool pwmSetValue (uint8_t value)   -bool setMem8 (volatile uint16_t *adr, uint8_t val) -  -uint8_t getMem8 (volatile uint16_t *adr) -  +bool setMem8 (volatile uint8_t *adr, uint8_t val) +  +uint8_t getMem8 (volatile uint8_t *adr) +  bool setMem16 (volatile uint16_t *adr, uint16_t val)   uint16_t getMem16 (volatile uint16_t *adr) @@ -129,6 +129,8 @@ Public Member Functions   uint8_t getRegister (volatile uint8_t *adr)   +uint16_t * getInterruptCounterOffset (void) +  @@ -752,6 +754,27 @@ constexpr static uint32_t  - + @@ -809,12 +826,6 @@ constexpr static uint32_t 

Static Public Member Functions

Definition at line 10 of file b15f.cpp.

+ + + +

◆ getInterruptCounterOffset()

+ +
+
+ + + + + + + + +
uint16_t * B15F::getInterruptCounterOffset (void )
+
+

Liefert die Adresse des ersten Interrupt Counters (BASISR).

Returns
Adresse (in der MCU)
+ +

Definition at line 509 of file b15f.cpp.

+
@@ -776,19 +799,13 @@ constexpr static uint32_t 
Returns
Wert der Speicherzelle
-
Exceptions
- - -
DriverException
-
-

Definition at line 481 of file b15f.cpp.

- -

◆ getMem8()

+ +

◆ getMem8()

@@ -796,7 +813,7 @@ constexpr static uint32_t 
uint8_t B15F::getMem8 (volatile uint16_t * volatile uint8_t *  adr)
Returns
Wert der Speicherzelle
-
Exceptions
- - -
DriverException
-
-

Definition at line 443 of file b15f.cpp.

@@ -835,19 +846,13 @@ constexpr static uint32_t 
-

Liefert den Wert eines 8-Bit MCU Registers. Diese Funktion arbeitet analog zu getMem8(), jedoch mit einer 8-Bit Adresse.

Parameters
+

Diese Funktion ist ein Alias für getMem8().

Parameters
adrSpeicheradresse
Returns
Wert des Registers
-
Exceptions
- - -
DriverException
-
-

Definition at line 504 of file b15f.cpp.

@@ -1064,19 +1069,13 @@ constexpr static uint32_t 
Returns
true, falls Vorgang erfolgreich
-
Exceptions
- - -
DriverException
-
-

Definition at line 461 of file b15f.cpp.

- -

◆ setMem8()

+ +

◆ setMem8()

-

Setzt direkt den Wert eines 8-Bit MCU Registers. Diese Funktion arbeitet analog zu setMem8(), jedoch mit einer 8-Bit Adresse. Wichtig: bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen!

Parameters
+

Diese Funktion ist ein Alias für setMem8(). Wichtig: bei einer falschen Adresse kann das Board 15 ernsthaften Schaden nehmen!

Parameters
@@ -1152,12 +1145,6 @@ constexpr static uint32_t 
adrSpeicheradresse
valNeuer Wert für das Register
Returns
true, falls Vorgang erfolgreich
-
Exceptions
- - -
DriverException
-
-

Definition at line 499 of file b15f.cpp.

@@ -1222,7 +1209,7 @@ constexpr static uint32_t 
diff --git a/docs/html/classDot-members.html b/docs/html/classDot-members.html index f5a30a8..eff6dfc 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 5599dbe..035562e 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 bab0a2b..1d0c1bd 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 e07842c..1a7b594 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 ded9b93..a69812f 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 9a24386..f285e08 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 cbd10bb..e955451 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 4f9fbc5..3bfd286 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 23ac216..9d3edba 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 7cd032b..9395f0f 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 319ec23..4daacc2 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 89036d2..b49ffa4 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 97893dd..caaa953 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 cce9df2..b3a005a 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 ad42b19..53ea548 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 7016221..60d8c2c 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 860d56d..90992b1 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 5f04ee9..4ae9eba 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 b95ad6d..e25d197 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 ca71666..bb1b006 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 9f1f0a0..fd1ce88 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 8baa922..cbe7466 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 1c9bb5f..c896c1d 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 04c3f56..e6192dd 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:179
diff --git a/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html b/docs/html/dir_1788f8309b1a812dcb800a185471cf6c.html index 45d394d..5db4270 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 da1db98..a738022 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 8602bb6..51407aa 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 afb9290..e26f694 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 6109de2..9fad20a 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/files.html b/docs/html/files.html index fd7f89f..f29bc93 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -100,7 +100,7 @@ $(function() { diff --git a/docs/html/functions.html b/docs/html/functions.html index cb1b56b..9b83567 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -179,11 +179,14 @@ $(function() {
  • getInstance() : B15F
  • +
  • getInterruptCounterOffset() +: B15F +
  • getMem16() : B15F
  • getMem8() -: B15F +: B15F
  • getParaFirstCurve() : PlottyFile @@ -303,7 +306,7 @@ $(function() { : B15F
  • setMem8() -: B15F +: B15F
  • setParaFirstCurve() : PlottyFile @@ -395,7 +398,7 @@ $(function() { diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index bdaa77e..945fe98 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html @@ -172,11 +172,14 @@ $(function() {
  • getInstance() : B15F
  • +
  • getInterruptCounterOffset() +: B15F +
  • getMem16() : B15F
  • getMem8() -: B15F +: B15F
  • getParaFirstCurve() : PlottyFile @@ -273,7 +276,7 @@ $(function() { : B15F
  • setMem8() -: B15F +: B15F
  • setParaFirstCurve() : PlottyFile @@ -362,7 +365,7 @@ $(function() { diff --git a/docs/html/functions_vars.html b/docs/html/functions_vars.html index c8b2400..c1bc690 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 37f9113..dbe3d51 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 85b7169..2e70898 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 ebe94d2..3dc3a89 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 d8ee077..d940869 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 506dbff..40fcab9 100644 --- a/docs/html/requests_8h_source.html +++ b/docs/html/requests_8h_source.html @@ -70,10 +70,10 @@ $(function() {
    requests.h
    -
    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 
    25 uint8_t const rq_len[] = {
    26  1 /* RQ_DISCARD */,
    27  1 /* RQ_TEST */ + 1 /* test byte */,
    28  1 /* RQ_INFO */,
    29  1 /* RQ_INT_TEST */ + 1 /* test int high low */ + 1 /* test int high high */,
    30  1 /* RQ_SELF_TEST */,
    31  1 /* RQ_DIGITAL_WRITE_0 */ + 1 /* port value */,
    32  1 /* RQ_DIGITAL_WRITE_1 */ + 1 /* port value */,
    33  1 /* RQ_DIGITAL_READ_0 */,
    34  1 /* RQ_DIGITAL_READ_1 */,
    35  1 /* RQ_READ_DIP_SWITCH */,
    36  1 /* RQ_ANALOG_WRITE_0 */ + 1 /* test int high low */ + 1 /* test int high high */,
    37  1 /* RQ_ANALOG_WRITE_1 */ + 1 /* test int high low */ + 1 /* test int high high */,
    38  1 /* RQ_ANALOG_READ */ + 1 /* adc channel */,
    39  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 */,
    40  1 /* RQ_PWM_SET_FREQ */ + 1 /* freq low low */ + 1 /* freq low high */ + 1 /* freq high low */ + 1 /* freq high high */,
    41  1 /* RQ_PWM_SET_VALUE */ + 1 /* pwm value */,
    42  1 /* RQ_SET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value (8-bit) */,
    43  1 /* RQ_GET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */,
    44  1 /* RQ_SET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value low */ + 1 /* memory value high */,
    45  1 /* RQ_GET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */,
    46 };
    47 
    48 #endif // REQUESTS_H
    +
    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 
    26 uint8_t const rq_len[] =
    27 {
    28  1 /* RQ_DISCARD */,
    29  1 /* RQ_TEST */ + 1 /* test byte */,
    30  1 /* RQ_INFO */,
    31  1 /* RQ_INT_TEST */ + 1 /* test int high low */ + 1 /* test int high high */,
    32  1 /* RQ_SELF_TEST */,
    33  1 /* RQ_DIGITAL_WRITE_0 */ + 1 /* port value */,
    34  1 /* RQ_DIGITAL_WRITE_1 */ + 1 /* port value */,
    35  1 /* RQ_DIGITAL_READ_0 */,
    36  1 /* RQ_DIGITAL_READ_1 */,
    37  1 /* RQ_READ_DIP_SWITCH */,
    38  1 /* RQ_ANALOG_WRITE_0 */ + 1 /* test int high low */ + 1 /* test int high high */,
    39  1 /* RQ_ANALOG_WRITE_1 */ + 1 /* test int high low */ + 1 /* test int high high */,
    40  1 /* RQ_ANALOG_READ */ + 1 /* adc channel */,
    41  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 */,
    42  1 /* RQ_PWM_SET_FREQ */ + 1 /* freq low low */ + 1 /* freq low high */ + 1 /* freq high low */ + 1 /* freq high high */,
    43  1 /* RQ_PWM_SET_VALUE */ + 1 /* pwm value */,
    44  1 /* RQ_SET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value (8-bit) */,
    45  1 /* RQ_GET_MEM_8 */ + 1 /* memory address low */ + 1 /* memory address high */,
    46  1 /* RQ_SET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */ + 1 /* memory value low */ + 1 /* memory value high */,
    47  1 /* RQ_GET_MEM_16 */ + 1 /* memory address low */ + 1 /* memory address high */,
    48  1 /* RQ_COUNTER_OFFSET */,
    49 };
    50 
    51 #endif // REQUESTS_H
    diff --git a/docs/html/search/all_6.js b/docs/html/search/all_6.js index 02c5955..ff9844a 100644 --- a/docs/html/search/all_6.js +++ b/docs/html/search/all_6.js @@ -8,8 +8,9 @@ var searchData= ['getdescy',['getDescY',['../classPlottyFile.html#ab4a847fd71a804182f211233e194df45',1,'PlottyFile']]], ['getfunctiontype',['getFunctionType',['../classPlottyFile.html#a88bb7d8350ed5fbc7a40e8d903c94bdb',1,'PlottyFile']]], ['getinstance',['getInstance',['../classB15F.html#a8b4533d232c55ef2aa967e39e2d23380',1,'B15F']]], + ['getinterruptcounteroffset',['getInterruptCounterOffset',['../classB15F.html#a055e5b62432aa08c711f430fc0181d86',1,'B15F']]], ['getmem16',['getMem16',['../classB15F.html#a5f84a830f054fbede9444d3b9bb566c4',1,'B15F']]], - ['getmem8',['getMem8',['../classB15F.html#ad6314ec0a2701f6b2ea49b7623b9e1c4',1,'B15F']]], + ['getmem8',['getMem8',['../classB15F.html#a404bd21d5db7270744eea77edfd9578a',1,'B15F']]], ['getparafirstcurve',['getParaFirstCurve',['../classPlottyFile.html#a40828c93d66fe80166c4f603d5bdfa48',1,'PlottyFile']]], ['getparastepwidth',['getParaStepWidth',['../classPlottyFile.html#a9da23f2bb8e6eb1837fc992ffd4057db',1,'PlottyFile']]], ['getquadrant',['getQuadrant',['../classPlottyFile.html#a54e94e80061a27614f2d4d63697d3376',1,'PlottyFile']]], diff --git a/docs/html/search/all_b.js b/docs/html/search/all_b.js index 07ce94c..8a220d2 100644 --- a/docs/html/search/all_b.js +++ b/docs/html/search/all_b.js @@ -7,7 +7,7 @@ var searchData= ['setdescy',['setDescY',['../classPlottyFile.html#a38a3a4dfc76bc70523727584bf01d590',1,'PlottyFile']]], ['setfunctiontype',['setFunctionType',['../classPlottyFile.html#a4e5ab1ebb012a5cc1a3d6458a4cd512f',1,'PlottyFile']]], ['setmem16',['setMem16',['../classB15F.html#ae2dc09141f3300c751b57adacf2bed71',1,'B15F']]], - ['setmem8',['setMem8',['../classB15F.html#a965b879d92787203e0971db20e247dfe',1,'B15F']]], + ['setmem8',['setMem8',['../classB15F.html#a04e52727c1ac7f5e600163c73deb29f2',1,'B15F']]], ['setparafirstcurve',['setParaFirstCurve',['../classPlottyFile.html#aa676414793becb975506f48d6e949dd0',1,'PlottyFile']]], ['setparastepwidth',['setParaStepWidth',['../classPlottyFile.html#a6caebd31e04e2e7081cc007047350355',1,'PlottyFile']]], ['setquadrant',['setQuadrant',['../classPlottyFile.html#a1953ee0d9a87b7353c16139584e9c2ae',1,'PlottyFile']]], diff --git a/docs/html/search/functions_5.js b/docs/html/search/functions_5.js index 02c5955..ff9844a 100644 --- a/docs/html/search/functions_5.js +++ b/docs/html/search/functions_5.js @@ -8,8 +8,9 @@ var searchData= ['getdescy',['getDescY',['../classPlottyFile.html#ab4a847fd71a804182f211233e194df45',1,'PlottyFile']]], ['getfunctiontype',['getFunctionType',['../classPlottyFile.html#a88bb7d8350ed5fbc7a40e8d903c94bdb',1,'PlottyFile']]], ['getinstance',['getInstance',['../classB15F.html#a8b4533d232c55ef2aa967e39e2d23380',1,'B15F']]], + ['getinterruptcounteroffset',['getInterruptCounterOffset',['../classB15F.html#a055e5b62432aa08c711f430fc0181d86',1,'B15F']]], ['getmem16',['getMem16',['../classB15F.html#a5f84a830f054fbede9444d3b9bb566c4',1,'B15F']]], - ['getmem8',['getMem8',['../classB15F.html#ad6314ec0a2701f6b2ea49b7623b9e1c4',1,'B15F']]], + ['getmem8',['getMem8',['../classB15F.html#a404bd21d5db7270744eea77edfd9578a',1,'B15F']]], ['getparafirstcurve',['getParaFirstCurve',['../classPlottyFile.html#a40828c93d66fe80166c4f603d5bdfa48',1,'PlottyFile']]], ['getparastepwidth',['getParaStepWidth',['../classPlottyFile.html#a9da23f2bb8e6eb1837fc992ffd4057db',1,'PlottyFile']]], ['getquadrant',['getQuadrant',['../classPlottyFile.html#a54e94e80061a27614f2d4d63697d3376',1,'PlottyFile']]], diff --git a/docs/html/search/functions_9.js b/docs/html/search/functions_9.js index 07ce94c..8a220d2 100644 --- a/docs/html/search/functions_9.js +++ b/docs/html/search/functions_9.js @@ -7,7 +7,7 @@ var searchData= ['setdescy',['setDescY',['../classPlottyFile.html#a38a3a4dfc76bc70523727584bf01d590',1,'PlottyFile']]], ['setfunctiontype',['setFunctionType',['../classPlottyFile.html#a4e5ab1ebb012a5cc1a3d6458a4cd512f',1,'PlottyFile']]], ['setmem16',['setMem16',['../classB15F.html#ae2dc09141f3300c751b57adacf2bed71',1,'B15F']]], - ['setmem8',['setMem8',['../classB15F.html#a965b879d92787203e0971db20e247dfe',1,'B15F']]], + ['setmem8',['setMem8',['../classB15F.html#a04e52727c1ac7f5e600163c73deb29f2',1,'B15F']]], ['setparafirstcurve',['setParaFirstCurve',['../classPlottyFile.html#aa676414793becb975506f48d6e949dd0',1,'PlottyFile']]], ['setparastepwidth',['setParaStepWidth',['../classPlottyFile.html#a6caebd31e04e2e7081cc007047350355',1,'PlottyFile']]], ['setquadrant',['setQuadrant',['../classPlottyFile.html#a1953ee0d9a87b7353c16139584e9c2ae',1,'PlottyFile']]], diff --git a/docs/html/timeoutexception_8h_source.html b/docs/html/timeoutexception_8h_source.html index 458e529..dd7ce8c 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 ca5fec7..5db3a25 100644 --- a/docs/html/ui_8cpp_source.html +++ b/docs/html/ui_8cpp_source.html @@ -83,12 +83,12 @@ $(function() {
    bool digitalWrite1(uint8_t)
    Definition: b15f.cpp:218
    void discard(void)
    Definition: b15f.cpp:33
    -
    constexpr static uint16_t WDT_TIMEOUT
    Time in ms after which the watch dog timer resets the MCU.
    Definition: b15f.h:291
    +
    constexpr static uint16_t WDT_TIMEOUT
    Time in ms after which the watch dog timer resets the MCU.
    Definition: b15f.h:289
    void reconnect(void)
    Definition: b15f.cpp:18
    bool analogWrite0(uint16_t port)
    Definition: b15f.cpp:277
    diff --git a/docs/html/ui_8h_source.html b/docs/html/ui_8h_source.html index 1531fd6..2c56213 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 38250a0..cb7fd95 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 2a868bd..2fe0983 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 89f154f..88c1632 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 e907712..074d99b 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:161
    diff --git a/docs/html/view_8h_source.html b/docs/html/view_8h_source.html index d7f657e..a37d10d 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 d15929a..8a51312 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 ad3a7ad..8a15417 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 c0d70cf..983c1f7 100644 --- a/docs/html/view__monitor_8cpp_source.html +++ b/docs/html/view__monitor_8cpp_source.html @@ -70,7 +70,7 @@ $(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());
    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  std::this_thread::sleep_for(std::chrono::milliseconds(100));
    82 
    83  uint8_t be0 = drv.digitalRead0();
    84  uint8_t be1 = drv.digitalRead1();
    85  uint8_t dsw = drv.readDipSwitch();
    86  uint16_t adc[8];
    87  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    88  adc[i] = drv.analogRead(i);
    89 
    90 
    91  std::stringstream str;
    92 
    93  // hline
    94  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    95  if(i % 2 == 0)
    96  str << "-";
    97  else
    98  str << " ";
    99  str << std::endl;
    100 
    101  str << "Digitale Enigaenge:" << std::endl;
    102  str << "Binaere Eingabe 0: " << fancyDigitalString(be0) << std::endl;
    103  str << "Binaere Eingabe 1: " << fancyDigitalString(be1) << std::endl;
    104  str << "Dip Schalter (S7): " << fancyDigitalString(dsw) << std::endl;
    105 
    106  // hline
    107  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    108  if(i % 2 == 0)
    109  str << "-";
    110  else
    111  str << " ";
    112  str << std::endl;
    113 
    114  str << "Analoge Eingaenge:" << std::endl;
    115  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    116  {
    117  str << "Kanal " << std::to_string((int) i) << ": ";
    118  str << fancyAnalogString(adc[i]) << std::endl;
    119  }
    120 
    121  text = str.str();
    122  repaint();
    123  }
    124  catch(DriverException& ex)
    125  {
    126  std::cout << "DriverException: " << ex.what() << std::endl;
    127  drv.delay_ms(1000);
    128  }
    129  catch(...)
    130  {
    131  try
    132  {
    133  drv.reconnect();
    134  }
    135  catch(...)
    136  {
    137  B15F::abort("Die Verbindung ist unterbrochen worden. Wurde ein Stecker gezogen? :D");
    138  return;
    139  }
    140  }
    141  }
    142 }
    +
    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());
    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  std::this_thread::sleep_for(std::chrono::milliseconds(100));
    82 
    83  uint8_t be0 = drv.digitalRead0();
    84  uint8_t be1 = drv.digitalRead1();
    85  uint8_t dsw = drv.readDipSwitch();
    86  uint16_t adc[8];
    87  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    88  adc[i] = drv.analogRead(i);
    89 
    90 
    91  std::stringstream str;
    92 
    93  // hline
    94  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    95  if(i % 2 == 0)
    96  str << "-";
    97  else
    98  str << " ";
    99  str << std::endl;
    100 
    101  str << "Digitale Enigaenge:" << std::endl;
    102  str << "Binaere Eingabe 0: " << fancyDigitalString(be0) << std::endl;
    103  str << "Binaere Eingabe 1: " << fancyDigitalString(be1) << std::endl;
    104  str << "Dip Schalter (S7): " << fancyDigitalString(dsw) << std::endl;
    105 
    106  // hline
    107  for(uint8_t i = 0; i < width - 2 * text_offset_x; i++)
    108  if(i % 2 == 0)
    109  str << "-";
    110  else
    111  str << " ";
    112  str << std::endl;
    113 
    114  str << "Analoge Eingaenge:" << std::endl;
    115  for(uint8_t i = 0; i < sizeof(adc) / sizeof(adc[0]); i++)
    116  {
    117  str << "Kanal " << std::to_string((int) i) << ": ";
    118  str << fancyAnalogString(adc[i]) << std::endl;
    119  }
    120 
    121  text = str.str();
    122  repaint();
    123  }
    124  catch(DriverException& ex)
    125  {
    126  std::cout << "DriverException: " << ex.what() << std::endl;
    127  drv.delay_ms(1000);
    128  }
    129  catch(...)
    130  {
    131  try
    132  {
    133  drv.reconnect();
    134  }
    135  catch(...)
    136  {
    137  B15F::abort("Die Verbindung ist unterbrochen worden. Wurde ein Stecker gezogen? :D");
    138  return;
    139  }
    140  }
    141  }
    142 }
    uint8_t digitalRead0(void)
    Definition: b15f.cpp:232
    uint8_t readDipSwitch(void)
    Definition: b15f.cpp:260
    @@ -84,7 +84,7 @@ $(function() { diff --git a/docs/html/view__monitor_8h_source.html b/docs/html/view__monitor_8h_source.html index bc70925..f1256d5 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 e6f2d13..3e97ebc 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 14ab7a2..5c3550b 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 652a9e7..5ec711f 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 39fb378..5fa357b 100644 --- a/docs/html/view__selection_8h_source.html +++ b/docs/html/view__selection_8h_source.html @@ -75,7 +75,7 @@ $(function() {