Autor Tema: mostrar numeros decimales ethernet  (Leído 1710 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado wolfman77

  • PIC12
  • **
  • Mensajes: 82
    • Dos en la ruta
mostrar numeros decimales ethernet
« en: 25 de Octubre de 2018, 14:26:55 »
Hola a todos, estoy armando un voltimetro que me muestre el valor a traves de la red, utilizo un modulo enc28j60, me muestra el valor perfectamente en el puerto serie, pero en la web no puedo mostrar el valor de value, alguien me podria decir que tengo mal o darme una idea?

este es el codigo:
Código: [Seleccionar]
#include <EtherCard.h>

static byte mymac[] = { 0xDD, 0xDD, 0xDD, 0x00, 0x01, 0x05 };
static byte myip[] = { 192, 168, 1, 177 };
byte Ethernet::buffer[700];

float value;

void setup() {
   Serial.begin(9600);
   if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
      Serial.println("No se ha podido acceder a la controlador Ethernet");
   else
      Serial.println("Controlador Ethernet inicializado");
   if (!ether.staticSetup(myip))
      Serial.println("No se pudo establecer la dirección IP");
   Serial.println();
}

static word homePage() {
 BufferFiller bfill = ether.tcpOffset();
 bfill.emit_p(PSTR(
      "<html><head></head>"
      "<body>"
      "<META HTTP-EQUIV='REFRESH' CONTENT='1'>"
      "<div style='text-align:left;'>"
      "<h3>Test-001</h3>"
      "<br>Entrada 1: $D abc</br>"
      "<br>Entrada 2: $D xyz</br>"
      "</body></html>"),
value,
analogRead(1));
   return bfill.position();
}

void loop()
{
    float value = fmap(analogRead(0), 0, 1023, 0.0, 57.0);   // cambiar escala a 0.0 - 55.0     
        if (ether.packetLoop(ether.packetReceive()))
   {
      ether.httpServerReply(homePage());
   }
 Serial.println(value);
}

float fmap(float x, float in_min, float in_max, float out_min, float out_max)
{
   return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Volviendo al mundo de los PIC....


 

anything