fabic has joined #rust-embedded
starblue2 has quit [Ping timeout: 252 seconds]
starblue2 has joined #rust-embedded
dcz has joined #rust-embedded
emerent has quit [Ping timeout: 250 seconds]
emerent has joined #rust-embedded
dreamcat4 has quit [Quit: Connection closed for inactivity]
fabic has quit [Ping timeout: 240 seconds]
fabic has joined #rust-embedded
fabic has quit [Ping timeout: 252 seconds]
fabic has joined #rust-embedded
fabic has quit [Ping timeout: 240 seconds]
Amadiro has joined #rust-embedded
dreamcat4 has joined #rust-embedded
<re_irc> <@r​icharddodd:m​atrix.org> What's the best image format for size & decompress speed (where compression can be as slow as you like)?
<re_irc> <@n​ewam:m​atrix.org> Some ST chips have JPG acceleration if that's an option.
<re_irc> <@n​ewam:m​atrix.org> Apart from that I am not really sure, never had to optimize for those things. Let me know if you find an answer though, I'm curious
<re_irc> <@r​icharddodd:m​atrix.org> I'm on nrf.
<re_irc> <@r​icharddodd:m​atrix.org> Some more background: I'm drawing pixel graphics, so there is a lot of repetition in the data. Maybe an easy option is to use a palette and have 4 bits per pixel (ish) rather than the current 16.
<re_irc> <@n​ewam:m​atrix.org> GIF optimizes for large single-color areas, and is a simple format so it would be fast to decode.
<re_irc> <@n​ewam:m​atrix.org> For pixel graphics maybe GIF?
<re_irc> <@n​ewam:m​atrix.org> You _could_ also do SVG if you're doing simple shapes, that would likely win for size; rendering time would be insane though.
<re_irc> <@k​fessel:m​atrix.org> bitplane rle
fabic has joined #rust-embedded
<re_irc> <@r​icharddodd:m​atrix.org> [this seems like a good resource](https://www2.seas.gwu.edu/~ayoussef/cs225/lossless.html)
<re_irc> <@a​damgreig:m​atrix.org> I'm going mad... anyone have any idea what's going on here 🤔 https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=84f788b7264fa4d85ecc124228f63b3b
<re_irc> <@r​icharddodd:m​atrix.org> adamgreig: rustc constant folding bug?
<re_irc> <@r​icharddodd:m​atrix.org> looks like a rustc bug to me
<re_irc> <@d​irbaio:m​atrix.org> adamgreig: the last line really means `-(2.2901367690947287_f64.powf(6.001453979405872_f64))` which is different
<re_irc> <@d​irbaio:m​atrix.org> if you do `(-2.2901367690947287_f64).powf(6.001453979405872_f64)` you get NaN too
<re_irc> <@r​icharddodd:m​atrix.org> Ohh that is why I'm an amateur :)
<re_irc> <@n​ewam:m​atrix.org> |
<re_irc> <@n​ewam:m​atrix.org> 8 | dbg!(-2.2901367690947287_f64.powf(6.001453979405872_f64));
<re_irc> <@n​ewam:m​atrix.org> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(2.2901367690947287_f64.powf(6.001453979405872_f64))`
<re_irc> <@n​ewam:m​atrix.org> |
<re_irc> <@n​ewam:m​atrix.org> clippy found it
<re_irc> <@d​irbaio:m​atrix.org> sneaky stuff!
<re_irc> <@a​damgreig:m​atrix.org> of course, duh, thanks
<re_irc> <@a​damgreig:m​atrix.org> constants huh :D
<re_irc> <@r​icharddodd:m​atrix.org> python correctly answers (144.4399128868319+0.6597788145514544j)
<re_irc> <@r​icharddodd:m​atrix.org> python > rust
<re_irc> <@a​damgreig:m​atrix.org> >>> -2.2901367690947287 ** 6.001453979405872
<re_irc> <@a​damgreig:m​atrix.org> -144.4414197619219
<re_irc> <@a​damgreig:m​atrix.org> does it now :P
<re_irc> <@a​damgreig:m​atrix.org> (of course, if you do pose the problem properly...)
<re_irc> <@a​damgreig:m​atrix.org> >>> (-2.2901367690947287) ** 6.001453979405872
<re_irc> <@a​damgreig:m​atrix.org> (144.4399128868319+0.6597788145514544j)
<re_irc> <@r​icharddodd:m​atrix.org> In [3]: a = -2.2901367690947287
<re_irc> <@r​icharddodd:m​atrix.org> In [4]: a
<re_irc> <@r​icharddodd:m​atrix.org> Out[4]: -2.2901367690947287
<re_irc> <@r​icharddodd:m​atrix.org> In [5]: b = 6.001453979405872
<re_irc> <@d​irbaio:m​atrix.org> `j` instead of `i`, wtf?
<re_irc> <@r​icharddodd:m​atrix.org> python is for engineers, who I'm told use j for imag
<re_irc> <@r​icharddodd:m​atrix.org> or something
<re_irc> <@n​ewam:m​atrix.org> can confirm. i is for current.
<re_irc> <@d​irbaio:m​atrix.org> ahhh I recall hearing that before
<re_irc> <@d​irbaio:m​atrix.org> still, wtf
<re_irc> <@a​damgreig:m​atrix.org> did you not cover jamaginary numbers in school?
<re_irc> <@r​icharddodd:m​atrix.org> and c is speed of light?
<re_irc> <@d​irbaio:m​atrix.org> imajinary nujbers
<re_irc> <@n​ewam:m​atrix.org> richarddodd: yes because logic :D
<re_irc> <@n​ewam:m​atrix.org> Then when we run out of the english alphabet we use greek because whynot
<re_irc> <@h​argonix:m​atrix.org> and after that hebrew
<re_irc> <@a​damgreig:m​atrix.org> you know you're in trouble when the equations get into hebrew lol
<re_irc> <@n​ewam:m​atrix.org> voltage, velocity, viscosity... and loads of others.
<re_irc> <@n​ewam:m​atrix.org> just don't ask about v.
<re_irc> <@c​ome_744:c​onverser.eu> newam: Ah… This c…
<re_irc> <@a​damgreig:m​atrix.org> ❤️ `#[clippy::many_single_char_names]`
<re_irc> <@r​icharddodd:m​atrix.org> totally OT, but if I was teaching anything algebraic now, I would use emoji rather than greek letters. Greek intimidates needlessly
<re_irc> <@h​argonix:m​atrix.org> newam: we always used U for voltage...never got why
<re_irc> <@a​damgreig:m​atrix.org> I thought writing greek letters was bad enough but I can't imagine having to draw all the emojis while writing equations :P
<re_irc> <@r​icharddodd:m​atrix.org> (only emoji for lesson 1)
<re_irc> <@c​ome_744:c​onverser.eu> Don't emoji look alike too much ?
<re_irc> <@a​damgreig:m​atrix.org> 🏃 for velocity, 🎯 for position?
<re_irc> <@h​argonix:m​atrix.org> we should just switch alphabets in formulas occasionally to confuse people more
<re_irc> <@r​icharddodd:m​atrix.org> What I mean is: newcomers imbue greek letters with special meaning, when all we want is "something that represents an unknown number"
<re_irc> <@b​obmcwhirter:m​atrix.org> I learned y=mx+b for graphing, but my kid learned y=sx+c or somesuch weirdness.
<re_irc> <@c​ome_744:c​onverser.eu> y = ax + b here
<re_irc> <@h​argonix:m​atrix.org> y = mx + t here
<re_irc> <@c​ome_744:c​onverser.eu> And α for angles
<re_irc> <@h​argonix:m​atrix.org> yeah greek for angles seems to be generally agreed upon
<re_irc> <@r​icharddodd:m​atrix.org> I'm fighting a bug and wondering, can 64KB ever mean 64 * 1000 rather than 64 * 1024?
<re_irc> <@c​ome_744:c​onverser.eu> Yes if you say KiB for 1024
<re_irc> <@r​icharddodd:m​atrix.org> Côme: that might explain a lot, thanks!
<re_irc> <@c​ome_744:c​onverser.eu> ;=
<re_irc> <@a​damgreig:m​atrix.org> lol, y=mx+c was my childhood
<re_irc> <@a​damgreig:m​atrix.org> sx+c... I guess s for slope?
<re_irc> <@a​damgreig:m​atrix.org> makes more sense than m for gradieMt I guess
<re_irc> <@c​ome_744:c​onverser.eu> m for multiplicator and c for constant ?
<re_irc> <@d​khayes117:m​atrix.org> Modulus of slope
<re_irc> <@j​duchniewicz:m​atrix.org> y=ax+b here
<re_irc> <@d​irbaio:m​atrix.org> y=ax+b is best
<re_irc> <@d​irbaio:m​atrix.org> and generalizes nicely to higher degree polynomials... y = ax2 + bx + c
<re_irc> <@a​damgreig:m​atrix.org> y=a_n x^n + ... + a_1 x + a_0
<re_irc> <@a​damgreig:m​atrix.org> surely if you want it to generalise you might need to go beyond 26 powers :P
<re_irc> <@j​duchniewicz:m​atrix.org> For me it is also the simplest haha
<re_irc> <@a​damgreig:m​atrix.org> I guess you'd get into trouble when you got to x * x^24 actually
<re_irc> <@d​irbaio:m​atrix.org> hehehe then you just say "we have a polynomial P" and gtfo
<re_irc> <@j​duchniewicz:m​atrix.org> The subscripts are more scientific
<re_irc> <@d​khayes117:m​atrix.org> Drunk maths guy, "screw it, I'm using M for slope, yolo"
<re_irc> <@a​damgreig:m​atrix.org> "it's just for this one chapter, whatever, who cares"
<re_irc> <@d​irbaio:m​atrix.org> n, m, k sound like integers for when doing discrete maths
<re_irc> <@d​irbaio:m​atrix.org> using M for the slope is a crime
<re_irc> <@d​khayes117:m​atrix.org> With calc though, you don't write ..+ b with derivatives, its ..+ c
fabic has quit [Ping timeout: 252 seconds]
<re_irc> <@d​irbaio:m​atrix.org> c for "constant"
<re_irc> <@d​irbaio:m​atrix.org> a for "a constant"
<re_irc> <@d​irbaio:m​atrix.org> y = ax + c
<re_irc> <@d​irbaio:m​atrix.org> gg ez
<re_irc> <@d​khayes117:m​atrix.org> Maybe they should type annotate the variables instead of changing them haha
fabic has joined #rust-embedded
GenTooMan has quit [Ping timeout: 250 seconds]
GenTooMan has joined #rust-embedded
fabic has quit [Ping timeout: 240 seconds]
<re_irc> <@f​irefrommoonlight:m​atrix.org> Im a fan of greek letter variable names when appropriate. You used to need to suppress a Rust warning about non ASCII identifiers, but they might have removed that lint
<re_irc> <@f​irefrommoonlight:m​atrix.org> Using custom keyboard shortcuts
<re_irc> <@a​damgreig:m​atrix.org> on linux you can use the dead_greek dead key, e.g. for me, altgr+g then a gives α, or shift+s for Σ, etc
<re_irc> <@a​damgreig:m​atrix.org> just gotta remember that f is for phi... φ Φ
<re_irc> <@h​argonix:m​atrix.org> If you're working in emacs there is a cool built in thing you can use. you can switch your input method to Tex with set-input-method and then type stuff like \alpha \beta \gamma and emacs will automaticaly replace all TeX commands youtyped (and it knows about of course) with the proper utf-8 characters.
<re_irc> <@a​damgreig:m​atrix.org> also works in jupyter notebook, it's nice
<re_irc> <@c​ome_744:c​onverser.eu> adamgreig: Which *sounds* logical (pun intended)
<re_irc> <@c​ome_744:c​onverser.eu> adamgreig: TIL, I thought it was only a Bépo layout feature
<re_irc> <@f​irefrommoonlight:m​atrix.org> On Windows, I use a custom keyboard layout that works in a very similar way! Didn't know it was standard in Linux
<re_irc> <@f​irefrommoonlight:m​atrix.org> Only just right alt+key
<re_irc> <@f​irefrommoonlight:m​atrix.org> The Tex approach is nice too, and eaiser to adopt
<re_irc> <@f​irefrommoonlight:m​atrix.org> I haven't used Greek letters in an embedded project, but they're nice for scientific and mathematical code
<re_irc> <@f​irefrommoonlight:m​atrix.org> Although I do use them in comments, eg measuring conductivity in micro etc
<re_irc> <@f​irefrommoonlight:m​atrix.org> Or degrees (I'm phone typing now)
fabic has joined #rust-embedded
fabic has quit [Ping timeout: 250 seconds]
dcz has quit [Remote host closed the connection]
dcz has joined #rust-embedded
<re_irc> <@v​italy.codes:m​atrix.org> Hello fellow crustaceans! 🦀
<re_irc> <@v​italy.codes:m​atrix.org> Happy to be here.
<re_irc> <@b​arafael:m​atrix.org> I want to define a simple protocol for exchanging data over a serial port. Simple structs, but should be as small as possible. Doesn't have to be super quick to parse though. Any recommendations? Is this what postcard does?
<re_irc> <@r​ahix:m​atrix.org> barafael: Yes, postcard does exactly what you need
<re_irc> <@n​ewam:m​atrix.org> What is postcard? Tried googling a few things, didn't come up with anything but letter mail
<re_irc> <@v​italy.codes:m​atrix.org> newam: https://github.com/jamesmunns/postcard
<re_irc> <@v​italy.codes:m​atrix.org> barafael: postcard is serialization library. you can use it, but also you need to have some sort of encoding scheme, like https://en.wikipedia.org/wiki/Type%E2%80%93length%E2%80%93value
<re_irc> <@b​arafael:m​atrix.org> Thanks rahix , taking a look
<Lumpio-> It has built-in support for cobs framing
<Lumpio-> And for different frame types you can just have the top level type be an enum
rektide has quit [Quit: leaving]
rektide has joined #rust-embedded
rektide has quit [Quit: leaving]
rektide has joined #rust-embedded
<re_irc> <@f​irefrommoonlight:m​atrix.org> Iirc I asked if postcard was suitable for a similar task when it was announced here recently, and was told it's not
<re_irc> <@f​irefrommoonlight:m​atrix.org> What does the data look like?
<Lumpio-> Why'd they say it was not suitable?
<re_irc> <@j​amesmunns:m​atrix.org> Happy to answer any postcard questions :)
<re_irc> <@j​amesmunns:m​atrix.org> Iirc, I think the last time I said it wasn't suitable was when someone was trying to implement some existing protocol with postcard
<re_irc> <@j​amesmunns:m​atrix.org> Postcard generally expects you to have rust/postcard on both ends, or something that explicitly follows postcards wire format
<re_irc> <@j​amesmunns:m​atrix.org> It's not really designed to mimic other existing protocols.
<re_irc> <@j​amesmunns:m​atrix.org> But if someone else said it wasn't suitable, the I dunno :D
<re_irc> <@j​amesmunns:m​atrix.org> But assuming you have rust on both sides of the wire, either MCU to MCU, MCU to PC, or PC to PC, it should pretty much be what you want. And COBS will work if you need framing over a serial port, a TCP port, or similar
<re_irc> <@f​irefrommoonlight:m​atrix.org> The example in question was flash memory storage, which is a conceptually similar problem (Struct in -> Byte array out)
<re_irc> <@f​irefrommoonlight:m​atrix.org> As in, what dotcypress said: The bulk of this problem is the encoding
<re_irc> <@f​irefrommoonlight:m​atrix.org> Unrelated: In the interest of practical examples, I just published this, which is part of a 2-unit stovetop IR thermometer. Demonstrates use of a handful of nrf-52 protocols, as well as how to structure a program that's suitable for long-term battery opteration:
<re_irc> <@f​irefrommoonlight:m​atrix.org> Uses thalesfragoso 's ESB library, although on a custom fork due to PAC compatibility issues
<re_irc> <@g​damjan:s​podeli.org> how do you receive the data?
<re_irc> <@f​irefrommoonlight:m​atrix.org> MLX90614 sensor. Interaction with it is in `sensor.rs`
<re_irc> <@g​damjan:s​podeli.org> no, I meant the ESB transmission
<re_irc> <@f​irefrommoonlight:m​atrix.org> a separate unit that has a small OLED display, and the same MCU module
<re_irc> <@f​irefrommoonlight:m​atrix.org> I can post the reception code if you'd like. It's working now on 2 dev boards, but I don't have the display set up
<re_irc> <@f​irefrommoonlight:m​atrix.org> (Ie the receiver is just printing to console ATM and needs more testing before I publish)
<re_irc> <@f​irefrommoonlight:m​atrix.org> Also has 2 buttons: C/F, and emissivity adjustment
<re_irc> <@g​damjan:s​podeli.org> I wonder if there's something to receive the ESB data on a PC/laptop
<re_irc> <@f​irefrommoonlight:m​atrix.org> That would be cool. Switching to bluetooth would be one way around that. And would have the practical advantage of letting people read it on phones as well. However... I can't figure out BT at this time, and don't want to delay the project further
<re_irc> <@f​irefrommoonlight:m​atrix.org> Maybe something like...
<re_irc> ... this:https://www.digikey.com/en/product-highlight/n/nordic-semi/nrf52840-usb-dongle?utm_adgroup=Semiconductor%20Modules&utm_source=google&utm_medium=cpc&utm_campaign=Dynamic%20Search_EN_RLSA_Buyers&utm_term=&utm_content=Semiconductor%20Modules&gclid=CjwKCAjwmqKJBhAWEiwAMvGt6ABr48vVG2w08Wl8v3jmhSDcK5nZ4P6crUekanf8hv3Prq5d7hMtJRoCQxUQAvD_BwE
<re_irc> <@f​irefrommoonlight:m​atrix.org> Or more to the point: Make a USB dongle that contains a Nordic chip