Shop OBEX P1 Docs P2 Docs Learn Events
Loading User Interface code into different cogs? — Parallax Forums

Loading User Interface code into different cogs?

ekeefeekeefe Posts: 4
edited 2010-01-27 05:44 in Propeller 1
Hello,

I would like to put a small program together that involves four different input devices(keypad, IR and 2 encoders), 2x20 LCD, Video out and serial communications.

I have the code for each of these sections already written and working.

What I would like to do is have the code for each device on a separate cog on one propeller.

I would like to separate the code into different cogs so the interface is very responsive to input and quick to display output.

For the input devices, I would like to write to memory locations that are readable from the serial code/cog and sent out.

I would like the serial code/cog to be able to write to memory locations that can be read by the LCD and Video out cogs, so I can display data.

Is there a code example of how to separate the code into different cogs the way I have suggested?

Any help would be great.

Thank you in advance,

ED

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-27 01:48
    One of the Propeller Education Kit tutorials covers the subject of multiple cog programs.· I suggest you start there.

    Keep in mind that the Propeller is very fast, much faster than any UI needs.· It may simplify the code to separate it into sections that would each execute on its own cog, but it's not needed for responsiveness.

    Also keep in mind that many of the objects you plan to use like a video driver and one or more serial drivers each require a cog internally, so you can start running out of cogs.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-01-27 04:56
    The dracblade single board computer does something similar. Of course, your devices are slightly different but the concepts are similar. eg the dracblade has a 20x4 LCD and yours is 20x2, the dracblade has a PC keyboard and yours is a keypad. The dracblade has two serial ports and I'm not sure how many you need.

    The great thing is that pretty much all the code exists in the propeller object exchange. The thing that doesn't exist is the tiny program to glue all the objects together but that isn't hard to write as most of the objects are written to a common standard - eg for output devices you have something like displayobject.out(byte) or displayobject.hex(value, numberofdigits).

    Your code may not be one cog with pure assembly as most objects are a mix of spin and assembly.

    But your glue program could be only a few lines of (pseudo code) spin;
    repeat
      a:=object1.readvalue
      b:=object2.readvalue
      c:=object3.readvalue
      object4.out(a)
      object5.out(b)
    
    


    If you already have the code written for each object then the glue code should be fairly easy.

    Some objects are even more useful, eg the 4 serial ports in one cog object has buffers on the input, so you only have to read them occasionally, and you can keep reading till the buffer is empty, then go and do something else for a while. The concept of buffers can be extended to any input object.

    And if timing is a problem you can attach priority to some things - eg on the dracblade it scans the keyboard continuously and has a counter and when the counter reaches 1000 it then scans the serial port.

    Can you post some code for the objects already written - maybe we can have a go gluing them together?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-27 05:44
    Is your LCD a HD44780 compatible? There is another thread ( http://forums.parallax.com/forums/default.aspx?f=25&m=396005 ) in which I posted a driver that can be used in a way you would like it. You can define a screen-buffer in HUB-RAM and simply write to that. The driver will send the data to the display without any further action.
Sign In or Register to comment.