diff --git a/espCode/src/main.cpp b/espCode/src/main.cpp index 831b510..89544ce 100644 --- a/espCode/src/main.cpp +++ b/espCode/src/main.cpp @@ -38,7 +38,7 @@ void setup(){ mlx.setMode(MLX90640_CHESS); mlx.setResolution(MLX90640_ADC_16BIT); mlx90640_resolution_t res = mlx.getResolution(); - mlx.setRefreshRate(MLX90640_8_HZ); + mlx.setRefreshRate(MLX90640_16_HZ); mlx90640_refreshrate_t rate = mlx.getRefreshRate(); Wire.setClock(2000000); } diff --git a/testApp/build.sh b/testApp/build.sh new file mode 100644 index 0000000..2b8ffdc --- /dev/null +++ b/testApp/build.sh @@ -0,0 +1 @@ +g++ -o test ./*.cpp -lCppLinuxSerial \ No newline at end of file diff --git a/testApp/test b/testApp/test index bd57d41..aacf3f6 100755 Binary files a/testApp/test and b/testApp/test differ diff --git a/testApp/test.cpp b/testApp/test.cpp index 190f85e..97c40c4 100644 --- a/testApp/test.cpp +++ b/testApp/test.cpp @@ -11,13 +11,25 @@ #include +std::vector split(std::string str, std::string c){ + std::vector out; + std::string token; + size_t pos = 0; + while ((pos = str.find(c)) != std::string::npos) { + token = str.substr(0, pos); + out.push_back(token); + str.erase(0, pos + c.length()); + } + return out; +} + int main(){ mn::CppLinuxSerial::SerialPort serialPort("/dev/ttyACM0", mn::CppLinuxSerial::BaudRate::B_460800, mn::CppLinuxSerial::NumDataBits::EIGHT, mn::CppLinuxSerial::Parity::NONE, mn::CppLinuxSerial::NumStopBits::ONE); - serialPort.SetTimeout(100); // Block for up to 100ms to receive data + serialPort.SetTimeout(150); // Block for up to 100ms to receive data serialPort.Open(); float out_buf[24][32]; @@ -27,14 +39,40 @@ int main(){ while(true){ serialPort.Write("@"); while(s.find('@') == std::string::npos){ - std::cout << s.find('@') << std::endl; std::string readData; serialPort.Read(readData); s += readData; - std::cout << readData << std::endl; } - std::cout << "found \\n at pos: " << s.find('\n') << std::endl; - std::cout << s << std::endl; + s = s.substr(0,s.length()-2); + std::vector splitted = split(s, "|"); + std::vector treated; + for(std::string str : splitted){ + treated.push_back(std::stof(str)); + } + //system("clear"); + for(int i = 0; i < 24; i++){ + for(int j = 0; j < 32; j++){ + if(i*32+j >= treated.size()) break; + float t = treated.at(i*32+j); + if(t != NULL){ + std::string c = " "; + if (t < 20) c = " "; + else if (t < 23) c = "░"; + else if (t < 25) c = "░"; + else if (t < 27) c = "▒"; + else if (t < 29) c = "▒"; + else if (t < 31) c = "▓"; + else if (t < 33) c = "▓"; + else if (t < 35) c = "█"; + else if (t < 37) c = "█"; + std::cout << c; + }else{ + std::cout << " "; + } + if(j == 31) + std::cout << std::endl; + } + } s = ""; } return 0;