EmbeddedNim / picostdlib

Nim wrapper for the raspberry pi stdlib
MIT License
70 stars 11 forks source link

Remove procedures from picostdlib.nim #23

Closed casey-SK closed 2 years ago

casey-SK commented 2 years ago

I placed sleep() and sleepMicroseconds into the time.nim module and moved all of the other proc's inside picostdlib into stdio.nim . Personally, I prefer it this way, and believe it is more consistent across the board.

I was not sure what effects deleting the picostlib.nim file would do to nimble install as a hybrid installation, so I didn't delete it yet.

casey-SK commented 2 years ago

I tested the following program, and it worked fine:

import picostdlib/[gpio, time, stdio]

stdioInitAll()

let led = 20.Gpio
led.init()
led.setDir(Out)
while true:
  led.put(High)
  sleep(1500)
  led.put(Low)
  print("blink")
  sleep(1500)
beef331 commented 2 years ago

Bump the nimble version and update all examples. Perhaps we should make picostdlib import and export all submodules.

casey-SK commented 2 years ago

would that mean you would just use

import picostdlib

and never have to worry about importing individual submodules?

beef331 commented 2 years ago

Indeed, it'd export all sub modules making life easier if wanted.

casey-SK commented 2 years ago

do you think we want that, or do we want granular control? would there be a difference in size of the .uf2 file? I assume that Nim does not compile/import procs and modules which are never used in the main program?

beef331 commented 2 years ago

It was just an idea. It does not compile code that's not needed, only code that's used. We can just remove the main module I think if it's not needed.

casey-SK commented 2 years ago

I suppose to be idiomatic like the Nim standard library, we should just have one module imported?

beef331 commented 2 years ago

I mean you can selectively import if needed, it's not really idiomatic, just an option.

casey-SK commented 2 years ago

I plan on making another PR very soon that will completely overhaul the examples folder. Can we have broken examples for a little bit and approve this PR?

beef331 commented 2 years ago

Sounds fine for now, if you do not get the examples overhauled in due time I'll fix it myself.

casey-SK commented 2 years ago

sounds good!