Forum > Embedded - AVR
UnoLib - library in Pascal for Arduino Uno and ATMega328p
ackarwow:
UnoLib is now also on Reddit (https://www.reddit.com/r/unolib/), so I encourage you to discuss the library there as well. :)
ackarwow:
We have been at work on some significant improvements to the float32.pas unit. We have added the ability to use standard operators like +, -, *, and / directly with the TFloat32 type. We have attached the updated unit and its documentation for you to review, and any help with testing is welcome :)
Here is a sample test program for Arduino Uno
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program TestFloat32; {$IF NOT (DEFINED(atmega328p) or DEFINED(arduinouno) or DEFINED(arduinonano) or DEFINED(fpc_mcu_atmega328p) or DEFINED(fpc_mcu_arduinouno) or DEFINED(fpc_mcu_arduinonano))} {$Fatal Invalid controller type, expected: atmega328p, arduinouno, or arduinonano}{$ENDIF} {$mode ObjFPC}{H+}{$MODESWITCH ADVANCEDRECORDS} uses float32, hardwareserial, timer, stringutils; var StrA, StrB, StrC: string[32]; F32a, F32b, F32c: TFloat32; i: UInt32;begin //type your setup code here Serial.Start(9600); Delay(1000); //program main loop //type your code here while true do begin Serial.WriteLn('BEGIN TEST'); Serial.Flush(); StrA := 'Hello ' + 'How '+ 'Are ' + 'You'; Serial.WriteLn(StrA); Serial.Flush(); StrA := 'Very ' + 'Well '+ 'Thank ' + 'You'; Serial.WriteLn(StrA); Serial.Flush(); StrA := ''; F32a.RawData.Raw := $44201062; // 640.256 StrA := F32a.ToString(3); Serial.Write('TFloat32 : $44201062 = 640.256 result: ' + StrA); Serial.Writeln(''); Serial.Flush(); StrA := ''; F32a.RawData.Raw := $40490FDB; // 3.14159 StrA := F32a.ToString(5); Serial.Write('TFloat32 : $40490FDB = 3.14159 result: ' + StrA); Serial.Writeln(''); Serial.Flush(); StrA := ''; F32a.RawData.Raw := $3F49FBE7; // 0.789 StrA := F32a.ToString(3); Serial.Write('TFloat32 : $3F49FBE7 = 0.789 result: ' + StrA); Serial.Writeln(''); Serial.Flush(); Serial.Flush(); StrA := ''; F32a.RawData.Raw := $C2029DB2; // -32.654 StrA := F32a.ToString(3); Serial.Write('TFloat32 : $C2029DB2 = -32.654 result: ' + StrA); Serial.Writeln(''); Serial.Flush(); StrA := ''; F32a := TFloat32.Create('789.123'); StrA := F32a.ToString(3); Serial.Write('TFloat32.Create(''798.123'') result: ' + StrA); Serial.Writeln(''); Serial.Flush(); StrA := ''; F32b := TFloat32.Create('3.14159'); F32c := Rad2DegFloat32(F32b); StrB := ''; StrC := F32c.ToString(5); Serial.Write('Rad2DegFloat32(3.14159) result: ' + StrC); Serial.Writeln(''); Serial.Flush(); StrC := ''; F32b := TFloat32.Create('3.14159'); F32c := SinFloat32(F32b); StrC := F32c.ToString(5); Serial.Write('SinFloat32(3.14159) result: ' + StrC); Serial.Writeln(''); Serial.Flush(); StrC := ''; F32b := TFloat32.Create('3.14159'); F32c := CosFloat32(F32b); StrC := F32c.ToString(5); Serial.Write('CosFloat32(3.14159) result: ' + StrC); Serial.Writeln(''); Serial.Flush(); StrA := ''; StrB := ''; StrC := ''; F32a := TFloat32.Create('10.0'); F32b := TFloat32.Create('21.0'); F32c := F32a + F32b; StrC := F32c.ToString(6); StrA := F32A.ToString(6); StrB := F32B.ToString(6); Serial.Write(StrA + ' + ' + StrB + ' = ' + StrC); Serial.Writeln(''); Serial.Flush; StrA := ''; StrB := ''; StrC := ''; F32a := TFloat32.Create('125.0'); F32b := TFloat32.Create('4.0'); F32C := F32a mod F32b; StrC := F32c.ToString(6); StrA := F32A.ToString(6); StrB := F32B.ToString(6); Serial.Write(StrA + ' mod ' + StrB + ' = ' + StrC); Serial.Writeln(''); Serial.Flush; Serial.WriteLn('END TEST'); Serial.Flush(); Delay(1000); end;end.
ackarwow:
We have just released UnoLib 1.2 (https://sourceforge.net/projects/unolib/) featuring a new documentation overhaul aimed at making it easier to start using the library. The new How to Start guide offers two paths: a simple, automated setup via AVRPascal IDE or a manual configuration for advanced users (FPCUPdeluxe/Lazarus). We have updated the API for 13 modules, added clear connection diagrams to key examples, and included standard operators (+, -, *, /) for the TFloat32 type.
Changes:
- added the ability to use standard operators (+, -, *, /) directly with the TFloat32 type (by @Dzandaa)
- added new string conversion routines for TFloat32 (by @Dzandaa and @ackarwow)
- added new "docs" directory containing documentation (PDF files) for most library modules and the How to start guide for beginners
ackarwow:
UnoLib has received a small update. Changes include:
- optimized and extended StringUtils routines
- new SPI library unit based on the Arduino implementation
- ILI9163 TFT display example demonstrating SPI communication
The display example uses a 128×128 color TFT display connected to an Arduino Uno and renders the UnoLib logo from program memory using an indexed bitmap and palette.
Repository: https://github.com/ackarwow/unolib
ackarwow:
New version of UnoLib (1.3) has been released. Changes:
- added ArduinoISP.pas example (thanks to Christof Biner for the suggestion)
- added SPI support (spi.pas) and TestILI9163.pas example
- updated stringutils.pas and defs.pas
- made minor changes in fix16.pas
Download: https://sourceforge.net/projects/unolib/
Navigation
[0] Message Index
[#] Next page
[*] Previous page