Loading User Interface code into different cogs?
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
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
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.
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