Files
OBPkp61/include/main.h

79 lines
1.8 KiB
C

#pragma once
// WIFI AP
#define WIFI_CHANNEL 9
#define WIFI_MAX_STA 2
// NMEA2000 defaults
#define N2K_DEFAULT_NODEID 124
#define NMEA2000_HEARTBEAT_INTERVAL 5000 // milliseconds
// Keys
#define KEY_1 GPIO_NUM_5 // D2
#define KEY_2 GPIO_NUM_6 // D3
#define KEY_3 GPIO_NUM_7 // D4
#define KEY_4 GPIO_NUM_8 // D5
#define KEY_5 GPIO_NUM_9 // D6
#define KEY_6 GPIO_NUM_10 // D7
#define KEY_DST GPIO_NUM_17 // D8
// Buzzer
#define BUZZER GPIO_NUM_43 // TX
#define LEDC_CHANNEL 0
#define LEDC_TIMER_8_BIT 8
#define LEDC_BASE_FREQ 5000
// LEDS
#define LED_A GPIO_NUM_3 // A2
#define LED_B GPIO_NUM_2 // A1
#define LED_C GPIO_NUM_1 // A0
#define RGBLED_R GPIO_NUM_14 // A7 red
#define RGBLED_G GPIO_NUM_13 // A6 green
#define RGBLED_B GPIO_NUM_4 // A3 blue
#define LED_USER GPIO_NUM_48 // internal red user led
#define LED_IR GPIO_NUM_46 // internal rgb led on strapping pins
#define LED_IG GPIO_NUM_0 // ! B1 <-> Buzzer
#define LED_IB GPIO_NUM_45
// CAN bus for NMEA2000 connection
#define CAN_TX GPIO_NUM_18 // D9
#define CAN_RX GPIO_NUM_21 // D10
#define CAN_RECOVERY_PERIOD 3000
// I2C temp. sensor
#define I2C_SDA GPIO_NUM_11 // A4
#define I2C_SCL GPIO_NUM_12 // A5
#define I2C_SPEED 100000UL // 100kHz clock speed on I2C bus
// I2C addresses
#define SHT31_ADDRESS 0x44
// SPI display connector (optional)
#define SPI_MOSI GPIO_NUM_38 // D11
#define SPI_MISO GPIO_NUM_47 // D12
#define SPI_SCK GPIO_NUM_48 // D13
#define SPI_CS GPIO_NUM_46 // B0
// Button indices
#define BUTTON_1 0
#define BUTTON_2 1
#define BUTTON_3 2
#define BUTTON_4 3
#define BUTTON_5 4
#define BUTTON_6 5
#define BUTTON_DST 6
enum class ButtonPressType : uint8_t
{
SHORT, // < 1 second
MEDIUM, // >= 1 second and < 3 seconds
LONG // >= 3 seconds
};
struct ButtonEvent
{
uint8_t buttonId;
ButtonPressType pressType;
};