Coder Social home page Coder Social logo

wsm-lib-cpp-qt's Introduction

C++ Qt Wsm library

This repository contains a fully open-source C++ library for communicating with a Wireless SpeedoMeter.

It connects to the (virtual) serial port, which is associated with Bluetooth SPP profile.

Requirements

This library uses Qt's SerialPort which creates a very good cross-platform abstraction of serial port interface. Thus, the library uses Qt's mechanisms like slots and signals.

It is not usable without Qt.

There are no other requirements.

Usage

You may use this library in two major ways:

  • Simply include wsm.h header file into your project and use instance of Wsm class.
  • Compile this project using qmake and use compiled object file.

Basic information

  • See wsm.h for API specification.
  • To change the version of this library, update both constants at wsm.pro file and wsm.h file. This is needed for proper behavior as a standalone-lib and plain header too.

Authors

This library was created by:

Do not hesitate to contact author in case of any troubles!

License

This application is released under the Apache License v2.0 .

wsm-lib-cpp-qt's People

Contributors

horacekj avatar

Watchers

 avatar  avatar  avatar

wsm-lib-cpp-qt's Issues

Use `const` (and possibly `constexpr`)

Here, instead of

wsm-lib-cpp-qt/wsm.cpp

Lines 79 to 82 in c8cbbf4

const uint8_t MSG_SPEED = 0x1;
const uint8_t MSG_BATTERY = 0x2;
uint8_t type = (static_cast<uint8_t>(message[0]) >> 4) & 0x7;

you may write

constexpr uint8_t MSG_SPEED = 0x1; 
constexpr uint8_t MSG_BATTERY = 0x2; 

const uint8_t type = (static_cast<uint8_t>(message[0]) >> 4) & 0x7; 

Because const means that the value of the variable does not change after initialization. But constexpr means that the value of this variable is allways the same - and that includes that its initializer is a constant expression. I believe you want to say here something like this:

the variable for MSG_SPEED is only a symbolic name for the constant 0x01

Note that this is C++-specific. For example, const in C# has similar meaning as constexpr in C++.

Use switch here

Use switch here instead of if-else-if

if (type == MSG_SPEED) {

And extract the parsing code into separate procedures - one for handling speed, other for handling battery.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.