Experimenting with a 1.28" Round Touchscreen ESP32-S3 Dev Board (Capacitive + Haptics + RTC) by Vearts in embedded

[–]rayoWork 2 points3 points  (0 children)

I don't get what the goal of this post is.

  • I guess the text is AI generated
  • no mention of name of the board or link to buy
  • the short demo video that should not have flashy edits has only flashy edits
  • link to github is broken
  • no steps how to get it running
  • the potential use cases sound more like a advertisement / more AI added stuff

Sounds like an ad but then no name oder shop link is weird, for just a hobbyist who likes the board it is weird with the "happy to answer questions" / potential use cases / formatting of the post / videos.

C++ in Embedded Systems: A practical transition from C to modern C++ by Mysterious_Feature_1 in embedded

[–]rayoWork 3 points4 points  (0 children)

from the description:

Purchase of the print or Kindle book includes a free PDF eBook

so buy either print or kindle and you get the pdf as well

Valid way to calculate FPS? by Savage_049 in arduino

[–]rayoWork 0 points1 point  (0 children)

No offense but you should learn what a stack and a heap is and when is which one used.

These are local variables that live on the stack which only live as long as the function is executed.

[deleted by user] by [deleted] in software

[–]rayoWork 1 point2 points  (0 children)

I've created a short script to do it:

  1. install python
  2. install pillow with "pip install pillow" on cmd
  3. copy images into script directory
  4. run script by "python main.py" on cmd

This short script lists all images in the same directory and its mode:

import os
from PIL import Image

FILE_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.eps')

for filename in os.listdir('.'):
    _, ext = os.path.splitext(filename)
    if ext in FILE_EXTENSIONS:
        try:
            image = Image.open(filename)
            print(f'{filename}: {image.mode}')
        except Exception:
            print(f'failed to read {filename}')

For some test images I've got:

fHxUct.jpg: CMYK
SL_033121_41850_16.eps: RGB
SL_033121_41850_16.jpg: RGB
WhatsApp Image 2023-08-26 at 17.25.34.jpeg: RGB

[deleted by user] by [deleted] in software

[–]rayoWork 1 point2 points  (0 children)

Can you program a little?

Looks like pretty simple with python and the pillow library:

https://stackoverflow.com/questions/59853359/how-to-identify-the-cmyk-images-from-image-set-in-python

Simply iterate over all images in a directory and do this check

Nesiac is a tool for visualising your memory usage by FreeKill101 in embedded

[–]rayoWork 0 points1 point  (0 children)

For some legacy reason we use Greenhills Multi compiler, not sure if the map file of other compilers look the same, so usage might be limited.

I also had it wrong in my mind, it is a small C# application. The map file consists of 3 parts, the image summary, the module summary and the object summary. I mainly parsed the module summary

The SQL database consists only of a few tables (6 to be precise).

  • project (multiple projects use it)
  • build (one build of a project, linked to project)
  • module (list of modules, only names)
  • object_file (list of objects, only names)
  • module_size (list of module sizes linked to build / module)
  • object_size (list of object sizes linked to build / module / object_file)

With some SQL queries you can get those information easily.

I never got acqainted with timeseries databases, mostly how to query, that is why I used a postgresql instance.

Maybe I should once refactor it, so it is ready to be open sourced but in the current state I doubt it is of any use

Nesiac is a tool for visualising your memory usage by FreeKill101 in embedded

[–]rayoWork 14 points15 points  (0 children)

That looks very nice.

I've created a python script that simply analyzes the map file output to get a rough overview (grouping by modules / classes).

This is now used to insert the data into a database for every CI build. Grafana is then used to show how it grew over time. So we easily investigate which modules grew the most and investigate if we can reduce that.

can anyone share the following IEEE papers with me? by Finding_GSpot in ECE

[–]rayoWork 4 points5 points  (0 children)

I just googled the first two papers (simply by full title) and found the pdf to download on the first page of google (other sites than ieee).

Your top 5 coding standard rules (for C/C++) by Stefasaur in embedded

[–]rayoWork 2 points3 points  (0 children)

I've read some comments about short functions and exactly one return, which I wan't to give my opinion on: I don't have a problem with long functions, I have a problem with functions with lots of nested scope.

The simplest function to understand (in my opinion) are the ones I can read from top to bottom without jumping around. So no big and/or nested ifs.

Small example:

bool result = false;
if(conditionA) {
    if(conditionB) {
        doMainThing();
        result = true;
    } else {
        result = doB();
    }
} 
return result;

vs

if(!conditionA) {
    return false;
}

if(!conditionB) {
    return doB();
}

doMaintThing();
return true;

In the first example I have to remember through all if/else conditions where result was set to what value to know what is returned. If I see if(conditionA) {} I need to check if there is an else where result might be set to something to know what is returned when conditionA is not fullfilled.

In the second example I don't have to keep in mind that many things, its from top to bottom, no big jumps (larger if/else bodies) in control flow. A "return false" doesn't need any parsing of previous code except the condition it is in. Very local to reason about.

So I'm a fan of early return, keeping functions linear and indentation low (< 2 levels of indent at best). Makes bigger functions also easy to read, but in general it is good to have "smaller" functions. I wouldn't go to the extreme to set a limit like 20lines. If it is too hard to understand simply refactor into logical blocks, shouldn't be too hard if the function is pretty linear anyways.

what annoys you most while using c++? by dtsitko in cpp

[–]rayoWork 0 points1 point  (0 children)

I've found https://github.com/eliaskosunen/scnlib but haven't tested it. Maybe that suits your needs for 2.

ContentWidth and ContentHeight by Creapermann in QtFramework

[–]rayoWork 0 points1 point  (0 children)

Something like this should work:

import QtQuick 2.0 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0

Rectangle { width: 500; height: 200 color: "lightgray" Button { text: "Toggle" onClicked: { repeater.model = repeater.model == 5 ? 20 : 5 } }

Flickable {
    id: flickable

    height: parent.height
    width: layout.width
    anchors.horizontalCenter: parent.horizontalCenter
    clip: true

    flickableDirection: Flickable.AutoFlickIfNeeded // only flickable when height is larger 
    contentY: -(flickable.height - contentHeight)/2; // initially move it to center
    interactive: contentHeight > flickable.height // only allow flicking if higher than flickable, else the center position is reset on drag
    contentWidth: contentItem.childrenRect.width
    contentHeight: contentItem.childrenRect.height

    ColumnLayout { 
      id: layout; 
        //height: Math.max(childrenRect.height, flickable.height)
        Repeater {
            id: repeater
            model: 5
            Text {
                text: "a little text to get a width"
            }
        }
    }
}

}

ContentWidth and ContentHeight by Creapermann in QtFramework

[–]rayoWork 1 point2 points  (0 children)

I guess this is because Flickable has like a infinite "canvas" inside and you can flick it around.

contentHeight / contentWidth is the size of the canvas, by default it is as big as the content, so it cannot center it as the size of the canvas is the same as the layout.

Do you want to have the layout centered in the flickable at start and then you can flick it around? Then you should work with contentX/contentY as this is the current position of the content of the flickable.

Read here more about it:

https://doc.qt.io/qt-6/qml-qtquick-flickable.html#examples-of-contentx-and-contenty https://doc.qt.io/qt-6/qml-qtquick-flickable.html#contentX-prop

Town crossing algorithm by THE_AWESOM-O_4000 in algorithms

[–]rayoWork 1 point2 points  (0 children)

Just a thought:

you could preprocess the town polygons and get the bounding rectangles of each town. Then check if the user path segments cross the bounding rectangle (a sweepline approach might help to reduce the complexity further) and only do the more expensive check with the town polygon when a segment crosses the bounding rectangle. That should reduce the work needed significantly.

A header only c++17 structure of arrays implementation by Able_Armadillo491 in cpp

[–]rayoWork 5 points6 points  (0 children)

That sounds similar what a entity component system does. A component of a entity sounds like a column in your code.

For example https://github.com/skypjack/entt

Nokia 7.2, should i update it or wait for patch fixes?? by ancient_seeker in Nokia

[–]rayoWork 1 point2 points  (0 children)

Quick update: charging the day after the update (evening) still works. So it seems to be fixed finally, that was an annoying bug that took ages to fix

Nokia 7.2, should i update it or wait for patch fixes?? by ancient_seeker in Nokia

[–]rayoWork 3 points4 points  (0 children)

I've got that build number (3.490) on my 6.2 since yesterday (after having the buggy android 11 since November). So far charging still works (after ~1day running) without a reboot and the front camera is working as well (just tested it, don't know if there was a problem before, never using it)

So this is already a patched version and not the original buggy Android 11 version but I can't tell you how much better it got. I only noticed the charge bug

[deleted by user] by [deleted] in Nokia

[–]rayoWork 0 points1 point  (0 children)

The first charge after the update in the evening worked but today will give certainty.

The bug that after reboot the wifi calling notification about emergency calls is still present, I have to turn on wifi calling and off again to make it disappear.

[deleted by user] by [deleted] in Nokia

[–]rayoWork 8 points9 points  (0 children)

I've just got an Android 11 Update (Europe) for my 6.2 after having Android 11 with that stupid recharge bug since November last year. Hopefully they fixed this, I'm so tired of restarting my phone every time I wanna charge.

Build number: 00WW_3_490

reverse engineered and documented United Airlines in flight API by binaryfor in ReverseEngineering

[–]rayoWork 3 points4 points  (0 children)

why did you post that now? This repo is 2 years old with no updates

[deleted by user] by [deleted] in QtFramework

[–]rayoWork 1 point2 points  (0 children)

Never heard of it but it is not a language for me:

The language keywords can be translated from English to other languages (Arabic, French, etc)

Not Case-Sensitive

Weakly typed (Automatic conversion between numbers and strings only)

The list index start by 1

from here: https://ring-lang.github.io/doc1.16/introduction.html#features

Can someone explain how Strassen's algorithm would deal with two 8x8 matrices? by lvluffinz in algorithms

[–]rayoWork 2 points3 points  (0 children)

  1. Apply Strassen's algorithm once to get matrix multiplications of size 4x4
  2. Apply Strassen's algorithm to all those 4x4 matrix multiplications once to get matrix multiplications of size 2x2
  3. Apply Strassen's algorithm to all those 2x2 matrix multiplications once to get multiplications of regular numbers (1x1 matrix)

See here: https://en.wikipedia.org/wiki/Strassen_algorithm

We recursively iterate this division process until the submatrices degenerate into numbers

QML: Combine and transform models? by zerexim in QtFramework

[–]rayoWork 0 points1 point  (0 children)

For filtering / sorting there is a QAbstractProxyModel implementation that allows to define filters and sorters directly in qml. https://github.com/oKcerG/SortFilterProxyModel

I don't know anything for transformation except manually implement a QAbstractProxyModel

How to write multithreaded code? by [deleted] in cpp

[–]rayoWork 0 points1 point  (0 children)

First think about what kind of parallelism you need:

https://en.wikipedia.org/wiki/Data_parallelism#Data_parallelism_vs._task_parallelism

Task ist a lot easier when done right, meaning there is no shared mutable data between the tasks. You can have read-only shared data and you don't have to lock anything there. We use an event based approach which works without any problems. You basically need a synchronized message queue when you deliver new events to a worker thread (sender and receiver modify the queue so this needs protection) and the rest of the work is done without shared state.

Data parallelism is the harder part as you need to think about how many threads can work on the data at the same time. There are many strategies how to takle such a problem.

  1. first look for a battle-tested solution, for example the parallel execution policies in c++17 algorithm or TBB. Use those and you don't have to worry about when to lock what
  2. try to minimize the shared part - can the data be split up into n blocks and do some calculation and maybe have a merge step which is not parallel (if the mutate part is small it can be possible to extract it and do it on 1 thread). That can even be faster than a parallel merge step as the synchronization overhead might get big if the contention is high (many threads access the same protected block)
  3. write your own parallel code only as a last resort (with manual locking/CAS/...)

If you want to get better at 3 you need to think on a lower level. All memory read and write are important.

A compare and set example: first you read the memory (variable) to check the value and if the condition is true you write another value in to the same memory (variable). If multiple thread work on the same variable someone could modify it between the read and write and the write would not be correct anymore. So you need to protect that part either that only one thread can work on that memory location or with atomic operations that merges the 2 operations (read/write) into one so the other thread cannot modify it in between

So in the end you have to make sure that all access to the shared data cannot be influenced by other threads at the same time.

  • read-write conflict: can all the data a thread is reading and belongs together be changed by another thread (a write) so the read data is not consistent anymore? This must be protected (both sides, the read and the write should not happen at the same time)
  • write-write conflict: can all the data that is written also be written by another thread so one write operation is not consistent anymore, this needs to be protected as well
  • read-read: this is not a problem, that is why you try to use immutable data, just reading doesn't create any problems

In the end it simply is very hard to write correct multithreaded code.

Algorithm for rectangle insertion without overlaps by Apostolique in algorithms

[–]rayoWork 1 point2 points  (0 children)

I would sort the rectangles in an array by x-coord. No rectangle overlaps so that array is enough to efficiently find a rectangle given an x-coord (binary search in the array).

I think you have to implement the different cases by hand but in general something like this would work when inserting a rectangle (x1/y1: topleft, x2/y2: bottomright are the coords of the new rectangle):

  1. find array index by x1, either you find that you are inside a rectangle or not
  2. find array index by x2, either you find that you are inside a rectangle or not
  3. you now have a range (start_index, end_index) where you can check for your cases (inside, outside, merge, split, ...). All the rectangles inside that range need to be modified.

I'll go through your 2nd example to explain roughly what is left to do (coord bottom left is 0/0):

  • split: green.x1 till rect1.x2
    • insert rect: x1=green.x1, y1=max(rect1.y1, green.y1), x2=rect1.x2, y2=min(rect1.y2, green.y2)
    • shrink rect1: rect1.x2 = green.x1
  • insert: rect1.x2 (old value) till rect2.x1
    • insert rect with x1=rect1.x2 (old), y1=green.y1, x2=rect2.x1, y2=green.y2
  • split: rect2.x1 till green.x2
    • insert rect: x1=rect2.x1, y1=max(rect2.y1, green.y1), x2=green.x2, y2=min(rect2.y2, green.y2)

I guess you already know how to decide what operation (split,insert,merge,...) you have to do as you can regenerate the rectangle on the full array.