Page 1 of 1
Buttons Plugin
Posted: February 16th, 2005, 11:00 pm
by _X7JAY7X_
This is what I am trying to do. I have created hardware that simply mimics the buttons from a Matrix Orbital lcd. I want to be able to hook these buttons up to the serial port and be able to use them with a parallel HD44780 Display.
I have a few years of C++ experience that may be helpful in writing plugins, however I do not know if a plugin would be possible for this or the right option.
I am trying to get most of the functionality of matrix orbital buttons in lcd smartie, however the backlight option will not work.
Can you point me in the right direction?
Thanks
Jason
Posted: February 16th, 2005, 11:35 pm
by clansley
Although the plugin system isn't meant for implementing hardware support, I think it's possible to do what you want.
In LCD Smartie you would usually use $MObutton(X) in the event section to make use of key presses. What you could do is create a plugin that opens the serial port and reads from it (in it's own thread), and instead of using $MObutton, you could use $dll(yourdll,1,X,0) and your plugin could just check if the last key received from the serial port was X and return 1 if it was otherwise 0.
There's a basic sample C++ plugin available for download. On the palmorb site there's some basic serial code available for download.
Chris.
Posted: February 17th, 2005, 12:44 am
by _X7JAY7X_
I get what your saying but, are you saying I can actually use the Actions menu with a dll? I cannot say
if $dll(....) > 1 then Playwinamp
it will not let me enter the dll string right after the if statement.
Can you post some example syntax for the plugin, so I can understand how to construct it.
Jason
Posted: February 17th, 2005, 7:59 pm
by clansley
You should be able to type the $dll(...) stuff in after the if - when you say you can't what do you mean?
Posted: February 18th, 2005, 1:45 am
by _X7JAY7X_
I have figured the if dll() part out.
However, I have got the plugin to read the serial port and return the value of the letter (i.e. Button A = 41 hex). The problem is is that smartie "hangs" while its waiting for an input from the serial port. Do you have any ideas?
Thanks
Jason
Posted: February 18th, 2005, 5:21 am
by _X7JAY7X_
I dont know if this is the best way, but the only thing I could figure out is to repeatedly sending a byte to the computer from the buttons that tells it that it is there so it doesnt hang on the input.
Do you have a better idea?
Thanks
Jason
Posted: February 18th, 2005, 9:40 am
by clansley
The best method is to do the serial port reading in it's own thread.
A cheap and dirty idea would be to save the last key as a global int variable and look at that when your function1 is called. A better but harder method is to use a global buffer containing unread keypresses, with a critrical section guarding accesses to it.
Posted: February 18th, 2005, 2:40 pm
by _X7JAY7X_
Do you have any examples of this? I found this serial port code online and it uses the ReadLine command to get info from the serial port. This is what it is waiting on.
Are you good with C++? Can you look at the code or do you know of a good website with examples.
Thanks
Jason
Posted: February 18th, 2005, 8:03 pm
by clansley
Reading from the serial port is usually a blocking thing - that's why you need to do it in it's own thread. I know C++ (that's what my job is doing) but not on Windows - I'm a unix programmer.
But it's not hard - you should be able to find examples of threading code on the web.
Posted: February 19th, 2005, 7:58 am
by _X7JAY7X_
Ok I have created a thread that waits for a read of a buttons, if not it will time out after X amount of time. I think this will work, but here is the problem......... I have worked on the code a reguler .exe file and it works fine, however when I converted it to a dll it is giving me errors with functions. For example, I have
function 1 (x,x) (dll function 1, called as function 1 from smartie)
{
void Thread( void* pParams )
{ <-----
}
void main(void)
{ <----
}
}
it is giving me an error where the arrows are at, it is says:
error C2601: 'Thread' : local function definitions are illegal
error C2601: 'main' : local function definitions are illegal
is there a certain way to call function within .dll functions?
any ideas?
Thanks
Jason
Posted: February 19th, 2005, 8:38 am
by _X7JAY7X_
I have figured it out, I got it to return the Hex Value of the button without locking Smartie up, and it seems to work fine. I disabled the "wait for so long" loop to read in a character and it works better.
With this loop enabled it was making the processor run at about 20%.
Posted: February 22nd, 2005, 2:38 am
by _X7JAY7X_
It is now completely done. I have added file support to change the Com port and to show plugin status. It is limited to basic output such as the time the plugin was started.
I have been using it now for the last few days. It works great.
Posted: June 28th, 2005, 1:53 pm
by penjuin
could you please post a link to it?