Latest commits (Ultibo core 1.2.127)

Releases, updates and announcements from the Ultibo team.
User avatar
Site Admin
Posts: 1975
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Latest commits (Ultibo core 1.2.127)

Postby Ultibo » Tue Aug 23, 2016 6:11 am

The latest commits for Ultibo core are now available on GitHub. Changes include PWM support, WiringPi API, enhancements, bug fixes and more.

Brief list of changes:

  • Add PWM device unit and hardware PWM drivers for Raspberry Pi
  • Add port of WiringPi API including WiringPiI2C, WiringSerial and WiringPiSPI
  • Fix ConsoleWindowClearEx() to only reset the cursor position to top left when requested (Affected ConsoleClrEol function)
  • Fix ConsoleReadLn to support basic handling of Backspace and Tab keys
  • Expand SysBasicEventWaitFor return values to support TEventObject.WaitFor
  • Add new SysRandomize() function to allow RandSeed to be initialized with a unique value when calling Randomize()
  • Fix extra invalid character at the end of any domain name value obtained via DHCP
  • Add implementation of ConsoleWindowScrollLeft() and ConsoleWindowScrollRight() functions
  • Add handling of WINDOW_FLAG_AUTO_SCROLL flag in Console unit
  • Change Console and Console Window to use a recursive Mutex, remove code to release lock on recursive calls
  • Fix handling of certain removable USB drives with no partitions, would not be recognized as a valid drive
  • Update Timezone unit with latest world timezone data
  • Change VirtualDisk unit to implement correct locking in all functions and remove unnecessary exception handlers
  • Add new GPIOAvailable() function in Platform unit with implementation from GPIO unit
  • Add new ConsoleWindowResetViewport() and ConsoleWindowResetRect() functions
  • Fix ConsoleWindowClear() and ConsoleWindowClearEx() incorrect X2 and Y2 values on character console
  • Remove dependancy of Ultibo unit on Console and Font units
  • Fix cursor tracking on HD44780 console driver
  • Change the VirtualGPIO API in Platform to be in line with the GPIO functions
  • Modify PlatformRPi and PlatformRPi2 units to allow Activity LED support if no GPIO driver included
  • Add additional CLOCK_ID_* values and correct the translation of some existing ones

PWM driver:

As per the standard device model in Ultibo core, the PWM implementation includes a device unit to provide the API and Raspberry Pi specific drivers for each model. The drivers provide access to both PWM channels in the Raspberry Pi and support setting all available parameters including clock frequency, range, mode and duty cycle. While the PWM device does not specifically deal with PWM audio it is possible to generate tones using the PWM device in the Raspberry Pi by setting the correct GPIO pins when configuring the PWM device, a later driver will deal with specific support for audio playback using PWM on the Raspberry Pi.

To use the PWM device API include the PWM unit in your project, the API includes the following functions:

  • PWMDeviceStart - Start a PWM device
  • PWMDeviceStop - Stop a PWM device
  • PWMDeviceWrite - Write a data value (duty cycle) to a PWM device
  • PWMDeviceGet/SetGPIO - Get or Set the GPIO pin for a PWM device
  • PWMDeviceGet/SetMode - Get or Set the mode for a PWM device
  • PWMDeviceGet/SetRange - Get or Set the range (period) for a PWM device
  • PWMDeviceGet/SetFrequency - Get or Set the clock frequency for a PWM device
  • PWMDeviceGet/SetPolarity - Get or Set the output polarity for a PWM device
  • PWMDeviceConfigure - Configure the Duty cycle and output period (in nanoseconds) for a PWM device (This is similar to the Linux API)
  • PWMDeviceProperties - Get the properties of a PWM device to determine what features it supports and the current settings
See the comments in the header of each function for details of the required parameters.

WiringPi API port:

This commit includes a working port of Gordon Hendersons WiringPi library (, the WiringPi library is designed to provide a subset of the Wiring library used by Arduino and other microcontrollers and has been used in a large number of Raspberry Pi examples. It has also been ported to other languages such as Python, Perl and Ruby, the Ultibo port of WiringPi is intended to allow easy translation of examples by providing the API as closely as possible to the original.

At this stage all of the setup, core, timing, threads, priority, interrupt, shift and Raspberry Pi specific functions are implemented as well as the I2C, serial and SPI library functions. This should be sufficient to allow porting of many existing examples without needing to change function names, pins or parameter values, for full documentation and more information see the WiringPi reference ( as well as many other online sources of information.

The WiringPi library also includes support of a range of I2C and SPI devices such as I/O expanders, Analog to Digital (and Digital to Analog) converters, real time clocks and LCD displays ( If these devices are not yet natively supported in Ultibo core then the Wiring unit will also allow easy porting of these extensions from WiringPi.

For details of how to apply the latest source to your Ultibo core installation and rebuild your run time library see the wiki page Building from Source or watch the Building the RTL video on YouTube. | Make something amazing
Posts: 1387
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Latest commits (Ultibo core 1.2.127)

Postby Gavinmc42 » Tue Aug 23, 2016 8:06 am

You have been busy.
PWM audio will be interesting.

Putting a speaker in some of my IoT stuff as audio alarms with the possibility of playing wav formatted warning.
"Warning, warning, freezer one is melting" etc, flashing lights people ignore sometimes.
"Step away from the vehicle", push bike alarm made from Pi Zero.

Was looking in the WiringI2C.pas code to see if I can use all three i2c.
Looks like this is only for one, but is it the right one, I2C0?

Code: Select all

function wiringPiI2CSetup(devId:LongInt):LongInt;
{Open the I2C device, and regsiter the target (slave) device}
 if rev = 1 then
 else if rev = 2 then
User avatar
Site Admin
Posts: 1975
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Latest commits (Ultibo core 1.2.127)

Postby Ultibo » Tue Aug 23, 2016 11:46 pm

Gavinmc42 wrote:Was looking in the WiringI2C.pas code to see if I can use all three i2c.
Looks like this is only for one, but is it the right one, I2C0?

I2C0 is the correct one when the default settings are used because this is an Ultibo device name not a Linux or RPi device name and the default setup only enables one I2C device.

There is however an extra function in WiringI2C called wiringPiI2CSetupInterface which is part of the original library but not documented, it allows specifying a device by name and would work with more than one I2C device if the settings in GlobalConfig were also changed to allow more than one to be enabled.

So the unit actually allows for options in both cases and still remains fully compatible with the original, it just looks different because it doesn't use the Linux names. | Make something amazing

Return to “Ultibo”

Who is online

Users browsing this forum: No registered users and 1 guest