|
Post by Pjot on Jul 25, 2022 17:53:09 GMT 1
Thanks Joe, It works perfectly now! Very good job. I like it how small the code is, and yet how powerful the browser. Also small things, like right mouse button -> Copy URL work as usual. Best regards Peter
|
|
|
Post by bigbass on Aug 7, 2022 2:20:45 GMT 1
Hello if you want to use a GUI you have to get the low level code working also Qt low level code for serial ports and usb serial ports have their own special way of doing things this is cli low level code for hardware hacking portcheck.bac'---depends libqt5serialport5-dev for my rpi3 connected from USB to an arduino nano I need to connect with this ./portcheck /dev/ttyUSB0 115200 if you have a standard arduino or other serial connection this should work ./portcheck /dev/ttyACM0 9600 PRAGMA INCLUDE <iostream> <QtCore/QDebug> PRAGMA INCLUDE <QtCore/QStringList> PRAGMA INCLUDE <QtCore/QTextStream> PRAGMA INCLUDE <QtCore/QSize> <QtSerialPort/QSerialPort> PRAGMA INCLUDE <cstdio> <QtCore/QCoreApplication> <QtCore/QObject> PRAGMA INCLUDE <QtCore/QCommandLineParser> <QtCore/QCommandLineOption> PRAGMA LDFLAGS -lQt5Core -lQt5SerialPort -lpthread -latomic PRAGMA COMPILER g++ 'serial port testing light version for cli only no widget dependencies added ' ported fom https://code.qt.io/cgit/qt/qtserialport.git/tree/examples/serialport/creadersync?h=5.15 'by bigbass Aug 6 2020
'more low level code for rpi3 here https://basic-converter.proboards.com/post/11787/thread
'RPI3 PRAGMA OPTIONS -Wno-return-type -Wno-write-strings -Wno-pointer-arith -Wformat=1 PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC
'x86 'PRAGMA OPTIONS -Wno-return-type -Wno-write-strings -Wno-pointer-arith 'PRAGMA OPTIONS -I/usr/include/x86_64-linux-gnu/qt5 -fPIC
'---depends libqt5serialport5-dev
OPTION PARSE FALSE DEF FN PRINTOUT(x) = qDebug(x) DEF FN PRINTABLE(p) = qPrintable(p) '--- remove the need to use << DEF FN STANDARDOUT(s) = standardOutput << (s)
DECLARE app TYPE QCoreApplication* DECLARE argumentCount TYPE int DECLARE argumentList TYPE QStringList DECLARE serialPort TYPE QSerialPort DECLARE serialPortName TYPE QString DECLARE serialPortBaudRate TYPE int DECLARE readData TYPE QByteArray
'---main QCoreApplication coreApplication(argc, argv) 'special note we use QCoreApplication 'instead of the standard QApplication when its al cli argumentCount = QCoreApplication::arguments().size() argumentList = QCoreApplication::arguments() QTextStream standardOutput(stdout) IF (argumentCount == 1) THEN COLOR FG TO INTENSE RED EPRINT "Usage: ./portcheck <serialportname> [baudrate]" PRINT "Tip maybe /dev/ttyACM0 or /dev/ttyUSB0 " COLOR RESET RETURN 1 END IF IF (argumentCount == 2) THEN COLOR FG TO INTENSE RED PRINT "You need to enter a Buad Rate " PRINT "Tip maybe 9600 or 115200" COLOR RESET END END IF
serialPortName = argumentList.at(1) serialPort.setPortName(serialPortName)
serialPortBaudRate = argumentList.at(2).toInt() serialPort.setBaudRate(serialPortBaudRate)
IF (serialPort.open(QIODevice::ReadOnly)) == false THEN COLOR FG TO INTENSE RED EPRINT "Failed to open port" COLOR RESET END IF readData = serialPort.readAll() WHILE (serialPort.waitForReadyRead(3000)) == true readData.append(serialPort.readAll()) IF (serialPort.error() == QSerialPort::ReadError) THEN
COLOR FG TO INTENSE RED EPRINT "Failed to read from port" COLOR RESET RETURN 1 ELIF (serialPort.error() == QSerialPort::TimeoutError OR readData.isEmpty()) THEN COLOR FG TO INTENSE RED EPRINT "No data was currently available for reading from port " COLOR RESET RETURN 0 END IF COLOR FG TO INTENSE GREEN PRINT "Data successfully received from port" PRINTOUT(PRINTABLE(serialPortName)) PRINTOUT(PRINTABLE(readData)) COLOR RESET END WEND END app->exec()
|
|
|
Post by bigbass on Aug 9, 2022 15:02:08 GMT 1
Hello Porting c++ code to bacon can be challenging at times if you mix the code with classes it gets even more complex if you add a tool kit such as Qt that has their own way of doing things well, we could complain about it most people do (that's fine I complained about it too) and get stuck there or you could try to "fix it" to make it a little more readable so this is my first attempt to make Qt more "basic looking" of course you can rename what you like the point is some long commands could be simplified here we go I took the above demo example of the low level port code and did some syntax candy (with no sugar just natural sweeteners ok ) same commands work as the above demo (with an original source code reference too) ' ported fom code.qt.io/cgit/qt/qtserialport.git/tree/examples/serialport/creadersync?h=5.15
PRAGMA INCLUDE <iostream> <QtCore/QDebug> PRAGMA INCLUDE <QtCore/QStringList> PRAGMA INCLUDE <QtCore/QTextStream> PRAGMA INCLUDE <QtCore/QSize> <QtSerialPort/QSerialPort> PRAGMA INCLUDE <cstdio> <QtCore/QCoreApplication> <QtCore/QObject> PRAGMA INCLUDE <QtCore/QCommandLineParser> <QtCore/QCommandLineOption> PRAGMA LDFLAGS -lQt5Core -lQt5SerialPort -lpthread -latomic PRAGMA COMPILER g++ 'serial port testing light version for cli only no widget dependencies added ' ported fom https://code.qt.io/cgit/qt/qtserialport.git/tree/examples/serialport/creadersync?h=5.15 'by bigbass Aug 6 2020
'more low level code for rpi3 here https://basic-converter.proboards.com/post/11787/thread
'RPI3 PRAGMA OPTIONS -Wno-return-type -Wno-write-strings -Wno-pointer-arith -Wformat=1 PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC
'x86 'PRAGMA OPTIONS -Wno-return-type -Wno-write-strings -Wno-pointer-arith 'PRAGMA OPTIONS -I/usr/include/x86_64-linux-gnu/qt5 -fPIC
'---depends libqt5serialport5-dev
OPTION PARSE FALSE DEF FN PRINTOUT(x) = qDebug(x) DEF FN PRINTABLE(p) = qPrintable(p) '--- remove the need to use << DEF FN STANDARDOUT(s) = standardOutput << (s)
'attempt to make Qt low level code easier to understand and read with macros DEF FN GETARG(a) = argumentList.at(a) DEF FN ARG2INT(n) = argumentList.at(n).toInt() DEF FN BAUDRATE(b) = serialPort.setBaudRate(b) DEF FN PORTNAME(p) = serialPort.setPortName(p) DEF FN WAIT2READ(w) = serialPort.waitForReadyRead(w)
'attempt to make Qt low level code easier to understand and read ALIAS QCoreApplication::arguments().size() TO ARGSIZE ALIAS QCoreApplication::arguments() TO ARGLIST ALIAS serialPort.open(QIODevice::ReadOnly) TO OPENPORT ALIAS serialPort.readAll() TO READPORT ALIAS serialPort.error() TO PORT_ERROR ALIAS QSerialPort::TimeoutError TO TIMEOUT_ERROR ALIAS readData.isEmpty() TO DATA_ERROR ALIAS QSerialPort::ReadError TO READ_ERROR ALIAS readData.append(serialPort.readAll()) TO APPENDING_DATA(READPORT) ALIAS app->exec() TO DISPLAY()
DECLARE app TYPE QCoreApplication* DECLARE argumentCount TYPE int DECLARE argumentList TYPE QStringList DECLARE serialPort TYPE QSerialPort DECLARE serialPortName TYPE QString DECLARE serialPortBaudRate TYPE int DECLARE readData TYPE QByteArray
'---main app = new QCoreApplication(argc, argv) argumentCount = ARGSIZE argumentList = ARGLIST IF (argumentCount == 1) THEN COLOR FG TO INTENSE RED EPRINT "Usage: ./portcheck <serialportname> [baudrate]" PRINT "Tip maybe /dev/ttyACM0 or /dev/ttyUSB0 " COLOR RESET RETURN 1 END IF IF (argumentCount == 2) THEN COLOR FG TO INTENSE RED PRINT "You need to enter a Buad Rate " PRINT "Tip maybe 9600 or 115200" COLOR RESET END END IF
serialPortName = GETARG(1) PORTNAME(serialPortName) serialPortBaudRate =ARG2INT(2) BAUDRATE(serialPortBaudRate) IF (OPENPORT) == false THEN COLOR FG TO INTENSE RED EPRINT "Failed to open port" COLOR RESET END IF readData = READPORT WHILE (WAIT2READ(3000)) == true APPENDING_DATA(READPORT) IF (PORT_ERROR == READ_ERROR) THEN COLOR FG TO INTENSE RED EPRINT "Failed to read from port" COLOR RESET RETURN 1 ELIF (PORT_ERROR == TIMEOUT_ERROR OR DATA_ERROR) THEN COLOR FG TO INTENSE RED EPRINT "No data was currently available for reading from port " COLOR RESET RETURN 0 END IF COLOR FG TO INTENSE GREEN PRINT "Data successfully received from port" PRINTOUT(PRINTABLE(serialPortName)) PRINTOUT(PRINTABLE(readData)) COLOR RESET END WEND END DISPLAY()
|
|
|
Post by bigbass on Aug 14, 2022 9:00:31 GMT 1
using qmake with bacon what? .... I was very curious how to regenerate a new Makefileusing qmake and without the Qt dependency is that possible ? since picscale a long time bacon cli app has been tested heavily it will be used in this demo I also did some cli apps using qt and this seemed like a fun thing to try out and see what happens special thanks to vovchik for his app that will be tested even some more *spoiler it worked fine as expected with qmake on the rpi3 picscale.tar.gz (33.24 KB) qmake is way out there in the undocumented things for bacon but it serves as a working example and a mini tutorial all that to say just run ./build then read through the build script to see what happens P.S from here adding a qt GUI would be possible too just by adding back the widgets and gui options and then code your gui Joe UPDATED found the options for a clean compile with qmake gcc -c -Wno-sign-compare -Wno-unused-parameter -fno-strict-aliasing -O2 -Wall -Wextra -fPIC -I. -I. -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -o picscale.bac.o src/picscale.bac.c g++ -Wl,-O1 -o picscale picscale.bac.o -ldl
terminal output ./build Converting 'picscale.bac'... done, 309 lines were processed in 0.169 seconds. Creating lexical analyzer... done. Applying indentation... done. We finished preparing the bacon source code and moved files where they belong We will do this for you and qmake -project to configure the code We will do this also and qmake Info: creating stash file /home/joe/Downloads/picscale/.qmake.stash We will do this also and make and strip the binary Please wait it will compile for your OS now gcc -c -Wno-sign-compare -Wno-unused-parameter -fno-strict-aliasing -O2 -Wall -Wextra -fPIC -I. -I. -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -o picscale.bac.o src/picscale.bac.c g++ -Wl,-O1 -o picscale picscale.bac.o -ldl If all went well picscale is ready!
ERROR: Check input arguments!
picscale image resizer/converter - v.0.1d by vovchik, Aug 2020
Input formats supported: pnm, pbm, pgm, ppm, tga, xpm, tiff, pcx, gif, xbm, wmf, icns, bmp, png, jpg, svg and ico.
Output formats supported: png, jpg, bmp, tiff and ico.
Input parameters: -i oldfilename -o newfilename height width quality/compression/depth
Example: picscale -i old.png -o new.png 128 128 9
Quality/compression/depth settings:
bmp (N/A): 0 - 100 jpeg (quality): 0 - 100 png (compression): 0 - 9 tiff (compression type): 1 - 8 ico (depth): 16, 24 or 32
Check out BaCon at www.basic-converter.org
Run a test to convert BaCon.png to 128 x128 Warning: width result not divisible by 2 Warning: height result not divisible by 2 File new.png created. Original image: BaCon.png New dimensions (w x h): 128 x 128 Quality of new image: 9 BaCon.png is now new.png 128x128 joe@raspberrypi:~/Downloads/picscale $
|
|
|
Post by bigbass on Aug 21, 2022 7:53:57 GMT 1
Hello many things in linux is a learning curve sometimes you read a lot before you can do something even considered "simple" the problem doesn't lie in not having a lot of information ... it is sorting though it and putting it all together and make it work (having some demos) there are several things I haven't documented the qt side of things with bacon And decided the best way is with some working code examples I think that we could do a lot more with qt we are just scratching the surface and I will also make a porting guide from qt to bacon QMAKE_BACON.tar.gz (4.11 KB) you would think that qt and qmake would generate larger bacon binaries but the reality is they are smaller if you don't believe me try the examples and compare the results Joe
|
|
|
Post by bigbass on Sept 7, 2022 16:31:16 GMT 1
|
|
|
Post by bigbass on Oct 29, 2022 2:02:51 GMT 1
This one is more involved with dependencies and for the moment only is available for Manjaro RPI 3/4 the link goes into more details why and there is a README the source code link has even more details I'll get to the point just show me the code for Bacon Qt webengine ! sourceforge.net/p/bacon-qt5/wiki/qt-webengine/
|
|
|
Post by bigbass on Nov 3, 2022 19:34:40 GMT 1
BaCon Qt Digital Clock trying is a big part of the process not to mention (crash and burn too by taking risks) I wanted to learn Qt and figured that its a big complex thing to take in at one time so I thought that if I can figure out a few demos it will start to make sense someday still a long way from where I want to be but here is some progress this demo helped me to see things from a different perspective sourceforge.net/p/bacon-qt5/wiki/Qt-digital-clock/
|
|
|
Post by bigbass on Nov 7, 2022 17:33:42 GMT 1
|
|
|
Post by Pjot on Nov 8, 2022 18:07:35 GMT 1
Thanks Joe, Your demos look really nice and demonstrate the power of Qt very well BR Peter
|
|
|
Post by bigbass on Nov 8, 2022 20:23:00 GMT 1
Hello Peter Thanks for taking a look a it
Qt is another option to add to the list of what can connect to the bacon compiler!
still trying to figure things out and simplify the porting part QML Quick may be the easiest road to do Qt based widgets in the end
I will quietly work on some demos in the background they are fun to work with and port Joe
|
|
|
Post by vovchik on Nov 8, 2022 21:18:49 GMT 1
Dear Joe,
Thanks. Looks great and also works on my x86_64 Mint.
With kind regards, vovchik
|
|
|
Post by bigbass on Nov 8, 2022 22:06:32 GMT 1
Hello vovchik
Thanks for giving it a try
Glad to hear it Works on Mint x86_64
Hope all is well With you
Joe
|
|
|
Post by bigbass on Nov 17, 2022 18:13:51 GMT 1
Qt wearable devices Smart watches oh my... Will we ever be able to get BaCon to be compiled on a smart watch ? don't know for sure all the details but we are getting close! sourceforge.net/p/bacon-qt5/wiki/qt-smartwatch/it was fun to port this demo to bacon one app is a whole OS for a watch Joe
|
|
|
Post by Pjot on Nov 18, 2022 9:26:10 GMT 1
Thanks Joe,
The amount of code is impressively small!
BR Peter
|
|