Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Donovan Buck
    @dtex
    Writes are working really well already.
    Matt Haines
    @beardedinventor
    oh, sorry i read that totally wrong..
    Donovan Buck
    @dtex
    Oh wait a minute...
    register = “0x3B”; is actually register = 0x3B.tostring();
    So, all
    i2c_addr = pin[0] << 1;
    register = 0x3B.tostring();
    numbytes = pin[2].tointeger();
    
    local result = i2c.read(i2c_addr, register, numbytes);
    Matt Haines
    @beardedinventor
    oh, geeze
    this should actually be an easy fix (for your squirrel)
    Donovan Buck
    @dtex
    :+1:
    Matt Haines
    @beardedinventor
    you want to change the register address you're reading from to "\x3B"
    Donovan Buck
    @dtex
    I’ve tried that, but I get this error when I do:
    2015-01-17 11:30:50 UTC-6    [Agent]    ERROR: cannot convert the string
    2015-01-17 11:30:50 UTC-6    [Agent]    ERROR:   in unknown vimp:68
    2015-01-17 11:30:50 UTC-6    [Agent]    ERROR:   from unknown overrides:3
    2015-01-17 11:30:50 UTC-6    [Agent]    ERROR:   from unknown vimp:31
    Matt Haines
    @beardedinventor
    register = "\x3B";

    i think this should also work:

    register = 0x3B.tochar();

    Donovan Buck
    @dtex
    Both give me that error.
    This is weird:
    server.log(0x3B.tochar()); <— logs ```;```
    server.log(0x3B.tostring()); <— logs ```59```
    server.log(“\x3B"); <— logs ```;```
    Matt Haines
    @beardedinventor
    0x3B is treated as a number (just represented in hex)
    so server.log(0x3B.tostring()) is equivalent to server.log(59.tostring())
    whereas the \x00 notation (inside of quotes) is a way of building strings with hex bytes
    so you can do things like:
    local someString = "\x00\x01\x02";
    for i2c.read you want a string of characters (a ; in your case)
    Donovan Buck
    @dtex
    Got it, but I don’t see why I would get the cannot convert string with:
    local word = i2c.read(i2c_addr, "\x3B", numbytes);
    Matt Haines
    @beardedinventor
    neither do i :/ I have an identical line in my code (with the only difference being the addresses im reading from) and im not getting a string conversation error
    Donovan Buck
    @dtex
    Okay. All my stuff is still mixed in with Tyrion so let me whip up a Squirrel only approach and see if it still happens.
    Thank you for looking at this. I’ll post back tonight with the Squirrel only result
    Matt Haines
    @beardedinventor
    no problem :) i'll probably pop back in throughout the day, and also keep playing with this to see if i can figure out some johnny-five i2c stuff :)
    Matt Haines
    @beardedinventor
    @dtex - found what was going on
    register is being passed in as a string, so we need to .tointeger() it before we can .tochar() it
    (or rather, it was getting .tostring()'ed in the update function).. I updated it to look like this, and I'm getting expected results:
    i2c_addr = pin[0] << 1;
    register = pin[1];
    numbytes = pin[2].tointeger();
    
    local word = i2c.read(i2c_addr, register.tochar(), numbytes);
    Donovan Buck
    @dtex
    Awesome, thank you so much! I'm away from the computer right now but when I get home I'll fix it in Tyrion. I owe you one for sure.
    Derek Wheelden
    @frxnz
    @dtex I just finished setting up my imp. I've got the IR sensor and I just finished soldering headers to the Adafruit I2C PWM driver, so let me know if I can do anything with those to help you test
    Donovan Buck
    @dtex
    @beardedinventor Woo hoo, it works!
    @rwaldron I just need to add support for i2cReadOnce, some tests and I’m done. I also think I should explore passing the frequency to Tyrion since so many posts to the agent will never even be read.
    @frxnz It’d be helpful to test the PWM driver and make sure I didn’t break that while trying to get I2C reads working.
    Derek Wheelden
    @frxnz
    Can do. Is imp-io up to date or do you have a branch I should pull down?
    Donovan Buck
    @dtex
    You should use dtex/imp-io and dtex/Tyrion to test I2C
    Derek Wheelden
    @frxnz
    @dtex Testing the PWM driver now. Something doesn't seem quite right
    I got servo.sweep() to work once, but it the steps were kind of erratic. And now I can't get the servo to move
    Also, guessing you'll want to add this line:
    Imp.prototype.sendI2CConfig = Imp.prototype.i2cConfig;
    Derek Wheelden
    @frxnz
    It started working again, not sure what happened there. Here's a video of servo.sweep() weirdness https://www.dropbox.com/s/bvbkm8mwfpr085a/servo.mov?dl=0
    I noticed there were timing issues even with led.blink(), so may not be an I2C issue?
    All of the other servo methods seem to work fine
    Donovan Buck
    @dtex
    That all makes sense and works as expected. Keep in mind that any commands sent from Johnny-Five are relayed through a cloud service and all the timing for both sweep and blink are handled in Johnny-Five. A new command is sent for each change of state and each command has to go through the cloud service. In sweep, we literally set each and every position throughout the sweep from Johnny-Five. Thank you for checking this out.
    I just watched the video. Honestly, I’m really impressed that sweep worked as well as it did.
    Donovan Buck
    @dtex
    Maybe one day we will have direct LAN communication with the Imp (like Voodspark) and be able to do more “real-time” things. Until then this platform is better suited for things where a second or so of latency won’t matter. For those things the Imp is completely kick ass.
    Derek Wheelden
    @frxnz
    Yea I realized it was going over wifi after I stepped away. D'oh!
    Donovan Buck
    @dtex

    @rwaldron There are two things I would like to add to imp-io but they are not things found/done in Firmata. I think they are important given the nature of how the Imp works.

    1. Add a reporting frequency parameter to the io opts with a default of one whole second. This allows us to set the interval that is used for Reporting.update(). A typical IoT project could have a value measured in minutes instead of milliseconds. Currently most reports back to the agent are ignored so they are wasting bandwidth.
    2. Add a command to remove elements from the Reporting.pins array. I would like to tell the Imp to stop reporting when I get the result of an i2cReadOnce call.

    Both of this things are easily done, but for the second I need to add a command. What is the authoritative source for this list and can I add new ones?

    const PIN_MODE = 0xF4;
    const ANALOG_WRITE = 0xE0;
    const SERVO_WRITE = 0xE1;
    const DIGITAL_WRITE = 0x90;
    const REPORT_ANALOG = 0xC0;
    const REPORT_DIGITAL = 0xD0;
    const I2C_REQUEST = 0x76;
    const I2C_REPLY = 0x77;
    const I2C_CONFIG = 0x78;
    const SYSTEM_RESET = 0xFF;
    Rick Waldron
    @rwaldron
    SAMPLING_INTERVAL = 0x7A
    Donovan Buck
    @dtex
    Perfect, I’ll use that for item 1
    Rick Waldron
    @rwaldron
    i2cReadOnce and i2cRead have “sub commands” that are built-in
    one sec
    for i2cReadOnce: