The Wait method is an instance method, so in order to call it directly I’d need to create an instance of Task. The call to Task.Delay is a static method that returns a Task. The solution turned out to be quite simple, and was sitting right in front of me, in the form of one of the other drivers in GHI’s Bitbucket repo. Given that the hardware responds very quickly, there’s no good reason to make the measurement functions async, so I wanted to avoid that anyway. While this does provide close to the same functionality, that particular syntax requires the containing method to be marked as async, and when I tried that, I found that my entire app ended up hanging. The Gadgeteer driver for the sensor I am using uses Thread.Sleep(1) to provide a 1ms pause as part of the code that reads the temperature and humidity data from the sensor v9ia a digital IO pin.Ī quick Bing search later, I thought I had the answer (I’d link to the post, but the site appears to be down, unfortunately), which was to substitute:įor the call to Thread.Sleep. The important difference, as noted above is that the latter does not support the use of Thread.Sleep to pause execution of a program. NET Gadgeteer programming) and the UWP model which is used on Windows 10 IoT Core. NET Micro Framework (which is the basis for. The trouble that I ran into is that there are some differences in the programming model between the. The good news is that since GHI makes their Gadgeteer mainboard and driver code available on Bitbucket, it was easy to find the driver code for the sensor I’m using and work on a port to work on the Pi. However, in my case, it turned out that the temperature and humidity sensor I was using was an older model which was not directly supported. with drivers that have already been ported to work with Windows 10 IoT Core), integrating them into a UWP project is as simple as downloading the relevant NuGet packages. The original driver included a call to Thread.Sleep, which it turns out is not available in a UWP app.įor Gadgeteer modules that are directly supported (i.e. In my case, I’m running Windows 10 IoT Core on my Pi 2, so that I can stick with programming in C#. NET Gadgeteer TempHumidity module using the GHI Electronics FEZ Cream, which is a HAT (Hardware Attached on Top) for the Raspberry Pi 2 that allows the use of Gadgeteer modules. I was building an app to read sensor data from a. Wanted to share a quick solution to an issue I ran into while working on a Universal Windows Platform (UWP) app for my Raspberry Pi 2.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |