Repository navigation
Expand file tree
/
Copy pathserial_simhub.cpp
More file actions
113 lines (98 loc) · 3.23 KB
/
Copy pathserial_simhub.cpp
File metadata and controls
113 lines (98 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "config.h"
#if defined(USE_SIMHUB)
#include <Arduino.h>
#include "serial.h"
#define VERSION 'j'
#define DEVICE_NAME "E90 Cluster (veikkos)"
#define DEVICE_UNIQUE_ID "55324453-cb75-50da-e080-78e37b21c548"
#define ENABLED_BUTTONS_COUNT 0
#define ENABLED_BUTTONMATRIX 0
#define BMATRIX_COLS 0
#define BMATRIX_ROWS 0
#define TM1638_ENABLEDMODULES 0
#define MAX7221_ENABLEDMODULES 0
#define TM1637_ENABLEDMODULES 0
#define TM1637_6D_ENABLEDMODULES 0
#define ENABLE_ADA_HT16K33_7SEGMENTS 0
#define MAX7221_MATRIX_ENABLED 0
#define ENABLE_ADA_HT16K33_SingleColorMatrix 0
#define ENABLE_ADA_HT16K33_BiColorMatrix 0
#define I2CLCD_enabled 0
#define ENABLED_NOKIALCD 0
#define ENABLED_OLEDLCD 0
#define WS2812B_RGBLEDCOUNT 0
#define PL9823_RGBLEDCOUNT 0
#define WS2801_RGBLEDCOUNT 0
#ifndef SIGNATURE_0
#define SIGNATURE_0 'N'
#endif
#ifndef SIGNATURE_1
#define SIGNATURE_1 '/'
#endif
#ifndef SIGNATURE_2
#define SIGNATURE_2 'A'
#endif
#include "FlowSerialRead.h"
#include "SHCustomProtocol.h"
SHCustomProtocol shCustomProtocol;
#include "SHCommands.h"
static char loop_opt;
static unsigned long lastSerialActivity = 0;
static void simHubIdle(bool critical) {
shCustomProtocol.idle();
}
void serialBegin()
{
FlowSerialBegin(19200);
shCustomProtocol.setup();
arqserial.setIdleFunction(simHubIdle);
}
void serialPoll() {
shCustomProtocol.loop();
// Wait for data
if (FlowSerialAvailable() > 0) {
if (FlowSerialTimedRead() == MESSAGE_HEADER)
{
lastSerialActivity = millis();
// Read command
loop_opt = FlowSerialTimedRead();
if (loop_opt == '1') Command_Hello();
else if (loop_opt == '8') Command_SetBaudrate();
else if (loop_opt == 'J') Command_ButtonsCount();
else if (loop_opt == '2') Command_TM1638Count();
else if (loop_opt == 'B') Command_SimpleModulesCount();
else if (loop_opt == 'A') Command_Acq();
else if (loop_opt == 'N') Command_DeviceName();
else if (loop_opt == 'I') Command_UniqueId();
else if (loop_opt == '0') Command_Features();
else if (loop_opt == '3') Command_TM1638Data();
else if (loop_opt == 'V') Command_Motors();
else if (loop_opt == 'S') Command_7SegmentsData();
else if (loop_opt == '4') Command_RGBLEDSCount();
else if (loop_opt == '6') Command_RGBLEDSData();
else if (loop_opt == 'R') Command_RGBMatrixData();
else if (loop_opt == 'M') Command_MatrixData();
else if (loop_opt == 'G') Command_GearData();
else if (loop_opt == 'L') Command_I2CLCDData();
else if (loop_opt == 'K') Command_GLCDData(); // Nokia | OLEDS
else if (loop_opt == 'P') Command_CustomProtocolData();
else if (loop_opt == 'X')
{
String xaction = FlowSerialReadStringUntil(' ', '\n');
if (xaction == F("list")) Command_ExpandedCommandsList();
else if (xaction == F("mcutype")) Command_MCUType();
else if (xaction == F("tach")) Command_TachData();
else if (xaction == F("speedo")) Command_SpeedoData();
else if (xaction == F("boost")) Command_BoostData();
else if (xaction == F("temp")) Command_TempData();
else if (xaction == F("fuel")) Command_FuelData();
else if (xaction == F("cons")) Command_ConsData();
else if (xaction == F("encoderscount")) Command_EncodersCount();
}
}
}
if (millis() - lastSerialActivity > 5000) {
Command_Shutdown();
}
}
#endif