How can I change element position at runtime on the Nextion Enhanced 7.0? - arduino

I have Nextion 7.0 Enhanced capacitive display. I want to display map on the display and place the picture of pointer on a specific place on the display. I use the Arduino board for computing the position and loading data from SD card.
I tried to use move function, but the Enhenced displays doesn't support this function. and when I tried to change x and y attribute, I got the message "Assignment operation failed"

Related

What components to choose for monitoring free preferential places in a minibus on Arduino?

I need cards for concessionaires lying next to the driver so that their number is shown on the display next to the bus route number. When the driver at the entrance issues the card to concessionaire 1, the display should accordingly show "Preferential Seats - 3"
instead of "Preferential Seats - 4". That is, reduced by 1. So what components are needed to implement such an idea using Arduino?
I thought it would require a scanner, chips to insert into the benefit recipient card, some kind of microcontroller to process the data, and a display to display the information

Extract contacts and messages from a Nokia 105 full dump (.bin) file

Have a problem where I had to read the complete firmware (using an eeprom reader) from a hardware disabled (beyond repair) Nokia 105 (RM-908) in order to try and extract SMSes and the contacts. Using a hex editor I can see the all the data, however,I cannot manage to find out the complete information. For instance the date and receiver of the messages or the user associated with the contact numbers. The only idea I believe that can be done is to extract the personal user area PMM from the bin, get another set with the same version of this disabled device, build up an image, flash the resulting image using an appropriate flasher in the working device and read the content off this device. While I am unsure if this will work (theoretically might work), would like to try to avoid this procedure as it is very time consuming and maybe get to the target data directly via hex editing or any other application.
thanks for any help

How to properly save window state in QML

I read the Qt Documentations, I checked out a couple examples provided with the SDK, I build Qt Creator from source to see how the Qt devs do it...still no luck.
I am developing a cross platform application for Windows and Mac. On the Mac side I can try basically any of my solutions all of them work perfectly (I guess that is a thanks to the MacOS). On the other hand on Windows I always find some kind of bug or sketchy behavior.
Before I go into more details the root of my problems is supporting multiple monitor environments with monitors, which have different resolutions.
My two main solutions in a nutshell:
Since I am writing my application mainly in QML I use ApplicationWindow for my main window. I save the state of my ApplicationWindow in Settings. My code takes into consideration if the previously saved position is still valid (for example if the application was closed while it was on a monitor, which is no longer available)...the only reason why I have to do this because Windows would just open my app's window in "outer space" (Mac handles this automatically). My application (on Windows) gets into a really weird state if I close my application on one of the monitors and then I change the other monitors scaling factor and then I reopen my application. It opens up on the right monitor but it gets way over scaled and the UI elements are just weirdly floating. If I resize the window everything gets back to normal.
I exposed my QML ApplicationWindow to C++ put into a QWidget container, which then I attached to a QMainWindow by setting it as a setCentralWidget. With this method I have access to saveGeometry and restoreGeometry, which automatically takes care of multiple monitor positioning, but the scaling anomaly what I described in 1. still persist.
Did anybody solved this? Thanks in advance for any help and hin
#retif asked for me to provide a writeup when I commented I knew about these types of issues months ago.
TLDR
When dealing with an absolute positioning issue with a Qt Windows on the Windows OS - especially on Windows 10, it's best to be using system-DPI awareness. Some interpolation is required when going from Windows coordinate spaces (at different DPI awareness levels) to Qt coordinate spaces when you are trying to have the best scaling.
Here's what I did on my team's application.
The Problem:
It is really hard to do absolute positioning of a Qt Window when there are multiple monitors and multiple DPI resolutions to contend with.
Our application window "pops up" from a Windows task tray icon (or menu bar icon on Mac).
The original code would take the Windows screen coordinate position of the tray icon and use that as a reference to compute the positioning of the window.
At app startup, before Qt was initialized, we'd set the environment variable, QT_SCALE_FACTOR to be a floating point value of the (systemDPI/96.0). Sample code:
HDC hdc = GetDC(nullptr);
unsigned int dpi = ::GetDeviceCaps(hdc, LOGPIXELSX);
stringstream dpiScaleFactor;
dpiScaleFactor << (dpi / 96.0);
qputenv("QT_SCALE_FACTOR", QByteArray::fromStdString(dpiScaleFactor.str()));
The code above takes the primary monitors "DPI scale" and tells Qt to match it. It has the pleasant effect of letting Qt compute all scaling natively instead of a bitmap stretch like Windows would do in a non-DPI aware application.
Because we initialize Qt using the QT_SCALE_FACTOR environment variable (based on primary monitor DPI), we were using that value to scale the Windows coordinates when converting to Qt's QScreen coordinate space for this initial window placement.
Everything worked fine on single monitor scenarios. It even worked fine on multi-monitor scenarios as long as the DPI on both monitors was the same. But on configurations of multiple monitors with different DPIs, things got off. If the window had to pop-up on the non-primary monitor as a result of a screen change or a projector getting plugged in (or unplugged), weird stuff would happen. The Qt windows would appear in the wrong position. Or in some cases, the content inside the window would scale incorrectly. And when it did work, there would be a "too big" or "too small" problem of the windows scaled to one DPI when positioned on a similar sized monitor running at a different DPI.
My initial investigation revealed that Qt's coordinate space for the different QScreens geometries looked off. The coordinates of each QScreen rect was scaled based on the QT_SCALE_FACTOR, but the adjacent axis of the individual QScreen rects were not aligned. e.g. One QScreen rect might be {0,0,2559,1439}, but the monitor to the right would be at {3840,0,4920,1080}. What happened to the region where 2560 <= x < 3840 ? Because our code that scaled x and y based on QT_SCALE_FACTOR or DPI was relying on primary monitor being at (0,0) and all monitors to have adjacent coordinate spaces. If our code scaled the assumed position coordinate to something on the other monitor, it might get positioned in an odd place.
It took a while to realize this wasn't a Qt bug per se. It's just that Qt is just normalizing the Windows coordinate space that has these weird coordinate space gaps to begin with.
The fix:
The better fix is to tell Qt to scale to the primary monitor's DPI setting and run the process in system-aware DPI mode instead of per-monitor-aware DPI mode. This has the benefit of letting Qt scale the window correctly and without blurriness or pixelation on the primary monitor and to let Windows scale it on monitor changes.
A bit of background. Read everything in this section of High DPI programming on MSDN. A good read.
Here's what we did.
Kept the initialization of the QT_SCALE_FACTOR as described above.
Then we switched the initialization of our process and Qt from per-monitor DPI awareness to system-aware DPI. Th benefit of system-dpi is that it lets Windows auto-scale the application windows to the expected size as the monitors change out from underneath it. (All Windows APIs act as if all monitors have the same DPI). As discussed above, Windows is doing a bitmap stretch under the hood when the DPI is different from primary monitor. So there's a "blurriness issue" to contend with on monitor switching. But it's sure better than what it was doing before!
By default Qt will try to initialize the process to a per-monitor aware app. To force it to run in system-dpi awareness, call SetProcessDpiAwareness with a value of PROCESS_SYSTEM_DPI_AWARE very early in application startup before Qt initializes. Qt won't be able to change it after that.
Just switching to System-aware dpi fixed a bunch of other issues.
Final bug fix:
Because we position our window at an absolute position (directly above the systray icon in the task tray), we rely on the Windows API,Shell_NotifyIconGetRect to give us the coordinate of the systray. And once we know the offset of the systray, we calculate a top/left position to position for our window be on the screen. Let's call this position X1,Y1
However, the coordinates returned from Shell_NotifyIconGetRect on Windows 10 will always be the "per-monitor aware" native coordinates and not scaled to the System DPI. Use PhysicalToLogicalPointForPerMonitorDPI to convert. This API doesn't exist on Windows 7, but it's not needed. Use LoadLibrary and GetProcAddress for this API if you are supporting Windows 7. If the API doesn't exist, just skip this step. Use PhysicalToLogicalPointForPerMonitorDPI to convert X1,Y1 to a system-aware DPI coordinate wel'll call X2,Y2.
Ideally, X2,Y2 is passed to Qt methods like QQuickView::setPosition But....
Because we were using the QT_SCALE_FACTOR environment variable to get the application to scale the primary monitor DPI, all the QScreen geometries would have normalized coordinates that were different from what Windows used as the screen coordinate system. So the final windows position coordinate of X2,Y2 computed above would not map to the expected position in Qt coordinates if the QT_SCALE_FACTOR environment var was anything but 1.0
Final fix to get the final top/left position of the Qt window calculated.
Call EnumDisplayMonitors and enumerate the monitors list. Find the monitor in which X2,Y2 discussed above is positioned on. Save off the MONITORINFOEX.szDevice as well as the MONITORINFOEX.rcMonitor geometry in a variable called rect
Call QGuiApplication::screens() and enumerate these objects to find the QScreen instance whose name() property matches the MONITORINFOEX.szDevice in the previous step. And then save off the QRect returned by the geometry() method of this QScreen into a variable called qRect. Save the QScreen into a pointer variable called pScreen
Final step of converting X2,Y2 to XFinal,YFinal is this algorithm:
XFinal = (X2 - rect.left) * qRect.width
------------------------------- + qRect.left
rect.width
YFinal = (Y2 - rect.top) * qRect.height
------------------------------- + qRect.top
rect.height
This is just basic interpolation between screen coordinate mappings.
Then the final window positioning is to set both the QScreen and XFinal,YFinal positions on the view object of Qt.
QPoint position(XFinal, YFinal);
pView->setScreen(pScreen);
pView->setPosition(position);
Other solutions considered:
There is the Qt mode called Qt::AA_EnableHighDpiScaling that can be set on the QGuiApplication object. It does much of the above for you, except it forces all scaling to be an integral scale factor (1x, 2x, 3x, etc... never 1.5 or 1.75). That didn't work for us because a 2x scaling of the window on a DPI setting of 150% looked too big.

AdaFruit pn532 NFC/RFID detecting multiple tags?

I am working off an Arduino UNO with an AdaFruit pn532 NFC/RFID shield. The Goal is to have a shoe box, with a false bottom. Under that false bottom would be my prototype, which hopes to be able to tell every mifare tag (up to 6) that is in the box, above the false bottom.
I started with one shield, and had it detecting up to two tags with in range..
If i placed one tag it logged that one tag over and over again in the loop() of my sketch.
If I placed two tags above the shield it logged the two tags in an alternating pattern. ("tag1","tag2","tag1"....)
But when I placed three tags, it only logs the third tag.. This is essentially using the adaFruit mifare example.
I then set up the UNO with two shields and in the loop() checked both.. worked exactly the same. Once there were three tags, regardless of which pn352 they were placed on (2 on one, and 1 on another, or all three on one) it only logs one tag.
Has anyone tried to create anything that would detect up to 6 tags in range? If so could you share your discoveries?
New to Arduino..
thanks
The answer to your question leads into the technology of RFID. The reader emits radio waves at the operating frequency (usually 125kHz or 13.56MHz). When you bring an RFID tag to the reader - it accumulates the energy of the magnetic field of the reader and use this energy to transmits the ID at the same frequency back to the reader. The key point is that the RFID protocol does not provide for work with several tags at once.
So, if you bring 2 or more tags to the reader - they simultaneously start to generate RF signal, each with its own ID, thus "interrupting" each other. As a result, your reader gets garbage instead of the correct ID payload.

How to create wave forms in ModelSim Altera Starter

I'm using Altera ModelSim 10.1d for a verilog project for a class. I can't figure out how to run the simulation properly. I have a very simple verilog file (just a 2 to 1 multiplexer) and I want to try 4 different combinations of inputs.
According to the guides on Altera's site I've done the following:
1) Clicked Simulate->Start Simulation and selected the mux file
2) Clicked Add Wave in the 'Sim' pane
3) Then clicked run.
All I get are some flat lines. How can I modify the wave form of the inputs? Right clicking an input in the objects pane and going to 'modify' has a 'change value' option but it is grayed out.
Any ideas?
You need to create a testbench that drives the inputs to the mux. The simulator doesn't know how to do that without being told. You can manually fiddle with the inputs in the wave window by right clicking on them and selecting the force dialog to set a new value but it is tedious to use for anything but debug.

Resources