New version of AVR Library (100326): X2 support (and more)

Hello,

We have released a new version of the Pololu AVR Library (release 100326).

  • The library now fully supports the Orangutan X2.
  • New analog functions: analog_read_average_millivolts(), read_trimpot_millivolts(), analog_conversion_result_millivolts(), read_vcc_millivolts(), and set_millivolt_calibration(). The last two functions make it possible to measure your logic voltage and calibrate your millivolt conversions for the times when it is not 5V.
  • New pushbutton functions: get_single_debounced_button_press() and get_single_debounced_button_release(). These functions are non-blocking and make it much easier to add button-triggered events to your main loop.
  • It is now possible to alternate between using OrangutanServos functions and OrangutanBuzzer functions in the same program, though it is still not possible to have both active at the same time. The servos_stop() function was added to free up Timer1 for other uses (such as generating buzzer signals).
  • Fixed LCD printf() bug that was causing it to act as if the LCD on the Orangutan SVP was only 8x2 rather than 16x2. The function lcd_init_printf() now correctly initialized printf() for the default LCD size of the device being used (20x4 for the X2, 16x2 for the SVP, and 8x2 for all else). Added the function lcd_init_printf_with_dimensions(), which lets you specify the LCD dimensions (in case you are using a different LCD or only want to use a portion of your LCD).
  • The OrangutanLCD functions now work better on Orangutan SVPs that have their LCDs removed. Previously each LCD command would take 10 ms to timeout in such a situation, causing code with a lot of LCD function calls to run much more slowly with the LCD off than with the LCD on. Now such functions will timeout after 50 us when the LCD is off. The LCD timeout is only an issue with the Orangutan SVP.
  • The interrupt that drives the OrangutanTime system timer has been rewritten in assembly to be approximately twice as fast, so it takes up less of the available processing time.
  • Added the OrangutanTime function get_ticks(), which returns the number of ticks (in units of 0.4 us) that have elapsed since the first time an OrangutanTime function was called. The ticks counter does not get reset by the time_reset() function like the millisecond counter does. Ticks can be used as a high-resolution system timer that overflows every 28.6 minutes.
  • Rewrote the OrangutanPulseIn code to use system ticks for timing rather than Timer1, making it much easier to use. It lets you measure high and low pulses with 0.4us resolution and lengths up to 28 minutes on arbitrary digital inputs, and it works entirely in the background, driven by pin-change interrupts. It can be used to measure the duty cycles and frequencies of PWM signals, to read hobby servo pulses, etc.
  • Added a number of new example programs: lcd3-hello-world, pulsein1, pulsein2, pushbuttons2, serial2, servos1, servos-and-buzzer, stepper-motor1, wdt, and x2-demo-program. The stepper-motor1 example shows how you can control a single bipolar stepper motor with the motor driver outputs of any Orangutan. See the comments at the tops of the example program C files for information on what they do and how to use them.

You can download the library here. Since this was a fairly substantial update to the library, please don’t hesitate to let us know if any part of the library seems not to be working the way you expect. As always, we would love to hear any comments and suggestions you have!

Also, we are still in the process of updating the library documentation to cover this new release, so parts of the documentation will be incomplete (and possibly out of date) for the next few days.

Thanks,
-Ben