Ein Roboter mit bürstenlosem Antrieb, differenzial und NRF24L01 Funk. Großflächig gebaut um ein großes Solarpanel aufzunehmen. https://gitlab.informatik.hs-fulda.de/fdai5253/roboter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1016 B

  1. #include "compatibility.h"
  2. static struct timeval start, end;
  3. //static long mtime, seconds, useconds;
  4. /**********************************************************************/
  5. /**
  6. * This function is added in order to simulate arduino delay() function
  7. * @param milisec
  8. */
  9. void __msleep(int milisec)
  10. {
  11. struct timespec req = {0};
  12. req.tv_sec = 0;
  13. req.tv_nsec = milisec * 1000000L;
  14. nanosleep(&req, (struct timespec *)NULL);
  15. //usleep(milisec*1000);
  16. }
  17. void __usleep(int milisec)
  18. {
  19. struct timespec req = {0};
  20. req.tv_sec = 0;
  21. req.tv_nsec = milisec * 1000L;
  22. nanosleep(&req, (struct timespec *)NULL);
  23. //usleep(milisec);
  24. }
  25. /**
  26. * This function is added in order to simulate arduino millis() function
  27. */
  28. void __start_timer()
  29. {
  30. gettimeofday(&start, NULL);
  31. }
  32. long __millis()
  33. {
  34. static long mtime, seconds, useconds;
  35. gettimeofday(&end, NULL);
  36. seconds = end.tv_sec - start.tv_sec;
  37. useconds = end.tv_usec - start.tv_usec;
  38. mtime = ((seconds) * 1000 + useconds/1000.0) + 0.5;
  39. return mtime;
  40. }