Avatar for ClearMemory041063


Member since Apr 2016 • Last active Nov 2017
  • 52 conversations

Retired. Just having fun now.
I'm running an Espruino Board connected to ESP8266 via serial port.

Working on a program derived from the SD card file server example.
When you request a file from the displayed list, it looks at the file extension and modifies the MIME header field.
This causes files with the extension .HTML to load the Web page.
Files with the extension .js allow an .HTML file to include scripts.
Files with the extension .csv cause Excel to load the file into a spreadsheet, which can be saved on your hard drive.

I'm having problems with another part that accepts POSTs from a client.

Most recent activity

  • Avatar for ClearMemory041063

    Annotate the report descriptor

    /* Annotate the report descriptor 
    /* Copyright (c) 2015 Gordon Williams, Pur3 Ltd. See the file LICENSE for copying permission. */
    var mouse = require("USBMouse");
    setWatch(function() {
      mouse.send(20,20,mouse.BUTTONS.NONE); // X movement, Y movement, buttons pressed
    }, BTN, {debounce:100,repeat:true, edge:"rising"});
    E.setUSBHID ⇒
    Call type:
    USB HID will only take effect next time you unplug and re-plug your Espruino. If you're disconnecting it from power you'll have to make sure you have save()d after calling this function.
    Note: This is only available in devices that support USB HID (Espruino Pico and Espruino WiFi)
    opts - An object containing at least reportDescriptor, an array representing the report descriptor. Pass undefined to disable HID.
      reportDescriptor : [
      0x05,   0x01, //Usage Page (Generic Desktop Controls)
      0x09,   0x02, //Usage (Mouse)
      0xA1,   0x01, //Collection (application)
      0x09,   0x01, //Usage (Pointer)
      0xA1,   0x00, //Collextion (Physical)
      0x05,   0x09, //Usage Page (Button)
      0x19,   0x01, //Usage Minimum (1)
      0x29,   0x03, //Usage Maximum (5)
      0x15,   0x00, //Logical Minimum (0)
      0x25,   0x01, //Logical Maximum (5)
      0x95,   0x03, //Report Count (3)
      0x75,   0x01, //Report Size (1)
      0x81,   0x02, //Input (Data, Variable,Absolute,Bit Field)
      0x95,   0x01, //Report Coint (1)
      0x75,   0x05, //Report Size (5)
      0x81,   0x01, //Input (Constant, Array, Absolute, Bit Field)
      0x05,   0x01, //Usage Page (Generic Desktop Controls)
      0x09,   0x30, //Usage 00
      0x09,   0x31, //Usage (X)
      0x09,   0x38, //Usage (Wheel)
      0x15,   0x81, //Logical Minimum(-127)
      0x25,   0x7F, //Logical Maximum(127)
      0x75,   0x08, //Report Size (8)
      0x95,   0x03, //Report Count (3)
      0x81,   0x06, // Input (Data, Variablr,Relative, Bit Field)
      0xC0,  //End Collection
      0x09,  0x3c, // ?????
      0x05,  0xff, 
      0x09,  0x01, 
      0x15,  0x00, 
      0x25,  0x01, 
      0x75,  0x01, 
      0x95,  0x02, 
      0xb1,  0x22, 
      0x75,  0x06, 
      0x95,  0x01, 
      0xb1,  0x01, 
      0xc0  //end collection
    exports.BUTTONS = {
      NONE : 0,
      LEFT : 1,
      RIGHT : 2,
      MIDDLE : 4
    exports.send = function(x,y,b) {
    E.sendUSBHID ⇒
    Call type:
    data - An array of bytes to send as a USB HID packet
    1 on success, 0 on failure
  • Avatar for ClearMemory041063

    I've been searching for some Vogan poetry to further understand what is going on. Some of it gets really deep in the weeds.
    Here is a link that seems to be about the right level to start with.

    Usb Made Simple

    It covers the hardware and bus messages but importantly the Descriptors that are used in the module.

    This tool looks like it could be useful for creating a descriptor

    HID Descriptor Tool from USB.org

    @Gordon Espruino continues to amaze!

  • Avatar for ClearMemory041063

    Had time to try the mouse driver today. Here's the code:

    // 15 Nov 2017
    // Use pushbutton on pin B3 to reset
    // Loads mouse driver into the USB boot
    // Every second move mouse cursor by 20 pixels
    // in a square pattern
    //load and save the program
    // unplug and replug the Pico USB
    // mouse cursor should be moving in square pattern
    // reconnect to WebIde
    // mouse cursor still moving
    // Type reset() in left  pane of WebIde
    // Type save() in left pane of WebIde
    var mouse = require("USBMouse");
    // A way back to normal just in case
    var but1=B3;
    },but1, {debounce:100,repeat:true, edge:"falling"});
    var i=0;
    setInterval(function () {
      switch (i){
        case 0:
          mouse.send(0, 20, mouse.BUTTONS.NONE); // X movement, Y movement,
        case 1:
          mouse.send(20, 0, mouse.BUTTONS.NONE); // X movement, Y movement,
        case 2:
          mouse.send(0, -20, mouse.BUTTONS.NONE); // X movement, Y movement,
        case 3:
          mouse.send(-20, 0, mouse.BUTTONS.NONE); // X movement, Y movement,
      if( i>3) i=0;
    }, 1000);

    It's interesting that the WebIde still talks through the USB port with the mouse functions.

  • Avatar for ClearMemory041063

    A question concerning this example page.
    Espruino USB HID

    If you copy one of the examples into the WebIde, send it to a Pico, and save it, how can you restore the Pico to its original state?
    Perhaps rig a push button on a pin and do a setwatch on that pin that does a reset()?

  • Avatar for ClearMemory041063

    Hi @tbd. Lots of Midi possibilities. I'm just crawling around the basic Vogan poetry at this point, and will be glad to get USB Midi to connect with a Pico. Hopefully the HID info will transfer for a Bluetooth connection later on.

    Here are links I've glanced at today:
    Also looked at USB sniffer programs for a debug method.




  • in ESP8266
    Avatar for ClearMemory041063

    Look at the attached HTML files in the link @allObjects supplied above.