cadentius_aurelius's recent activity

  1. Comment on What programming/technical projects have you been working on? in ~comp

    cadentius_aurelius
    (edited )
    Link
    The Two Trees of Valinor, silver Telperion and golden Laurelin, provided light to the Undying Lands in a regular 12-hour light cycle, switching between silver light and golden light. A few months...

    The Two Trees of Valinor, silver Telperion and golden Laurelin, provided light to the Undying Lands in a regular 12-hour light cycle, switching between silver light and golden light.

    A few months ago, I wrote a very small library that maps real-world time onto this cycle, returning the brightnesses of the trees at any given time as a pair of 0.0 <= n <= 1.0 scaling floats, according to rather simple curves. I also included a rudimentary color struct so that it could turn those scalars into RGB. Last month, I obtained an LED light strip, and set to work writing a driver to run it off the GPIO on my Raspberry Pi.

    It has been...a journey.

    WS2812B dictates that a data signal has a period in the vicinity of 1.25μs, with pulses as short as 0.4μs. My first attempt was to simply toggle the GPIO that quickly in software, but I soon found out that, using Rust, I could only generate a signal with a period of around 10μs...So I went all-in and learned a bit of ARM assembly to build and link in via build.rs.

    First, I wrote my waiting spin-loop; then I ran it with a value of 2000000000, five times, and measured the runtime with time. Finding that each loop averaged ~3ns (at 1GHz, 3 cycles per loop, surprisingly nice), I set that as a constant to divide the delay values to find the iteration counts. This worked...sort of. Raspbian was rudely swapping me out and making my actual delays utterly unpredictable; the colors were usually generally correct, but shifted bits were making them the wrong brightness or making them bleed into each other. Breaking more new territory, I even compiled a custom kernel for the first time, in order to get realtime scheduling, but even that was not enough to keep that 3ns consistent.

    My third attempt was to modify my assembly spin-loop to read the output level of GPIO18, which I would set running with the PWM hardware as a bootleg clock, and for which the output value is conveniently just a few registers down in the same memory block I already had mapped. I have a variant of the loop that watches for changes in the level, and a variant that watches for only the rising edge; and by painstaking and tedious experimentation, I zeroed in on a set of values that keep the signal remarkably close to stable, even with being swapped out. This is currently my best-working version, and it is almost perfect, so long as I only run the update once every few seconds. Its stability is even affected by how much debug info I print before and after each update.

    For the past few days, I have been trying to comprehend the process of using DMA to inject the data directly into the hardware PWM output, which, if it works, should be perfect. However, pretty much all of the example code is in C, and I do not know C very well, which is something of an obstacle.

    I just wanted some holy trees, man.


    UPDATE: I have perfected the driver. The DMA+PWM approach was a dead end, so I finally surrendered and used the SPI hack that seems to be the go-to method. The library was written for a different version of the WS28XX protocol, so the timing values were just barely wrong, but fortunately, it includes a function that assumes the data you give it is already encoded for SPI; all I had to do was write a new encoder using my own timing constants, and now I can essentially use that library as an easy preconfigured gate into the SPI device.

    A quick stress test with all sleeps removed showed that my full pipeline can output upwards of 2400 strip refreshes per second, with no flickering. I now possess the light of a Silmaril.

    5 votes
  2. Comment on 70TB of Parler users’ messages, videos, and posts leaked by security researchers in ~tech

  3. Comment on 70TB of Parler users’ messages, videos, and posts leaked by security researchers in ~tech

    cadentius_aurelius
    Link Parent
    The parent comment is deleted, but for awareness could you repeat the false claim (in context as false)? If it is something I saw I would like to be set straight on it.

    The parent comment is deleted, but for awareness could you repeat the false claim (in context as false)? If it is something I saw I would like to be set straight on it.

    1 vote
  4. Comment on What programming/technical projects have you been working on? in ~comp

    cadentius_aurelius
    Link
    I have been getting really into Rust, and have been making improvements on my small experimental tool, LSR, which is based on what I would prefer to be the behavior of ls -R. Essentially, to...

    I have been getting really into Rust, and have been making improvements on my small experimental tool, LSR, which is based on what I would prefer to be the behavior of ls -R. Essentially, to recursively list a directory tree, outputting only the relative paths, for direct use as arguments in other commands. For example:

    ~$ lsr top
    top/sub1/file1a
    top/sub1/file1b
    top/sub2/file2a
    top/sub2/file2b
    top/sub2/file2
    top/file3a
    

    So far, I really like Docopt. You write the help text as a &str constant first, and it gets automatically parsed and used to turn the command line input into usable values.

    Usage:  lsr [-adDLq] [<path>...]
            lsr -h
    
    Options:
        -a, --all           Include 'Hidden' Files and Directories.
        -d, --dirs          Print the Directories themselves, not just Files.
        -D, --dirs-first    Traverse Subdirectories before printing Files.
        -L, --dereference   Follow Symbolic Links to Directories.
        -q, --quote         Quote output Paths.
        -h, --help          Show this text.
    

    This, plus defining the struct and feeding the input into Docopt, results in a fully formed object with boolean attributes like args.flag_dereference. Not even Python has anything that makes this so easy.

    6 votes
  5. Comment on How should I host my images? in ~tech

    cadentius_aurelius
    Link
    I have recently taken to making gifs, and I have built a couple tools to make it clean. The first one is nothing more than a wrapper for FFmpeg that I use to quickly cut out a 10-30 second chunk...

    As a bonus, can anyone recommend software for optimizing GIF and video files for sharing online? (Same preferences as above.)

    I have recently taken to making gifs, and I have built a couple tools to make it clean.


    The first one is nothing more than a wrapper for FFmpeg that I use to quickly cut out a 10-30 second chunk of video that I want to gif. It has no fancy features.
    https://pastebin.com/3XaXJWZv

    snip /path/to/input/file.mkv 5:29 15 ~/Videos/gif/base.mkv
    

    The second one, loosely based on a blog post by Giphy, has three stages:

    1. Scale the source video down to a temporary video with the size of the final gif
    2. Generate an optimal color palette from the video
    3. Convert the temporary video into a gif, using the palette

    Command line options are inserted directly into the ffmpeg call in step 1, so you can pass FFmpeg options after the input filename. Use environment variables HEIGHT and WIDTH to control the output size, passed to the scale filter, or the FILTER env var to replace it with something else, like a crop.
    https://pastebin.com/PppXSSea

    mkgif ~/Videos/gif/base.mkv -ss 3 -t 10 -r 15
    
    HEIGHT=480 mkgif ~/Videos/gif/base.mkv -ss 3 -t 5
    

    I have made many gifs with this workflow. Here are a few.

    4 votes
  6. Comment on What are your favorite and least favorite gaming tropes? in ~games

    cadentius_aurelius
    Link
    When higher "difficulty" settings make the AI literally cheat, it is a bad AI. In Stellaris, and Civilization, and many other games, rather than making the AI better, high difficulties give the AI...

    When higher "difficulty" settings make the AI literally cheat, it is a bad AI.

    In Stellaris, and Civilization, and many other games, rather than making the AI better, high difficulties give the AI players free resources. My personal rule is to play on the highest difficulty setting which is still materially fair, and in many games, it is honestly a little upsetting how "low" that level is.

    I recognize that game AI, especially for a grand strategy game, is in no way trivial. But come on.

    8 votes
  7. Comment on What are the most worthwhile DLCs you've played? in ~games

    cadentius_aurelius
    (edited )
    Link
    The DLC for Dark Souls 2 is top-tier. Crown of the Ivory King might be my favorite part of the entire series, and Dark Souls 2 is my least favorite. Only thing, though, is that they are HARD. If...

    The DLC for Dark Souls 2 is top-tier. Crown of the Ivory King might be my favorite part of the entire series, and Dark Souls 2 is my least favorite. Only thing, though, is that they are HARD. If you thought the base game was tough then youre really in for it.

    Spoiler Additionally, the crowns you get from the DLCs entirely nullify the effects of Hollowing (losing max HP on death).

    Afterthoughts:

    1. Civilization: Beyond Earth is essentially just Civ5 with a science fiction reskin. It is a very good reskin but that is all it is. The Rising Tide expansion, however, makes it an entirely unique game, and a very good one.
    2. The expansions for Shovel Knight are all complete games, arguably better than the original.
    4 votes
  8. Comment on What programming/technical projects have you been working on? in ~comp

    cadentius_aurelius
    (edited )
    Link Parent
    The movement of an Object over a period of time is a line segment, from the point of the Position Vector P of the object to the point of P plus the Velocity Vector V multiplied by the amount of...

    The movement of an Object over a period of time is a line segment, from the point of the Position Vector P of the object to the point of P plus the Velocity Vector V multiplied by the amount of time t; that is, P + Vt. So, at the beginning of the period, lets say 1s, the object is at P, and at the end of the period, it is at P + 1V. We compare the distance between the Objects D at 0s, and at 1s, and at the midpoint, 0.5s. The change in distance over the first half, between t=0 and t=0.5, is H1, and the change over the second half is H2. This is the "slice". Additionally we sum the radii of the Objects, for R, which is the distance at which the Objects touch.

    I wont go into too much specific detail on the logic, because it is very tedious and I needed to draw myself probably ten different diagrams to get my mind around it, and even then I wasnt even sure it works until I tried it (and Im still not certain there are no edge cases). But essentially, comparing H1 with H2, and checking D against R, its possible to conclude, if the Objects collide during this time period, whether the collision happens in the first half or the second half of the period. With that information, we then repeat this process across either the first half or the second half of the time period: (0s, 0.25s, 0.5s) or (0.5s, 0.75s, 1.0s).

    This process is iterated a number of times, and eventually, it homes in on the exact moment of collision. At that moment, the Velocities of the Objects are changed and they bounce apart, and then time continues from there. Initially, I used 7 iterations, but now I have it repeat indefinitely, until either:

    1. Collision is ruled impossible.
    2. The distance D at the time of collision is known to a precision smaller than 1cm.

    E: One thing to note is that, for the purposes of my math, I mentally redefined "collision" to mean "the last possible moment before the Objects intersect". So this is probably the best way to understand it when reading it.


    E (11 months later): In the intervening months I have learned that I just reinvented the binary search :D So yeah, that is what I used here. Binary search to find the first value of time where the distance between the spheres is less than the sum of their radii.

    3 votes
  9. Comment on What programming/technical projects have you been working on? in ~comp

    cadentius_aurelius
    Link
    I have been creating a 3D game engine in Python for a bit over a year. It does not have any graphical capability, other than a sanity-checking module that creates static images with matplotlib to...

    I have been creating a 3D game engine in Python for a bit over a year.

    It does not have any graphical capability, other than a sanity-checking module that creates static images with matplotlib to check my geometry math, and it is not real-time; However, it is still "real time". What I mean by that is that it sleeps for a period (my current setting is five minutes), taking input and such. After sleeping for that length of time, it simulates that length of time all at once, and sleeps for input until the next tick.

    The end product I have in mind is a mostly-hard science fiction game/sandbox, played over SSH, which can be summed up as, "Your starship runs a Linux server; Fly it from the command line". This is approximately where I am:

    • [x] A Client-Server framework capable of transferring JSON data structures
    • [/] A Terminal-based "fullscreen" CLI with multiple panes
    • [x] A unified World, divided into discrete Domains, built on four NumPy NDArrays for Position, Velocity, Heading, and Rotation of every Object; Time is progressed by simply adding the master Velocity Array to the master Position Array
    • [x] A Coordinates class which provides Objects an interface to find their correct values in the master Arrays
    • [x] An Object class that stores intrinsic values such as mass and radius (all Objects are spherical cows)
    • [ ] Subclasses of Object for specific things such as asteroids, ships, weaponry rounds, etc.
    • [x] A high-precision collision detection system based on a method, which I invented (but highly doubt I am the first to invent), which I call "time-slicing" (and is completely unrelated to timeslicing in computer multitasking)
    • [/] Accurate-to-reality collision reaction math between Objects

    Unfortunately I cannot share it here right now because that VCS profile is associated with a different "realm" of usernames from the ones I use here and I try to keep them separate, but I can discuss it in abstract terms.

    10 votes
  10. Comment on What editor/IDE do you use? in ~comp

    cadentius_aurelius
    Link
    For just hammering out a Shell script, or editing a few lines of a single module or config, Kate. Its in the KDE ecosystem, so it has some integrations with stuff like Dolphin, and it can be used...

    For just hammering out a Shell script, or editing a few lines of a single module or config, Kate. Its in the KDE ecosystem, so it has some integrations with stuff like Dolphin, and it can be used as a backend in other KDE programs (none come to mind, but there was at least one specialized editor that I realized was using all my Kate settings). Frankly not much more advanced than NP++, but it is fast and it has an absurdly wide array of highlighting syntaxes (and 99% of the time it guesses correctly which to use).

    For any project with more than a file or two, PyCharm. Even non-Python things. Relative to Kate, it is fat and it is slow, taking up a gigabyte of RAM on average, but wow...the power. Ctrl-click to jump to declaration of any name, double-ctrl+up/down or alt-click to add more cursors, configurable inspections for everything, a keybind to instantly run Black, and even VCS integrations that correctly call to my YubiKey to sign/push commits.

    It could be that I am just used to doing refactors the hard way, but JB really locked me in with this one.

    2 votes
  11. Comment on What's your SILLY unpopular opinion? in ~talk

    cadentius_aurelius
    Link Parent
    Ouranos is Greek for "sky". We do that already :P

    Ouranos is Greek for "sky". We do that already :P

    2 votes
  12. Comment on What's your SILLY unpopular opinion? in ~talk

    cadentius_aurelius
    (edited )
    Link
    The name of the Seventh Planet is Caelus. Every planet in the solar system is named for a Roman deity (not the Greek analogue). Mercury, Venus, Terra (in countless fictional worlds), Mars,...

    The name of the Seventh Planet is Caelus. Every planet in the solar system is named for a Roman deity (not the Greek analogue). Mercury, Venus, Terra (in countless fictional worlds), Mars, Jupiter, Saturn, Caelus, and Neptune. When Pluto (Greek) was canon, there was more of a justification, but now, there is none beyond tradition.

    Ouranos is dead. Long live Caelus.

    14 votes
  13. Comment on Why OpenBSD Rocks in ~comp

    cadentius_aurelius
    Link Parent
    Like I always say: "Customization is like meth; Im always happiest while tweaking"

    Like I always say: "Customization is like meth; Im always happiest while tweaking"

    2 votes
  14. Comment on What are you reading these days? #14 in ~books

    cadentius_aurelius
    Link
    Meditations by Marcus Aurelius. A couple years ago I got a copy of the Art of War, and then I got a second copy because it seemed like a better edition. And then I got a third edition for...

    Meditations by Marcus Aurelius.

    A couple years ago I got a copy of the Art of War, and then I got a second copy because it seemed like a better edition. And then I got a third edition for Christmas. Now its halfway between running joke and legit collection, but I have eight different editions of the Art of War, and several of them are bundled with other classical works like the Prince, or the Tao Te Ching, which got me into ancient philosophy in general and led me to Aurelius. Stoicism is legit, dude.

    2 votes
  15. Comment on <deleted topic> in ~comp

    cadentius_aurelius
    Link Parent
    My single favorite feature is window rules. I can force any program to be a borderless window. Not great for performance, probably, but so convenient for games.

    My single favorite feature is window rules. I can force any program to be a borderless window. Not great for performance, probably, but so convenient for games.

    2 votes
  16. Comment on Governments Are Spending Billions on Software They Can Get with Freedom in ~tech

    cadentius_aurelius
    Link Parent
    Greatly agree with a warning system. It is not clear from this thread but I would seriously hope that a user is at least informed when their weight is reduced, and given a chance to regain it....

    Greatly agree with a warning system. It is not clear from this thread but I would seriously hope that a user is at least informed when their weight is reduced, and given a chance to regain it. Doing it silently, or permanently, or with no thought as to whether the misuse is out of malicious intent or just ignorance feels very unfriendly to newcomers (of which I am still one myself) and/or those not fully in the know.

    Im a bit concerned now, to be honest.

    4 votes
  17. Comment on The long-awaited moment... Dracula theme added! Oh also, the site is publicly visible now (but let's not be too noisy about it yet). in ~tildes.official

  18. Comment on The long-awaited moment... Dracula theme added! Oh also, the site is publicly visible now (but let's not be too noisy about it yet). in ~tildes.official

    cadentius_aurelius
    Link Parent
    Hey so a bit of a noob question: Im here to contribute and really like the site so far, but Im overall relatively new to the "collaborative coding" scene in general. Is there somewhere I should...

    Hey so a bit of a noob question: Im here to contribute and really like the site so far, but Im overall relatively new to the "collaborative coding" scene in general. Is there somewhere I should discuss ideas I have before starting to work on them? Or should I just start doing stuff, and toss up merge requests on Gitlab and discuss the ideas there?

    4 votes
  19. Comment on Are there any thoughts for a notification system or a mobile app? in ~tildes

    cadentius_aurelius
    Link Parent
    Maybe some kind of "promotion value" applied to a thread on a new reply, with that value being divided by the depth of the reply?

    ...topics not floating back to the top in the activity based sort method if the new comments in the threads were at a certain depth...

    Maybe some kind of "promotion value" applied to a thread on a new reply, with that value being divided by the depth of the reply?

    2 votes
  20. Comment on What mobile games are worth playing? in ~games

    cadentius_aurelius
    Link
    On Android, Pixel Dungeon is absolutely incredible, AND open-source. There are even forks of it, including Shattered and Sprouted. Easily the most faithfully modernized roguelike I know of,...

    On Android, Pixel Dungeon is absolutely incredible, AND open-source. There are even forks of it, including Shattered and Sprouted. Easily the most faithfully modernized roguelike I know of, complete with turn based gameplay, randomized scrolls/potions, cursed equipment, and very scarce food. The win condition is even called the Amulet of Yendor in a direct callback.

    It has 20 levels, and the farthest Ive ever gotten is level 16. Ive been playing it almost 5 years now (albeit quite intermittently).

    23 votes