Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/GenericDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "LuaHelper.h"
#include "Logger.h"

const double GenericDisplay::MAX_VALUE = 10000000;
// MAX_VALUE now defined as constexpr in header

GenericDisplay::GenericDisplay(bool _use_bcd)
{
Expand Down
8 changes: 4 additions & 4 deletions src/core/GenericDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GenericDisplay
GenericDisplay(bool _use_bcd); // bcd: binary encoded decimal
GenericDisplay(GenericDisplay* other);

static const double MAX_VALUE;
static constexpr double MAX_VALUE = 10000000.0;
void set_nr_bytes(int _nr_of_bytes);

// called from UsbHidDevice worker thread
Expand Down Expand Up @@ -54,9 +54,9 @@ class GenericDisplay
double const_value;
int nr_of_bytes;
private:
const unsigned char BLANK_CHAR = 0xFF;
const unsigned char ZERO_CHAR = 0x00;
const unsigned char PERIOD_CHAR = 0xD0;
static constexpr unsigned char BLANK_CHAR = 0xFF;
static constexpr unsigned char ZERO_CHAR = 0x00;
static constexpr unsigned char PERIOD_CHAR = 0xD0;

int dataref_index;
bool get_decimal_components(int number, unsigned char* buffer, int _minimum_number_of_digits, int _dot_position);
Expand Down
4 changes: 2 additions & 2 deletions src/devices/arduino-homecockpit/ArduinoHomeCockpit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "core/UsbHidDevice.h"
#include "core/Logger.h"

#define WRITE_BUFFER_SIZE 64
#define READ_BUFFER_SIZE 9
constexpr int WRITE_BUFFER_SIZE = 64;
constexpr int READ_BUFFER_SIZE = 9;

std::filesystem::path get_plugin_path();

Expand Down
12 changes: 6 additions & 6 deletions src/devices/fip/FIPFonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ void init_fip_fonts(){
fip_font_positions[125] = Font(174,34,5,16);
fip_font_positions[126] = Font(77,17,8,16);
}
const int FIP_FONT_FILE_WIDTH=256;
const int FIP_FONT_FILE_HEIGHT=256;
const int FIP_FONT_HEIGHT=16;
const int FIP_MAX_FONT_WIDTH=13;
const int FIP_MAX_FONT_ASCII_ID=126;
const int FIP_MIN_FONT_ASCII_ID=32;
constexpr int FIP_FONT_FILE_WIDTH = 256;
constexpr int FIP_FONT_FILE_HEIGHT = 256;
constexpr int FIP_FONT_HEIGHT = 16;
constexpr int FIP_MAX_FONT_WIDTH = 13;
constexpr int FIP_MAX_FONT_ASCII_ID = 126;
constexpr int FIP_MIN_FONT_ASCII_ID = 32;
2 changes: 1 addition & 1 deletion src/devices/fip/FIPImageLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool ImageBuffer::load_from_bmp_file(std::string file_name)

file.read((char*)&bmp_header, sizeof(bmp_header));

if (bmp_header.type != 0x4d42) // the BMP magic number
if (bmp_header.type != BMP_MAGIC_NUMBER)
{
Logger(logERROR) << file_name << " bad magic number in BMP header: " << bmp_header.type << std::endl;
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/devices/fip/FIPImageLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <fstream>
#include "FIPLayer.h"

// BMP file format constants
constexpr uint16_t BMP_MAGIC_NUMBER = 0x4d42;

#pragma pack(push)
#pragma pack(1)
typedef struct {
Expand Down
6 changes: 3 additions & 3 deletions src/devices/fip/FIPScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class FIPScreen : public GenericScreen
{
private:
std::map<int, FIPPage*> pages;
const int SCREEN_WIDTH = 320;
const int SCREEN_HEIGHT = 240;
const int BIT_PER_PIXEL = 24;
static constexpr int SCREEN_WIDTH = 320;
static constexpr int SCREEN_HEIGHT = 240;
static constexpr int BIT_PER_PIXEL = 24;
std::mutex guard;
public:
FIPScreen();
Expand Down
4 changes: 2 additions & 2 deletions src/devices/fip/FIPTextLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class FIPTextLayer : public FIPImageLayer
private:
std::string text;
ImageBuffer font_image_buffer;
const int MAX_CHAR_COUNT = 32;
const int CHAR_SPACE = 2;
static constexpr int MAX_CHAR_COUNT = 32;
static constexpr int CHAR_SPACE = 2;
public:
FIPTextLayer();
FIPTextLayer(FIPTextLayer* other);
Expand Down
4 changes: 2 additions & 2 deletions src/devices/saitek-multi/SaitekMultiPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "saitek-multi/SaitekMultiPanel.h"
#include "core/Logger.h"

#define WRITE_BUFFER_SIZE 13
#define READ_BUFFER_SIZE 4
constexpr int WRITE_BUFFER_SIZE = 13;
constexpr int READ_BUFFER_SIZE = 4;

SaitekMultiPanel::SaitekMultiPanel(ClassConfiguration& config) :UsbHidDevice(config, READ_BUFFER_SIZE, WRITE_BUFFER_SIZE)
{
Expand Down
4 changes: 2 additions & 2 deletions src/devices/saitek-radio/SaitekRadioPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "saitek-radio/SaitekRadioPanel.h"
#include "core/Logger.h"

#define WRITE_BUFFER_SIZE 23
#define READ_BUFFER_SIZE 5
constexpr int WRITE_BUFFER_SIZE = 23;
constexpr int READ_BUFFER_SIZE = 5;

SaitekRadioPanel::SaitekRadioPanel(ClassConfiguration& config) :UsbHidDevice(config, READ_BUFFER_SIZE, WRITE_BUFFER_SIZE)
{
Expand Down
4 changes: 2 additions & 2 deletions src/devices/saitek-switch/SaitekSwitchPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "saitek-switch/SaitekSwitchPanel.h"
#include "core/Logger.h"

#define WRITE_BUFFER_SIZE 2
#define READ_BUFFER_SIZE 4
constexpr int WRITE_BUFFER_SIZE = 2;
constexpr int READ_BUFFER_SIZE = 4;

SaitekSwitchPanel::SaitekSwitchPanel(ClassConfiguration& config) :UsbHidDevice(config, READ_BUFFER_SIZE, WRITE_BUFFER_SIZE)
{
Expand Down
21 changes: 9 additions & 12 deletions src/devices/trc-1000/TRC1000Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@
#include "trc-1000/TRC1000Audio.h"
#include "core/UsbHidDevice.h"
#include "core/Logger.h"

#define WRITE_BUFFER_SIZE (8+1) // +1 for the hid report id at position 0
#define READ_BUFFER_SIZE 8

#define CMD_REQUEST_BUTTON_SATE 0x42
#define CMD_REQUEST_ENCODER_0 0x41

#define RESPONSE_BUTTON_STATE 0xc2
#define RESPONSE_ENCODER_0 0xc1

#define BUTTON_BUFFER_OFFSET 0
#define ENCODER_0_BUFFER_OFFSET 5

constexpr int WRITE_BUFFER_SIZE = 8 + 1; // +1 for the hid report id at position 0
constexpr int READ_BUFFER_SIZE = 8;
constexpr uint8_t CMD_REQUEST_BUTTON_SATE = 0x42;
constexpr uint8_t CMD_REQUEST_ENCODER_0 = 0x41;
constexpr uint8_t RESPONSE_BUTTON_STATE = 0xc2;
constexpr uint8_t RESPONSE_ENCODER_0 = 0xc1;
constexpr int BUTTON_BUFFER_OFFSET = 0;
constexpr int ENCODER_0_BUFFER_OFFSET = 5;

TRC1000Audio::TRC1000Audio(ClassConfiguration& config) :TRC1000(config, READ_BUFFER_SIZE, WRITE_BUFFER_SIZE)
{
Expand Down
25 changes: 11 additions & 14 deletions src/devices/trc-1000/TRC1000PFD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@
#include "core/UsbHidDevice.h"
#include "core/Logger.h"

#define WRITE_BUFFER_SIZE (8+1) // +1 for the hid report id at position 0
#define READ_BUFFER_SIZE 23

#define CMD_REQUEST_BUTTON_SATE 0x41
#define CMD_REQUEST_ENCODER_0 0x42
#define CMD_REQUEST_ENCODER_1 0x43

#define RESPONSE_BUTTON_STATE 0xc1
#define RESPONSE_ENCODER_0 0xc2
#define RESPONSE_ENCODER_1 0xc3

#define BUTTON_BUFFER_OFFSET 0
#define ENCODER_0_BUFFER_OFFSET 7
#define ENCODER_1_BUFFER_OFFSET 15
constexpr int WRITE_BUFFER_SIZE = 8 + 1; // +1 for the hid report id at position 0
constexpr int READ_BUFFER_SIZE = 23;
constexpr uint8_t CMD_REQUEST_BUTTON_SATE = 0x41;
constexpr uint8_t CMD_REQUEST_ENCODER_0 = 0x42;
constexpr uint8_t CMD_REQUEST_ENCODER_1 = 0x43;
constexpr uint8_t RESPONSE_BUTTON_STATE = 0xc1;
constexpr uint8_t RESPONSE_ENCODER_0 = 0xc2;
constexpr uint8_t RESPONSE_ENCODER_1 = 0xc3;
constexpr int BUTTON_BUFFER_OFFSET = 0;
constexpr int ENCODER_0_BUFFER_OFFSET = 7;
constexpr int ENCODER_1_BUFFER_OFFSET = 15;

TRC1000PFD::TRC1000PFD(ClassConfiguration& config) :TRC1000(config, READ_BUFFER_SIZE, WRITE_BUFFER_SIZE)
{
Expand Down
Loading