void SpektrumRX::logData(void){ sprintf(write_buffer,"%u,%u,%u,%u,%u,%u,%.0f\r\n", channel[0], channel[1], channel[2], channel[3], channel[4], channel[5], timeSinceStart()); writeLogFile(); }
void Game::update(float delta) { timeCounter += delta; this->delta = delta; // calculate lava flow time int lavaInterval = 20; if (inFinalBattle || ((int)timeSinceStart() / lavaInterval) % 2 == 1 || Input::pressed(sf::Keyboard::BackSpace)) { // for debugging purposes flowRate += delta / flowSpeed; } else { flowRate -= delta / flowSpeed; } flowRate = Mth::saturate(flowRate); lavaTime += delta * flowRate; // delay play on music in final battle if (inFinalBattle) { finalBattleMusicTimer += delta; if (finalBattleMusicTimer > 5.0f) { Resources::get().bossTrack.play(); finalBattleMusicTimer = -100000.0f; } } }
SpektrumRX::SpektrumRX(double t0, PWM_module * pwm) { read_len = -1; pwm_module = pwm; sprintf(devicename, "%s", MODEMDEVICE); time_t0 = t0; time_t0 = timeSinceStart(); memset(&reference_command[0], 10, sizeof(float)*6); spektrum_fd = open(devicename, O_RDWR | O_NOCTTY); if (spektrum_fd < 0){ perror(devicename); exit(1); } else std::cout << "Port " << devicename << " successfully opened." << std::endl; tcgetattr(spektrum_fd, &options); options.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); options.c_oflag &= ~(ONLCR | OCRNL); // set baud rate cfsetispeed(&options, B115200); cfsetospeed(&options, B115200); tcsetattr(spektrum_fd, TCSANOW, &options); openLogFile(); if (pthread_create(&autoSample_thread, 0, &thread_catch_spektrumrx, this) != 0){ std::cout << "Receive thread creation error." << std::endl; } // // Make thread priority high // struct sched_param sp; // sp.sched_priority = 95; // pthread_setschedparam(autoSample_thread, SCHED_FIFO, &sp); }