Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Varios questions #69

Open
Martinix75 opened this issue Jan 9, 2025 · 1 comment
Open

Varios questions #69

Martinix75 opened this issue Jan 9, 2025 · 1 comment

Comments

@Martinix75
Copy link
Contributor

Martinix75 commented Jan 9, 2025

@daniel-j
Hi daniel.
I am playing and cores the old programs to bring them to 0.4.0. First of all I noticed that (in my USB library, but perhaps also in /Pico /Stionim ->) the program fails:
../hardware/i2c.nim

proc stdinReadLine*(echoInput: bool = true): string =
  while true:
    let res = getcharTimeoutUs(100_000) #return -2 if empty buffer
    if res != PicoErrorTimeout.int: # --> if res >= 0 and PicoErrorTimeout.int:
      let character = res.char #non convert values < 0
      if character == '\r':
        echo ""
        break
      else:
        result.add(character)
        if echoInput:
          discard putcharRaw(character.cint)
          stdioFlush()

This is because (it seems) that "Gettimeoutus" if he has nothing written in the Buffer returns -2, and the conversion obviously fails. Give us a look!!

Second, I bought the RP 2350 to try it, I wondered if during the compilation (or I don't know when) to fill in for it, you have to put some flag somewhere!(I see that you added something for him)

for the monte is all! bye by Martin A.

I will definitely disturb you again

@Martinix75
Copy link
Contributor Author

Martinix75 commented Jan 12, 2025

@daniel-j
One thing that could perhaps be improved (as a lazy electronic) is the functions:

  • i2cWriteBlockingNim
  • i2cReadBlockingNim
    Making the following, modification, which for practical use is perhaps more "natural" and practical (after -> the suggested modification):
proc i2cWriteBlockingNim*(
    i2c: ptr I2cInst,
    address: I2cAddress, --> address: uint (o maybe Uint8)
    data: var openArray[uint8],
    noStop: bool = false
  ): int =
  ## Write bytes to I2C bus.
  ## If `noStop` is `true`, master retains control of the bus at the end of
  ## the transfer.
  result = i2c.writeBlocking(address, data[0].addr, data.len.uint, noStop) --> result = i2c.writeBlocking(address.I2cAddress, data[0].addr, data.len.uint, noStop)

bye by Andrea
p.s. Unfortunately with git I am not very good hindsight I would try to make a Commit (but I will try in case of examples)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant