Skip to content

Commit

Permalink
Merge pull request #301 from campenr/master
Browse files Browse the repository at this point in the history
fixed output and made it consistent with output from Ardunio version.
  • Loading branch information
TMRh20 authored Nov 7, 2016
2 parents 8ea5127 + b233ea1 commit b9a4fc6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 46 deletions.
7 changes: 4 additions & 3 deletions examples/scanner/scanner.ino
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void setup(void)
radio.startListening();
radio.stopListening();

radio.printDetails();

// Print out header, high then low digit
int i = 0;
while ( i < num_channels )
Expand Down Expand Up @@ -102,14 +104,13 @@ void loop(void)

// Listen for a little
radio.startListening();
delayMicroseconds(225);

delayMicroseconds(128);
radio.stopListening();

// Did we get a carrier?
if ( radio.testCarrier() ){
++values[i];
}
radio.stopListening();
}
}

Expand Down
83 changes: 40 additions & 43 deletions examples_linux/extra/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ using namespace std;
//RF24 radio(RPI_V2_GPIO_P1_15, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_4MHZ);

// Setup for GPIO 22 CE and CE1 CSN with SPI Speed @ 8Mhz
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);
//RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);

// Generic setup
RF24 radio(22, 0);

//
// Channel info
Expand Down Expand Up @@ -97,49 +99,44 @@ int main(int argc, char** argv)
}
printf("\n");

// forever loop
// forever loop
while(1)
{
if ( reset_array == 1 )
{
// Clear measurement values
memset(values,0,sizeof(values));
printf("\n");
}

// Scan all channels num_reps times
int i = num_channels;
while (i--)
{
// Select this channel
radio.setChannel(i);

// Listen for a little
radio.startListening();
delayMicroseconds(128);
//radio.stopListening();

// Did we get a carrier?
if ( radio.testCarrier() )
++values[i];
if ( values[i] == 0xf )
{
reset_array = 2;
}
radio.stopListening();
}

// Print out channel measurements, clamped to a single hex digit
i = 0;
while ( i < num_channels )
{
printf("%x",min(0xf,(values[i]&0xf)));
++i;
}

printf("\n");
}

{
// Clear measurement values
memset(values,0,sizeof(values));

// Scan all channels num_reps times
int rep_counter = num_reps;
while(rep_counter--)
{

int i = num_channels;
while (i--)
{

// Select this channel
radio.setChannel(i);

// Listen for a little
radio.startListening();
delayMicroseconds(128);
radio.stopListening();

// Did we get a carrier?
if ( radio.testCarrier() ) ++values[i];
}
}

// Print out channel measurements, clamped to a single hex digit
i = 0;
while ( i < num_channels )
{
printf("%x",min(0xf,(values[i]&0xf)));
++i;
}
printf("\n");
}

return 0;
}

Expand Down

0 comments on commit b9a4fc6

Please sign in to comment.