Windows 10: What is Windows Virtual Shields for Arduino and What Can It Do?

Discus and support What is Windows Virtual Shields for Arduino and What Can It Do? in Windows 10 News to solve the problem; This post is a general overview of the Windows Virtual Shields for Arduino library, one of the technologies being used in the World’s Largest Arduino... Discussion in 'Windows 10 News' started by Brink, Jan 26, 2016.

  1. Brink
    Brink New Member

    What is Windows Virtual Shields for Arduino and What Can It Do?


    As you can see, using a Virtual Shield is simple. In the sketch above, we include all necessary libraries and declare a VirtualShield object. We then declare a specific shield (Screen) object to represent the screen of the Windows 10 companion device in use. The program starts a serial communication, clears the screen of the Windows 10 companion device, and prints the line “Hello Virtual Shields” on the freshly cleared screen.

    A glimpse at the architecture

    Now that we’ve seen a simple sample, we can take a deeper dive into the architecture at play.

    [youtube]6twpmU7FRlA[/youtube]

    The communication between the Arduino library and the Microsoft Store app is done over a USB, Bluetooth, or network connection. The protocol uses JSON by making use of the efficient open-source library ArduinoJson. This is what a simple transaction looks like across the wire (Arduino on left, Windows 10 companion device on right):


    What is Windows Virtual Shields for Arduino and What Can It Do? [​IMG]


    This is a simplified illustration of the basic communication enabled by Windows Virtual Shields for Arduino.

    A more complex sample with sensors

    Let’s take a look at a more realistic example that includes sensors. All sensors in the Windows Virtual Shields for Arduino library have the four functions listed below:

    • get – This function is a one-time data request to a sensor. An example would be reading acceleration values off of an accelerometer.
    • start – The start function begins a series of get calls, performed at a specified interval. The interval could be determined by time (read accelerometer data every second) or value change (report if the acceleration changes by 1 unit).
    • onChange – This function is exactly like start, except it does not report a data reading the first time it is called. It will begin reporting based on a chosen time interval or change in sensor reading.
    • stop – This function ends a running start or onChange
    Working with GPS

    With a base knowledge of how sensors work in Windows Virtual Shields for Arduino, we can take a look at something more specific. The following sample will explore how to pull GPS readings from a Windows 10 device onto an Arduino.

    The code for this example is seen below:

    Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 #include <ArduinoJson.h> #include <VirtualShield.h> #include <Text.h> #include <Geolocator.h> VirtualShield shield; Text screen = Text(shield); Geolocator gps = Geolocator(shield); void gpsEvent(ShieldEvent* shieldEvent) { // If there is a sensor error (errors are negative)... display message if (shieldEvent->resultId < 0) { screen.printAt(3, "Sensor doesn't exist&quotWhat is Windows Virtual Shields for Arduino and What Can It Do? ;); screen.printAt(4, "or isn't turned on.&quotWhat is Windows Virtual Shields for Arduino and What Can It Do? ;); screen.printAt(6, "error: " + String(shieldEvent->resultId)); return; } String lat = String("Lat: &quotWhat is Windows Virtual Shields for Arduino and What Can It Do? ;) + String(gps.Latitude); String lon = String("Lon: &quotWhat is Windows Virtual Shields for Arduino and What Can It Do? ;) + String(gps.Longitude); screen.printAt(3, lat); screen.printAt(4, lon); } void setup() { shield.begin(); screen.clear(); screen.printAt(1, "Basic GPS Lookup&quotWhat is Windows Virtual Shields for Arduino and What Can It Do? ;); gps.setOnEvent(gpsEvent); // Check GPS if reading changes by ~1/6 of a mile gps.start(0, 0.01); } void loop() { shield.checkSensors(); } [/quote] In setup, we initialize the gps.setOnEvent handler to call gpsEvent whenever a response is received. Then in loop, we start the GPS and call the function checkSensors. The call to checkSensors is required to start receiving responses and processing callbacks for any sensor or capability. Finally, the gpsEvent function prints latitude and longitude readings every time the GPS senses a shift greater than our specified delta (0.01 longitudinal/latitudinal degrees).

    Here you can really start to see the power of Windows Virtual Shields for Arduino – it’s simple and easy to pull data from the Windows 10 companion device, and the device unifies a large collection of sensors and actuators that would otherwise be complex and costly.

    A glimpse at the architecture

    In the graphic below, we explore the underlying architecture of the GPS communication sample:


    What is Windows Virtual Shields for Arduino and What Can It Do? [​IMG]


    An end-to-end project


    Now that we’ve seen how sensors and simple screen capabilities work with Windows Virtual Shields for Arduino, we can take a look at a more complete project.

    Check out this simple Hackster.io project to see the library working in action.

    [youtube]GI80hujxg6k[/youtube]

    A quick look at more complex capabilities

    So we’ve sent text to a companion screen, and we know how to get sensor readings. That’s a good start! But we’ve just scratched the surface of what Windows Virtual Shields for Arduino is capable. In this section, we’ll take a brief glimpse at some of the more advanced capabilities that your Arduino can control on your Windows 10 companion device.

    Graphics

    Basic graphics instructions and events are handled the same as sensors. A rectangle instruction
    (id = screen.fillRectangle(80,120,70,70, YELLOW)) would produce the following communication:


    What is Windows Virtual Shields for Arduino and What Can It Do? [​IMG]


    And pressing and releasing the rectangle on the Windows 10 companion device would send back events tied to id.

    Speech

    The speech functionality of Windows Virtual Shields for Arduino includes Text-to-Speech and Speech Recognition. Here we see another huge advantage of Windows Virtual Shields for Arduino – we can leverage the computational power and APIs of the Windows 10 companion device to enable speech scenarios.

    Text-to-Speech is simple and can be initiated by a command such as speech.speak(“Hello World”). This particular command will make the Windows 10 companion device speak the words “Hello World”.

    The Speech Recognition functionality returns an indexed list of choices. Issuing the request recognition.listenFor(“yes,no”) would return an event with where 1=”yes”, 2=”no”, or 0=unrecognized (negative values are error indicators). The event can also account for groupings, such as recognizing a variety of words (“yes”, “yeah”, “ok”) as the single option “yes”. Recognition can also handle open-text, but is limited to 100 characters due to the memory and buffer size of an Arduino.

    Web

    You can also use the web capability to retrieve a web page and parse it before returning a web event to Arduino. This is really useful, as most web pages are larger than the entire Arduino onboard memory. The parsing engine uses an abbreviated instruction set to fully parse a web page.

    The following code retrieves a weather dump from NOAA as a JSON blob, then parses the JSON to retrieve the current weather.

    1
    2
    3 String url = "http://forecast.weather.gov/MapClick.php?lat=47.6694
    String parsingInstructions = "J:location.areaDescription|&^J:time.startPeriodName[0]|&^J:data.weather[0]";
    web.get(url, parsingInstructions);


    The event returns “Redmond WA|This Afternoon|Chance Rain”. As with speech, Windows Virtual Shields for Arduino moves expensive tasks to the companion device, allowing for more free memory on the Arduino.

    Where we want to expand Windows Virtual Shields for Arduino

    Windows Virtual Shields for Arduino has already come so far, but there are many ways in which we could improve the technology further. The great part is, the library is open-source – any developer interested in expanding this technology is more than welcome. All of the code is available from our GitHub page.

    Let’s take a look at three areas we would want to expand upon, if time were no obstacle!

    • First, we would add even more sensors and capabilities. NFC would make an excellent addition – this would enable scenarios like unlocking a door with your phone or transferring NFC payments. Others desired sensors and capabilities include: an Iris scanner (e.g. on a Lumia 950 XL); FM radio control; and device geofencing (rather than using the GPS and coding it yourself on Arduino). Also, Cortana would make an excellent addition.
    • Next, we could improve existing sensors and capabilities. For example, GPS returns a latitude, longitude, and altitude, and the sensor can be triggered on a settable delta. However, that delta is singular and applies to all properties equally. If you wanted to monitor a small change altitude, but not latitude or longitude – or ignore a large change in altitude (e.g. a tall building), then the sensor system would need more than one delta to monitor.
    • A third option would be to expand the scope. The Universal Windows Application currently connects to only one device at a time. We can imagine scenarios where multiple Arduinos can connect to a single app, such as in a home control systems (e.g. self-registering heating ducts opening/closing depending upon where you are).
    And of course, there are countless other ways in which this technology can evolve. Explore it yourself, and see what you can build!

    The World’s Largest Arduino Maker Challenge

    Now that you’ve learned the ins and outs of Windows Virtual Shields for Arduino, it’s time to put your newly-learned skills to the test. The World’s Largest Arduino Maker Challenge would be a great opportunity to make use of the library.

    The competition’s title is no overstatement – with more than 3,000 participants and 1,000 submitted project ideas in just the preliminary phase, this is truly the World’s Largest Arduino Maker Challenge. The contest is brought to you by Microsoft, Hackster.io, Arduino, Adafruit, and Atmel.

    The parameters of the contest are simple – participants must develop a Universal Windows Application (UWA) that interfaces with an Arduino using a connection. Windows Virtual Shields for Arduino and Windows Remote Arduino are two recommended ways of establishing this connection. Check out the contest site for more details.

    We hope you take this opportunity to learn more about the library and submit something great for the World’s Largest Arduino Maker Challenge! We can’t wait to see what you make!

    [/quote]
    Source: What is Windows Virtual Shields for Arduino and What Can It Do? | Building Apps for Windows

    :)
     
    Brink, Jan 26, 2016
    #1
  2. what!?!? Win User

    Apps not closing, still running in background

    Thanks for the response. I am not looking for a "close all" function. Sometimes I intentionally want to leave an app running. In windows phone 8.1, I could exit and close th app by merely selecting the arrow/back button, I am looking for that same functionality.
    When I'm in an app, I want to be able to exit directly from there and not have it continuing in the background.
     
    what!?!?, Jan 26, 2016
    #2
  3. what!?!? Win User
    Apps not closing, still running in background

    I just got my Lumia 950 phone. On my prior Windows phone, when I pressed the arrow/back button on the bottom left screen, I would exit the app. On Windows 10 phone, I've been doing that and I just realized I'm not exiting the apps. I had intentionally not
    exited an app (because it had my boarding pass). Instead of back button, I pressed the middle window button. Later when I went back to call up my airline app, I pressed the arrow/back button and held it. Similar to my old windows phone, it showed me all the
    apps that were open. SURPRISE! unlike my previous phone, no app had been closing. Right now, I can't seem to find a "one click" way to exit an app. The only way is after I've done a few things, I hold the back button and click the "X" on each of the open items.

    Can someone tell me how to exit an app with one click or swipe so that it is not still running, i.e. when I press the back button I will not see it? I'm sure this is something simple. I search the instructions that came with the phone and looked in the
    forum but haven't found the answer.

    thanks in advance the assist.
     
    what!?!?, Jan 26, 2016
    #3
Thema:

What is Windows Virtual Shields for Arduino and What Can It Do?

Loading...
  1. What is Windows Virtual Shields for Arduino and What Can It Do? - Similar Threads - Virtual Shields Arduino

  2. What is a virtual network?

    in Windows 10 Software and Apps
    What is a virtual network?: What is a virtual network? https://answers.microsoft.com/en-us/windows/forum/all/what-is-a-virtual-network/df6861de-f0d7-4c83-a894-c5a89fac32dd
  3. What Is Virtual Memory?

    in Windows 10 Gaming
    What Is Virtual Memory?: Something Called Virtual Memory is using up 330 Gigabytes of 464. I was just figuring out things in Settings, after so many things i got into System > Storage. i looked up after "More" and i saw "System And Reserved" and then i saw Virtual Memory. Please tell me how to clean...
  4. What Is Virtual Memory?

    in Windows 10 BSOD Crashes and Debugging
    What Is Virtual Memory?: Something Called Virtual Memory is using up 330 Gigabytes of 464. I was just figuring out things in Settings, after so many things i got into System > Storage. i looked up after "More" and i saw "System And Reserved" and then i saw Virtual Memory. Please tell me how to clean...
  5. What was Shield streaming?

    in Windows 10 Software and Apps
    What was Shield streaming?: Windows 10 Home 2004 Hello, It is only available in Windows Pro? Thanks [img] 162825
  6. WHAT IS VIRTUAL RAM??????

    in Windows 10 Customization
    WHAT IS VIRTUAL RAM??????: MY PC HAS 2 GB RAM INSTALLED. IT AUTOMATICALLY SETS 2 GB AS VIRTUAL RAM. I SEE MY PC RAN SLOW SO I SET VIRTUAL RAM TO 8 GB. NOW PERFORMANCE JUST IMPROVED. What is virtual ram?????? What Is the use of virtual ram???? How is it works?????? Is there anything to do...
  7. what is the Microsoft green shield on the sender's name.

    in AntiVirus, Firewalls and System Security
    what is the Microsoft green shield on the sender's name.: What is the Microsoft green shield on the sender's name, an where is it located andwhat does it look like https://answers.microsoft.com/en-us/windows/forum/all/what-is-the-microsoft-green-shield-on-the-senders/b35c5f51-45ca-42cd-9f7c-e1d0e9299000"
  8. whats virtualization and what does it do?

    in AntiVirus, Firewalls and System Security
    whats virtualization and what does it do?: hi I just enabled virtualization in my bios settings for my notebook because I was experimenting with a feature I was aware the pc had but never used it,but core isolation settings in windows security says its can't be enabled because something might be incompatable,i...
  9. What does the shield mean>

    in Windows 10 BSOD Crashes and Debugging
    What does the shield mean>: I have some programs on my desktop (both 7 & 10) that have a shield on them What does it mean?[ATTACH] https://answers.microsoft.com/en-us/windows/forum/windows_10-performance/what-does-the-shield-mean/d0105021-66fc-4cca-8c4c-7edd6bcaaedb
  10. What is Windows Remote Arduino and What Can It Do?

    in Windows 10 News
    What is Windows Remote Arduino and What Can It Do?: This post is an overview of the Windows Remote Arduino library, one of the technologies used in the World’s Largest Arduino Maker Challenge. Windows Remote Arduino is an open-source Windows library that allows any Windows 10 device – be it a Windows Phone, Surface, PC, or...