FLTK-term

For issues with communication ports, protocols, etc.
dasyar
Posts: 372
Joined: Dec 04, 2008 15:31

Re: FLTK-term

Post by dasyar »

Well, I have come to a complete standstill in terms of getting the incoming data to display in the Text_Editor window. I can get the incoming data to display in the console window, after you do a keypress in the Text_Editor window, which indicates that I have two way communication on the Com port.

After staring at the example code, it has not become apparent as to how I should go about this. My general consensus about FLTK, it is not a very intuitive toolkit, at all, and if you go to the FLTK site and read the documentation, you get even more confused because all the explanations are in the C++ format.

I will probably keep hacking away at this, but at some point, the head banging will have to stop before irreparable brain damage occurs.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK-term

Post by D.J.Peters »

A GUI is event driven may be you have to triger an redraw event manualy.
Something like this.

Joshy

Code: Select all

#INCLUDE "fltk-c.bi"
sub ButtonCb cdecl (byval widget as FL_WIDGET ptr, byval buffer as any ptr)
  static as integer counter=0
  counter+=1
  var txt = "message " & counter & !"\n"
  Fl_Text_BufferAppend(buffer,strptr(txt))
  ' triger an redraw event (parent from widget the window)
  Fl_WidgetRedraw Fl_WidgetWindow(widget)
end sub
'
' main
'
var win = Fl_Double_WindowNew(620,520,"Terminal Test")
var edt = Fl_Text_EditorNew(10,10,Fl_WidgetGetW(win)-20,Fl_WidgetGetH(win)-42)
var buf = Fl_Text_BufferNew()
var btn = Fl_ButtonNew(10,Fl_WidgetGetH(win)-20,Fl_WidgetGetW(win)-20,20,"add text")
Fl_WidgetSetCallbackArg(btn,@ButtonCB,buf)
Fl_Text_DisplaySetBuffer(edt,buf)
Fl_Text_DisplaySetTextFont(edt,Fl_COURIER_BOLD)
Fl_GroupSetResizable(win,edt)
Fl_WindowShow(win)
Fl_Run()
dasyar
Posts: 372
Joined: Dec 04, 2008 15:31

Re: FLTK-term

Post by dasyar »

Event propagation, I guess the Text_Editor widget is an event that is driven by the keypress; now, I guess, I have to somehow create a widget event that does the port input functionality. How does one make a widget for port input, and would Fl_Activate/Fl_Deactivate be enough to automate the whole procedure? I get this feeling that I am getting in way over my head with this, also not even sure if FLTK can do something like that, in a workable fashion.
dasyar
Posts: 372
Joined: Dec 04, 2008 15:31

Re: FLTK-term

Post by dasyar »

Looking into this a little further, maybe a widget event is not what I am looking for. The way an event is being described is a button press, or maybe moving the cursor to another window?

Since freeBasic uses the console window, is this considered to be a widget or an event in terms of FLTK? If it is, then how do I make use of it, this is the kind of stuff you will not find in the FLTK docs, I think this would be a freeBasic specific aspect. I also looked again in the fltk-c-1.3.3 zip file, and I did not see anything in there that even comes close to describing how to use events within freeBasic context. Yes, I know this is free software provided by some hardworking individual, but what the heck, at least some docs covering all of the commands of FLTK as it pertains to freeBasic, would be some help. Maybe that way I would have fewer posts here, that might be a good thing?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK-term

Post by D.J.Peters »

Normaly user input triggers an event going to the RS232.
The response of any connected device is the other event trigger the output event.

I don't see your problem ?

TIP:
You can make your RS232 stuff event driven or use Fl_Wait() and handle RS232 changes manualy.
See at Fl_Wait01.bas and Fl_Wait02.bas

Joshy

here are my event driven RS232 for windows: http://www.freebasic.net/forum/viewtopi ... 18&t=14150
Post Reply