Skip to content

Commit

Permalink
Added a method to automatically list enabled and disabled devices so …
Browse files Browse the repository at this point in the history
…that this information needn't be manually created any longer.

Now devices are pretty much plug-n-play without a whole lot of manual work.
  • Loading branch information
collin80 committed Apr 7, 2014
1 parent 584a046 commit 42120e7
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 16 deletions.
2 changes: 2 additions & 0 deletions BrusaMotorController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ BrusaMotorController::BrusaMotorController() : MotorController() {
limiterStateNumber = 0;

tickCounter = 0;

commonName = "Brusa DMC5 Inverter";
}

/*
Expand Down
2 changes: 2 additions & 0 deletions CanBrake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ CanBrake::CanBrake() : Throttle() {
responseId = 0;
responseMask = 0x7ff;
responseExtended = false;

commonName = "CANBus brake";
}

void CanBrake::setup() {
Expand Down
2 changes: 2 additions & 0 deletions CanThrottle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ CanThrottle::CanThrottle() : Throttle() {
responseId = 0;
responseMask = 0x7ff;
responseExtended = false;

commonName = "CANBus accelerator";
}

void CanThrottle::setup() {
Expand Down
5 changes: 5 additions & 0 deletions Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ Device::Device() {
prefsHandler = NULL;
//since all derived classes eventually call this base method this will cause every device to auto register itself with the device manager
DeviceManager::getInstance()->addDevice(this);
commonName = "Generic Device";
}

//Empty functions to handle these callbacks if the derived classes don't

void Device::setup() {
}

char* Device::getCommonName() {
return commonName;
}

void Device::handleTick() {
}

Expand Down
2 changes: 2 additions & 0 deletions Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Device: public TickObserver {
void handleTick();
bool isEnabled();
virtual uint32_t getTickInterval();
char* getCommonName();

virtual void loadConfiguration();
virtual void saveConfiguration();
Expand All @@ -64,6 +65,7 @@ class Device: public TickObserver {

protected:
PrefHandler *prefsHandler;
char *commonName;

private:
DeviceConfiguration *deviceConfiguration; // reference to the currently active configuration
Expand Down
16 changes: 16 additions & 0 deletions DeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,19 @@ uint8_t DeviceManager::countDeviceType(DeviceType deviceType) {
}
return count;
}

void DeviceManager::printDeviceList() {
Logger::console("Currently enabled devices: (DISABLE= to disable)");
for (int i = 0; i < CFG_DEV_MGR_MAX_DEVICES; i++) {
if (devices[i] && devices[i]->isEnabled()) {
Logger::console(" %X %s", devices[i]->getId(), devices[i]->getCommonName());
}
}

Logger::console("Currently disabled devices: (ENABLE= to enable)");
for (int i = 0; i < CFG_DEV_MGR_MAX_DEVICES; i++) {
if (devices[i] && !devices[i]->isEnabled()) {
Logger::console(" %X %s", devices[i]->getId(), devices[i]->getCommonName());
}
}
}
1 change: 1 addition & 0 deletions DeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class DeviceManager {
MotorController *getMotorController();
Device *getDeviceByID(DeviceId);
Device *getDeviceByType(DeviceType);
void printDeviceList();

protected:

Expand Down
1 change: 1 addition & 0 deletions DmocMotorController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ DmocMotorController::DmocMotorController() : MotorController() {
online = 0;
activityCount = 0;
// maxTorque = 2000;
commonName = "DMOC645 Inverter";
}

void DmocMotorController::setup() {
Expand Down
2 changes: 2 additions & 0 deletions ELM327_Emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ ELM327Emu::ELM327Emu() {
serialInterface = &Serial2;
else //older hardware used this instead
serialInterface = &Serial3;

commonName = "ELM327 Emulator over Bluetooth";
}

/*
Expand Down
9 changes: 6 additions & 3 deletions GEVCU.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>__SAM3X8E__;USB_VID=0x2341;USB_PID=0x003e;USBCON;ARDUINO=154;ARDUINO_MAIN;printf=iprintf;__SAM__;F_CPU=84000000L;__cplusplus;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>__SAM3X8E__;USB_VID=0x2341;USB_PID=0x003e;USBCON;USB_MANUFACTURER="Unknown";USB_PRODUCT="Arduino Due";ARDUINO=154;ARDUINO_MAIN;printf=iprintf;__SAM__;__sam__;F_CPU=84000000L;__cplusplus;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<BrowseInformation>true</BrowseInformation>
<AdditionalIncludeDirectories>c:\arduino\hardware\arduino\sam\cores\arduino;c:\arduino\hardware\arduino\sam\variants\arduino_due_x;C:\Users\Collin\Documents\Arduino\libraries\due_rtc;C:\Users\Collin\Documents\Arduino\libraries\due_rtc\utility;C:\Users\Collin\Documents\Arduino\libraries\due_can;C:\Users\Collin\Documents\Arduino\libraries\due_can\utility;C:\Users\Collin\Documents\Arduino\libraries\due_wire;C:\Users\Collin\Documents\Arduino\libraries\due_wire\utility;C:\Users\Collin\Documents\Arduino\libraries\DueTimer;C:\Users\Collin\Documents\Arduino\libraries\DueTimer\utility;c:\arduino\hardware\arduino\sam\system\CMSIS\CMSIS\Include\;c:\arduino\hardware\arduino\sam\system\CMSIS\Device\ATMEL\;c:\arduino\hardware\arduino\sam\system\libsam;c:\arduino\hardware\arduino\sam\system\libsam\include;c:\arduino/hardware/tools/g++_arm_none_eabi\arm-none-eabi\include;c:\arduino/hardware/tools/g++_arm_none_eabi\arm_none_eabi\include\;c:\arduino/hardware/tools/g++_arm_none_eabi\lib\gcc\arm-none-eabi\4.4.1\include;c:\arduino/hardware/tools/g++_arm_none_eabi\lib\gcc\arm-none-eabi\4.4.1\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>C:\Users\Collin\Desktop\GEVCU\Visual Micro\.GEVCU.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<AdditionalIncludeDirectories>c:\arduino-1.5.4\hardware\arduino\sam\cores\arduino;c:\arduino-1.5.4\hardware\arduino\sam\variants\arduino_due_x;C:\Users\collin\Documents\Arduino\libraries\due_rtc;C:\Users\collin\Documents\Arduino\libraries\due_rtc\utility;C:\Users\collin\Documents\Arduino\libraries\due_can;C:\Users\collin\Documents\Arduino\libraries\due_can\utility;C:\Users\collin\Documents\Arduino\libraries\due_wire;C:\Users\collin\Documents\Arduino\libraries\due_wire\utility;C:\Users\collin\Documents\Arduino\libraries\DueTimer;C:\Users\collin\Documents\Arduino\libraries\DueTimer\utility;c:\arduino-1.5.4\libraries;c:\arduino-1.5.4\hardware\arduino\sam\libraries;C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\default\debuggers;C:\Users\collin\Documents\Arduino\libraries;c:\arduino-1.5.4\hardware\arduino\sam\system\CMSIS\CMSIS\Include\;c:\arduino-1.5.4\hardware\arduino\sam\system\CMSIS\Device\ATMEL\;c:\arduino-1.5.4\hardware\arduino\sam\system\libsam;c:\arduino-1.5.4\hardware\arduino\sam\system\libsam\include;c:\arduino-1.5.4/hardware/tools/g++_arm_none_eabi\arm-none-eabi\include;c:\arduino-1.5.4/hardware/tools/g++_arm_none_eabi\arm_none_eabi\include\;c:\arduino-1.5.4/hardware/tools/g++_arm_none_eabi\lib\gcc\arm-none-eabi\4.4.1\include;c:\arduino-1.5.4/hardware/tools/g++_arm_none_eabi\lib\gcc\arm-none-eabi\4.4.1\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>C:\Users\collin\Desktop\GEVCU\Visual Micro\.GEVCU.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<IgnoreStandardIncludePath>true</IgnoreStandardIncludePath>
</ClCompile>
<Link>
Expand Down Expand Up @@ -87,6 +87,9 @@
<ClInclude Include="CanPIDListener.h" />
<ClInclude Include="CanThrottle.h" />
<ClInclude Include="config.h" />
<ClInclude Include="constants.h">
<FileType>CppCode</FileType>
</ClInclude>
<ClInclude Include="Device.h" />
<ClInclude Include="DeviceManager.h" />
<ClInclude Include="DeviceTypes.h">
Expand Down
3 changes: 3 additions & 0 deletions GEVCU.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
<ClInclude Include="CanBrake.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="constants.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="GEVCU.ino" />
Expand Down
1 change: 1 addition & 0 deletions PotBrake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/
PotBrake::PotBrake() : Throttle() {
prefsHandler = new PrefHandler(POTBRAKEPEDAL);
commonName = "Potentiometer (analog) brake";
}

/*
Expand Down
1 change: 1 addition & 0 deletions PotThrottle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/
PotThrottle::PotThrottle() : Throttle() {
prefsHandler = new PrefHandler(POTACCELPEDAL);
commonName = "Potentiometer (analog) accelerator";
}

/*
Expand Down
16 changes: 3 additions & 13 deletions SerialConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,9 @@ void SerialConsole::printMenu() {
uint8_t systype;
sysPrefs->read(EESYS_SYSTEM_TYPE, &systype);
Logger::console("SYSTYPE=%i - Set board revision (Dued=2, GEVCU3=3, GEVCU4=4)", systype);
SerialUSB.println("ENABLE - Enable the given device by ID");
SerialUSB.println("DISABLE - Disable the given device by ID");
Logger::console(" %X DMOC645 Inverter", DMOC645);
Logger::console(" %X Brusa DMC5 Inverter", BRUSA_DMC5);
//Logger::console(" Brusa Charger = %X", BRUSACHARGE);
//Logger::console(" TCCH Charger = %X", TCCHCHARGE);
Logger::console(" %X Potentiometer (analog) accelerator", POTACCELPEDAL);
Logger::console(" %X Potentiometer (analog) brake", POTBRAKEPEDAL);
Logger::console(" %X CANBus accelerator", CANACCELPEDAL);
Logger::console(" %X CANBus brake", CANBRAKEPEDAL);
Logger::console(" %X WIFI (iChip2128)", ICHIP2128);
Logger::console(" %X ELM327 Emulator over Bluetooth", ELM327EMU);


DeviceManager::getInstance()->printDeviceList();

if (motorController && motorController->getConfiguration()) {
MotorControllerConfiguration *config = (MotorControllerConfiguration *) motorController->getConfiguration();
SerialUSB.println();
Expand Down
2 changes: 2 additions & 0 deletions ichip_2128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ ICHIPWIFI::ICHIPWIFI() {
serialInterface = &Serial2;
else //older hardware used this instead
serialInterface = &Serial3;

commonName = "WIFI (iChip2128)";
}

/*
Expand Down

0 comments on commit 42120e7

Please sign in to comment.