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.

143 lines
2.7 KiB

  1. /*
  2. Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. version 2 as published by the Free Software Foundation.
  6. 03/17/2013 : Charles-Henri Hallard (http://hallard.me)
  7. Modified to use with Arduipi board http://hallard.me/arduipi
  8. Changed to use modified bcm2835 and RF24 library
  9. */
  10. /**
  11. * Channel scanner
  12. *
  13. * Example to detect interference on the various channels available.
  14. * This is a good diagnostic tool to check whether you're picking a
  15. * good channel for your application.
  16. *
  17. * Inspired by cpixip.
  18. * See http://arduino.cc/forum/index.php/topic,54795.0.html
  19. */
  20. #include <cstdlib>
  21. #include <iostream>
  22. #include <RF24/RF24.h>
  23. using namespace std;
  24. //
  25. // Hardware configuration
  26. //
  27. // CE Pin, CSN Pin, SPI Speed
  28. // Setup for GPIO 22 CE and GPIO 25 CSN with SPI Speed @ 1Mhz
  29. //RF24 radio(RPI_V2_GPIO_P1_22, RPI_V2_GPIO_P1_18, BCM2835_SPI_SPEED_1MHZ);
  30. // Setup for GPIO 22 CE and CE0 CSN with SPI Speed @ 4Mhz
  31. //RF24 radio(RPI_V2_GPIO_P1_15, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_4MHZ);
  32. // Setup for GPIO 22 CE and CE1 CSN with SPI Speed @ 8Mhz
  33. //RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);
  34. // Generic setup
  35. RF24 radio(22, 0);
  36. //
  37. // Channel info
  38. //
  39. const uint8_t num_channels = 126;
  40. uint8_t values[num_channels];
  41. const int num_reps = 100;
  42. int reset_array=0;
  43. int main(int argc, char** argv)
  44. {
  45. //
  46. // Print preamble
  47. //
  48. //Serial.begin(115200);
  49. //printf_begin();
  50. printf("RF24/examples/scanner/\n");
  51. //
  52. // Setup and configure rf radio
  53. //
  54. radio.begin();
  55. radio.setAutoAck(false);
  56. // Get into standby mode
  57. radio.startListening();
  58. radio.stopListening();
  59. radio.printDetails();
  60. // Print out header, high then low digit
  61. int i = 0;
  62. while ( i < num_channels )
  63. {
  64. printf("%x",i>>4);
  65. ++i;
  66. }
  67. printf("\n");
  68. i = 0;
  69. while ( i < num_channels )
  70. {
  71. printf("%x",i&0xf);
  72. ++i;
  73. }
  74. printf("\n");
  75. // forever loop
  76. while(1)
  77. {
  78. // Clear measurement values
  79. memset(values,0,sizeof(values));
  80. // Scan all channels num_reps times
  81. int rep_counter = num_reps;
  82. while(rep_counter--)
  83. {
  84. int i = num_channels;
  85. while (i--)
  86. {
  87. // Select this channel
  88. radio.setChannel(i);
  89. // Listen for a little
  90. radio.startListening();
  91. delayMicroseconds(128);
  92. radio.stopListening();
  93. // Did we get a carrier?
  94. if ( radio.testCarrier() ) ++values[i];
  95. }
  96. }
  97. // Print out channel measurements, clamped to a single hex digit
  98. i = 0;
  99. while ( i < num_channels )
  100. {
  101. printf("%x",min(0xf,(values[i]&0xf)));
  102. ++i;
  103. }
  104. printf("\n");
  105. }
  106. return 0;
  107. }
  108. // vim:ai:cin:sts=2 sw=2 ft=cpp