|
Post by alexfish on Jan 24, 2021 23:52:13 GMT 1
Hi All
Thought I would post RE: cairo circle
many many posts on using arc . that needs translate to get it in position : generally making a mess of further drawing routines::
here is an Alex 'hack of the day' to draw a circl exactly where you need it
LOCAL ts TYPE float cairo_move_to(c1,400,400) FOR ts= 0 TO 359 cairo_rel_line_to( c1,(COS(RAD(ts)) ) * 2 , (SIN(RAD(ts)) ) * 2 ) NEXT cairo_stroke(c1)
Have Fun + BR Alex
|
|
|
Post by alexfish on Jan 27, 2021 17:55:24 GMT 1
Hi All
Now got the GPS coords working
Have done parts a GPS nmea decoder . need to finalise the last bits , then this will be posted on a separate thread
along with other drivers for the openseamaps
BR Alex
|
|
|
Post by alexfish on Jan 28, 2021 1:50:28 GMT 1
Hi ALL
as can see there is no coververtions of type as in deg min and sec. etc,etc
in short I did a straight rip from Foxtrot gps::
but for now can have some fun,
also in there is Distance and Bearing.
Have Fun + BR Alex
DEF FN DEG2RAD(deg) = (deg * M_PI / 180.0) DEF FN RAD2DEG(rad) = (rad / M_PI * 180.0)
' =================================== FUNCTION LONDEG2LONMIN ( float lon) TYPE STRING ' ===================================
LOCAL lonmin[20] TYPE static char LOCAL degrees TYPE int LOCAL minutes TYPE float degrees = (abs( (lon>0) ? floor(lon) : ceil(lon) )) minutes = ((fabs(lon) - (float)degrees) * 60) sprintf (lonmin,"%d°%.3f' %s",degrees,minutes,(lon>0) ? "E" : "W") RETURN lonmin
END FUNCTION
' ================================= FUNCTION LATDEG2LATMIN (float lat) TYPE STRING ' =================================
LOCAL latmin[20] TYPE static char LOCAL degrees TYPE int LOCAL minutes TYPE float degrees = (abs( (lat>0) ? floor(lat) : ceil(lat) )) minutes = ((fabs(lat) - (float)degrees) * 60) sprintf (latmin,"%d°%.3f' %s", degrees,minutes,(lat>0) ? "N" : "S") RETURN latmin
END FUNCTION
' ================================= FUNCTION LATDEG2LATSEC(float lat) TYPE STRING ' =================================
LOCAL latsec[20] TYPE static char LOCAL degrees, full_minutes TYPE int LOCAL minutes, seconds TYPE float degrees = abs( (lat>0) ? floor(lat) : ceil(lat) ) minutes = (fabs(lat) - (float)degrees) * 60 full_minutes = floor(minutes) seconds = (minutes - (float)full_minutes) * 60 sprintf( latsec,"%d°%d'%.2f\" %s", degrees,full_minutes,seconds,(lat>0) ? "N" : "S") RETURN latsec
END FUNCTION
' ================================== FUNCTION LONDEG2LONSEC ( float lon) TYPE STRING ' ==================================
LOCAL lonmin[20] TYPE static char LOCAL degrees, full_minutes TYPE int LOCAL minutes, seconds TYPE float degrees = (abs( (lon>0) ? floor(lon) : ceil(lon) )) minutes = ((fabs(lon) - (float)degrees) * 60) full_minutes = (floor(minutes)) seconds = ((minutes - (float)full_minutes) * 60)
sprintf(lonmin,"%d°%d'%.2f\" %s",degrees,full_minutes,seconds,(lon>0) ? "E" : "W") RETURN lonmin
END FUNCTION
' ========================================================= FUNCTION GET_DISTANCE (double lat1, double lon1, double lat2, double lon2) TYPE float ' =========================================================
LOCAL distance = 0 TYPE float LOCAL tmp TYPE double tmp = sin(DEG2RAD(lat1)) * sin(DEG2RAD(lat2)) + cos(DEG2RAD(lat1)) * cos(DEG2RAD(lat2)) * cos(DEG2RAD(lon2) - DEG2RAD(lon1)) distance = 6371.0 * acos(tmp) RETURN distance
END FUNCTION
' ======================================================== FUNCTION GET_BEARING(double lat1, double lon1, double lat2, double lon2) TYPE float ' ======================================================== LOCAL bearing, tmp TYPE double
tmp = atan2(sin(DEG2RAD(lon2)-DEG2RAD(lon1)) * cos(DEG2RAD(lat2)), \ cos(DEG2RAD(lat1)) * sin(DEG2RAD(lat2)) - \ sin(DEG2RAD(lat1)) * cos(DEG2RAD(lat2)) * cos(DEG2RAD(lon2)-DEG2RAD(lon1)) )
bearing = ((tmp < 0) ? tmp + M_PI*2 : tmp)
RETURN RAD2DEG(bearing)
END FUNCTION
|
|
|
Post by alexfish on Jan 28, 2021 11:56:29 GMT 1
And so to the setup
now have ENTRY widget Input working > this leads to getting the LIST & EDIT working
as to the Navigation App and to some of the above
Here is a working example with Weather the shaded to left is for other data like AIS & Routes
The shaded areas highlight where you are
Bottom Left is the Weather at the Location
As note not all bits of Northsea are in the Kap or decoded btiles the App will Download the Missing on Request:: these are stored separate to the main directory, just in case
BR Alex
|
|
|
Post by alexfish on Jan 29, 2021 7:30:29 GMT 1
Hi All
Further to this thread
RE X11 Thead , Methods stated there are now depricated , they work but in most case will only key one Byte
Here is the Driver, It will return the code as a String & or to Include UTF8
OPTION PARSE FALSE
PRAGMA LDFLAGS `pkg-config --libs x11` PRAGMA OPTIONS `pkg-config --cflags x11` PRAGMA INCLUDE <X11/Xlib.h> PRAGMA INCLUDE <X11/Xutil.h>
DECLARE dpy TYPE Display* DECLARE win TYPE Window DECLARE xim TYPE XIM DECLARE xic TYPE XIC
'setlocale(LC_ALL, "") dpy = XOpenDisplay(NULL)
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 100, 100, 0, 0, 0) XMapRaised(dpy, win) XSync(dpy , FALSE)
XSetLocaleModifiers("")
xim = XOpenIM(dpy, 0, 0, 0)
IF ( NOT(xim)) THEN ' fallback to internal input method XSetLocaleModifiers("@im=none") xim = XOpenIM(dpy, 0, 0, 0) PRINT "FallBack" END IF
xic = XCreateIC(xim, \ XNInputStyle,XIMPreeditNothing | XIMStatusNothing, \ XNClientWindow, win, \ XNFocusWindow, win, \ NULL)
XSetICFocus (xic) XSelectInput(dpy, win, KeyPressMask | KeyReleaseMask )
LOCAL prev_ev = {}, ev = {} TYPE XEvent
WHILE (1) DO
XNextEvent(dpy, &ev)
IF (XFilterEvent(&ev, None) == TRUE ) THEN
CONTINUE
END IF
SELECT ev.type
CASE KeyPress
LOCAL status TYPE Status LOCAL keysym TYPE KeySym keysym = NoSymbol LOCAL text [32] TYPE char memset(text,'\0',32) LOCAL is_repeat TYPE int LOCAL txt$ TYPE STRING
' =========================================== is_repeat = prev_ev.type == KeyRelease && \ prev_ev.xkey.time == ev.xkey.time && \ prev_ev.xkey.keycode == ev.xkey.keycode ' ========================================== ev.xkey.state &= ~ControlMask
Xutf8LookupString(xic, &ev.xkey, text, sizeof(text) - 1, &keysym, &status) ' ================================================ IF (status == XBufferOverflow) THEN
' ignore END IF
' ================================================== IF (status == XLookupChars) THEN txt$ = text PRINT "Got String: " , txt$ )
END IF
' ========================================================
IF (status == XLookupBoth) THEN LOCAL sym_name$ TYPE STRING txt$ = text txt$=CHOP$(txt$) sym_name$ = XKeysymToString(keysym) PRINT "Have Two: ", txt$ , " : " , sym_name$ END IF
' ================================================ IF (status == XLookupKeySym) THEN
LOCAL sym_name2$ TYPE STRING
sym_name2$ = XKeysymToString(keysym)
PRINT "Have keysym: ", sym_name$
END IF
' ================================================= IF (keysym == XK_Escape) THEN
END
END IF
END SELECT
WEND
Updated use Memset to get clean read of Have Fun + BR Alex
|
|
|
Post by alexfish on Mar 11, 2021 23:12:37 GMT 1
Miss post
|
|