code cleanup
This commit is contained in:
@@ -14,6 +14,8 @@ find_package(Qt5Widgets CONFIG REQUIRED)
|
|||||||
|
|
||||||
find_package(Qt5Sql REQUIRED)
|
find_package(Qt5Sql REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Populate a CMake variable with the sources
|
# Populate a CMake variable with the sources
|
||||||
set(helloworld_SRCS
|
set(helloworld_SRCS
|
||||||
main.cpp
|
main.cpp
|
||||||
@@ -27,6 +29,8 @@ set(helloworld_SRCS
|
|||||||
database.cpp
|
database.cpp
|
||||||
windowrennliste.cpp
|
windowrennliste.cpp
|
||||||
training.cpp
|
training.cpp
|
||||||
|
timemodel.cpp
|
||||||
|
qvectorhelper.cpp
|
||||||
|
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
windowrace.ui
|
windowrace.ui
|
||||||
@@ -36,5 +40,6 @@ set(helloworld_SRCS
|
|||||||
)
|
)
|
||||||
# Tell CMake to create the helloworld executable
|
# Tell CMake to create the helloworld executable
|
||||||
add_executable(Rennbahn ${helloworld_SRCS})
|
add_executable(Rennbahn ${helloworld_SRCS})
|
||||||
|
|
||||||
# Use the Widgets module from Qt 5
|
# Use the Widgets module from Qt 5
|
||||||
target_link_libraries(Rennbahn Qt5::Widgets Qt5::Core Qt5::Sql)
|
target_link_libraries(Rennbahn Qt5::Widgets Qt5::Core Qt5::Sql)
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <usb.h>
|
#ifdef ATMEGA
|
||||||
|
#include <usb.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define USB_LED_ON 1
|
#define USB_LED_ON 1
|
||||||
#define USB_LED_OFF 0
|
#define USB_LED_OFF 0
|
||||||
@@ -32,7 +34,9 @@ HardwareSetup::HardwareSetup() {
|
|||||||
// //perror("ioperm");
|
// //perror("ioperm");
|
||||||
// }
|
// }
|
||||||
this->stop = 0;
|
this->stop = 0;
|
||||||
|
#ifdef ATMEGA
|
||||||
this->handle = nullptr;
|
this->handle = nullptr;
|
||||||
|
#endif
|
||||||
this->fd = 0;
|
this->fd = 0;
|
||||||
}
|
}
|
||||||
void HardwareSetup::setStop() {
|
void HardwareSetup::setStop() {
|
||||||
@@ -48,10 +52,12 @@ HardwareSetup::~HardwareSetup() {
|
|||||||
this->stop = 1;
|
this->stop = 1;
|
||||||
|
|
||||||
if (HARDWARE_VERSION == 2) {
|
if (HARDWARE_VERSION == 2) {
|
||||||
|
#ifdef ATMEGA
|
||||||
if (this->handle) {
|
if (this->handle) {
|
||||||
usb_close(this->handle);
|
usb_close(this->handle);
|
||||||
}
|
}
|
||||||
this->handle = NULL;
|
this->handle = NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (HARDWARE_VERSION == 3) {
|
else if (HARDWARE_VERSION == 3) {
|
||||||
// close filedescriptor
|
// close filedescriptor
|
||||||
@@ -63,6 +69,7 @@ HardwareSetup::~HardwareSetup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef ATMEGA
|
||||||
|
|
||||||
/* Used to get descriptor strings for device identification */
|
/* Used to get descriptor strings for device identification */
|
||||||
int HardwareSetup::usbGetDescriptorString(usb_dev_handle * dev, int index,
|
int HardwareSetup::usbGetDescriptorString(usb_dev_handle * dev, int index,
|
||||||
@@ -158,12 +165,14 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char * vendorName,
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void HardwareSetup::run() {
|
void HardwareSetup::run() {
|
||||||
|
|
||||||
struct TransStruct buffer[6];
|
struct TransStruct buffer[6];
|
||||||
|
|
||||||
if (HARDWARE_VERSION == 2) {
|
if (HARDWARE_VERSION == 2) {
|
||||||
|
#ifdef ATMEGA
|
||||||
int testmode = 0;
|
int testmode = 0;
|
||||||
|
|
||||||
int nBytes = 0;
|
int nBytes = 0;
|
||||||
@@ -300,7 +309,9 @@ void HardwareSetup::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} // end HARDWARE_VERSION 2
|
} // end HARDWARE_VERSION 2
|
||||||
|
|
||||||
else if (HARDWARE_VERSION == 3) {
|
else if (HARDWARE_VERSION == 3) {
|
||||||
|
|
||||||
fd = open(PORT_PATH, O_RDONLY);
|
fd = open(PORT_PATH, O_RDONLY);
|
||||||
|
|||||||
@@ -5,8 +5,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <usb.h>
|
#ifdef ATMEGA
|
||||||
|
#include <usb.h>
|
||||||
|
#endif
|
||||||
struct TransStruct {
|
struct TransStruct {
|
||||||
uint16_t time;
|
uint16_t time;
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
@@ -21,17 +22,19 @@ class HardwareSetup : public QThread {
|
|||||||
private:
|
private:
|
||||||
bool shellBefore;
|
bool shellBefore;
|
||||||
bool deaBefore;
|
bool deaBefore;
|
||||||
|
#ifdef ATMEGA
|
||||||
usb_dev_handle * handle;
|
usb_dev_handle * handle;
|
||||||
|
int usbGetDescriptorString(usb_dev_handle * dev, int index, int langid,
|
||||||
|
char * buf, int buflen);
|
||||||
|
usb_dev_handle * usbOpenDevice(int vendor, char * vendorName, int product,
|
||||||
|
char * productName);
|
||||||
|
#endif
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
bool getShell();
|
bool getShell();
|
||||||
bool getDea();
|
bool getDea();
|
||||||
int * findBit(int * array, int zahl);
|
int * findBit(int * array, int zahl);
|
||||||
bool stop;
|
bool stop;
|
||||||
int usbGetDescriptorString(usb_dev_handle * dev, int index, int langid,
|
|
||||||
char * buf, int buflen);
|
|
||||||
usb_dev_handle * usbOpenDevice(int vendor, char * vendorName, int product,
|
|
||||||
char * productName);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setStop();
|
void setStop();
|
||||||
|
|||||||
Reference in New Issue
Block a user