tx-gxx-linux/device/gxx-linux/small_lcd/app_spi_lcd/DevUtil.cpp

35 lines
660 B
C++
Raw Permalink Normal View History

#include "DevUtil.h"
#include <fstream>
2023-05-02 01:50:55 +00:00
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <stdlib.h>
#include <fcntl.h>
int read_dev_i(std::string path) {
int val = -1;
std::ifstream ifin(path.c_str());
ifin >> val;
return val;
}
std::string read_dev_s(std::string path) {
std::string val;
std::ifstream ifin(path.c_str());
ifin >> val;
return val;
}
DeviceExport::DeviceExport()
{
int num = sizeof(ports) / sizeof(ports[0]);
for (int i = 0; i < num; i++)
write_dev(IOEXPORTPATH, ports[i]);
num = sizeof(pwms) / sizeof(pwms[0]);
for (int i = 0; i < num; i++)
write_dev(string_format(PWMEXPORTPATH, pwms[i]), 0);
}
2023-05-02 01:50:55 +00:00