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.
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.
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.
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, ¤tS1Pulse), pulseIn(pulsesS2, ¤tS2Pulse));
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.
Another test... Copy from Arduino 1.8.13
/* Sharp IR Range Finder Implementation of Tim Bower's Virtual Triange Wall Follower. * IRFollowWall * Calibration has shown that the IR sensors can measure from 3.9 inches to 31.5 inches. * This is a test using an A* Prime board with two Sharp IR Sensors and a servo to point the leftmost sensor perpendicular to the robot's pose. * IRSensor1 - Pin: A2, 5V * IRSensor2 - Pin: A3, 5V * The two IR sensors are mounted on a servo with a 45 degree angle between them. * The coordinate frame is measured in inches. * The (0,0) of the robot's frame is somewhere behind the two sensors. * * NOTE: a positive AngleToWall => turn left * a negative AngleToWall => turn right This seems like the opposite of a polar coordinate system, ie. substract to turn left, add to turn right * * setM1Speed(int speed) * setM2Speed(int speed) * setSpeeds(int m1Speed, int m2Speed) * Speed should be between -400 and 400 * * Large parts of this sketch were browored from a Pololu compass demo. */ #include <DRV8835MotorShield.h> #include <Wire.h> #include <LSM303.h> #include <math.h>
To err is human.
To really foul up, use a computer.
Using <> after IDE 2.0.0 Copy for Forum (Markdown)
```cpp int8_t PCintPort::addPin(uint8_t arduinoPin, PCIntvoidFuncPtr userFunc, uint8_t mode) { PCintPin* tmp; tmp=firstPin; if (firstPin != NULL) { do { if (tmp->arduinoPin == arduinoPin) { enable(tmp, userFunc, mode); return(0); } if (tmp->next == NULL) break; tmp=tmp->next; } while (true); } ```Using {;} after IDE 2.0.0 Copy for Forum (Markdown)
```cpp int8_t PCintPort::addPin(uint8_t arduinoPin, PCIntvoidFuncPtr userFunc, uint8_t mode) { PCintPin* tmp; tmp=firstPin; if (firstPin != NULL) { do { if (tmp->arduinoPin == arduinoPin) { enable(tmp, userFunc, mode); return(0); } if (tmp->next == NULL) break; tmp=tmp->next; } while (true); } ```
Always copy the code from the editor, not the output console, and manually wrap it using triple backticks (```cpp and ```) for correct syntax highlighting.
void initialize() {
float r, x, y;
buildAngleArray(5.0f); // build out angle array at 5 degree increments
for (int t = 1; t <= sampleSize; t++) {
r = range[t];
x = r * cosf(angle[t]);
y = r * sinf(angle[t]);
printf("range[%d]=%2.7f angle[%d]=%2.7f x=%2.4f y=%2.4f\n",t,range[t],t,angle[t],x,y);
}
segmentation[0].start = 0;
segmentation[0].end = 0;
printf("end initialize() threshold=%2.7f\n\n",threshold);
return;
}
paste from cat of file. had to add spaces.
To err is human.
To really foul up, use a computer.