mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-30 03:26:13 +01:00
54 lines
2.3 KiB
C
54 lines
2.3 KiB
C
/*
|
|
* © 2021, Chris Harlow, Neil McKechnie. All rights reserved.
|
|
*
|
|
* This file is part of CommandStation-EX
|
|
*
|
|
* This is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* It is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
// This implementation is designed to be #included ONLY ONCE in the .ino
|
|
//
|
|
// It will create a driver implemntation and a shim class implementation.
|
|
// This means that other classes can reference the shim without knowing
|
|
// which library is involved.
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef LCD_Implementation_h
|
|
#define LCD_Implementation_h
|
|
#include "Display.h"
|
|
#include "SSD1306Ascii.h"
|
|
#include "LiquidCrystal_I2C.h"
|
|
|
|
|
|
// Implement the Display shim class as a singleton.
|
|
// The DisplayInterface class implements a display handler with no code (null device);
|
|
// The Display class sub-classes DisplayInterface to provide the common display code;
|
|
// Then Display class is subclassed to the specific device type classes:
|
|
// SSD1306AsciiWire for I2C OLED driver with SSD1306 or SH1106 controllers;
|
|
// LiquidCrystal_I2C for I2C LCD driver for HD44780 with PCF8574 'backpack'.
|
|
|
|
#if defined(OLED_DRIVER)
|
|
#define CONDITIONAL_DISPLAY_START for (DisplayInterface * dummy=new SSD1306AsciiWire(OLED_DRIVER);dummy!=NULL; dummy=dummy->loop2(true))
|
|
|
|
#elif defined(LCD_DRIVER)
|
|
#define CONDITIONAL_DISPLAY_START for (DisplayInterface * dummy=new LiquidCrystal_I2C(LCD_DRIVER);dummy!=NULL; dummy=dummy->loop2(true))
|
|
|
|
#else
|
|
// Create null display handler just in case someone calls displayHandler->something without checking if displayHandler is NULL!
|
|
#define CONDITIONAL_DISPLAY_START { new DisplayInterface(); }
|
|
#endif
|
|
|
|
#endif // LCD_Implementation_h
|