#include #include #include #include #include #include "gpio-mmap.h" using namespace std; int main(int argc, char* argv[]){ ifstream f(argv[1]); vector program; string l; while(f.is_open() && !f.eof()){ getline(f,l); for (string::iterator it = l.begin(); it < l.end(); it++){ if(*it=='[' || *it=='('){ program.push_back(0); }else if(*it==']'){ program.push_back(1); }else if(*it==')'){ program.push_back(2); }else if(*it=='>'){ program.push_back(3); }else if(*it=='<'){ program.push_back(4); }else if(*it=='-'){ program.push_back(5); }else if(*it=='+'){ program.push_back(6); }else if(*it==','){ program.push_back(7); } } } f.close(); uint8_t pins[6] = {16, 7, 2, 6, 4, 5}; gpio_map(); gpio_input(pins[0]/32, pins[0]%32); gpio_input(pins[1]/32, pins[1]%32); for(uint8_t i=2; i<6; i++){ gpio_output(pins[i]/32, pins[i]%32); GPIO_WRITE_PIN(pins[i],0); } cout << "start relais computer now, then hit Enter."; cin.get(); int i=0; while(i>=0 && i>1); GPIO_WRITE_PIN(pins[3], (program[i/10] & 4)>>2); if((i % 10 > 2) && (i % 10 < 7)){ GPIO_WRITE_PIN(pins[2], 1); }else{ GPIO_WRITE_PIN(pins[2], 0); } this_thread::sleep_for(chrono::milliseconds(15)); i+=!GPIO_READ_PIN(pins[0]); i-=!GPIO_READ_PIN(pins[1]); /*if((i+5)%10 == 0){ cout << program[i/10] << ";"; }*/ } if(i<0){ cout << endl << "Warning: Program ended with negative i"; } cout << endl; }