DCC-EX Simple Throttle
Simple throttle for a DCC-EX CommandStation
Loading...
Searching...
No Matches
/home/runner/work/DCCEXSimpleThrottle/DCCEXSimpleThrottle/Defines.h
Go to the documentation of this file.
1
/*
2
* © 2024 Peter Cole
3
* © 2023 Peter Cole
4
*
5
* This is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* It is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this code. If not, see <https://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef DEFINES_H
20
#define DEFINES_H
21
22
#include <U8g2lib.h>
23
25
26
#if __has_include("myConfig.h")
27
#include "myConfig.h"
28
#else
29
#warning myConfig.h not found, using defaults.
30
#endif
31
32
// If connection retries not defined, define default 20
33
#ifndef CONNECT_RETRIES
34
#define CONNECT_RETRIES 20
35
#endif
36
37
// Define the default console stream
38
#ifndef CONSOLE
39
#define CONSOLE Serial
40
#endif
// CONSOLE
41
42
// Define the default CommandStation connection serial object
43
// If using WiFi, this will not be used
44
#ifndef COMMANDSTATION_CONNECTION
45
#define COMMANDSTATION_CONNECTION Serial1
46
#endif
// COMMANDSTATION_CONNECTION
47
48
// Define default DCCEXProtocol buffer and param values if not in myConfig.h
49
#ifndef DCCEX_MAX_COMMAND_BUFFER_SIZE
50
#define DCCEX_MAX_COMMAND_BUFFER_SIZE 500
51
#endif
// DCCEX_MAX_COMMAND_BUFFER_SIZE
52
#ifndef DCCEX_MAX_COMMAND_PARAMS
53
#define DCCEX_MAX_COMMAND_PARAMS 50
54
#endif
// DCCEX_MAX_COMMAND_PARAMS
55
56
// Give OLED connection types a value
57
#define OLED_I2C 1
58
#define OLED_SPI 2
59
60
// Default display definitions
61
#ifndef OLED_CONNECTION
62
#define OLED_CONNECTION OLED_I2C
63
#endif
// OLED_CONNECTION
64
#ifndef OLED_ADDRESS
65
#define OLED_ADDRESS 0x3c
66
#endif
// OLED_ADDRESS
67
68
// Define the correct OLED type based on connection
69
#if (OLED_CONNECTION == OLED_I2C)
70
#define OLED_TYPE U8G2_SH1106_128X64_NONAME_F_HW_I2C
71
#elif (OLED_CONNECTION == OLED_SPI)
72
#define OLED_TYPE U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI
73
#else
74
#error Invalid OLED connection type specific, must be OLED_I2C or OLED_SPI
75
#endif
// OLED_CONNECTION
76
77
// Device/platform specific definitions
78
#if defined(ARDUINO_ARCH_STM32)
79
// No WiFi on Bluepill
80
#ifdef WIFI_ENABLED
81
// #undef WIFI_ENABLED
82
#endif
// WIFI_ENABLED
83
// Default pins for Bluepill
84
#ifndef ENCODER_DT_PIN
85
#define ENCODER_DT_PIN PC14
86
#endif
// ENCODER_DT_PIN
87
#ifndef ENCODER_CLK_PIN
88
#define ENCODER_CLK_PIN PC15
89
#endif
// ENCODER_CLK_PIN
90
#ifndef BUTTON_PIN
91
#define BUTTON_PIN PA0
92
#endif
// BUTTON_PIN
93
#ifndef SCL_PIN
94
#define SCL_PIN PB6
95
#endif
// SCL_PIN
96
#ifndef SDA_PIN
97
#define SDA_PIN PB7
98
#endif
// SDA_PIN
99
#ifndef CS_PIN
100
#define CS_PIN PA4
101
#endif
// CS_PIN
102
#ifndef DC_PIN
103
#define DC_PIN PA3
104
#endif
// DC_PIN
105
// Reference:
106
// SCK - PA5
107
// MISO - PA6
108
// MOSI - PA7
109
#elif defined(ARDUINO_ARCH_ESP32)
110
// WiFi on for ESP32
111
#ifndef WIFI_ENABLED
112
#define WIFI_ENABLED
113
#endif
// WIFI_ENABLED
114
115
// Define example WiFi connection parameters here
116
#ifndef COMMANDSTATION_COUNT
117
#define COMMANDSTATION_COUNT 2
// The number of EX-CommandStations to define
118
#endif
// COMMANDSTATION_COUNT
119
120
// Define example connection options for each EX-CommandStation entry
121
#ifndef COMMANDSTATION_NAMES
122
#define COMMANDSTATION_NAMES \
123
{ "Example 1", "Example 2" }
124
#endif
// COMMANDSTATION_NAMES
125
#ifndef COMMANDSTATION_IPS
126
#define COMMANDSTATION_IPS \
127
{ "192.168.4.1", "192.168.0.1" }
128
#endif
// COMMANDSTATION_IPS
129
#ifndef COMMANDSTATION_PORTS
130
#define COMMANDSTATION_PORTS \
131
{ 2560, 2560 }
132
#endif
// COMMANDSTATION_PORTS
133
#ifndef COMMANDSTATION_SSIDS
134
#define COMMANDSTATION_SSIDS \
135
{ "SSID1", "SSID2" }
136
#endif
// COMMANDSTATION_SSIDS
137
#ifndef COMMANDSTATION_PASSWORDS
138
#define COMMANDSTATION_PASSWORDS \
139
{ "Password1", "Password2" }
140
#endif
// COMMANDSTATION_PASSWORDS
141
142
// Default pin definitions for ESP32
143
#ifndef ENCODER_DT_PIN
144
#define ENCODER_DT_PIN 12
145
#endif
// ENCODER_DT_PIN
146
#ifndef ENCODER_CLK_PIN
147
#define ENCODER_CLK_PIN 14
148
#endif
// ENCODER_CLK_PIN
149
#ifndef BUTTON_PIN
150
#define BUTTON_PIN 13
151
#endif
// BUTTON_PIN
152
#ifndef SCL_PIN
153
#define SCL_PIN 22
154
#endif
// SCL_PIN
155
#ifndef SDA_PIN
156
#define SDA_PIN 23
157
#endif
// SDA_PIN
158
#ifndef CS_PIN
159
#define CS_PIN 5
160
#endif
// CS_PIN
161
#ifndef DC_PIN
162
#define DC_PIN 2
163
#endif
// DC_PIN
164
// Reference:
165
// SCK - 18
166
// MISO - 19
167
// MOSI - 23
168
#endif
// ARCH type
169
170
// UserConfirmationSelection Switch object defaults
171
#ifndef BUTTON_PIN_MODE
172
#define BUTTON_PIN_MODE INPUT_PULLUP
173
#endif
// BUTTON_PIN_MODE
174
#ifndef BUTTON_PIN_POLARITY
175
#define BUTTON_PIN_POLARITY LOW
176
#endif
// BUTTON_PIN_POLARITY
177
#ifndef BUTTON_DEBOUNCE_PERIOD
178
#define BUTTON_DEBOUNCE_PERIOD 50
179
#endif
// BUTTON_DEBOUNCE_PERIOD
180
#ifndef BUTTON_LONG_PRESS_PERIOD
181
#define BUTTON_LONG_PRESS_PERIOD 500
182
#endif
// BUTTON_LONG_PRESS_PERIOD
183
#ifndef BUTTON_DOUBLE_CLICK_PERIOD
184
#define BUTTON_DOUBLE_CLICK_PERIOD 250
185
#endif
// BUTTON_DOUBLE_CLICK_PERIOD
186
#ifndef BUTTON_DEGLITCH_PERIOD
187
#define BUTTON_DEGLITCH_PERIOD 10
188
#endif
// BUTTON_DEGLITCH_PERIOD
189
190
// Set invert throttle true as default is a rotary encoder
191
#ifndef INVERT_THROTTLE
192
#define INVERT_THROTTLE true
193
#endif
// INVERT_THROTTLE
194
195
// Set default throttle speed change steps (used to increment/decrement speed)
196
#ifndef THROTTLE_STEP
197
#define THROTTLE_STEP 1
198
#endif
// THROTTLE_STEP
199
#ifndef THROTTLE_STEP_FASTER
200
#define THROTTLE_STEP_FASTER 2
201
#endif
// THROTTLE_STEP_FASTER
202
#ifndef THROTTLE_STEP_FASTEST
203
#define THROTTLE_STEP_FASTEST 5
204
#endif
// THROTTLE_STEP_FASTEST
205
206
// Set default thresholds to determine speed steps
207
#ifndef THROTTLE_STEP_FASTER_THRESHOLD
208
#define THROTTLE_STEP_FASTER_THRESHOLD 200
209
#endif
// THROTTLE_STEP_FASTER_THRESHOLD
210
#ifndef THROTTLE_STEP_FASTEST_THRESHOLD
211
#define THROTTLE_STEP_FASTEST_THRESHOLD 125
212
#endif
// THROTTLE_STEP_FASTEST_THRESHOLD
213
214
// Define fonts in use for U8g2lib
215
#define DEFAULT_FONT u8g2_font_NokiaSmallPlain_tr
216
#define MENU_FONT u8g2_font_5x8_mr
217
#define SPEED_FONT u8g2_font_spleen12x24_mn
218
#define THROTTLE_FONT u8g2_font_6x10_mr
219
220
#endif
Generated by
1.9.8