erebus-labs / blocks-o-code

Open Hardware & Software Hardware Manipulative for K12 Students
http://www.erebuslabs.com/elaunch
GNU General Public License v2.0
4 stars 1 forks source link

uC LED control #87

Open jmickiewicz opened 9 years ago

jmickiewicz commented 9 years ago

Two LED's need to be controlled; a status and error light. This is implemented using the following python command: Adafruit_I2c.write8( reg, value)

register 6 controls error LED on PA5 register 7 controls status LED on PA4 value 1 means on, value 0 means off. other values will be invalid and ignored

These registers are readable using Adafruit_I2c.read8( reg)

alternate ideas : a single register with multiple valid values. ie bit0 is error bit1 is status. This would allow bit or's to do multiple commands in a single write, but makes things a little less clear. non-0/1 values could represent something, maybe a duty cycle or blink number. ie write8(6,2) is blink the error light. This would allow more flexibility, but I can't think of anything I'd actually want.

gstro commented 9 years ago

One idea for this is to always do a read for every operation, and just map each operation to a unique register:

0: ReadFunction,
... 
4: StatusLedOn, 
5: StatusLedOff, 
6: ErrorLedOn, 
7: ErrorLedOff, 
8: SendVertical, 
9: SendHorizontal
...

etc.

I do this for the operations I've implemented in the raster scan (SendVertical and SendHorizontal). I have it return the block function in the first 6 bits with above and right flags in the remaining two bits to signal if there are adjacent blocks:

----------------------------------------------
| above | right |       function             |  response byte from read 
----------------------------------------------
     [7]      [6]       [5:0]

This allows us to respond to updated functions and block placement immediately after the command. I do also like your bit-field idea about extending functionality (e.g. duty cycles), so maybe some register numbers will respond to some writes as well.

ghost commented 9 years ago

@htylo assure the lexer closes smbus before serializing and piping the output to the parser -- while slower, it assures that parser/interpreter error handling can grab control of the i2c to light up error lights without collisions

gstro commented 9 years ago

Referencing #88, we now have the following byte returned from each i2c read:

------------------------------------------------------------
| above | right |    category   |         token            |    response byte from read 
------------------------------------------------------------
      [7]     [6]           [5:4]                      [3:0]
ghost commented 9 years ago

This needs to be plugged into the following callback:

blocks-o-code/src/controller/abc/error.py -> ErrorFilter.action(self, line, column)
erebuslabs commented 9 years ago

What's the status of this one? Is it in? If so - during what commit?

gstro commented 9 years ago

We have control of the status and error leds over the global TWI bus (via abc_global.py in 382de30703a44fa34afaf254101298b6ac796267). The current implementation uses these for topology-collection feedback, i.e. if the blocks have been "discovered" or if they are considered "out of bounds," as was demonstrated in our final presentation.

We did not complete the syntax-error detection hooks (I think that's what Tyler was mentioning above), so this wasn't closed. Not sure how you want to handle it from here.