Commit 1bee8296 authored by Thierry Paris's avatar Thierry Paris

0.30

parent 90c08d6f
@..\MakeDoc.bat
\ No newline at end of file
@..\MakeLibrary.bat
@../MakeTests.bat
= DcDccNanoControler extension Library for Arduino =
= DcDccNanoController extension Library for Arduino =
This library is made to build Basic Dcc controler on small Arduinos Nano or Uno.
This library is made to build Basic Dcc controller on small Arduinos Nano or Uno.
For more information about this library please visit us at
http://www.locoduino.org/spip.php?article224 in french or
http://git.framasoft.org/locoduino.org/DcDccNanoControler/wikis/home for both french and english.
http://git.framasoft.org/locoduino.org/DcDccNanoController/wikis/home for both french and english.
== License ==
......
DcDccNanoControler

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestExe", "TestExe.vcxproj", "{9696B190-8A31-45BA-A43E-0287102EF438}"
ProjectSection(ProjectDependencies) = postProject
......@@ -26,12 +26,10 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9696B190-8A31-45BA-A43E-0287102EF438}.Debug|x64.ActiveCfg = Debug|x64
{9696B190-8A31-45BA-A43E-0287102EF438}.Debug|x64.Build.0 = Debug|x64
{9696B190-8A31-45BA-A43E-0287102EF438}.Debug|x86.ActiveCfg = Debug|Win32
{9696B190-8A31-45BA-A43E-0287102EF438}.Debug|x86.Build.0 = Debug|Win32
{9696B190-8A31-45BA-A43E-0287102EF438}.Debug|x86.ActiveCfg = Debug|x64
{9696B190-8A31-45BA-A43E-0287102EF438}.Release|x64.ActiveCfg = Release|x64
{9696B190-8A31-45BA-A43E-0287102EF438}.Release|x64.Build.0 = Release|x64
{9696B190-8A31-45BA-A43E-0287102EF438}.Release|x86.ActiveCfg = Release|Win32
{9696B190-8A31-45BA-A43E-0287102EF438}.Release|x86.Build.0 = Release|Win32
{9696B190-8A31-45BA-A43E-0287102EF438}.Release|x86.ActiveCfg = Release|x64
{2CEDFF9D-11AC-46B3-92B0-8B43CBCCFFAC}.Debug|x64.ActiveCfg = Debug|x64
{2CEDFF9D-11AC-46B3-92B0-8B43CBCCFFAC}.Debug|x64.Build.0 = Debug|x64
{2CEDFF9D-11AC-46B3-92B0-8B43CBCCFFAC}.Debug|x86.ActiveCfg = Debug|Win32
......@@ -42,12 +40,10 @@ Global
{2CEDFF9D-11AC-46B3-92B0-8B43CBCCFFAC}.Release|x86.Build.0 = Release|Win32
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Debug|x64.ActiveCfg = Debug|x64
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Debug|x64.Build.0 = Debug|x64
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Debug|x86.ActiveCfg = Debug|Win32
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Debug|x86.Build.0 = Debug|Win32
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Debug|x86.ActiveCfg = Debug|x64
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Release|x64.ActiveCfg = Release|x64
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Release|x64.Build.0 = Release|x64
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Release|x86.ActiveCfg = Release|Win32
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Release|x86.Build.0 = Release|Win32
{CC4048D1-7AC0-4D3D-98A3-2922D996B5AB}.Release|x86.ActiveCfg = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
......@@ -26,20 +18,6 @@
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
......@@ -59,12 +37,6 @@
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
......@@ -72,39 +44,20 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(VisualStudioDir)\..\Arduino\ArduiEmulator\ArduiEmulator;$(VisualStudioDir)\..\Arduino\Libraries\DIO2\VStudio;$(VisualStudioDir)\..\Arduino\Libraries\Commanders\VStudio;$(VisualStudioDir)\..\Arduino\Libraries\Commanders\src;$(VisualStudioDir)\..\Arduino\Libraries\LcdUi\VStudio;$(VisualStudioDir)\..\Arduino\Libraries\LcdUi\src;$(VisualStudioDir)\..\Arduino\Libraries\EEPROMextent\VStudio</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(VisualStudioDir)\..\Arduino\ArduiEmulator\ArduiEmulator;$(VisualStudioDir)\..\Arduino\Libraries\DIO2\VStudio;$(VisualStudioDir)\..\Arduino\Libraries\DcDccNanocontroller\VStudio;$(VisualStudioDir)\..\Arduino\Libraries\Commanders\VStudio;$(VisualStudioDir)\..\Arduino\Libraries\LcdUi\VStudio;$(VisualStudioDir)\..\Arduino\Libraries\DcDccNanocontroller\src;$(VisualStudioDir)\..\Arduino\Libraries\Commanders\src;$(VisualStudioDir)\..\Arduino\Libraries\LcdUi\src</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../ArduiEmulator/ArduiEmulator</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies />
<SubSystem>Windows</SubSystem>
<EntryPointSymbol>Main</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);VISUALSTUDIO;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<PreprocessToFile>false</PreprocessToFile>
</ClCompile>
<Link>
......@@ -115,16 +68,6 @@
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies />
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
......@@ -174,12 +117,12 @@
<ClCompile Include="..\..\LcdUi\src\WindowSplash.cpp" />
<ClCompile Include="..\..\LcdUi\src\WindowText.cpp" />
<ClCompile Include="..\..\LcdUi\src\WindowYesNo.cpp" />
<ClCompile Include="..\src\Controler.cpp" />
<ClCompile Include="..\src\ControlerDc.cpp" />
<ClCompile Include="..\src\ControlerDccpp.cpp" />
<ClCompile Include="..\src\controller.cpp" />
<ClCompile Include="..\src\controllerDc.cpp" />
<ClCompile Include="..\src\controllerDccpp.cpp" />
<ClCompile Include="..\src\DCCpp\CurrentMonitor.cpp" />
<ClCompile Include="..\src\DCCpp\PacketRegister.cpp" />
<ClCompile Include="..\src\DcDccControler.cpp" />
<ClCompile Include="..\src\DcDcccontroller.cpp" />
<ClCompile Include="..\src\Function.cpp" />
<ClCompile Include="..\src\Handle.cpp" />
<ClCompile Include="..\src\Locomotive.cpp" />
......@@ -215,6 +158,7 @@
<ClInclude Include="..\..\Commanders\src\SerialCommander.hpp" />
<ClInclude Include="..\..\Commanders\src\TextInterpreter.hpp" />
<ClInclude Include="..\..\Commanders\VStudio\ButtonsCommanderKeyboard.hpp" />
<ClInclude Include="..\..\Commanders\VStudio\Commanders.h" />
<ClInclude Include="..\..\Commanders\VStudio\DCC_Decoder.hpp" />
<ClInclude Include="..\..\Commanders\VStudio\mcp_can.h" />
<ClInclude Include="..\..\Commanders\VStudio\mcp_can_dfs.h" />
......@@ -235,14 +179,14 @@
<ClInclude Include="..\..\LcdUi\src\WindowSplash.hpp" />
<ClInclude Include="..\..\LcdUi\src\WindowText.hpp" />
<ClInclude Include="..\..\LcdUi\src\WindowYesNo.hpp" />
<ClInclude Include="..\src\Controler.hpp" />
<ClInclude Include="..\src\ControlerDc.hpp" />
<ClInclude Include="..\src\ControlerDccpp.hpp" />
<ClInclude Include="..\src\controller.hpp" />
<ClInclude Include="..\src\controllerDc.hpp" />
<ClInclude Include="..\src\controllerDccpp.hpp" />
<ClInclude Include="..\src\DCCpp\Config.h" />
<ClInclude Include="..\src\DCCpp\CurrentMonitor.h" />
<ClInclude Include="..\src\DCCpp\DCCpp_Uno.h" />
<ClInclude Include="..\src\DCCpp\PacketRegister.h" />
<ClInclude Include="..\src\DcDccNanoControler.h" />
<ClInclude Include="..\src\DcDccNanocontroller.h" />
<ClInclude Include="..\src\English16.h" />
<ClInclude Include="..\src\French16.h" />
<ClInclude Include="..\src\Function.hpp" />
......
11/08/2017 V0.3
- Fix syntax controler -> controller !
15/07/2017 V0.2
- First commit.
29/06/2017 V0.1
- DcDccNanoControler project is born !
\ No newline at end of file
- DcDccNanocontroller project is born !
\ No newline at end of file
/*************************************************************
project: <Dc/Dcc Controler>
project: <Dc/Dcc Controller>
author: <Thierry PARIS>
description: <Dc/Dcc Nano controler sample>
description: <Dc/Dcc Nano Controller sample>
*************************************************************/
#include "French16.h"
#include "Commanders.h"
#include <Commanders.h>
#include "DcDccNanoControler.h"
#include "DcDccNanoController.h"
#include <LiquidCrystal.h>
#include "ScreenLiquid.hpp" // DcDccNaNoControler include file associated with LiquidCrystal...
#include "ScreenLiquid.hpp" // DcDccNaNoController include file associated with LiquidCrystal...
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
ScreenLiquid screen;
......@@ -38,8 +38,8 @@ void setup()
// if dcdcc pin equals to 255, dcc mode is forced.
// if dcdcc pin equals to 0, dc mode is forced.
// otherwise, pin state give dc or dcc.
DcDccControler::begin(A5, &screen);
DcDccControler::beginMain(255, DCC_SIGNAL_PIN_MAIN, 11, A6); // Dir, Pwm, current sensor pin
DcDccController::begin(A5, &screen);
DcDccController::beginMain(255, DCC_SIGNAL_PIN_MAIN, 11, A6); // Dir, Pwm, current sensor pin
}
void loop()
......@@ -50,6 +50,6 @@ void loop()
if (eventId == UNDEFINED_ID)
eventId = EVENT_NONE;
DcDccControler::loop(eventId, Commanders::GetLastEventData());
DcDccController::loop(eventId, Commanders::GetLastEventData());
}
/*************************************************************
project: <Dc/Dcc Controler>
project: <Dc/Dcc Controller>
author: <Thierry PARIS>
description: <Dc/Dcc Nano controler sample>
description: <Dc/Dcc Nano Controller sample>
*************************************************************/
#include "French16.h"
#include "Commanders.h"
#include "DcDccNanoControler.h"
#include "DcDccNanoController.h"
#include <LiquidCrystal.h>
#include "ScreenLiquid.hpp"
......@@ -76,8 +76,8 @@ void setup()
// if dcdcc pin equals to 0, dc mode is forced.
// otherwise, pin state give dc or dcc.
screen.begin(16, 2, DcDccStringTable, &lcd);
DcDccControler::begin(255/*A5*/, &screen);
DcDccControler::beginMain(255, DCC_SIGNAL_PIN_MAIN, 11, A6); // Dc: Dir, Pwm, current sensor
DcDccController::begin(255/*A5*/, &screen);
DcDccController::beginMain(255, DCC_SIGNAL_PIN_MAIN, 11, A6); // Dc: Dir, Pwm, current sensor
}
void loop()
......@@ -91,6 +91,6 @@ void loop()
if (eventId == UNDEFINED_ID)
eventId = EVENT_NONE;
DcDccControler::loop(eventId, Commanders::GetLastEventData());
DcDccController::loop(eventId, Commanders::GetLastEventData());
}
......@@ -6,7 +6,7 @@
# Datatypes (KEYWORD1)
#######################################
DcDccControler KEYWORD1
DcDccController KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
......
name=DcDccNanoControler
version=0.2
name=DcDccNanoController
version=0.3
author=Thierry Paris - Locoduino
maintainer=https://git.framasoft.org/locoduino.org/DcDccNanoControler
sentence=This library is made to build a basic Dcc controler on small Arduinos Nanos or Uno.
maintainer=https://git.framasoft.org/locoduino.org/DcDccNanoController
sentence=This library is made to build a basic Dcc controller on small Arduinos Nanos or Uno.
paragraph=
category=Device Control
url=https://git.framasoft.org/locoduino.org/DcDccNanoControler
url=https://git.framasoft.org/locoduino.org/DcDccNanoController
architectures=*
/*************************************************************
project: <Dc/Dcc Controler>
project: <Dc/Dcc Controller>
author: <Thierry PARIS>
description: <Base Controler>
description: <Base Controller>
*************************************************************/
#include "DcDccNanoControler.h"
#include "Controler.hpp"
#include "DcDccNanoController.h"
#include "Controller.hpp"
//-------------------------------------------------------------------
#ifndef __controlerDc_H__
#define __controlerDc_H__
#ifndef __ControllerDc_H__
#define __ControllerDc_H__
//-------------------------------------------------------------------
#include "Controler.hpp"
#include "Controller.hpp"
//-------------------------------------------------------------------
......@@ -12,7 +12,7 @@
#define NB_PWM_FREQ_11_3 7
class ControlerDc : public Controler
class ControllerDc : public Controller
{
private:
uint8_t dcPWMpin; // SignalEnable
......@@ -24,7 +24,7 @@ class ControlerDc : public Controler
static const byte divisors_11_3_pow2[];
byte DCFrequencyDivisorIndex;
inline ControlerDc() { this->dcPWMpin = 0; this->dcDirPin = 0; this->DCFrequencyDivisorIndex = 3; this->slowMode = false; this->maxSpeed = 255; }
inline ControllerDc() { this->dcPWMpin = 0; this->dcDirPin = 0; this->DCFrequencyDivisorIndex = 3; this->slowMode = false; this->maxSpeed = 255; }
public:
void begin();
......
......@@ -8,7 +8,7 @@ Part of DCC++ BASE STATION for the Arduino
**********************************************************************/
#include "../DcDccNanoControler.h"
#include "../DcDccNanoController.h"
//#include "DCCpp_Uno.h"
//#include "PacketRegister.h"
//#include "Comm.h"
......
//-------------------------------------------------------------------
#ifndef __dcDccNanoControler_H__
#define __dcDccNanoControler_H__
#ifndef __dcDccNanoController_H__
#define __dcDccNanoController_H__
//-------------------------------------------------------------------
// This file is just a link to the real include file...
......@@ -22,13 +22,10 @@
#ifdef VISUALSTUDIO
#define DDC_DEBUG_MODE
#define ARDUINO_AVR_MEGA // for test
#include "../../DIO2/VStudio/DIO2.h"
#else
#if !defined(ARDUINO_AVR_UNO) && !defined(ARDUINO_AVR_NANO) // Must be compiled for UNO or NANO
#error DcDccNanoControler can only work for Arduino UNO or NANO !
#error DcDccNanoController can only work for Arduino UNO or NANO !
#endif
#include "DIO2.h"
#endif
#ifndef __LcdUi_H__
......@@ -37,15 +34,6 @@
#define FUNCTION_NUMBER 2
#ifdef DDC_DEBUG_MODE
static void CheckPinNb(GPIO_pin_t inPin, const __FlashStringHelper *inFunc);
static void CheckPinNb(int inPin, const __FlashStringHelper *inFunc);
#define CHECKPIN(val, text) CheckPinNb(cval, text)
#else
#define CHECKPIN(val, text)
#endif
extern const char * const DDC_config_table[] PROGMEM;
extern const char * const string_table[] PROGMEM;
......@@ -55,7 +43,7 @@ extern const char * const string_table[] PROGMEM;
const char str_title[] PROGMEM = "Dc/Dcc Nano V0.1";
const char str_copyright[] PROGMEM = "By Thierry Paris";
#else
const char str_title[] PROGMEM = "Dc/Dcc Nano Controler V0.1";
const char str_title[] PROGMEM = "Dc/Dcc Nano Controller V0.1";
const char str_copyright[] PROGMEM = "By Thierry Paris";
#endif
......@@ -135,17 +123,14 @@ const char * const DcDccStringTable[] PROGMEM
enum DcDcc
{
DcChangeStopped,
PanicStopped,
ProgramMode,
Dc,
Dcc
};
#include "Locomotive.hpp"
#include "ControlerDc.hpp"
#include "ControlerDccpp.hpp"
#include "ControllerDc.hpp"
#include "ControllerDccpp.hpp"
#include "Handle.hpp"
......@@ -157,19 +142,18 @@ enum DcDcc
#define WINDOWTYPE_INTERRUPT_EMERGENCY 10
#define EEPROM_DDC_CONFIG_SIZE 64
#include <LcdEvents.h>
#include "LcdEvents.h"
class DcDccControler
class DcDccController
{
public:
static DcDcc dcType;
static DcDcc dcTypeAtStart;
static Handle handle;
//static int handleAddcounter;
static Controler *pControler;
static Controller *pController;
private:
DcDccControler() {}
DcDccController() {}
static bool beginFinished;
static void beforeFirstLoop();
......
/*************************************************************
project: <Dc/Dcc Controler>
project: <Dc/Dcc Controller>
author: <Thierry PARIS>
description: <Base functions of the library>
*************************************************************/
#include "DcDccNanoControler.h"
#include "DcDccNanoController.h"
#include "Locomotive.hpp"
#include "EEPROM.h" // only for EEPROM.length() !
DcDcc DcDccControler::dcType;
DcDcc DcDccControler::dcTypeAtStart;
Handle DcDccControler::handle;
//Handle ** DcDccControler::pHandleList;
//int DcDccControler::handleAddcounter;
Controler * DcDccControler::pControler;
bool DcDccControler::beginFinished;
#ifdef DDC_DEBUG_MODE
void CheckPinNb(GPIO_pin_t inPin, const __FlashStringHelper *inFunc)
{
return CheckPinNb(GPIO_to_Arduino_pin(inPin), inFunc);
}
void CheckPinNb(int inPin, const __FlashStringHelper *inFunc)
{
if (inPin <= 0 || inPin >= NUM_DIGITAL_PINS)
{
Serial.print(F("Pin "));
Serial.print(inPin);
Serial.print(F(" error in "));
Serial.println(inFunc);
}
}
#endif
DcDcc DcDccController::dcType;
Handle DcDccController::handle;
Controller * DcDccController::pController;
bool DcDccController::beginFinished;
//#define DDC_DEBUG_MODE
void DcDccControler::begin(uint8_t inDcDccSelectPin, LcdScreen *apScreen)
void DcDccController::begin(uint8_t inDcDccSelectPin, LcdScreen *apScreen)
{
#ifdef DDC_DEBUG_MODE
Serial.println(F(""));
Serial.println(F("Dc/Dcc Controler"));
Serial.println(F("Dc/Dcc Nano Controller"));
Serial.println(F("Developed by Thierry Paris."));
Serial.println(F(""));
Serial.println(F("*** Setup started."));
#endif
//DcDccControler::pHandleList = NULL;
//cDccControler::handleAddcounter = 0;
DcDccControler::pControler = NULL;
DcDccControler::beginFinished = false;
//DcDccController::pHandleList = NULL;
//cDccController::handleAddcounter = 0;
DcDccController::pController = NULL;
DcDccController::beginFinished = false;
#ifdef DDC_DEBUG_MODE
Serial.println(F("Setup started (Nano version)..."));
Serial.println(F("Setup started..."));
#endif
#ifndef VISUALSTUDIO
//while (!Serial);
#endif
DcDccControler::dcType = Dc;
DcDccController::dcType = Dc;
if (inDcDccSelectPin == 255)
DcDccControler::dcType = Dcc;
DcDccController::dcType = Dcc;
if (inDcDccSelectPin > 0 && inDcDccSelectPin < 255)
{
pinMode(inDcDccSelectPin, INPUT_PULLUP);
if (digitalRead(inDcDccSelectPin) == HIGH)
DcDccControler::dcType = Dcc;
DcDccController::dcType = Dcc;
}
// Just for let the time to the microC to initialize internals...
......@@ -75,51 +54,51 @@ void DcDccControler::begin(uint8_t inDcDccSelectPin, LcdScreen *apScreen)
LcdScreen::YesMsg = STR_YES;
LcdScreen::NoMsg = STR_NO;
if (DcDccControler::dcType == Dc)
if (DcDccController::dcType == Dc)
{
#ifdef DDC_DEBUG_MODE
Serial.println(F("Start in Dc mode"));
#endif
DcDccControler::pControler = new ControlerDc();
DcDccController::pController = new ControllerDc();
}
else
{
#ifdef DDC_DEBUG_MODE
Serial.println(F("Start in Dcc mode"));
#endif
DcDccControler::pControler = new ControlerDccpp();
DcDccController::pController = new ControllerDccpp();
}
DcDccControler::pControler->begin();
DcDccControler::handle.begin();
DcDccControler::handle.GetUI()->begin(apScreen);
DcDccController::pController->begin();
DcDccController::handle.begin();
DcDccController::handle.GetUI()->begin(apScreen);
}
void DcDccControler::beginMain(uint8_t DirectionMotor, uint8_t SignalPin, uint8_t SignalEnablePin, uint8_t CurrentMonitor)
void DcDccController::beginMain(uint8_t DirectionMotor, uint8_t SignalPin, uint8_t SignalEnablePin, uint8_t CurrentMonitor)
{
DcDccControler::pControler->beginMain(DirectionMotor, SignalPin, SignalEnablePin, CurrentMonitor);
DcDccController::pController->beginMain(DirectionMotor, SignalPin, SignalEnablePin, CurrentMonitor);
}
void DcDccControler::beginProg(uint8_t DirectionMotor, uint8_t SignalPin, uint8_t SignalEnablePin, uint8_t CurrentMonitor)
void DcDccController::beginProg(uint8_t DirectionMotor, uint8_t SignalPin, uint8_t SignalEnablePin, uint8_t CurrentMonitor)
{
DcDccControler::pControler->beginProg(DirectionMotor, SignalPin, SignalEnablePin, CurrentMonitor);
DcDccController::pController->beginProg(DirectionMotor, SignalPin, SignalEnablePin, CurrentMonitor);
}
void DcDccControler::beforeFirstLoop()
void DcDccController::beforeFirstLoop()
{
if (DcDccControler::dcType == Dc)
if (DcDccController::dcType == Dc)
{
// Affect a special loco to this handle.
DcDccControler::handle.SetControledLocomotive(Locomotive::AnalogLocomotive);
DcDccControler::handle.MoreLessIncrement = 10;
DcDccController::handle.SetControlledLocomotive(Locomotive::AnalogLocomotive);
DcDccController::handle.MoreLessIncrement = 10;
}
ConfigLoad();
DcDccControler::handle.StartUI();
DcDccControler::handle.StartContent();
DcDccController::handle.StartUI();
DcDccController::handle.StartContent();
DcDccControler::handle.EndSetup();
DcDccController::handle.EndSetup();
#ifdef DDC_DEBUG_MODE
Serial.print(F("*** Setup Finished."));
......@@ -135,21 +114,21 @@ void DcDccControler::beforeFirstLoop()
#endif
}
void DcDccControler::loop(unsigned long inEvent, int inData)
void DcDccController::loop(unsigned long inEvent, int inData)
{
if (!DcDccControler::beginFinished)
if (!DcDccController::beginFinished)
{
DcDccControler::beforeFirstLoop();
DcDccControler::beginFinished = true;
DcDccController::beforeFirstLoop();
DcDccController::beginFinished = true;
}
if (DcDccControler::pControler != 0)
DcDccControler::pControler->loop();
if (DcDccController::pController != 0)
DcDccController::pController->loop();
DcDccControler::handle.loop(inEvent, inData);
DcDccController::handle.loop(inEvent, inData);
}
void DcDccControler::ConfigLoad()
void DcDccController::ConfigLoad()
{
// The first three bytes must be 'DDC' to assume that there is already a saved configuration
// in the EEPROM. If not, reset all the EEPROM to 0, and save the 'DDC' identifier.
......@@ -160,40 +139,40 @@ void DcDccControler::ConfigLoad()
}
else
{
if (DcDccControler::dcType == Dc)
if (DcDccController::dcType == Dc)
{
byte dCFrequencyDivisorIndex = EEPROM.read(3);
if (dCFrequencyDivisorIndex < NB_PWM_FREQ_11_3)
// Set frequency, even if the pin is not correct at this moment !
((ControlerDc *)DcDccControler::pControler)->DCFrequencyDivisorIndex = dCFrequencyDivisorIndex;
((ControllerDc *)DcDccController::pController)->DCFrequencyDivisorIndex = dCFrequencyDivisorIndex;
}
// Must be done only when the good value is in Locomotive::FunctionNumber...
DcDccControler::handle.ConfigLoad();
DcDccController::handle.ConfigLoad();
}
}
int DcDccControler::ConfigSave()
int DcDccController::ConfigSave()
{
EEPROM.update(0, 'D');
EEPROM.update(1, 'D');
EEPROM.update(2, 'C');
int pos = 4;
if (DcDccControler::dcType == Dc)
EEPROM.update(3, ((ControlerDc *)DcDccControler::pControler)->DCFrequencyDivisorIndex);
if (DcDccController::dcType == Dc)
EEPROM.update(3, ((ControllerDc *)DcDccController::pController)->DCFrequencyDivisorIndex);
else
{
}
// Must be done only when the good value is in Locomotive::FunctionNumber...
DcDccControler::handle.ConfigSave();
DcDccController::handle.ConfigSave();
return pos; // Pos of next writing...
}
void DcDccControler::ConfigReset()
void DcDccController::ConfigReset()
{
for (uint16_t i = 0; i < EEPROM.length(); i++)
EEPROM.update(i, 0);
......
/*************************************************************
project: <Dc/Dcc Controler>
project: <Dc/Dcc Controller>
author: <Thierry PARIS>
description: <Class for a decoder function>
*************************************************************/
#include "DcDccNanoControler.h"
#include "Function.hpp"
#include "EEPROM.h"
#include "DcDccNanoController.h"
#include "Function.hpp"
Function::Function(int inDccId)
{
this->SlotNumber = 255;
......
/*************************************************************
project: <Dc/Dcc Controler>
project: <Dc/Dcc Controller>
author: <Thierry PARIS>
description: <Class for one handle>
*************************************************************/
#include "DcDccNanoControler.h"
#include "DcDccNanoController.h"
#ifndef NO_BUTTONSCOMMANDERPOTENTIOMETER
#include "Commanders.h"
#include <Commanders.h>
#endif