Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BridgeDriver FrontPanelButtons MCP23017 SDFileSystem TextLCD mbed
Diff: Device.hpp
- Revision:
- 0:22618cf06f45
- Child:
- 2:3e7baa3e3fec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Device.hpp Tue Sep 16 15:28:59 2014 +0000
@@ -0,0 +1,73 @@
+#ifndef DEVICE_HPP
+#define DEVICE_HPP
+
+#include "Initialization.hpp"
+#include "mbed.h"
+#include "LocalPinNames.h"
+#include "BridgeDriver.h"
+#include "DeviceClasses.h"
+//#include "Motor.hpp"
+//#include "VoltageDriver.hpp"
+
+enum DeviceType{MOTOR, VOLTAGE_DRIVER};
+static const enum DeviceType Device_Map[] = {MOTOR, VOLTAGE_DRIVER};
+const char *DeviceNames[] = {"MOTOR", "VOLTAGE_DRIVER"};
+extern int numDevices = sizeof(DeviceNames)/sizeof(DeviceNames[0]);
+extern int currNumDevices = 0;
+
+/*
+class Device{
+
+ public:
+ char name[100];
+ static Device* newDevice(int);
+ int interpret();
+};
+
+extern Device devices[15]; //Initialize array of devices, initially assume 15 devices will be used (will expand as needed)
+
+void addDevice(int deviceFound){
+
+ //devices[currNumDevices] = Device::newDevice(deviceFound);
+ currNumDevices++;
+}
+ */
+
+
+
+
+struct DeviceData {
+ DeviceType type;
+ char name[MAX_LINE_LENGTH];
+ union {
+ Voltage_Driver VOLTAGE_DRIVER;
+ Motor MOTOR;
+ };
+};
+
+extern struct DeviceData devices[15]; //Initialize array of devices, initially assume 15 devices will be used (will expand as needed)
+
+void relayLine(DeviceData device){
+ switch(device.type){
+ case MOTOR: device.MOTOR.interpret(); break;
+ case VOLTAGE_DRIVER: device.VOLTAGE_DRIVER.interpret(); break;
+ }
+}
+
+void addDevice(int deviceFound){
+
+ //Save the device type
+ switch (Device_Map[deviceFound]){
+ case MOTOR: devices[currNumDevices].type = MOTOR; break;
+ case VOLTAGE_DRIVER: devices[currNumDevices].type = VOLTAGE_DRIVER; break;
+ }
+
+ strcpy(devices[currNumDevices].name, lineData.word[1]); //Save the Local Name of the Device, the second word in a device adding line is the Local_Name
+ relayLine(devices[currNumDevices]); //Give the command to the appropraite class in order to initialize itself based on the line
+ currNumDevices++; //Increment the total number of devices created
+}
+
+
+
+#endif
+