ChanServ changed the topic of #rust-embedded to: Welcome to the Rust Embedded IRC channel! Bridged to #rust-embedded:matrix.org and logged at https://libera.irclog.whitequark.org/rust-embedded, code of conduct at https://www.rust-lang.org/conduct.html
DepthDeluxe_ has quit [Ping timeout: 252 seconds]
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
IlPalazzo-ojiisa has quit [Ping timeout: 268 seconds]
starblue has quit [Ping timeout: 260 seconds]
starblue has joined #rust-embedded
crabbedhaloablut has quit [Ping timeout: 255 seconds]
crabbedhaloablut has joined #rust-embedded
emerent has joined #rust-embedded
DepthDeluxe_ has joined #rust-embedded
sigmaris has joined #rust-embedded
DepthDeluxe_ has quit [Ping timeout: 260 seconds]
<re_irc> <jobroe> Good Morning, I'm looking for a microcontroller board which supports wifi. I would like to build a "button" which controlles my WLED via JSON-API. Any recommondations ?
<re_irc> < (@k900:0upti.me)> ESP32 or Pi Pico W are basically your only options for availability reasons
<re_irc> <jobroe> Ok thanks
<re_irc> <jobroe> The Pi Pico W doesn't seem to be well supported yet, right? I only found the MR https://github.com/jannic/rp-hal/tree/pico-w/boards/rp-pico-w which says: "NOTE: This is work in progress. Wifi access is not yet implemented."
<re_irc> < (@k900:0upti.me)> It's a work in progress
IlPalazzo-ojiisa has joined #rust-embedded
<re_irc> < (@wucke13:matrix.org)> : Is it possible that encdec doesn't work with generics?
<re_irc> <Félix | Totem> What's wrong with my scan function?
<re_irc> pub fn scan(&mut self) -> KeyState {
<re_irc> pub struct KeyState(pub [[bool; 6]; 7]);
<re_irc> let keys = self.cols.iter().map(|col| {
<re_irc> <Félix | Totem> +All is set to true.
<re_irc> <Félix | Totem> That means that all the rows are high for each col turned on.
<re_irc> < (@xiretza:xiretza.xyz)> what's the definition of "Self"?
<re_irc> < (@xiretza:xiretza.xyz)> and what is the behaviour you're expecting?
<re_irc> <Félix | Totem> I have like 120 lines. I can copy paste online, 2 min
<re_irc> - Each col is turned on then off, one after the other.
<re_irc> - Each time, after waiting for a bit, I read the state of the line to see if the key has been pressed (high = pressed, low = not pressed).
<re_irc> - I build the KeyState from this. true in the table means that the key is pressed.
<re_irc> < (@xiretza:xiretza.xyz)> what does the hardware look like? are there pullup/pulldown resistors?
<re_irc> <Félix | Totem> This is a QMK keyboard with a STM32F303. This is the matrix from the QMK code:
<re_irc> // #define MATRIX_ROW_PINS { B10, B11, B12, B13, B14, B15 }
<re_irc> // #define MATRIX_COL_PINS { A0, A1, A2, A3, A6, A7, B0 }
<re_irc> <Félix | Totem> : I've no idea. I don't even understand those words.
<re_irc> < (@xiretza:xiretza.xyz)> there is certainly one problem, though it doesn't explain the symptoms by itself: you are driving all the columns at the same time (one high, all others low), which will break as soon as you press two keys on different columns at the same time - you need open collector/open drain outputs, not push-pull
<re_irc> < (@xiretza:xiretza.xyz)> * in the same row
<re_irc> <Félix | Totem> : It's not at the same time, though. I do it one after the other.
<re_irc> < (@xiretza:xiretza.xyz)> you also need some kind of biasing on your input pins, since they will be floating if no switch is pressed - they're not connected to anything. you need to check if the board already contains discrete pullup/pulldown resistors, and if not, use the pullups/pulldowns built into the GPIO peripheral
<re_irc> < (@xiretza:xiretza.xyz)> Félix | Totem: you are, the pin doesn't magically stop existing when you're not currently looking at it in the current iteration
<re_irc> < (@xiretza:xiretza.xyz)> the column pins are always driven low, except for one iteration, where each is driven high for one iteration
<re_irc> <Félix | Totem> I'm sorry, I don't understand. From what I understand, I do exactly whet is written here https://pcbheaven.com/wikipages/How_Key_Matrices_Works/
<re_irc> < (@xiretza:xiretza.xyz)> the magic sentence there is "Then, i will give power to only one column, the column B."
<re_irc> < (@xiretza:xiretza.xyz)> the other ones aren't being driven low (like they are in your code), they're left floating
<re_irc> <Félix | Totem> floating? I don't understand: either they're high, or they're low, ain't they?
<re_irc> < (@xiretza:xiretza.xyz)> if you set them up in push-pull mode, yes, that's true - but it's not what you need
<re_irc> < (@xiretza:xiretza.xyz)> what you need is to have them either driven (high or low, doesn't really matter), or left floating
<re_irc> < (@k900:0upti.me)> The thing you're missing is that pins aren't actually physically "high" or "low"
<re_irc> < (@k900:0upti.me)> Like, that's not the only two states they can be in
<re_irc> < (@k900:0upti.me)> Really the pin itself doesn't really have "state"
<re_irc> < (@k900:0upti.me)> It all depends on what it's connected to and how
<re_irc> < (@k900:0upti.me)> https://en.m.wikipedia.org/wiki/Open_collector might help though it's not a great explanation
<re_irc> <Félix | Totem> That's weird because I took some inspiration from this: https://github.com/TeXitoi/keyseebee/blob/master/firmware/src/main.rs#L112 and I reused the same modes.
<re_irc> <Félix | Totem> And matrix uses the same kind of code https://github.com/TeXitoi/keyberon/blob/master/src/matrix.rs#L65
<re_irc> I just saw that high and low are reversed tho
<re_irc> <Félix | Totem> : Thanks
<re_irc> < (@xiretza:xiretza.xyz)> Félix | Totem: oh, sorry, didn't see that you had enabled the internal pull-ups on the inputs - that explains your current problem then! you're telling it to connect a resistor to each input pin that pulls it high if nothing is connected that would pull it low (i.e. a pressed switch that is connecting the row to a low column)
<re_irc> < (@xiretza:xiretza.xyz)> therefore all the inputs are high when nothing is being pressed
<re_irc> <Félix | Totem> : I'm not sure to understand. Does t replace the open drain you're talking about?
<re_irc> < (@xiretza:xiretza.xyz)> Félix | Totem: no, you still need open drain outputs if more than one key can be pressed at the same time
<re_irc> <Félix | Totem> : And should I set_high before, then set_low after? Or the opposite?
<re_irc> < (@xiretza:xiretza.xyz)> if you use open drain outputs, then you need pull-downs on your inputs
<re_irc> < (@xiretza:xiretza.xyz)> sorry no, pull-downs
<re_irc> <Félix | Totem> There is no method “floating”, so I'm not sure how disable the column
<re_irc> <Félix | Totem> +to
<re_irc> < (@xiretza:xiretza.xyz)> that's because all your colums are floating, except for one, which is being pulled to ground - the row inputs for which a switch is pressed on that column will be driven low (through the switch), all the others will be pulled high by the pullups
<re_irc> < (@xiretza:xiretza.xyz)> sorry no, pull-ups
<re_irc> < (@xiretza:xiretza.xyz)> Félix | Totem: "set_low()" for low, "set_high()" for floating
* re_irc (@k900:0upti.me) makes a note for embedded-hal v3
<re_irc> <Félix | Totem> : That's not super logical, but that looks like this image, at least http://dangerousprototypes.com/docs/images/thumb/2/24/Output-types.png/490px-Output-types.png
<re_irc> <Félix | Totem> The second one: switch to the upper side makes it float
<re_irc> <Félix | Totem> * switching
<re_irc> < (@xiretza:xiretza.xyz)> Félix | Totem: yeah, it's basically a missing abstraction, the hardware register is only ever 0 or 1, what happens depends on the pin configuration
<re_irc> < (@k900:0upti.me)> Looks like there's actually kind of an RFC for this already
<re_irc> < (@xiretza:xiretza.xyz)> : tristate is a whole other can of worms too
<re_irc> <Félix | Totem> : That's totally clear now. I always forget that I don't read the electric current directly, but only a bit in the CPU.
<re_irc> < (@xiretza:xiretza.xyz)> what we'd need are a bunch of traits that offer "set_high()", "set_low()", "set_floating()" methods each, and then implement a subset of those traits based on the pin state
<re_irc> < (@xiretza:xiretza.xyz)> * respectively,
<re_irc> < (@xiretza:xiretza.xyz)> * typestate
<re_irc> <Félix | Totem> I use "into_open_drain_output" for the columns and "into_pull_down_input" for the rows, with:
<re_irc> pub fn scan(&mut self) -> KeyState {
<re_irc> let keys = self.cols.iter().map(|col| {
<re_irc> col.set_low().into_ok_(); // The pin is ON
<re_irc> <Félix | Totem> * "row.is_low" and "is_high"
<re_irc> < (@xiretza:xiretza.xyz)> you need "into_pull_up_input"
<re_irc> < (@xiretza:xiretza.xyz)> right now the inputs are always low, either through the closed switch to the grounded column, or through the pull-down - you can't tell the difference
<re_irc> <Félix | Totem> : And now it works. That's so cool, thanks a lot 😁
emerent has quit [Ping timeout: 246 seconds]
emerent has joined #rust-embedded
DepthDeluxe_ has joined #rust-embedded
<re_irc> <Félix | Totem> My board can play some audio (8 bits I think), does someone have some resource about how to use it? I have this definition in C:
<re_irc> #define AUDIO_PIN A5
<re_irc> #define AUDIO_PIN_ALT A4
<re_irc> #define AUDIO_PIN_ALT_AS_NEGATIVE
<re_irc> < (@xiretza:xiretza.xyz)> what does the C++ code do?
<re_irc> < (@xiretza:xiretza.xyz)> does it just bit-bang the pin or does it use a peripheral?
<re_irc> < (@k900:0upti.me)> I'm guessing "A" means "analog" here
<re_irc> I guess it bit-bang the pin, as you says. The audio is really simple
<re_irc> <Félix | Totem> : I'm afraid to read the QMK source code 😅
<re_irc> < (@k900:0upti.me)> Actually no, it's just the pin mapping
<re_irc> < (@k900:0upti.me)> And no, it's using the on-chip ADC
<re_irc> < (@k900:0upti.me)> * DAC
<re_irc> <Félix | Totem> : Thanks
<re_irc> < (@ryankurte:matrix.org)> : the macros? in general they -should- but i'm sure there are plenty of cases they don't (macros are hard)...
<re_irc> you can always manually implement "Encode" and "Decode", but it'd be great to have issues / test cases to reproduce any broken cases so we can improve em
<re_irc> < (@ryankurte:matrix.org)> ahh i found the issue, thanks!
DepthDeluxe_ has quit [Ping timeout: 252 seconds]
<re_irc> < (@yatekii:matrix.org)> https://twitter.com/MakeAugusta/status/1611754659252736000 sorry had to drop this, top too fucking kek :D
DepthDeluxe_ has joined #rust-embedded
dne has quit [Remote host closed the connection]
dne has joined #rust-embedded
DepthDeluxe__ has joined #rust-embedded
DepthDeluxe has joined #rust-embedded
DepthDeluxe_ has quit [Ping timeout: 255 seconds]
DepthDeluxe__ has quit [Ping timeout: 252 seconds]
DepthDeluxe has quit [Ping timeout: 252 seconds]
IlPalazzo-ojiisa has quit [Quit: Leaving.]