Request for hug.bac
Dec 19, 2022 20:25:20 GMT 1
Post by alexfish on Dec 19, 2022 20:25:20 GMT 1
Hi Peter
not sure if you have any vision of more updates to hug.bac
need to stop timeout:: and then restart
A REPEAT of TIMEOUT(*,*) will not work in hug imager apps
Example code of what I be doing, of NOTE there a RESETKEY ... thinking TIMEOUTSTOP or TIMOUT*
Full demo Code of using hug.bac with hug imager, include Geo*.bac
BR
Alex
not sure if you have any vision of more updates to hug.bac
need to stop timeout:: and then restart
A REPEAT of TIMEOUT(*,*) will not work in hug imager apps
Example code of what I be doing, of NOTE there a RESETKEY ... thinking TIMEOUTSTOP or TIMOUT*
ELIF KEY() = 65366 THEN
' Hug hack to stop callback whilst downloading tiles + updating canvas
g_source_remove(hug_gui_properties.timeout_id)
hug_gui_properties.timeout_id=-1
RESETKEY
'sequence ------------------------------
ZOOM = BB_MAPBOX.zoom
DECR ZOOM
GPS(54.48774,-0.61498,ZOOM)
SET_GEO(N,S,W,E)
TILES_GET()
MAPTILES(-256,-256*3)
TIMEOUT(50,Key_Press)
ELIF KEY() = 65362 THEN
Full demo Code of using hug.bac with hug imager, include Geo*.bac
'file Demo, streetmap.bac
INCLUDE "includegtk.bac"
' TO Scroll CANVAS , will these be in the lib? NO.
DECLARE CANY , CANX
'HOME$
'is this in the lib? Yes in Geo*bac , but good practice
'to start an app if accessing files
' append with '/' IE HOME$ & "/path/to/foo"
'=======================================================
HOME$ = GETENVIRON$("HOME")
'=======================================================
' best method to move gps position to suit, Practice before venture
' best practice :keep this file in root save this file as:
': as in for reference
FUNCTION Key_Press
IF KEY() THEN
' need to ref keys
' avoid UP/DOWN Arrow keys whem MOUSE enabled on widgets
'
'PRINT KEY()
IF KEY() = 65365 THEN
' Hug hack to stop callback whilst updating canvas
g_source_remove(hug_gui_properties.timeout_id)
hug_gui_properties.timeout_id=-1
RESETKEY
ZOOM = BB_MAPBOX.zoom
INCR ZOOM
GPS(54.48774,-0.61498,ZOOM)
SET_GEO(N,S,W,E)
TILES_GET()
MAPTILES(-256,-256*3)
TIMEOUT(50,Key_Press)
ELIF KEY() = 65366 THEN
' Hug hack to stop callback whilst updating canvas
g_source_remove(hug_gui_properties.timeout_id)
hug_gui_properties.timeout_id=-1
RESETKEY
'sequence ------------------------------
ZOOM = BB_MAPBOX.zoom
DECR ZOOM
GPS(54.48774,-0.61498,ZOOM)
SET_GEO(N,S,W,E)
TILES_GET()
MAPTILES(-256,-256*3)
TIMEOUT(50,Key_Press)
ELIF KEY() = 65362 THEN
DECR CANY,128/2
MOVE(win,canvas,CANX,CANY)
ELIF KEY() = 65364 THEN
INCR CANY,128/2
MOVE(win,canvas,CANX,CANY)
ELIF KEY() = 65361 THEN
DECR CANX,128/2
MOVE(win,canvas,CANX,CANY)
ELIF KEY() = 65363 THEN
INCR CANX,128/2
MOVE(win,canvas,CANX,CANY)
END IF
RESETKEY
END IF
'=======================================
RETURN TRUE
END FUNCTION
'=Callback Icon Button ========================================
SUB Click()
PRINT "Button Click Event"
'rest of code here
END SUB
'==============================================================
/*
===============================================================
= Notes === play with ZOOM levels + arrow keys then venture =
= n = "tiles" north of gps pos, s south of =
= e left of gps w -> =
===============================================================
*/
' some basic rule for normal use: more on advanced use later
N = 4
S = 2
W = 5
E = 4
IF (N > 5) THEN
N=6
CANY= -256
END IF
IF (S > 5) THEN
S=6
END IF
IF (E > 5) THEN
E=6
END IF
IF (W > 5) THEN
W=6
END IF
'============
IF (N < 2) THEN
N=2
END IF
IF (S < 2) THEN
S=2
END IF
IF (E < 3) THEN
E=2
END IF
IF (W < 3) THEN
W=2
END IF
'=====================================================================
' IF GPS THEN PASS DATA HERE LAT FIRST & THEN LON
' need if last pos not = this pos then , sequential style in
' Key_Press ZOOM home and page down keys Change
' but can map own keys...
GPS(54.48774,-0.61498,18)
'######################################################################
SET_GEO(N,S,W,E)
'------------------------
BB_MAPBOX.provider$ = "https://a.tile.openstreetmap.org"
BB_MAPBOX.cache$ = "bacon-osm-maps"
'BB_MAPBOX.degmin$ -------------------------
BB_MAPBOX.rem$ = "Pos: " & BB_MAPBOX.degsec$
' if files to download , tec wise on rpi 4g 20 - 30 secs to 3 - 4 min
' depend on scope of NSWE. why NSWE '-N , +S , -W, +E' of GPS pos
' can Mmax this out to download many tiles
' this Max will be demo'd in ,thinking, tutorial or in hints an tips
PRINT "Please Wait 3,4 minutes getting Tiles"
TILES_GET()
'------------------------
' medium size, Then Maximize window . position gps to suit then minimise back
win = WINDOW("test imager",800,550)
RESIZABLE(win,TRUE)
'------------------------
canvas = CANVAS(4352,4352)
ATTACH(win,canvas,0,0)
EBOXSVISABLE(canvas,FALSE)
' Map tiles to hug Canvas Typical values -----------
'typical +CANX start -128 0n 4x3 screen @ 1920X1080 monitor
MAPTILES(-256,-256*3)
CANX= -128
MOVE(win,canvas,CANX,CANY)
'------------------------
ico = G_ICON("document-open",4,22)
RATTACH(win,ico,3,3)
CALLBACK(ico,Click)
'------------------------
TIMEOUT(50,Key_Press)
DISPLAY
'--END ALL THAT ------------
BR
Alex