|
Post by vovchik on Feb 13, 2021 22:06:27 GMT 1
Dear all, I am still playing around with these SVGs and have introduced some lighting/shadow effects. With kind regards, vovchik
|
|
|
Post by alexfish on Feb 15, 2021 14:39:47 GMT 1
Hi All RE svg animation, for reference: sometime ago I did some svg animations using HUG & librsvg. some where about HEREBR Alex
|
|
|
Post by vovchik on Apr 12, 2021 23:16:22 GMT 1
Dear all, I just read about Swatch Internet Time (SIT), about which I had known nothing, and decided to implement it using GUIFN and Webkit. It works nicely on Mint and Pi4 in terms of display, but I have an error in the SIT hour calculation. The solution is probably trivial, but it is late now, and I will look tomorrow morning. The c code is simple: main(){printf("%03d",(int)((time(0)+3600)%86400/86.4));} /* Explanation: %03d - tells printf to zero-pad up to 3 digits. time(NULL)+3600 - gets amount of seconds (UTC) elapsed since epoch and adds an hour to it (UTC+1). %86400 - divides epoch by the amount of seconds in a 24hr day and gets the remainder (representing seconds elapsed, so far, "today"). /86.4 - divide remaining seconds by 86.4 to get the ".beat" count since midnight (UTC+1).
Compile (GCC):
Save as swatch.c
gcc swatch.c -o swatch -no-pie */
The archive contains an html file that explains what SIT is, in addition to the clock gui and a command line program to show SIT. With kind regards, vovchik Attachments:
swatch-clock.tar.gz (4.21 KB)
|
|
|
Post by Pjot on Apr 13, 2021 6:10:11 GMT 1
Thanks vovchik, If I verify your calculation with the time calculated on this wikipedia page (top right) then it seems to be correct. Can you explain which error you see? BR Peter
|
|
|
Post by rikky on Apr 13, 2021 6:26:54 GMT 1
using :RPI3 Buster Openplotter installed : webkit2gtk-4.0-dev webkit2gtk-4.0 Compiling '/home/pi/Downloads/swatch-clock/swatchclock.bac'... cc `pkg-config --cflags gtk+-3.0` `pkg-config --cflags webkit2gtk-4.0` -c swatchclock.bac.c
./swatchclock.bac.gui.h:22:22: error: 'GTK_TYPE_WEBKIT_TYPE_WEB_VIEW' undeclared (first use in this function); did you mean 'WEBKIT_TYPE_WEB_VIEW'?
INFO: see full error report (y/[n])? y In file included from /home/pi/Downloads/swatch-clock/swatchclock.bac:201, from swatchclock.bac.c:2: ./swatchclock.bac.gui.h: In function '__b2c__guiDefine': ./swatchclock.bac.gui.h:22:22: error: 'GTK_TYPE_WEBKIT_TYPE_WEB_VIEW' undeclared (first use in this function); did you mean 'WEBKIT_TYPE_WEB_VIEW'? view= gtk_widget_new(GTK_TYPE_WEBKIT_TYPE_WEB_VIEW ,"width-request",XSIZE+10,"height-request",YSIZE+20, NULL); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WEBKIT_TYPE_WEB_VIEW ./swatchclock.bac.gui.h:22:22: note: each undeclared identifier is reported only once for each function it appears in make: *** [Makefile.bacon:6: swatchclock.bac.o] Error 1
I'll try on stretch Berryboot system this afternoon. Edit: Oeps sorry, crossed with Pjot. If I knew this, I would have kept my mouth.
|
|
|
Post by vovchik on Apr 13, 2021 9:58:35 GMT 1
Dear Peter,
The error is in the sit hour. I noticed it when the time changed to SIT 0h and SIT 4 s, which is just after 1 am CET. SIT hour gave 2 and not 0, so I have to check my parsing/calculation of the hour data. If you see where the problem is, please post!
With kind regards, vovchik
|
|
|
Post by Pjot on Apr 13, 2021 18:48:58 GMT 1
Hi vovchik,
I think you are missing the format string in PRINT. As your original C code shows, there is a "%03d" format for the output of the calculation. This means that the result should be padded with '0' if there are only 1 or 2 decimals.
So, a result of '1' will be printed as '001' and a result of '20' will be printed as '020'.
However, in your case you like to use floating numbers. Then we must specify a format for floating numbers, which is a bit more tricky, I had to lookup the C docs for this also. For floating numbers, you must specify the total length before the dot, and the fractional length after.
For example, "%08.2f" will provide a total field length of 8 items (including the comma) and with 2 digits after the comma.
As a result, in your case the code can be simplified as follows:
' ------------------ FUNCTION SWATCH_TIME$() ' ------------------ LOCAL swatchtime$
PRINT ((NOW+3600)%86400)/86.4 FORMAT "@%011.7f" TO swatchtime$
RETURN swatchtime$
END FUNCTION
HTH Peter
|
|
|
Post by Pjot on Apr 13, 2021 19:22:21 GMT 1
PS your code revealed a bug in PRINT..FORMAT..TO which caused the length of the resulting string to be missing.
This is now fixed in the latest beta.
BR Peter
|
|
|
Post by vovchik on Apr 13, 2021 20:08:09 GMT 1
Dear Peter, Thanks for the code fix (SIT) and the PRINT FORMAT fix. I will go fetch the new bata now.... With kind regards, vovchik
|
|
|
Post by Pjot on Apr 14, 2021 7:36:32 GMT 1
@ rikky : I think you are compiling with an older version of BaCon. Did you update to the latest beta? You need at least the commit from February 11 to prevent this issue. BR Peter
|
|
|
Post by rikky on Apr 15, 2021 6:40:37 GMT 1
Oh, right... bacon.sh from yesterday gives : Syntax error: argument to OPTION at line 1 in file '/home/pi/Downloads/swatch-clock/swatchclock.bac' not recognized! And make gives: rm -f build/* build-cpp/* Creating tokenizer for statements... done. Converting 'bacon.bac'... 5825./bacon.sh: line 772: 6354 Segmentation fault coproc COPROC "${g_BACONTOKEN}.exe" ./bacon.sh: line 363: "${COPROC[1]}": Bad file descriptor ./bacon.sh: line 364: "${COPROC[0]}": Bad file descriptor ./bacon.sh: line 363: "${COPROC[1]}": Bad file descriptor ./bacon.sh: line 364: "${COPROC[0]}": Bad file descriptor ./bacon.sh: line 226: g_ALL_MAIN_VARS[${VAR}]: bad array subscript Converting 'bacon.bac'... done, 5825 lines were processed in 991 seconds. Creating lexical analyzer... done. Warning: no CLOSE for the OPEN handle 'g_CFILE' at line 2720 in file 'bacon.bac'! Syntax error: the SUB/FUNCTION 'Pre_Tokenize_Functions__b2c__string_var' has no END in file 'bacon.bac'! make: *** [Makefile:22: bacon] Error 1 Rik
|
|
|
Post by Pjot on Apr 15, 2021 7:36:11 GMT 1
bacon.sh from yesterday gives : Syntax error: argument to OPTION at line 1 in file '/home/pi/Downloads/swatch-clock/swatchclock.bac' not recognized! That's correct, because the Shell version cannot convert GUI programs. Apparently, your shell crashes during conversion. Can you tell which shell you are using (BASH, KSH or ZSH)? Also, I am cursious to see the version. For all shells the version number should be higher than 4.x. Note that conversion with BASH is very slow. It is good with user interaction, but its scripting is not the strongest side. I'ld recommend KSH of ZSH instead. When using the './configure' script, you can force a shell by adding an argument, as follows: # ./configure --with-zsh
...and then run 'make'. BR Peter
|
|
|
Post by rikky on Apr 15, 2021 8:44:47 GMT 1
Argh ja. New system. Totally forgot that Raspberry likes to link bash to dash. Downloaded zsh ./configure --with-zsh now it works Rik
|
|
|
Post by Pjot on Apr 18, 2021 20:33:15 GMT 1
All, As announced on their blog, the GTK team has released the major version GTK 4. The last BaCon commit in fossil now also allows GTK4 code. There were quite a lot of changes in the API. Most notably, the GtkBin container class has vanished. This mostly means that we need to add child widgets manually by using helper functions. The below code works with GTK4 and demonstrates how to add a widget to a GtkFixed container. BR Peter OPTION GUI TRUE PRAGMA GUI gtk4
DECLARE (*put)() = gtk_fixed_put TYPE void
id = GUIDEFINE(" \ { type=WINDOW name=window callback=destroy title=\"GtkFixed demo\" height-request=200 width-request=400 } \ { type=FIXED name=fixed parent=window } \ { type=BUTTON name=button callback=clicked label=\"My First GTK4 program\" }")
CALL GUIFN(id, "fixed", put, GUIWIDGET(id, "button"), 100.0, 100.0)
WHILE TRUE event$ = GUIEVENT$(id) SELECT event$ CASE "window" BREAK CASE "button" PRINT "Button clicked" ENDSELECT WEND
|
|
|
Post by Pjot on Apr 22, 2021 16:34:48 GMT 1
All, To test the GTK4 support, I made the small program below. It seems that GTK4 has a Video widget built in. While working on this program, I could find one typo and one improvement for GTK in general (see fossil). The video widget works nicely, but I could not find subtitle support (yet). Anyway, interesting feature nevertheless BR Peter OPTION GUI TRUE PRAGMA GUI gtk4
DECLARE (*show)() = gtk_widget_show TYPE void DECLARE (*hide)() = gtk_widget_hide TYPE void DECLARE (*path)() = gtk_file_chooser_get_file TYPE GFile* DECLARE (*play)() = gtk_video_set_filename TYPE void
id = GUIDEFINE(" \ { type=WINDOW name=window callback=destroy title=\"BaCon Video Player\" } \ { type=BOX name=box parent=window orientation=GTK_ORIENTATION_VERTICAL } \ { type=VIDEO name=video parent=box autoplay=1 width-request=600 height-request=400 hexpand=1 vexpand=1 } \ { type=BUTTON name=button parent=box callback=clicked label=\"Select video...\" } \ { type=WINDOW name=dialog callback=close-request title=\"Open Video\" } \ { type=BOX name=box1 parent=dialog orientation=GTK_ORIENTATION_VERTICAL } \ { type=FILE_CHOOSER_WIDGET name=file parent=box1 action=GTK_FILE_CHOOSER_ACTION_OPEN width-request=300 height-request=400 vexpand=1 } \ { type=BUTTON name=open parent=box1 callback=clicked label=\"Select video...\" } ")
WHILE TRUE SELECT GUIEVENT$(id) CASE "window" BREAK CASE "button" CALL GUIFN(id, "dialog", show) CASE "dialog" CALL GUIFN(id, "dialog", hide) CASE "open" CALL GUIFN(id, "dialog", hide) PRINT g_file_get_path(GUIFN(id, "file", path)) FORMAT "%s" TO path$ CALL GUIFN(id, "video", play, path$) ENDSELECT WEND
Attachments:
|
|