SPI output example?

Hiya, would you guys mind tossing out an example of some SPI outputting code?  I’m trying a simple block of code and just chokin’ on compile errors.  Any successfully compiling lump o’ SPI-implementing output code would be great, don’t even worry about making the comments pretty.

Relevant code, in case you’re curious:



class LedInput extends InputPort
{
    
    hardware.configure(SPI_189);
    hardware.spi189.configure(SIMPLEX_TX, 4000);
    hardware.spi189.write("\x00\x99\x99");
   
}
 
// Register with the server
imp.configure(“Web Color”, [ LedInput() ], []);
 
// End of code.

You can’t put code inside a class like that, it needs to be within a function in the class. Without seeing the rest of your code I don’t know what you’re trying to achieve, but perhaps you mean to write to the SPI port when you receive some data from an input.  Something like this:


class LedInput extends InputPort
{
    constructor()
    {
        hardware.configure(SPI_189);
        hardware.spi189.configure(SIMPLEX_TX, 4000);
    }
    
    function set(value)
    {
        hardware.spi189.write("\x00\x99\x99");
    }
}
 
// Register with the server
imp.configure(“Web Color”, [ LedInput() ], []);
 
// End of code.

I suggest working through the worked examples in order as they cover all of this.

http://devwiki.electricimp.com/doku.php?id=workedexamples

Rob
Fen Consultants, UK

Ah, right you are kindly stranger!  Sorry for the simpleton question then- I skimmed the docs, successfully modified some of the examples, and then trusted my years of code-fu.