Empezando con CerbuinoBee y el Sensor de Temperatura

Una buena forma de empezar, es poder disponer un «paso» a «paso». Atendiendo a la consulta de un lector, me complace compartir con vosotros un punto de entrada para leer la temperatura y la humedad con un «Cerbuino Bee»

Una vez lanzado Visual Studio 2010 con los SDK’s de netmf QFE2 y el SDK 4.2 de GHI, desde el menú ‘Archivo’ >

·     Nuevo Projecto>Visual Basic>Gadgeteer>Net gadgeteer Application (NETMF 4.2)>Asignar nombre>Aceptar

Una vez en el diseñador y desde el ‘toolbox’ pestaña ‘Gadgeteer Mainboars’ seleccionar : Fez Cerbuino Bee, Luego desde la pestaña «seeed» arrastrar y soltar el modulo ‘TemperatureHumidity’, según la siguiente imagen :

Copiar/Pegar el siguiente código.

En el editor Seleccionar la pestaña «Program.vb».

Imports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports Gadgeteer.Modules.Seeed
 
' Ejemplo de lectura de temperatura / humedad 
 
Partial Public Class Program
 
    Private WithEvents timer As GT.Timer = New GT.Timer(1000)
 
    Public Sub ProgramStarted()
        timer.Start()
        Debug.Print("Program Started")
    End Sub
 
    Private blink As Boolean
    Private Sub timer_Tick(timer As Gadgeteer.TimerHandles timer.Tick
        Mainboard.SetDebugLED(blink)
        blink = Not blink
        temperatureHumidity.RequestMeasurement()
    End Sub
 
    Private Sub temperatureHumidity_MeasurementComplete(sender As Gadgeteer.Modules.Seeed.TemperatureHumidity, temperature As Double, relativeHumidity As DoubleHandles temperatureHumidity.MeasurementComplete
        Debug.Print("Temperature :" + temperature.ToString())
        Debug.Print("Humidity : " + relativeHumidity.ToString())
    End Sub
End Class

y en la ventana de ‘Debug’ podreis visualizar los resultados de la captura 🙂

 

Espero que os sea útil,
Feliz Año!
PepLluis,

 

Blinking para Mountaineer, para empezar a probar QFE2.

Un punto de entrada para probar que todo esta bien después de actualizar a QFE2.

using System.Threading;
using Microsoft.SPOT.Hardware;
using Mountaineer.Netmf.Hardware;
 
public class BlinkingLed
{
    public static void Main()
    {
        var Rojo = new OutputPort(OnboardIO.LedRed, false);
        var Verde = new OutputPort(OnboardIO.LedGreen, false);
        var Azul = new OutputPort(OnboardIO.LedBlue, false);
 
        while (true)
        {
            Rojo.Write(true);
            Thread.Sleep(500);
            Verde.Write(true);
            Thread.Sleep(500);
            Azul.Write(true);
            Thread.Sleep(1000);
            Rojo.Write(false);
            Thread.Sleep(500);
            Verde.Write(false);
            Thread.Sleep(500);
            Azul.Write(false);
            Thread.Sleep(100);
        }
    }
}

Saludos,
PepLluis. 

Netduino Plus También habla en VB

Empezando con Netduino Plus en QFE2 y el SDK para 4.2

  1. Instalar Visual Studio en cualquiera de sus versiones
  2. Descargar / Instalar el SDK 4.2 QFE2 de Microframework
  3. Descargar / Instalar el SDK 4.2 de Netduino
  • Lanzar Visual Studio.
  • Nuevo Proyecto
  • Microframework
  • Netduino Plus
  • Copiar el siguiente código y reemplazar por el existente en modulo1
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus
 
Module Module1
 
    Private led As New OutputPort(NetduinoPlus.Pins.ONBOARD_LED, False)
    Private tmr1 As New Timer(New TimerCallback(AddressOf tic), Nothing, 1000, 500)
 
    Sub Main()
        Thread.Sleep(System.Threading.Timeout.Infinite)
    End Sub
 
    Private onOff As Boolean
    Sub tic()
        onOff = Not onOff
        led.Write(onOff)
    End Sub
 
End Module

Feliz Navidad!
PepLluis,

 

 

Bon Nada! – Feliz Navidad – Merry Christmas 2012

Feliz Navidad y Prospero año nuevo!
Con la esperanza de reconciliar a la sociedad para encontrar nuevas formas de recuperar puestos de trabajo y el bienestar de las personas necesitadas.
Sin duda necesitamos caminar juntos para definir nuevos escenarios para que el mundo sea relamente mejor.
Mis mejores deseos para que este 2013 se convierta en el Año de pan con azúcar y vino!
 
Merry Christmas to you and your family as well
Hoping reconcile the society to find new ways to recover jobs and the day to day welfare for the needy people.
With no doubt we need walk together to define a new scenario to make the world better.
My best wishes to make this 2013 becomes the Year of bread with sugar and wine!
:-))
 
Tio
 
Pep Lluis,
Catalonian Claus.

VB Gadgeteer Webserver, SDK 4.2 QFE2 and Spider Premium Library’s

This is an small sample code to show how to build our basic gadgeteer web server using VB with Spider and the 4.2 RTM Premium library’s.
Start Visual Studio with a new gadgeteer project and copy/paste…That’s all! (remember add library’s references)

Imports System.Net
Imports System.Text
Imports Microsoft.SPOT.Hardware
 
Imports GHI.Premium.Net
 
Imports GT = Gadgeteer
 
Partial Public Class Program
 
    Private WithEvents ethernet As New EthernetBuiltIn()
    
    Private ip As New IPAddress(New Byte() {0, 0, 0, 0})
    Private WithEvents myweb As WebEvent
    '
    Private WithEvents timer As GT.Timer = New GT.Timer(1000)
 
    Public Sub ProgramStarted()
        'Initialize adapter
        ethernet.Open()
        ethernet.NetworkInterface.EnableDhcp()
        ethernet.NetworkInterface.EnableDynamicDns()
        NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet)
        'app timer on
        timer.Start()
    End Sub
 
    Private Sub ethernet_CableConnectivityChanged(sender As Object, e As GHI.Premium.Net.EthernetBuiltIn.CableConnectivityEventArgsHandles ethernet.CableConnectivityChanged
        If e.IsConnected Then
            ' reboot device after plug... to startup again
            PowerState.RebootDevice(True)
        End If
    End Sub
 
    Private Sub ReceivedWebEventHandler(path As String, method As WebServer.HttpMethod, responder As ResponderHandles myweb.WebEventReceived
        ' webb response
        responder.Respond(New System.Text.UTF8Encoding().GetBytes("Hello from " + ip.ToString() + " At " + System.DateTime.Now.ToString()), "text/html")
    End Sub
 
    Private tic As Boolean
    Private Sub timer_Tick(timer As Gadgeteer.TimerHandles timer.Tick
        ' blink debug led... system working
        tic = Not tic
        Mainboard.SetDebugLED(tic)
        ' get an IP from DHCP if no previous one
        If (ip.ToString = "0.0.0.0"And ethernet.IsCableConnected Then
            ip = IPAddress.GetDefaultLocalAddress()
            WebServer.StartLocalServer(ip.ToString(), 80)
            myweb = WebServer.SetupWebEvent("Hello")
        End If
    End Sub
End Class

Regards,
PepLluis,

Visual Studio Image Library

Pos Eso! 🙂 un nuevo gran recurso.

La Biblioteca de imagenes de Visual Studio contiene imágenes de aplicaciones que aparecen en Microsoft Visual Studio, Microsoft Windows, Office System y otros programas de Microsoft, esta biblioteca continene más de 5.000 imágenes que se pueden utilizar para crear aplicaciones que se parecezcan visualmente y de forma consistente con el estilo de software de Microsoft.

http://www.microsoft.com/en-us/download/details.aspx?id=35825

Saludos,
PepLluis, 

Microframework, Threats y TimerCallBacks

Conversando con un compañero que en 2009 asistimos a una charla sobre Microframework en el TechEd de Barcelona, me comentaba que era una lástima que netmf no pudiera ejecutar hilos….. Mi respuesta fue: Pero hombre! desde entonces ha llovido mucho!! Jajajaja.

Si habrá llovido que incluso ya está en ruta la versión 4.3 que se integrara en Visual Studio 2012.

Evidentemente estos últimos cuatro años como ya vengo diciendo en los últimos post, han dado una sana madurez a netmf. Si además del montón de funcionalidades actuales de netmf también disponemos de threats.

Valga este modesto ejemplo, para manejar dos ‘threading.timers’ :

Imports Microsoft.SPOT
Imports System.Threading
 
Namespace MFConsoleApplication1
    Public Module Module1
        Private tmr1 As New Timer(New TimerCallback(AddressOf tic), Nothing, 1000, 500)
        Private tmr2 As New Timer(New TimerCallback(AddressOf tac), Nothing, 1000, 500)
 
        Sub Main()
            ' desfasar el primer hilo del segundo para crear el Tic Tac
            Thread.Sleep(500)
            ' poner a dormir al hilo principal
            Thread.Sleep(System.Threading.Timeout.Infinite)
        End Sub
 
        ' CallBack para tic
        Sub tic(ByVal state As Object)
            Debug.Print("Tic")
        End Sub
        ' CallBack para cac
        Sub tac(ByVal state As Object)
            Debug.Print("Tac")
        End Sub
 
    End Module
 
End Namespace

Saludos,
PepLluis,