|
| 1 | +#include "Constants.h" |
| 2 | + |
| 3 | +/* Buffer initialisation */ |
| 4 | +namespace |
| 5 | +{ |
| 6 | + const uint8_t kUsbIconBuffer[] PROGMEM = { |
| 7 | + 0x00, 0x00, 0x0F, 0xF0, 0x08, 0x10, 0x08, 0x10, 0x0A, 0x50, 0x08, 0x10, 0x08, 0x10, 0x3F, 0xFC, |
| 8 | + 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x30, 0x0C, 0x10, 0x08, 0x1F, 0xF8, 0x00, 0x00 |
| 9 | + }; |
| 10 | + const uint8_t kBluetoothIconBuffer[] PROGMEM = { |
| 11 | + 0x00, 0x00, 0x01, 0x80, 0x01, 0xC0, 0x09, 0x60, 0x0D, 0x30, 0x07, 0x60, 0x03, 0xC0, 0x01, 0x80, |
| 12 | + 0x03, 0xC0, 0x07, 0x60, 0x0D, 0x30, 0x09, 0x60, 0x01, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00 |
| 13 | + }; |
| 14 | + const uint8_t kWiFiIconBuffer[] PROGMEM = { |
| 15 | + 0x00, 0x00, 0x60, 0x00, 0x7C, 0x00, 0x07, 0x00, 0x61, 0xC0, 0x78, 0x60, 0x0E, 0x30, 0x03, 0x10, |
| 16 | + 0x61, 0x98, 0x78, 0xC8, 0x0C, 0x4C, 0x06, 0x64, 0x62, 0x24, 0x73, 0x36, 0x73, 0x36, 0x00, 0x00 |
| 17 | + }; |
| 18 | + const uint8_t kStatusGoodIconBuffer[] PROGMEM = { |
| 19 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, |
| 20 | + 0x30, 0xE0, 0x39, 0xC0, 0x1F, 0x80, 0x0F, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 21 | + }; |
| 22 | + const uint8_t kStatusBadIconBuffer[] PROGMEM = { |
| 23 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x18, 0x1E, 0x3C, 0x1F, 0x7C, 0x0F, 0xF8, 0x07, 0xF0, |
| 24 | + 0x03, 0xE0, 0x07, 0xF0, 0x0F, 0xF8, 0x1F, 0x7C, 0x1E, 0x3C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00 |
| 25 | + }; |
| 26 | + const uint8_t kStatusResolvingIconBuffer[] PROGMEM = { |
| 27 | + 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x04, 0x30, 0x28, 0x08, 0x30, 0x04, 0x38, 0x04, 0x00, 0x04, |
| 28 | + 0x20, 0x00, 0x20, 0x1C, 0x20, 0x0C, 0x10, 0x14, 0x0C, 0x20, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00 |
| 29 | + }; |
| 30 | + //const uint8_t kLineBuffer[] PROGMEM = { |
| 31 | + // 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0xFE, 0xC6, 0x6C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, |
| 32 | + // 0x00, 0x00, 0x00, 0x00, 0x0C, 0x06, 0x03, 0x3F, 0x31, 0x1B, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00 |
| 33 | + //}; |
| 34 | + |
| 35 | + const uint8_t* const kStatusIcons[] = { |
| 36 | + kStatusGoodIconBuffer, |
| 37 | + kStatusBadIconBuffer, |
| 38 | + kStatusResolvingIconBuffer |
| 39 | + }; |
| 40 | + |
| 41 | + const uint8_t kDisplayPinConfig[] = { |
| 42 | + 46, |
| 43 | + 47 |
| 44 | + }; |
| 45 | +} |
| 46 | + |
| 47 | +/* Bluetooth (Hardware Serial3) */ |
| 48 | +// const uint8_t Constants::bluetooth_RX = 15; |
| 49 | +// const uint8_t Constants::bluetooth_TX = 14; |
| 50 | +const uint32_t Constants::kBluetoothSerialSpeed = 9600; |
| 51 | + |
| 52 | +/* Wi-fi (Hardware Serial2) */ |
| 53 | +// const uint8_t Constants::wifi_RX = 17; |
| 54 | +// const uint8_t Constants::wifi_TX = 16; |
| 55 | +const uint32_t Constants::kWifiSerialSpeed = 115200; |
| 56 | +const uint32_t Constants::kWifiHandshakeWaitMs = 30000; |
| 57 | + |
| 58 | +/* USB (Hardware Serial) */ |
| 59 | +// const uint8_t Constants::usb_RX = 0; |
| 60 | +// const uint8_t Constants::usb_TX = 1; |
| 61 | +const uint32_t Constants::kUsbSerialSpeed = 9600; |
| 62 | + |
| 63 | +/* Debug serial (Hardware Serial1) */ |
| 64 | +//const uint8_t Constants::dbg_uart_RX = 19; |
| 65 | +//const uint8_t Constants::dbg_uart_TX = 18; |
| 66 | +const uint32_t Constants::kDbgUartSpeed = 9600; |
| 67 | + |
| 68 | +/* Movement controller (L298N) */ |
| 69 | +const uint8_t Constants::kLeftEngineEnable = 11; |
| 70 | +const uint8_t Constants::kLeftEngineStraightPin = 7; |
| 71 | +const uint8_t Constants::kLeftEngineReversePin = 6; |
| 72 | +const uint8_t Constants::kRightEngineStraightPin = 5; |
| 73 | +const uint8_t Constants::kRightEngineReversePin = 4; |
| 74 | +const uint8_t Constants::kRightEngineEnable = 10; |
| 75 | + |
| 76 | +/* Distanse controller */ |
| 77 | +const uint8_t Constants::kDistanceSensorReadPin = A2; |
| 78 | +const uint8_t Constants::kDistanceSensorAPin = 33; |
| 79 | +const uint8_t Constants::kDistanceSensorBPin = 32; |
| 80 | +const uint8_t Constants::kDistanceSensorCPin = A3; |
| 81 | + |
| 82 | +/* Line controller */ |
| 83 | +// A = 0, B = 1, C = 2 |
| 84 | +const uint8_t Constants::kLineSensorReadPin = A0; |
| 85 | +const uint8_t Constants::kLineSensorAPin = 31; |
| 86 | +const uint8_t Constants::kLineSensorBPin = 30; |
| 87 | +const uint8_t Constants::kLineSensorCPin = A1; |
| 88 | + |
| 89 | +/* Servo controller */ |
| 90 | +const uint8_t Constants::kServoHorizontalPin = 34; |
| 91 | +const uint8_t Constants::kServoVerticalPin = 35; |
| 92 | + |
| 93 | +/* Display SSD1306 controller */ |
| 94 | +//const uint8_t Constants::kDisplaySpiMosiPin = 51; |
| 95 | +//const uint8_t Constants::kDisplaySpiClkPin = 52; |
| 96 | +const uint8_t Constants::kDisplayDcPin = 49; |
| 97 | +const uint8_t Constants::kDisplayCsPin = 48; |
| 98 | +const uint8_t Constants::kDisplayResetPin = -1; |
| 99 | + |
| 100 | +const char Constants::kCommandsDelimetr = ';'; |
| 101 | +const char Constants::kCommandsStopSymbol = '|'; |
| 102 | +const uint32_t Constants::kCommandsWaitTime = 50; |
| 103 | + |
| 104 | +/* Class constants */ |
| 105 | +const uint8_t Constants::kMinSpeed = 0; |
| 106 | +const uint8_t Constants::kMaxSpeed = 255; |
| 107 | +const uint16_t Constants::kServoDelay = 20; |
| 108 | + |
| 109 | +const uint8_t Constants::kCountDistanceSensors = 5; |
| 110 | +const int16_t Constants::kSensorDelay = 10; |
| 111 | + |
| 112 | +const uint8_t Constants::kCountLineSensors = 5; |
| 113 | +const uint16_t Constants::kMinimalLineBound = 270; |
| 114 | + |
| 115 | +const uint32_t Constants::kWaitCommandTimeInMs = 5000; |
| 116 | + |
| 117 | +const String Constants::kGoodAnswer = "OK"; |
| 118 | +const String Constants::kBadAnswer = "ERROR"; |
| 119 | + |
| 120 | +/* USB image */ |
| 121 | +const ImageConfiguration Constants::kUsbImageConfiguration = |
| 122 | +{ |
| 123 | + 0, |
| 124 | + 0, |
| 125 | + 16, |
| 126 | + 16, |
| 127 | +}; |
| 128 | +const ImageConfiguration Constants::kBluetoothImageConfiguration = |
| 129 | +{ |
| 130 | + 0, |
| 131 | + 16, |
| 132 | + 16, |
| 133 | + 16, |
| 134 | +}; |
| 135 | +const ImageConfiguration Constants::kWifiImageConfiguration = |
| 136 | +{ |
| 137 | + 0, |
| 138 | + 32, |
| 139 | + 16, |
| 140 | + 16, |
| 141 | +}; |
| 142 | +const ImageConfiguration Constants::kStatusImageConfiguration = |
| 143 | +{ |
| 144 | + 0, |
| 145 | + 48, |
| 146 | + 16, |
| 147 | + 16, |
| 148 | +}; |
| 149 | +const ImageConfiguration Constants::kLineImageConfiguration = |
| 150 | +{ |
| 151 | + 17, |
| 152 | + 0, |
| 153 | + 1, |
| 154 | + 64, |
| 155 | +}; |
| 156 | +const ImageConfiguration Constants::kPrintAreaImageConfiguration = |
| 157 | +{ |
| 158 | + 19, |
| 159 | + 0, |
| 160 | + 109, |
| 161 | + 64, |
| 162 | +}; |
| 163 | + |
| 164 | +const uint8_t* Constants::kUsbImage = kUsbIconBuffer; |
| 165 | +const uint8_t* Constants::kBluetoothImage = kBluetoothIconBuffer; |
| 166 | +const uint8_t* Constants::kWifiImage = kWiFiIconBuffer; |
| 167 | +const uint8_t* const* Constants::kStatusImages = kStatusIcons; |
| 168 | +const uint8_t Constants::kStatusImagesNum = sizeof(kStatusIcons) / sizeof(kStatusIcons[0]); |
| 169 | + |
| 170 | +const uint8_t* Constants::kDisplayTogglePins = kDisplayPinConfig; |
| 171 | +const uint8_t Constants::kDisplayTogglePinAmount = sizeof(kDisplayPinConfig) / sizeof(kDisplayPinConfig[0]); |
| 172 | + |
| 173 | +const String Constants::kBluetoothHeader = "Bluetooth"; |
| 174 | +const String Constants::kBluetoothAp = "TrackPlatformBT"; |
| 175 | +const String Constants::kBluetoothPassword = "7777"; |
| 176 | + |
| 177 | +const String Constants::kWifiHeader = "Wi-Fi"; |
| 178 | +const String Constants::kWifiAp = "TrackPlatformWiFi"; |
| 179 | +const String Constants::kWifiPassword = "1234567890"; |
| 180 | +const String Constants::kWifiIp = "192.168.4.1"; |
| 181 | + |
| 182 | +const String Constants::kDebugHeader = "Debug"; |
| 183 | + |
| 184 | +const String Constants::kHardwareInfoHeader = "Firmware"; |
| 185 | + |
| 186 | +Constants::Constants() |
| 187 | +{ |
| 188 | +} |
| 189 | + |
| 190 | +Constants::~Constants() |
| 191 | +{ |
| 192 | +} |
0 commit comments