Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.

Commit

Permalink
Various Lightning fixes
Browse files Browse the repository at this point in the history
Bug fixes to address various issues:
- Enable building a DEBUG Nuget package
- Removed redundant abs function from arduino.h, because it breaks
building some flavors
And, to improve source compatibility with existing Arduino Wiring
sketches :
- Added missing typedefs and functions to pgmspace
- Added WString.h to Arduino.h
- Added commonly used pin names to pins_arduino.h
  • Loading branch information
MahmoudGSaleh committed Jun 17, 2016
1 parent fb9e6e7 commit f0de020
Show file tree
Hide file tree
Showing 10 changed files with 468 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,5 @@ UpgradeLog*.htm

# Microsoft Fakes
FakesAssemblies/
*.opendb
*.opendb
Library/Lightning.VC.db
2 changes: 1 addition & 1 deletion Library/Lightning.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<CompileAsWinRT>true</CompileAsWinRT>
<AdditionalIncludeDirectories>..\Source;$(ProjectDir);$(DesktopExtSdkDir)INCLUDE\WinRT;$(DesktopExtSdkDir)INCLUDE\UM;..\SDKFromArduino\include;$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<PreprocessorDefinitions>%(PreprocessorDefinitions);WINAPI_PARTITION_PC_APP=1;LIGHTNING_DLL_EXPORTS;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;</PreprocessorDefinitions>
<PreprocessorDefinitions>%(PreprocessorDefinitions);WINAPI_PARTITION_PC_APP=1;LIGHTNING_DLL_EXPORTS;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
48 changes: 48 additions & 0 deletions Nuget/Microsoft.IoT.Lightning.Debug.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Microsoft.IoT.Lightning</id>
<version>1.1.0</version>
<title>Microsoft IoT Lightning SDK</title>
<authors>Microsoft Open Technologies, Inc.</authors>
<owners>Microsoft Open Technologies, Inc.</owners>
<licenseUrl>http://www.microsoft.com/en-us/legal/intellectualproperty/copyright/default.aspx</licenseUrl>
<projectUrl>https://github.com/ms-iot/lightning</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>The Lightning SDK allows rapid creation of applications for Windows Iot Core devices using the familiar Arduino interface.</description>
<summary>Microsoft IoT Lightning SDK</summary>
<releaseNotes />
<copyright>Copyright 2015</copyright>
<tags>lightning arduino microsoft native nativepackage</tags>
</metadata>

<files>

<file target="build\native\Microsoft.IoT.Lightning.targets" src="Microsoft.IoT.Lightning.targets" />
<file target="lib\uap10.0\Microsoft.IoT.Lightning.Providers.winmd" src="..\Library\Debug\Microsoft.Iot.Lightning.Providers\Microsoft.IoT.Lightning.Providers.winmd" />

<file target="runtimes\win10-x86\native\Lightning.dll" src="..\Library\Debug\Lightning\Lightning.dll" />
<file target="runtimes\win10-arm\native\Lightning.dll" src="..\Library\ARM\Debug\Lightning\Lightning.dll" />
<file target="runtimes\win10-x64\native\Lightning.dll" src="..\Library\x64\Debug\Lightning\Lightning.dll" />

<file target="runtimes\win10-x86\native\Microsoft.IoT.Lightning.Providers.dll" src="..\Library\Debug\Microsoft.Iot.Lightning.Providers\Microsoft.IoT.Lightning.Providers.dll" />
<file target="runtimes\win10-arm\native\Microsoft.IoT.Lightning.Providers.dll" src="..\Library\ARM\Debug\Microsoft.Iot.Lightning.Providers\Microsoft.IoT.Lightning.Providers.dll" />
<file target="runtimes\win10-x64\native\Microsoft.IoT.Lightning.Providers.dll" src="..\Library\x64\Debug\Microsoft.Iot.Lightning.Providers\Microsoft.IoT.Lightning.Providers.dll" />

<file target="lib\win10-x86\native\Lightning.lib" src="..\Library\Debug\Lightning\Lightning.lib" />
<file target="lib\win10-arm\native\Lightning.lib" src="..\Library\ARM\Debug\Lightning\Lightning.lib" />
<file target="lib\win10-x64\native\Lightning.lib" src="..\Library\x64\Debug\Lightning\Lightning.lib" />

<file target="include" src="..\Source\*.h" />
<file target="include\avr" src="..\Source\avr\*.h" />
<file target="include" src="..\SDKFromArduino\include\*.h" />

</files>

</package>






4 changes: 3 additions & 1 deletion Nuget/build-nupkg.cmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
@echo off
setlocal enableextensions disabledelayedexpansion
set NUSPEC="Microsoft.IoT.Lightning.nuspec"

:: Parse options
:GETOPTS
if /I "%~1" == "/?" goto USAGE
if /I "%~1" == "/Help" goto USAGE
if /I "%~1" == "/clean" set CLEAN=1
if /I "%~1" == "/nopack" set NOPACK=1
if /I "%~1" == "/debug" set NUSPEC="Microsoft.IoT.Lightning.Debug.nuspec"
shift
if not (%1)==() goto GETOPTS

Expand All @@ -25,7 +27,7 @@ IF ERRORLEVEL 1 (
echo Please install nuget.exe from http://nuget.org
goto err
)
nuget pack Microsoft.IoT.Lightning.nuspec -NoPackageAnalysis || goto err
nuget pack %NUSPEC% -NoPackageAnalysis || goto err

:end

Expand Down
44 changes: 33 additions & 11 deletions Providers/Microsoft.Iot.Lightning.Providers.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINRT_DLL;LIGHTNING_DLL_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
Expand All @@ -138,7 +138,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;LIGHTNING_DLL_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
Expand All @@ -155,7 +155,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINRT_DLL;LIGHTNING_DLL_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
Expand All @@ -173,7 +173,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;LIGHTNING_DLL_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
Expand All @@ -190,7 +190,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINRT_DLL;LIGHTNING_DLL_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
Expand All @@ -207,7 +207,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;LIGHTNING_DLL_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
Expand All @@ -231,6 +231,33 @@
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\SDKFromArduino\source\IPAddress.cpp" />
<ClCompile Include="..\SDKFromArduino\source\LiquidCrystal.cpp" />
<ClCompile Include="..\SDKFromArduino\source\Print.cpp" />
<ClCompile Include="..\SDKFromArduino\source\Stepper.cpp" />
<ClCompile Include="..\SDKFromArduino\source\Stream.cpp" />
<ClCompile Include="..\SDKFromArduino\source\WString.cpp" />
<ClCompile Include="..\source\arduino.cpp" />
<ClCompile Include="..\source\BcmI2cController.cpp" />
<ClCompile Include="..\source\BcmSpiController.cpp" />
<ClCompile Include="..\source\BoardPins.cpp" />
<ClCompile Include="..\source\BtI2cController.cpp" />
<ClCompile Include="..\source\BtSpiController.cpp" />
<ClCompile Include="..\source\DmapErrors.cpp" />
<ClCompile Include="..\source\DmapSupport.cpp" />
<ClCompile Include="..\source\eeprom.cpp" />
<ClCompile Include="..\source\GpioController.cpp" />
<ClCompile Include="..\source\GpioInterrupt.cpp" />
<ClCompile Include="..\source\HardwareSerial.cpp" />
<ClCompile Include="..\source\I2c.cpp" />
<ClCompile Include="..\source\I2cController.cpp" />
<ClCompile Include="..\source\I2cTransaction.cpp" />
<ClCompile Include="..\source\NetworkSerial.cpp" />
<ClCompile Include="..\source\PCA9685Support.cpp" />
<ClCompile Include="..\source\PulseIn.cpp" />
<ClCompile Include="..\source\Servo.cpp" />
<ClCompile Include="..\source\Spi.cpp" />
<ClCompile Include="..\source\SpiController.cpp" />
<ClCompile Include="AdcDeviceProvider.cpp" />
<ClCompile Include="GpioDeviceProvider.cpp" />
<ClCompile Include="I2cDeviceProvider.cpp" />
Expand Down Expand Up @@ -258,10 +285,5 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
</Xml>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Library\Lightning.vcxproj">
<Project>{5a83971a-3144-42c4-a59c-50ce291a5540}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
87 changes: 87 additions & 0 deletions Providers/Microsoft.Iot.Lightning.Providers.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<Filter Include="Dependencies">
<UniqueIdentifier>{8e086a04-3e6f-4b05-8632-aa6778921990}</UniqueIdentifier>
</Filter>
<Filter Include="Lightning">
<UniqueIdentifier>{fce8ddb6-24fb-4dbc-af5c-69a964538bbd}</UniqueIdentifier>
</Filter>
<Filter Include="SDKFromArduino">
<UniqueIdentifier>{4f3c2e96-909d-45b7-ab2f-d62797f00765}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
Expand All @@ -16,6 +22,87 @@
<ClCompile Include="ApiSupport.cpp">
<Filter>Dependencies</Filter>
</ClCompile>
<ClCompile Include="..\source\arduino.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\BcmI2cController.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\BcmSpiController.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\BoardPins.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\BtI2cController.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\BtSpiController.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\DmapErrors.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\DmapSupport.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\eeprom.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\GpioController.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\GpioInterrupt.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\HardwareSerial.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\I2c.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\I2cController.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\I2cTransaction.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\NetworkSerial.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\PCA9685Support.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\PulseIn.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\Servo.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\Spi.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\source\SpiController.cpp">
<Filter>Lightning</Filter>
</ClCompile>
<ClCompile Include="..\SDKFromArduino\source\IPAddress.cpp">
<Filter>SDKFromArduino</Filter>
</ClCompile>
<ClCompile Include="..\SDKFromArduino\source\LiquidCrystal.cpp">
<Filter>SDKFromArduino</Filter>
</ClCompile>
<ClCompile Include="..\SDKFromArduino\source\Print.cpp">
<Filter>SDKFromArduino</Filter>
</ClCompile>
<ClCompile Include="..\SDKFromArduino\source\Stepper.cpp">
<Filter>SDKFromArduino</Filter>
</ClCompile>
<ClCompile Include="..\SDKFromArduino\source\Stream.cpp">
<Filter>SDKFromArduino</Filter>
</ClCompile>
<ClCompile Include="..\SDKFromArduino\source\WString.cpp">
<Filter>SDKFromArduino</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
Expand Down
19 changes: 13 additions & 6 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ set config=Release

:msbuild
@rem Skip project generation if requested.
if defined nobuild goto exit
if defined nobuild goto pack

@rem Check if VS build env is available
if defined VCINSTALLDIR goto msbuild-found
Expand All @@ -104,18 +104,25 @@ if errorlevel 1 exit /b 1
msbuild Library\Lightning.sln /m /t:%target% /p:Configuration=%config% /p:Platform=x64 /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 exit /b 1

:pack
cd Nuget
CALL build-nupkg.cmd

if not "%config%"=="Debug" goto releasebuild
CALL build-nupkg.cmd /debug
cd ..
goto exit

:releasebuild
CALL build-nupkg.cmd
cd ..
goto :exit

:help
echo vcbuild.bat [debug/release] [clean] [nobuild]
echo build.bat [debug/release] [clean] [nobuild]
echo Examples:
echo vcbuild.bat : builds debug build
echo vcbuild.bat test : builds debug build and runs tests
echo vcbuild.bat release bench: builds release build and runs benchmarks
echo build.bat : builds release build
echo build.bat debug : builds debug build
echo build.bat nobuild : Create nuget only
goto exit

:exit
2 changes: 1 addition & 1 deletion source/arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "Adc.h"
#include "pins_arduino.h"
#include "PulseIn.h"
#include "WString.h"

#include "avr/macros.h"

Expand Down Expand Up @@ -117,7 +118,6 @@ inline int Log(const wchar_t *format, ...)
}

// Arduino math definitions
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) do {amt=((amt)<(low)?(low):((amt)>(high)?(high):(amt)));} while (0)
#define sq(x) ((x)*(x))
inline long map(long x, long in_min, long in_max, long out_min, long out_max)
Expand Down
Loading

0 comments on commit f0de020

Please sign in to comment.