mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
Merge branch 'devel' of https://github.com/DCC-EX/CommandStation-EX into devel
This commit is contained in:
commit
881463ada9
|
@ -72,18 +72,23 @@ static const FSH * guessI2CDeviceType(uint8_t address) {
|
||||||
void I2CManagerClass::begin(void) {
|
void I2CManagerClass::begin(void) {
|
||||||
if (!_beginCompleted) {
|
if (!_beginCompleted) {
|
||||||
_beginCompleted = true;
|
_beginCompleted = true;
|
||||||
|
|
||||||
|
// Check for short-circuit or floating lines (no pull-up) on I2C before enabling I2C
|
||||||
|
const FSH *message = F("WARNING: Possible short-circuit or inadequate pullup on I2C %S line");
|
||||||
|
pinMode(SDA, INPUT);
|
||||||
|
if (!digitalRead(SDA))
|
||||||
|
DIAG(message, F("SDA"));
|
||||||
|
pinMode(SCL, INPUT);
|
||||||
|
if (!digitalRead(SCL))
|
||||||
|
DIAG(message, F("SCL"));
|
||||||
|
|
||||||
|
// Now initialise I2C
|
||||||
_initialise();
|
_initialise();
|
||||||
|
|
||||||
#if defined(I2C_USE_WIRE)
|
#if defined(I2C_USE_WIRE)
|
||||||
DIAG(F("I2CManager: Using Wire library"));
|
DIAG(F("I2CManager: Using Wire library"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check for short-circuits on I2C
|
|
||||||
if (!digitalRead(SDA))
|
|
||||||
DIAG(F("WARNING: Possible short-circuit on I2C SDA line"));
|
|
||||||
if (!digitalRead(SCL))
|
|
||||||
DIAG(F("WARNING: Possible short-circuit on I2C SCL line"));
|
|
||||||
|
|
||||||
// Probe and list devices. Use standard mode
|
// Probe and list devices. Use standard mode
|
||||||
// (clock speed 100kHz) for best device compatibility.
|
// (clock speed 100kHz) for best device compatibility.
|
||||||
_setClock(100000);
|
_setClock(100000);
|
||||||
|
|
|
@ -82,10 +82,10 @@ private:
|
||||||
public:
|
public:
|
||||||
// Static function to handle "HALDisplay::create(...)" calls.
|
// Static function to handle "HALDisplay::create(...)" calls.
|
||||||
static void create(I2CAddress i2cAddress, int width, int height) {
|
static void create(I2CAddress i2cAddress, int width, int height) {
|
||||||
/* if (checkNoOverlap(i2cAddress)) */ new HALDisplay(0, i2cAddress, width, height);
|
if (checkNoOverlap(0, 0, i2cAddress)) new HALDisplay(0, i2cAddress, width, height);
|
||||||
}
|
}
|
||||||
static void create(uint8_t displayNo, I2CAddress i2cAddress, int width, int height) {
|
static void create(uint8_t displayNo, I2CAddress i2cAddress, int width, int height) {
|
||||||
/* if (checkNoOverlap(i2cAddress)) */ new HALDisplay(displayNo, i2cAddress, width, height);
|
if (checkNoOverlap(0, 0, i2cAddress)) new HALDisplay(displayNo, i2cAddress, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -125,10 +125,10 @@ The configuration file for DCC-EX Command Station
|
||||||
// define LCD_DRIVER for I2C address 0x27, 16 cols, 2 rows
|
// define LCD_DRIVER for I2C address 0x27, 16 cols, 2 rows
|
||||||
// #define LCD_DRIVER 0x27,16,2
|
// #define LCD_DRIVER 0x27,16,2
|
||||||
|
|
||||||
//OR define OLED_DRIVER width,height in pixels (address auto detected)
|
//OR define OLED_DRIVER width,height[,address] in pixels (address auto detected if not supplied)
|
||||||
// 128x32 or 128x64 I2C SSD1306-based devices are supported.
|
// 128x32 or 128x64 I2C SSD1306-based devices are supported.
|
||||||
// Use 132,64 for a SH1106-based I2C device with a 128x64 display.
|
// Use 132,64 for a SH1106-based I2C device with a 128x64 display.
|
||||||
// #define OLED_DRIVER 128,32
|
// #define OLED_DRIVER 128,32,0x3c
|
||||||
|
|
||||||
// Define scroll mode as 0, 1 or 2
|
// Define scroll mode as 0, 1 or 2
|
||||||
// * #define SCROLLMODE 0 is scroll continuous (fill screen if poss),
|
// * #define SCROLLMODE 0 is scroll continuous (fill screen if poss),
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
|
|
||||||
// Include devices you need.
|
// Include devices you need.
|
||||||
#include "IODevice.h"
|
#include "IODevice.h"
|
||||||
#include "IO_HCSR04.h" // Ultrasonic range sensor
|
//#include "IO_HALDisplay.h" // Auxiliary display devices (LCD/OLED)
|
||||||
#include "IO_VL53L0X.h" // Laser time-of-flight sensor
|
//#include "IO_HCSR04.h" // Ultrasonic range sensor
|
||||||
#include "IO_DFPlayer.h" // MP3 sound player
|
//#include "IO_VL53L0X.h" // Laser time-of-flight sensor
|
||||||
|
//#include "IO_DFPlayer.h" // MP3 sound player
|
||||||
|
//#include "IO_TouchKeypad.h // Touch keypad with 16 keys
|
||||||
//#include "IO_EXTurntable.h" // Turntable-EX turntable controller
|
//#include "IO_EXTurntable.h" // Turntable-EX turntable controller
|
||||||
//#include "IO_EXFastClock.h" // FastClock driver
|
//#include "IO_EXFastClock.h" // FastClock driver
|
||||||
|
|
||||||
|
@ -31,6 +33,61 @@
|
||||||
|
|
||||||
void halSetup() {
|
void halSetup() {
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// The following directives define auxiliary display devices.
|
||||||
|
// These can be defined in addition to the system display (display
|
||||||
|
// number 0) that is defined in config.h.
|
||||||
|
// A write to a line which is beyond the length of the screen will overwrite
|
||||||
|
// the bottom line, unless the line number is 255 in which case the
|
||||||
|
// screen contents will scroll up before the text is written to the
|
||||||
|
// bottom line.
|
||||||
|
//=======================================================================
|
||||||
|
//
|
||||||
|
// Create a 128x32 OLED display device as display number 1
|
||||||
|
// (line 0 is written by EX-RAIL 'SCREEN(1, 0, "text")').
|
||||||
|
|
||||||
|
//HALDisplay<OLED>::create(1, 0x3d, 128, 32);
|
||||||
|
|
||||||
|
// Create a 20x4 LCD display device as display number 2
|
||||||
|
// (line 0 is written by EX-RAIL 'SCREEN(2, 0, "text")').
|
||||||
|
|
||||||
|
// HALDisplay<LiquidCrystal>(2, 0x27, 20, 4);
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// User Add-ins
|
||||||
|
//=======================================================================
|
||||||
|
// User add-ins can be created when you want to do something that
|
||||||
|
// can't be done in EX-RAIL but does not merit a HAL driver. The
|
||||||
|
// user add-in is a C++ function that is executed periodically by the
|
||||||
|
// HAL subsystem.
|
||||||
|
|
||||||
|
// Example: The function will be executed once per second and will display,
|
||||||
|
// on screen #3, the first eight entries (assuming an 8-line display)
|
||||||
|
// from the loco speed table.
|
||||||
|
|
||||||
|
// Put the following block of code in myHal.cpp OUTSIDE of the
|
||||||
|
// halSetup() function:
|
||||||
|
//
|
||||||
|
// void updateLocoScreen() {
|
||||||
|
// for (int i=0; i<8; i++) {
|
||||||
|
// if (DCC::speedTable[i].loco > 0) {
|
||||||
|
// int speed = DCC::speedTable[i].speedCode;
|
||||||
|
// char direction = (speed & 0x80) ? 'R' : 'F';
|
||||||
|
// speed = speed & 0x7f;
|
||||||
|
// if (speed > 0) speed = speed - 1;
|
||||||
|
// SCREEN(3, i, F("Loco:%4d %3d %c"), DCC::speedTable[i].loco,
|
||||||
|
// speed, direction);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Put the following line INSIDE the halSetup() function:
|
||||||
|
//
|
||||||
|
// UserAddin::create(updateLocoScreen, 1000);
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// The following directive defines a PCA9685 PWM Servo driver module.
|
// The following directive defines a PCA9685 PWM Servo driver module.
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -176,6 +233,21 @@ void halSetup() {
|
||||||
// DFPlayer::create(10000, 10, Serial1);
|
// DFPlayer::create(10000, 10, Serial1);
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// 16-pad capacitative touch key pad based on TP229 IC.
|
||||||
|
//=======================================================================
|
||||||
|
// Parameters below:
|
||||||
|
// 11000 = first VPIN allocated
|
||||||
|
// 16 = number of VPINs allocated
|
||||||
|
// 25 = local GPIO pin number for clock signal
|
||||||
|
// 24 = local GPIO pin number for data signal
|
||||||
|
//
|
||||||
|
// Pressing the key pads numbered 1-16 cause each of the nominated digital VPINs
|
||||||
|
// (11000-11015 in this case) to be activated.
|
||||||
|
|
||||||
|
// TouchKeypad::create(11000, 16, 25, 24);
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// The following directive defines an EX-Turntable turntable instance.
|
// The following directive defines an EX-Turntable turntable instance.
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
Loading…
Reference in New Issue
Block a user