Reorganization! Move all controllers into their own folders, move all RGBController wrappers into one folder, move i2c_smbus and serial_port dependencies into folders, and move main application/UI stuff into folders. Should help lead into creating a proper library
This commit is contained in:
parent
ef79de6c7c
commit
155ad165b1
61 changed files with 51 additions and 40 deletions
87
Controllers/LEDStripController/LEDStripControllerDetect.cpp
Normal file
87
Controllers/LEDStripController/LEDStripControllerDetect.cpp
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
#include "LEDStripController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_LEDStrip.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectLEDStripControllers *
|
||||
* *
|
||||
* Detect devices supported by the LEDStrip driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
LEDStripController* new_ledstrip;
|
||||
RGBController_LEDStrip* new_controller;
|
||||
|
||||
//Get file path in executable directory
|
||||
std::ifstream infile;
|
||||
char filename[2048];
|
||||
char arg1[64];
|
||||
|
||||
snprintf(arg1, 64, "/proc/%d/exe", getpid());
|
||||
readlink(arg1, filename, 1024);
|
||||
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
|
||||
strcat(filename, "/settings.txt");
|
||||
|
||||
//Open settings file
|
||||
infile.open(filename);
|
||||
|
||||
if (infile.good())
|
||||
{
|
||||
for (std::string line; std::getline(infile, line); )
|
||||
{
|
||||
if (line == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((line[0] != ';') && (line[0] != '#') && (line[0] != '/'))
|
||||
{
|
||||
char * argument;
|
||||
char * value;
|
||||
|
||||
value = (char *)line.c_str();
|
||||
|
||||
argument = strtok_r(value, "=", &value);
|
||||
|
||||
//Strip off new line characters if present
|
||||
argument = strtok(argument, "\r\n");
|
||||
value = strtok(value, "\r\n");
|
||||
|
||||
if(argument)
|
||||
{
|
||||
if (strcmp(argument, "ledstrip") == 0)
|
||||
{
|
||||
new_ledstrip = new LEDStripController();
|
||||
new_ledstrip->Initialize(value);
|
||||
|
||||
new_controller = new RGBController_LEDStrip(new_ledstrip);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
else if (strcmp(argument, "xmas") == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else if (strcmp(argument, "hueplus") == 0)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* DetectLEDStripControllers() */
|
||||
Loading…
Add table
Add a link
Reference in a new issue