Notifications
Clear all

Post code test

19 Posts
3 Users
1 Likes
992 Views
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 224
 

Testing a paste from vi running on Macbook

 

    // because i frequently don't get the screen session started in time

    printf("waiting for usb host");

    while (!stdio_usb_connected()) {

      printf(".");

      sleep_ms(500);

    }

    sleep_ms(2000);

 

end paste

To err is human.
To really foul up, use a computer.


   
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 224
 

Testing a paste from Arduino IDE running on Macbook

 

// because i frequently don't get the screen session started in time
printf("waiting for usb host");
while (!stdio_usb_connected()) {
printf(".");
sleep_ms(500);
}
sleep_ms(2000);

 

end paste

To err is human.
To really foul up, use a computer.


   
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 224
 

Copy Special 'plain text' from vi running on Macbook

gpio_set_irq_enabled_with_callback(S2_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true, &rec_callback);
// helper function that calls: gpio_set_irq_enabled(); gpio_set_irq_callback(); irq_set_enabled(IO_IRQ_BANK0, true);
gpio_set_irq_enabled(S1_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);
gpio_set_irq_enabled(S2_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);
gpio_set_irq_enabled(S3_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);
gpio_set_irq_enabled(S4_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);
gpio_set_irq_enabled(S5_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);
gpio_set_irq_enabled(S6_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);
gpio_set_irq_enabled(S7_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);
gpio_set_irq_enabled(S8_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);

 

end paste

To err is human.
To really foul up, use a computer.


   
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 224
 

more paste code fun...

int main() {
  stdio_init_all();

  gpio_init(S1_INP);     // enable I/O set to GPIO_FUNC_SIO and set to input
  gpio_set_dir(S1_INP, GPIO_IN);
  gpio_pull_down(S1_INP);  // the IR goes high when there is a reflection
  gpio_init(S2_INP);
  gpio_set_dir(S2_INP, GPIO_IN);
  gpio_pull_down(S2_INP);

  // because i frequently don't get the screen session started in time
  printf("waiting for usb host");
  while (!stdio_usb_connected()) {
    printf(".");
    sleep_ms(500);
  }
  sleep_ms(2000);

  gpio_set_irq_enabled_with_callback(S2_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true, &rec_callback);
  gpio_set_irq_enabled(S1_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);
  gpio_set_irq_enabled(S2_INP, GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true);

  uint64_t wait_time;

  resetPulseCnts();
  while (true) {

    printf("Sensor 1 %3.2fmm - Sensor 2 %3.2fmm\n",pulseIn(pulsesS1, &currentS1Pulse), pulseIn(pulsesS2, &currentS2Pulse));

    wait_time = time_us_64() + 800000;  // 800ms
    while (time_us_64() < wait_time) { }
    wait_time = time_us_64() + 200000;  // 200ms  So that there is time to catch some pulses
    resetPulseCnts();
    while (time_us_64() < wait_time) { }

  }

  return 0;
}

To err is human.
To really foul up, use a computer.


   
ReplyQuote
Page 2 / 2