From 7c47bb15620924eb5a6e0a4157b91a3e438c0900 Mon Sep 17 00:00:00 2001 From: FrightRisk <37218136+FrightRisk@users.noreply.github.com> Date: Tue, 29 Sep 2020 17:19:02 -0400 Subject: [PATCH] Fix Turnout and Output return value --- CommandStation-EX.ino | 16 +++---- DCC.h | 2 +- DCCEXParser.cpp | 21 ++++++--- Outputs.cpp | 2 +- config.example.h | 106 ------------------------------------------ 5 files changed, 25 insertions(+), 122 deletions(-) delete mode 100644 config.example.h diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index 5f1f87e..41a4c50 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -16,7 +16,7 @@ //////////////////////////////////////////////////////////////// // // Enables an I2C 2x24 or 4x24 LCD Screen -#if ENABLE_LCD +#ifdef ENABLE_LCD bool lcdEnabled = false; #if defined(LIB_TYPE_PCF8574) LiquidCrystal_PCF8574 lcdDisplay(LCD_ADDRESS); @@ -37,7 +37,7 @@ void setup() // // More display stuff. Need to put this in a .h file and make // it a class -#if ENABLE_LCD +#ifdef ENABLE_LCD Wire.begin(); // Check that we can find the LCD by its address before attempting to use it. Wire.beginTransmission(LCD_ADDRESS); @@ -45,17 +45,17 @@ void setup() { lcdEnabled = true; lcdDisplay.begin(LCD_COLUMNS, LCD_LINES); - lcdDisplay.setBacklight(255); + lcdDisplay.setBacklight(128); lcdDisplay.clear(); lcdDisplay.setCursor(0, 0); lcdDisplay.print("DCC++ EX v"); lcdDisplay.print(VERSION); lcdDisplay.setCursor(0, 1); -#if COMM_INTERFACE >= 1 - lcdDisplay.print("IP: PENDING"); -#else - lcdDisplay.print("SERIAL: READY"); -#endif +//#if COMM_INTERFACE >= 1 +// lcdDisplay.print("IP: PENDING"); +//#else + lcdDisplay.print("SERIAL: READY 1"); +//#endif #if LCD_LINES > 2 lcdDisplay.setCursor(0, 3); lcdDisplay.print("TRACK POWER: OFF"); diff --git a/DCC.h b/DCC.h index 580d8b7..529e326 100644 --- a/DCC.h +++ b/DCC.h @@ -162,7 +162,7 @@ private: #error CANNOT COMPILE - DCC++ EX ONLY WORKS WITH AN ARDUINO UNO, NANO 328, OR ARDUINO MEGA 1280/2560 #endif -#if ENABLE_LCD +#ifdef ENABLE_LCD #include #if defined(LIB_TYPE_PCF8574) #include diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 8a96e23..075bd32 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -424,7 +424,7 @@ bool DCCEXParser::parseZ(Print *stream, int params, int p[]) switch (params) { - + case 2: // { Output *o = Output::get(p[0]); @@ -436,11 +436,16 @@ bool DCCEXParser::parseZ(Print *stream, int params, int p[]) return true; case 3: // - Output::create(p[0], p[1], p[2], 1); + if (!Output::create(p[0], p[1], p[2], 1)) + return false; + StringFormatter::send(stream, F("")); return true; case 1: // - return Output::remove(p[0]); + if (!Output::remove(p[0])) + return false; + StringFormatter::send(stream, F("")); + return true; case 0: // { @@ -548,12 +553,16 @@ bool DCCEXParser::parseS(Print *stream, int params, int p[]) switch (params) { case 3: // create sensor. pullUp indicator (0=LOW/1=HIGH) - Sensor::create(p[0], p[1], p[2]); + if (!Sensor::create(p[0], p[1], p[2])) + return false; + StringFormatter::send(stream, F("")); return true; case 1: // S id> remove sensor - if (Sensor::remove(p[0])) - return true; + if (!Sensor::remove(p[0])) + return false; + StringFormatter::send(stream, F("")); + return true; break; case 0: // lit sensor states diff --git a/Outputs.cpp b/Outputs.cpp index 50a8eda..d72f744 100644 --- a/Outputs.cpp +++ b/Outputs.cpp @@ -90,7 +90,7 @@ void Output::activate(int s){ digitalWrite(data.pin,data.oStatus ^ bitRead(data.iFlag,0)); // set state of output pin to HIGH or LOW depending on whether bit zero of iFlag is set to 0 (ACTIVE=HIGH) or 1 (ACTIVE=LOW) if(num>0) EEPROM.put(num,data.oStatus); - + } /////////////////////////////////////////////////////////////////////////////// diff --git a/config.example.h b/config.example.h deleted file mode 100644 index bb3e302..0000000 --- a/config.example.h +++ /dev/null @@ -1,106 +0,0 @@ -/********************************************************************** - -Config.h -COPYRIGHT (c) 2013-2016 Gregg E. Berman -COPYRIGHT (c) 2020 Fred Decker - -The configuration file for DCC++ EX Command Station - -**********************************************************************/ - -///////////////////////////////////////////////////////////////////////////////////// -// NOTE: Before connecting these boards and selecting one in this software -// check the quick install guides!!! Some of these boards require a voltage -// generating resitor on the current sense pin of the device. Failure to select -// the correct resistor could damage the sense pin on your Arduino or destroy -// the device. -// -// DEFINE MOTOR_SHIELD_TYPE BELOW ACCORDING TO THE FOLLOWING TABLE: -// -// STANDARD_MOTOR_SHIELD : Arduino Motor shield Rev3 based on the L298 with 18V 2A per channel -// POLOLU_MOTOR_SHIELD : Pololu MC33926 Motor Driver (not recommended for prog track) -// FUNDUMOTO_SHIELD : Fundumoto Shield, no current sensing (not recommended, no short protection) -// FIREBOX_MK1 : The Firebox MK1 -// FIREBOX_MK1S : The Firebox MK1S -// | -// +-----------------------v -// -#define MOTOR_SHIELD_TYPE STANDARD_MOTOR_SHIELD - -///////////////////////////////////////////////////////////////////////////////////// -// -// The IP port to talk to a WIFI or Ethernet shield. -// -#define IP_PORT 2560 - -///////////////////////////////////////////////////////////////////////////////////// -// -// NOTE: Only supported on Arduino Mega -// Set to false if you not even want it on the Arduino Mega -// -#define ENABLE_WIFI true - -///////////////////////////////////////////////////////////////////////////////////// -// -// DEFINE WiFi Parameters (only in effect if WIFI is on) -// -#define WIFI_SSID "Your network name" -#define WIFI_PASSWORD "Your network passwd" -#define WIFI_HOSTNAME "dccex" - -///////////////////////////////////////////////////////////////////////////////////// -// -// DEFINE STATIC IP ADDRESS *OR* COMMENT OUT TO USE DHCP -// -//#define IP_ADDRESS { 192, 168, 1, 200 } - -///////////////////////////////////////////////////////////////////////////////////// -// -// DEFINE MAC ADDRESS ARRAY FOR ETHERNET COMMUNICATIONS INTERFACE -// -// Uncomment to use with Ethernet Shields -// -// NOTE: This is not used with ESP8266 WiFi modules. -// -// #define MAC_ADDRESS { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF } - -///////////////////////////////////////////////////////////////////////////////////// -// -// DEFINE LCD SCREEN USAGE BY THE BASE STATION -// -// Note: This feature requires an I2C enabled LCD screen using a PCF8574 based chipset. -// or one using a Hitachi HD44780. -// -// To enable, uncomment the line below and make sure only the correct LIB_TYPE line -// is uncommented below to select the library used for your LCD backpack - -//#define ENABLE_LCD - -#ifdef ENABLE_LCD - #define LIB_TYPE_PCF8574 - //#define LIB_TYPE_I2C - // This defines the I2C address for the LCD device - #define LCD_ADDRESS 0x27 //common defaults are 0x27 and 0x3F - - // This defines the number of columns the LCD device has - #define LCD_COLUMNS 16 - - // This defines the number of lines the LCD device has - #define LCD_LINES 2 -#endif - - -///////////////////////////////////////////////////////////////////////////////////// -// -// Enable custom command filtering -#define ENABLE_CUSTOM_FILTER false - -///////////////////////////////////////////////////////////////////////////////////// -// -// Enable custom command filtering -#define ENABLE_CUSTOM_CALLBACK false - -///////////////////////////////////////////////////////////////////////////////////// -// -// Enable custom command filtering -#define ENABLE_FREE_MEM_WARNING false