<re_irc> <@jamesmunns:beeper.com> like, IF you are powering both the STLink and the USB cable from EXACTLY the same USB souce (like a USB hub, the SAME SIDE of the computer), you'll be... probably? fine.
<re_irc> <@jamesmunns:beeper.com> but like, it's a bad habit.
<re_irc> <@dngrs:matrix.org> because the voltage could travel from one port into the circuit and back up the other port?
<re_irc> <@dngrs:matrix.org> yeah, I'm always using one voltage source
<re_irc> <@dngrs:matrix.org> I was under the impression that's probably ok
<re_irc> <@dngrs:matrix.org> but, again, dummy
<re_irc> <@jamesmunns:beeper.com> Basically, you never want two supplies to "fight" eachother
<re_irc> <@dngrs:matrix.org> yup - my thinking was this is just one supply
<re_irc> <@jamesmunns:beeper.com> if you want them to both feed in and contribute power, you should have a diode on each of them so power never flows "backwards"
<re_irc> <@jamesmunns:beeper.com> it can be tricky
<re_irc> <@jamesmunns:beeper.com> sometimes USB ports on opposite sides of the laptop have enough potential different to cause problems
<re_irc> <@jamesmunns:beeper.com> or even ports next to eachother, there is no guarantee they have to be at the same potential
<re_irc> <@jamesmunns:beeper.com> and if one is at 5.2v, and one is at 4.8v, the 5.2v one is going to "feed" the 4.8V one.
<re_irc> <@dngrs:matrix.org> either way, what we're talking about isn't what's giving me issues .. I need to measure the 5V rail when powering the board only via its USB connection. I suppose it will either have substantial voltage drop, or something about the board converter is pretty inefficient
<re_irc> <@jamesmunns:beeper.com> board converter?
<re_irc> <@dngrs:matrix.org> pretty sure the mcu runs at 3.3v
<re_irc> <@jamesmunns:beeper.com> yeah, are you feeding the leds from the 3.3v rail?
<re_irc> <@dngrs:matrix.org> it might also just be that the wires are too thin
<re_irc> <@dngrs:matrix.org> nope
<re_irc> <@dngrs:matrix.org> LEDs and distance sensor get 5V
<re_irc> <@jamesmunns:beeper.com> yeah, that should be more or less directly wired to Vbus from the USB
<re_irc> <@dngrs:matrix.org> a friend told me a while ago I shouldn't do high current stuff from board traces, they're not quite made for that
<re_irc> <@jamesmunns:beeper.com> The MCU probably uses like... <50mA
<re_irc> <@jamesmunns:beeper.com> (at 3.3v, so even less at 5v, though it's probably an LDO, but still, less than one of your LEDs probably)
<re_irc> <@dngrs:matrix.org> all a bit mysterious, my money's on flimsy 5V board traces now
<re_irc> <@jamesmunns:beeper.com> Do your LEDs have built in caps? and/or do you have some big electrolytic caps near your MCU/LEDs?
<re_irc> <@jamesmunns:beeper.com> like LEDs flashing on and off is probably pulsing a lot of power
<re_irc> <@dngrs:matrix.org> the sensor (temporarily) stops working when I make the LEDs really bright *and* stuff is powered from the board's USB connection; everything is fine when I power everything instead from the STLink (with a dedicated wire from STLink 5V to sensor+led+board 5v pin)
<re_irc> <@dngrs:matrix.org> I don't have big caps anywhere
<re_irc> <@jamesmunns:beeper.com> You should probably just get a separate 5v supply for the LEDs
<re_irc> <@dngrs:matrix.org> the LEDs are ws8211 (the ones with an external controller chip)
<re_irc> <@dngrs:matrix.org> looks like there's a cap on each LED board
<re_irc> <@jamesmunns:beeper.com> like, just power the board and sensor from USB, use a separate 5v supply for the LEDs, just make sure you tie the grounds together.
<re_irc> <@jamesmunns:beeper.com> but NOT the 5v lines
<re_irc> <@dngrs:matrix.org> I really really really like my things to have just one cable :D
<re_irc> <@jamesmunns:beeper.com> Then stop doing things that require many amps of power!
<re_irc> <@jamesmunns:beeper.com> or start using USB-PD
<re_irc> <@jamesmunns:beeper.com> though then you have to deal with 9/12/15/20V
<re_irc> <@dngrs:matrix.org> that's reasonable; I do want to emphasize that I can get enough amps from one (unpowered, even) usb hub port when powering via the stlink
<re_irc> <@dngrs:matrix.org> so my money's still on lousy 5v board trace
<re_irc> <@jamesmunns:beeper.com> ¯\_(ツ)_/¯
<re_irc> <@dngrs:matrix.org> which could probably be solved with a soldering iron and a few sacrificed goats
<re_irc> <@jamesmunns:beeper.com> I mean the easiest way to tell is use a multimeter and look at the voltage at the LEDs/sensors
<re_irc> <@jamesmunns:beeper.com> if it's drooping below 5V, then yeah, tiny traces are causing high resistance and causing heat and dropped voltages
<re_irc> <@dngrs:matrix.org> ya, I can tell for sure there's bigger voltage drop when powering through board USB, because then their hue is redder
<re_irc> <@jamesmunns:beeper.com> (or your PC USB supply has given up)
<re_irc> <@jamesmunns:beeper.com> If you're drooping low enough that the blue/green LEDs are dimming, that seems pretty bad (usually less than 3.x volts)
<re_irc> <@dngrs:matrix.org> (aerosmith - livin' on the edge starts playing)
patrickod has joined #rust-embedded
troth has quit [Ping timeout: 260 seconds]
troth has joined #rust-embedded
troth has quit [Ping timeout: 256 seconds]
tokomak has joined #rust-embedded
troth has joined #rust-embedded
starblue has quit [Ping timeout: 260 seconds]
starblue has joined #rust-embedded
PyroPeter has quit [Ping timeout: 240 seconds]
PyroPeter has joined #rust-embedded
dcz_ has quit [Ping timeout: 250 seconds]
<re_irc> <@mehmet:grusbv.com> This is bit late, but all USB sources have an electronic fuse in them. I am pretty sure that if you are drawing enough current to droop it to 3V, it would trip. (And windows scolds you with a notification(
<re_irc> <@mehmet:grusbv.com> So it could be the converter compensation. (Couldnt read it all through though)
<re_irc> <@eldruin:matrix.org> firefrommoonlight:matrix.org: I don't think that will happen since:
<re_irc> <@eldruin:matrix.org> 1. There many people interested in making Rust part of the Linux kernel (e.g. [Google](https://security.googleblog.com/2021/04/rust-in-linux-kernel.html), part of the Rust foundation).
<re_irc> <@eldruin:matrix.org> 2. The Fuchsia OS is also partially written in Rust and that has even [shipped](https://9to5google.com/2021/05/25/google-releases-fuchsia-os-nest-hub/)
<re_irc> <@eldruin:matrix.org> 3. Microsoft (also part of the Rust foundation) has been [experimenting with rewriting a low-level windows component](https://www.zdnet.com/article/microsofts-rust-experiments-are-going-well-but-some-features-are-missing/)
troth has quit [Ping timeout: 240 seconds]
<re_irc> <@dnj:matrix.org> Is it a bad practice to put constant variables inside ISRs?
<re_irc> <@dnj:matrix.org> Hi btw. 1st post here. ^^
troth has joined #rust-embedded
<re_irc> <@dnj:matrix.org> dnj:matrix.org: I'm curious that `const` make the variable to put in read-only memory or just won't let me change the value.
<re_irc> <@jannic:matrix.org> Usually, const values just get inlined into the generated object code. They are close to a #define in C.
<re_irc> <@dnj:matrix.org> sounds event better :)
Rondom has quit [Remote host closed the connection]
Rondom has joined #rust-embedded
dcz_ has joined #rust-embedded
fabic has joined #rust-embedded
<re_irc> <@dirbaio:matrix.org> it depends, if it's small it'll probably get inlined, if it's big it'll probably go in .rodata (flash)
<re_irc> <@dirbaio:matrix.org> but yeah they won't use RAM either way
<re_irc> <@gdamjan:spodeli.org> has anyone set github action that would check the program size and then generate some kind of a badge for the README.md ?
<re_irc> <@dnj:matrix.org> I can imagine that after build just run script (python?) with commands described in Embedded Book realted to size of binary.
<re_irc> <@dnj:matrix.org> But maybe I misunderstood.
<re_irc> <@gdamjan:spodeli.org> maybe I can combine it with https://github.com/marketplace/actions/bring-your-own-badge
<re_irc> <@firefrommoonlight:matrix.org> eldruin:matrix.org: Hadn't heard of Fuchsia; looks cool!
<re_irc> <@firefrommoonlight:matrix.org> Also, all the details you posted are strong votes for Rust continuing to focus on systems program (And therefor embedded)
sheb has joined #rust-embedded
<re_irc> <@barafael:matrix.org> I just published first version of my as5600 embedded-hal driver. There is one detail I'm unsure about how to implement it best. I got lots of enums, which are really just single bytes. And I have `From<u8> for Enum` and `From<Enum> for u8`. Those enums are easy to convert to u8 with `as`. Converting from u8 to enum is harder, as not all bit patterns are valid. I am using `num_derive::FromPrimitive` for this...
<re_irc> <@barafael:matrix.org> #[derive(Debug, Copy, Clone, FromPrimitive)]
<re_irc> ... By masking away the appropriate bits, I know that the conversion can never fail.
<re_irc> <@barafael:matrix.org> #[repr(u8)]
<re_irc> <@barafael:matrix.org> The entire code is here: [https://github.com/barafael/as5600-rs](https://github.com/barafael/as5600-rs)
<re_irc> <@jamesmunns:beeper.com> So, just because masking will make it *work*, it might still not be right
<re_irc> <@jamesmunns:beeper.com> like if the only okay values are 0-3, and I send 123, should that be interpreted as `0b11`? Or is that an error you're hiding?
<re_irc> <@barafael:matrix.org> good point, actually I should have specified. The datasheet explicitly states other values should be ignored
<re_irc> <@jamesmunns:beeper.com> Ah! In that case, you might want to have an INVALID representation
<re_irc> <@jamesmunns:beeper.com> but that's again, sort of hiding the error, because then you ALWAYS have to check if it's invalid
<re_irc> <@jamesmunns:beeper.com> In general, I'd probably (personally) `impl TryFrom<u8> for Enum`, and handle the errors at ingress
fabic has quit [Ping timeout: 268 seconds]
<re_irc> <@barafael:matrix.org> so you would make all the `From` impls `TryFrom`?
<re_irc> <@jamesmunns:beeper.com> Well, I'd still impl `From<Enum> for u8`, because that can't fail
<re_irc> <@jamesmunns:beeper.com> but the other way, where it CAN fail, I would use `TryFrom`
<re_irc> <@barafael:matrix.org> oh, right
<re_irc> <@jamesmunns:beeper.com> Or, I'd impl `From<u8>`, and have INVALID as one of the states, but that's less usable than `Result<Enum>` IMO, because you have to handle the bad case ALL the time, instead of just at parsing
<re_irc> <@barafael:matrix.org> i think that's a good idea.
<re_irc> <@barafael:matrix.org> thank you :)
<re_irc> <@adamgreig:matrix.org> I like the `num_enum` crate for these, it can derive the From and TryFrom for you
<re_irc> <@adamgreig:matrix.org> confusingly it also has FromPrimitive and IntoPrimitive but it seems like they do different things than your current `num_derive` crate?
<re_irc> <@adamgreig:matrix.org> hmm, what buttons do people like for menus on embedded things with minimal swearing from the user?
<re_irc> <@adamgreig:matrix.org> I have a bunch of non-hierarchical settings, so my current plan was just a SET, -, +, and each time you press SET it cycles through each item, and - and + immediately change it
<re_irc> <@adamgreig:matrix.org> eventually you reach the end and it cycles back to the home screen, or it times out after a minute maybe
<re_irc> <@adamgreig:matrix.org> could add a 'BACK' button which maybe goes to the previous setting (to save cycling through them all again), or 'HOME' to return home once done, or maybe 'ENTER' so you use +- to cycle through settings, then ENTER, then +/- to change that setting, then ENTER again to save it?
<re_irc> <@adamgreig:matrix.org> lots of choices and I'm sure I've come across most of them in the wild and hated most of them :P not as bad as just a single button and short/long presses though...
<re_irc> <@firefrommoonlight:matrix.org> I wish that functionality was built in
<re_irc> <@firefrommoonlight:matrix.org> it's useful
<re_irc> <@firefrommoonlight:matrix.org> and an intuitive extension of `repr(u8)`
<re_irc> <@firefrommoonlight:matrix.org> In embedded, useful for config enums that map to fields
<re_irc> <@firefrommoonlight:matrix.org> or serializing state for storage, atomics etc
<re_irc> <@firefrommoonlight:matrix.org> Re menu design: I think it depends too heavily on the use case. Eg what's displayed on the hardware, constraints re buttons / switches etc
<re_irc> <@firefrommoonlight:matrix.org> On one device I have, there are two columns of settings, and a 4-way switch. Up and down cycle through the items. (The columns wrap), back exists the menu. Fwd cycles some items, and goes to a deeper menu etc for others
<re_irc> <@firefrommoonlight:matrix.org> On a simpler device, there are 2 buttons, and a very simple selection. Button 1 enters the menu and shows the setting. Additional button 1 pushes cycle. Button 2 exits the menu. A timer also exits the menu if idle on it for 10s
<re_irc> <@firefrommoonlight:matrix.org> Button 2 does something different when not in the menu
<re_irc> <@firefrommoonlight:matrix.org> I still want an atomic enum
<re_irc> <@firefrommoonlight:matrix.org> Without awk workarounds
<re_irc> <@dngrs:matrix.org> jamesmunns:beeper.com: seconding this, in my book `INVALID` would be just another name for `Err(...)` (in fact, `Err(Invalid)` even!)
<re_irc> <@jamesmunns:beeper.com> Yeah, I really recommend the "check your errors at the door" approach
<re_irc> <@jamesmunns:beeper.com> sort of like how strings work in rust
<re_irc> <@jamesmunns:beeper.com> you never have to check if it's invalid, if it's impossible to create an invalid one safetly.
<re_irc> <@dngrs:matrix.org> I'd generalize that to "do any kind of conversion at api boundaries whenever you can get away with it"
<re_irc> <@jamesmunns:beeper.com> yep, yep
crabbedhaloablut has quit [Ping timeout: 276 seconds]
f33d1 has joined #rust-embedded
f33d1 has left #rust-embedded [WeeChat 3.3]
<re_irc> <@thejpster:matrix.org> So I might as well say it out loud ... I'm officially starting at Ferrous Systems tomorrow, providing training and Rust consultancy. https://twitter.com/therealjpster/status/1465047160081289222?s=20
<re_irc> <@firefrommoonlight:matrix.org> Congrats dude
<re_irc> <@k900:0upti.me> Congratulations!
patrickod has quit [Quit: ZNC 1.8.2 - https://znc.in]
cpk has joined #rust-embedded
tokomak has quit [Read error: Connection reset by peer]
dcz_ has quit [Ping timeout: 240 seconds]
dcz_ has joined #rust-embedded
<re_irc> <@firefrommoonlight:matrix.org> I'm ready to prototype a board that uses an H7 for audio
<re_irc> <@firefrommoonlight:matrix.org> Looks like I'm going to be desoldering a nucleo or something, and hoping the giant package fits
cpk has quit [Ping timeout: 265 seconds]