GithubHelp home page GithubHelp logo

picostdlib's People

Contributors

auxym avatar beef331 avatar casey-sk avatar flplv avatar ilikescaviar avatar martinix75 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

picostdlib's Issues

Colourized terminal output

Similar to how nimble looks.

  1. when the program is called with some arguments, print a hint: message to read back the interpreted arguments/option/flag
  2. tell the user whenever something is being pulled from the world wide web.
  3. nice colourized error messages.

multi-core rp2024

Hi Jason,
I wanted to do some multicore tests (it's a beautiful thing about rp2024 !!). But as usual they are a bit complex for me to wrapped.
If you have time you could take a look?
The functions are:
• void multicore_reset_core1 (void)
• void multicore_launch_core1 (void (* entry) (void))
• void multicore_launch_core1_with_stack (void (* entry) (void), uint32_t * stack_bottom, size_t stack_size_bytes)
• void multicore_launch_core1_raw (void (* entry) (void), uint32_t * sp, uint32_t vector_table)

Pagi 193 of the manual.
thanks and bye Martin A.

Add bindings for PIO API

I'm currently working in implementing this. The PIO API has a large number of functions, but as a first "mvp" PR, I'd like to bind at least enough to get the "blink" and "ws2812" examples working (and implemented in Nim).

nimble can't install picostdlib correctly

The nimble output:

[mfg@Methadon ~]$ nimble install https://github.com/EmbeddedNim/picostdlib
Downloading https://github.com/EmbeddedNim/picostdlib using git
   Warning: Package 'picostdlib' has an incorrect structure. It should contain a single directory hierarchy for source files, named 'picostdlib', but file 'blink.nim' is in a directory named 'template/src' instead. This will be an error in the future.
      Hint: If 'template/src' contains source files for building 'picostdlib', rename it to 'picostdlib'. Otherwise, prevent its installation by adding `skipDirs = @["template/src"]` to the .nimble file.
  Verifying dependencies for [email protected]
    Prompt: No local packages.json found, download it from internet? [y/N]
    Answer: y
Downloading Official package list
    Success Package list downloaded.
 Installing https://github.com/casey-SK/commandant@>= 0.15.1
Downloading https://github.com/casey-SK/commandant using git
  Verifying dependencies for [email protected]
 Installing [email protected]
   Success: commandant installed successfully.
 Installing https://github.com/beef331/micros@any version
Downloading https://github.com/beef331/micros using git
  Verifying dependencies for [email protected]
 Installing [email protected]
   Success: micros installed successfully.
 Installing [email protected]
   Building picostdlib/piconim using c backend
/home/mfg/.nimble/pkgs/micros-0.1.1/micros/definitions/routines.nim(161, 12) Warning: Use on a typed Procedure may result in accessing the wrong Stmtlist [User]
   Success: picostdlib installed successfully.
    Prompt: Missing directory /home/mfg/.nimble/pkgs/picostdlib-0.3.1/src/template. Continue? [y/N]
    Answer: N

It seems the structure makes it impossible for nimble to correctly install this package. The "missing" directory is obviously not missing.

[mfg@Methadon ~]$ ls .nimble/pkgs/picostdlib-0.3.1/
nimblemeta.json  piconim  piconim.nim  picostdlib  picostdlib.nimble  template
[mfg@Methadon ~]$ ls .nimble/pkgs/picostdlib-0.3.1/template/
config.nims  csource  src  template.nimble

Get TinyUSB (hid and cdc devices) working

Just wanted to mention that I'm working on this, so effort doesn't get duplicated too much.

  • Get a basic example to compile with callbacks and tasks called from Nim
  • Send HID input reports from Nim (mouse / keyboard)
  • Send/receive CDC data from Nim
  • Implement descriptor configuration (usb_descriptors.c file in tusb examples) in Nim
  • Generate the tusb_config.h file from Nim (???) Not sure if this one is possible or worth the effort.
  • Create a commented example
  • Write (some) doc strings

WIP is here: https://github.com/auxym/picostdlib/blob/tinyusb/src/picostdlib/tusb.nim

I don't currently plan to work on other device classes (MSC, midi, audio, etc) or USB host.

Error with Piconim 0.3.1 on old projects

Hi Jason,
Today (back from holidays) I updated Piconim 0.3.0 -> 0.3.1.
If I create a new project everything works well and is completed, while those created first by an error (which I put below). I also tried the "Piconim Setup--Sdk:/Home/Andrea/ProgPiconim/Pico-Sdk" command, but it did not give results.
what should I do ? Recreate the projects or is there another solution?

the error in the old progects:

make[2]: Leaving directory '/home/andrea/ProgPicoNim/scannerI2c/csource/build'
make[2]: Entering directory '/home/andrea/ProgPicoNim/scannerI2c/csource/build'
[ 14%] Building C object CMakeFiles/scannerI2c.dir/nimcache/@m..@s..@s[email protected]@[email protected]@[email protected]
In file included from /home/andrea/ProgPicoNim/scannerI2c/csource/build/nimcache/@m..@s..@s[email protected]@[email protected]@[email protected]:5:
/home/andrea/ProgPicoNim/scannerI2c/csource/nimbase.h:276:35: error: static assertion failed: ""
276 | #define NIM_STATIC_ASSERT(x, msg) _Static_assert((x), msg)
| ^~~~~~~~~~~~~~
/home/andrea/ProgPicoNim/scannerI2c/csource/nimbase.h:550:1: note: in expansion of macro 'NIM_STATIC_ASSERT'
550 | NIM_STATIC_ASSERT(sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8, "");
| ^~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/scannerI2c.dir/build.make:76: CMakeFiles/scannerI2c.dir/nimcache/@m..@s..@s[email protected]@[email protected]@[email protected]] Error 1
make[2]: Leaving directory '/home/andrea/ProgPicoNim/scannerI2c/csource/build'
make[1]: *** [CMakeFiles/Makefile2:1329: CMakeFiles/scannerI2c.dir/all] Error 2
make[1]: Leaving directory '/home/andrea/ProgPicoNim/scannerI2c/csource/build'
make: *** [Makefile:91: all] Error 2
make: Leaving directory '/home/andrea/ProgPicoNim/scannerI2c/csource/build'

Bunch of gcc warnings

Nothing is broken, just an annoyance. Don't remember seeing this before, but currently my pico projects (even a fresh blinky created with piconim init) results in whole bunch of complaining from gcc (see below).

Not sure what changed. I tried older Nim versions and still getting the same. Maybe a new gcc version? I am running arm-none-eabi-gcc (Arch Repository) 12.2.0.

"Regular" nim compiles don't do this, I guess the pico CMake/make stuff might be passing different -W flags to gcc?

In file included from /home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c:4:
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c: In function 'align_system_1616':
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c:281:52: warning: passing argument 3 of '__builtin_ssub_overflow' from incompatible pointer type [-Wincompatible-pointer-types]
  281 |                 if (nimSubInt(alignment, ((NI) 1), &TM__Q5wkpxktOdTGvlSRo9bzt9aw_3)) { raiseOverflow(); goto BeforeRet_;
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                    |
      |                                                    NI * {aka long int *}
/home/francis/.choosenim/toolchains/nim-1.6.0/lib/nimbase.h:589:64: note: in definition of macro 'nimSubInt'
  589 |     #define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res)
      |                                                                ^~~
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c:281:52: note: expected 'int *' but argument is of type 'NI *' {aka 'long int *'}
  281 |                 if (nimSubInt(alignment, ((NI) 1), &TM__Q5wkpxktOdTGvlSRo9bzt9aw_3)) { raiseOverflow(); goto BeforeRet_;
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/francis/.choosenim/toolchains/nim-1.6.0/lib/nimbase.h:589:64: note: in definition of macro 'nimSubInt'
  589 |     #define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res)
      |                                                                ^~~
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c:283:78: warning: passing argument 3 of '__builtin_sadd_overflow' from incompatible pointer type [-Wincompatible-pointer-types]
  283 |                 if (nimAddInt(address, (NI)(TM__Q5wkpxktOdTGvlSRo9bzt9aw_3), &TM__Q5wkpxktOdTGvlSRo9bzt9aw_4)) { raiseOverflow(); goto BeforeRet_;
      |                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                              |
      |                                                                              NI * {aka long int *}
/home/francis/.choosenim/toolchains/nim-1.6.0/lib/nimbase.h:588:64: note: in definition of macro 'nimAddInt'
  588 |     #define nimAddInt(a, b, res) __builtin_sadd_overflow(a, b, res)
      |                                                                ^~~
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c:283:78: note: expected 'int *' but argument is of type 'NI *' {aka 'long int *'}
  283 |                 if (nimAddInt(address, (NI)(TM__Q5wkpxktOdTGvlSRo9bzt9aw_3), &TM__Q5wkpxktOdTGvlSRo9bzt9aw_4)) { raiseOverflow(); goto BeforeRet_;
      |                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/francis/.choosenim/toolchains/nim-1.6.0/lib/nimbase.h:588:64: note: in definition of macro 'nimAddInt'
  588 |     #define nimAddInt(a, b, res) __builtin_sadd_overflow(a, b, res)
      |                                                                ^~~
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c:285:52: warning: passing argument 3 of '__builtin_ssub_overflow' from incompatible pointer type [-Wincompatible-pointer-types]
  285 |                 if (nimSubInt(alignment, ((NI) 1), &TM__Q5wkpxktOdTGvlSRo9bzt9aw_5)) { raiseOverflow(); goto BeforeRet_;
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                    |
      |                                                    NI * {aka long int *}
/home/francis/.choosenim/toolchains/nim-1.6.0/lib/nimbase.h:589:64: note: in definition of macro 'nimSubInt'
  589 |     #define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res)
      |                                                                ^~~
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c:285:52: note: expected 'int *' but argument is of type 'NI *' {aka 'long int *'}
  285 |                 if (nimSubInt(alignment, ((NI) 1), &TM__Q5wkpxktOdTGvlSRo9bzt9aw_5)) { raiseOverflow(); goto BeforeRet_;
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/francis/.choosenim/toolchains/nim-1.6.0/lib/nimbase.h:589:64: note: in definition of macro 'nimSubInt'
  589 |     #define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res)
      |                                                                ^~~
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c: In function 'nimDecRefIsLast':
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c:323:61: warning: passing argument 3 of '__builtin_ssub_overflow' from incompatible pointer type [-Wincompatible-pointer-types]
  323 |                         if (nimSubInt((*cell).rc, ((NI) 8), &TM__Q5wkpxktOdTGvlSRo9bzt9aw_10)) { raiseOverflow(); goto BeforeRet_;
      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                             |
      |                                                             NI * {aka long int *}
/home/francis/.choosenim/toolchains/nim-1.6.0/lib/nimbase.h:589:64: note: in definition of macro 'nimSubInt'
  589 |     #define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res)
      |                                                                ^~~
/home/francis/temp/proj/csource/build/nimcache/stdlib_system.nim.c:323:61: note: expected 'int *' but argument is of type 'NI *' {aka 'long int *'}
  323 |                         if (nimSubInt((*cell).rc, ((NI) 8), &TM__Q5wkpxktOdTGvlSRo9bzt9aw_10)) { raiseOverflow(); goto BeforeRet_;
      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(hundreds more lines of similar warnings)

example usb

thanks Jeson for the very useful getCharWithTimeout () implementation !!
as a test I wrote a small test program, if you want to include it among the examples!
serialUsb.nim.zip

Add timeUs32() end timeUs64()

Hi Jason I added two procedures (timeUs32() & 64) in the existing "time.nim" file creating a type structure:
{.push Header: "Something1".}
aaa
bbb
{.pop.}

{.push Header: "Something2".}
ccc
ddd
{.pop.}

But aren't they sure it's the correct thing to do, or if it is better to create a new Nim file?
P.S. He says we can increase version from 0.2.6 -> 0.2.7?

example usb2

Hello! I tried to enter the sample code usb, but git forbids me: Invalid username or password

andrea@tec-martin:/Documenti/Git/picostdlib> git push --set-upstream origin Martinix75
remote: Invalid username or password.
fatal: Autenticazione non riuscita per 'https://github.com/beef331/picostdlib.git/'
andrea@tec-martin:
/Documenti/Git/picostdlib>

I'm learning these days to use git, so chances are I'm still doing something wrong! :(

RFC: Add setup command and provide .gitignore in template

Current situation:

  • The template project created with piconim init does not contain a .gitignore file
  • This results in commiting, by default, the C files generated by nim as well as the full pico SDK, which might not be desired
  • The csource/build directory cannot be added to .gitignore, because it contains the Makefile, which is generated by cmake during piconim init. Thus, piconim build would fail on a fresh/clean repository.

Proposal:

  • Add a setup (or configure, or init and rename the current init to create) command that runs cmake with the SDK path provided as an optional argument. This is automatically run during init
  • Add a default gitignore file that ignores the entire csource/build directory as well as csource/*.c.
  • Thus, a user could clone a "clean" repository that was created by piconim init, run piconim setup (optionally providing as SDK path), and build it with piconim build.

If the maintainers agree with the idea, I could put in a PR.

Example for Pico W

Hi guys,

thanks for this lovely project; I really enjoyed the clean and useful examples! Would you mind showing how to use Nim with the Pico W, i.e. leveragint its wireless capabilities? My internet searches for this were fruitless so far and I think it would make a good addition to the repo.

Thanks a lot in advance!

Cheers,
Frank

I2c bus

hi Jason here I am again.
after having fun with usb, i would like to try to connect my I2c display.
So I wanted to ask if it was possible to implement the three basic functions for I2c:
i2c_init ()
i2c_write_blocking ()
i2c_read_blocking ()

I tried, but it's a little too much for me !!
thanks from Andrea

https://www.youtube.com/watch?v=092xFEmAS98
here is an example of what I would like to do (about)!!!!!

Move some hardcoded compiler flags to a nim.cfg file

See: https://github.com/beef331/picostdlib/blob/b1bae1b47f7f0057f3973f2a330fb90c9d116bd2/src/piconim.nim#L21

Library users might want to override some of these flags. Eg. running a debug or danger build instead of release, or ORC instead of ARC. I therefore propose to add a nim.cfg file to the template that specifies these flags, and remove the hardcoded values in piconim. The flags that are "absolutely necessary" for a working build should probably stay where they are (--cpu, --nimcache, useMalloc).

This once again breaks backwards compatibility with previously created projects (sorry). Users that want to upgrade would need to copy the new nim.cfg file in their project.

Thoughts?

Error: cannot open file: picostdlib

I followed the setup instructions, and when running piconim build firmware.nim (my project is called firmware) I get the following error:

pico-nim : create raspberry pi pico projects using Nim
Hint: used config file '/home/francis/.choosenim/toolchains/nim-1.6.2/config/nim.cfg' [Conf]
Hint: used config file '/home/francis/.choosenim/toolchains/nim-1.6.2/config/config.nims' [Conf]
....................................................
/home/francis/source/tmpcb-macropad/firmware/src/firmware.nim(2, 8) Error: cannot open file: picostdlib
oserr.nim(95)            raiseOSError
Error: unhandled exception: No such file or directory
Additional info: ("csource/@mfirmware.nim.c", "csource/firmware.c") [OSError]

Nim 1.6.2 on Linux (manjaro).

I can probably look into the issue myself in the next couple of days, just wanted to write it down somewhere.

pwm failed

Hi Jason, today I wanted to make a small PWM driver for an engine, but doing an initial test on the PWM (example of the library that worked ) today I got:
...
[ 15%] Building C object CMakeFiles/motorPwm.dir/nimcache/motorPwm.c.obj
In file included from /home/andrea/ProgPicoNim/motorPwm/csource/build/nimcache/motorPwm.c:5:
/home/andrea/ProgPicoNim/motorPwm/csource/nimbase.h:276:35: error: static assertion failed: "backend & Nim disagree on size for: PwmChannel{enum} [type declared in /home/andrea/.nimble/pkgs/picostdlib-0.2.11/picostdlib/pwm.nim(23, 3)]"
276 | #define NIM_STATIC_ASSERT(x, msg) _Static_assert((x), msg)
| ^~~~~~~~~~~~~~
/home/andrea/ProgPicoNim/motorPwm/csource/build/nimcache/motorPwm.c:25:1: note: in expansion of macro 'NIM_STATIC_ASSERT'
25 | NIM_STATIC_ASSERT(sizeof(enum pwm_chan) == 4, "backend & Nim disagree on size for: PwmChannel{enum} [type declared in /home/andrea/.nimble/pkgs/picostdlib-0.2.11/picostdlib/pwm.nim(23, 3)]");
| ^~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/motorPwm.dir/build.make:76: CMakeFiles/motorPwm.dir/nimcache/motorPwm.c.obj] Error 1

the program is (easy):
import picostdlib/[stdio, gpio, pwm]

let
pin0 = 0.Gpio
pin1 = 1.Gpio
pin0.setFunction(PWM)
pin1.setFunction(PWM)

let sliceNum = pin0.toSliceNum()

sliceNum.setWrap(3)
sliceNum.setChanLevel(A, 1u16)
sliceNum.setChanLevel(B, 3u16)
sliceNum.setEnabled(true)

cmakelists.txt mofied --> target_link_libraries(motorPwm pico_stdlib hardware_adc hardware_pwm hardware_gpio)
I don't understand where it may be the problem, can you make a test (maybe I am only tired toned this evening)? thank you

threads

hi Jason,
I wanted to ask if using "piconim build .." it is possible to pass build flags. I wanted to try to use threadpool (or similar) to manage the display (it's a test) but how do you know you have to enable "--threads: on" is it possible to do this? and generally is it possible to enable these flags when I launch the command?

thanks from Martin A.

Implement Tests

Implement tests for the following:

  1. Tests of all successful outcomes of the init subcommand
    • with just name argument
    • with name and sdk path
    • with name, sdk path, and nimbase path
    • ensure --overwrite works as intended.
  2. Tests of all successful outcomes of the `build subcommand
  3. Tests which of all likely events where error messages have been defined

problem with Nim 1.6.0

good morning,
i just found a problem with nim 1.6.0 that didn't exist with nim 1.4.8!

import random (just import it to generate the error !! )

now create an error:
/home/andrea/ProgPicoNim/test160/src/os.nim(63, 10) Error: OS module not ported to your operating system!
oserr.nim(94) raiseOSError
Error: unhandled exception: No such file or directory
Additional info: "("csource/@mtest160.nim.c", "csource/test160.c", "No such file or directory")" [OSError]

i know you probably can't do anything about it, but i tell you (maybe it's a bug of nim 1.6.0 ?????)
bye!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.