Creating and uploading a custom JASON file to enable a custom board

Hi all,

I recall reading a while back that there is a JASON file that allows me to setup the pins for a custom setup. Does someone have a pointer to that topic?

I have a very early board design showing up next Tuesday and I would like to start digging into the setup of the Daisy Seed for this system.

Thank you for your time and help,
Brett

Here’s your pointer: GitHub - electro-smith/json2daisy: Utility for converting JSON board definitions into valid, libDaisy compatible C++ board support files

Hi Brett!

The tool @antisvin linked should work for you. It’s based off of the same custom JSON that was added for oopsy, and extended to be able to be able to generate all of our existing platforms (we’ll be adding support for those extensions back into oopsy over the next month or so).

There are some example JSON files (for the existing electrosmith breakout boards) kind of hidden away within the repo at the moment. The Daisy Pod being one of the simplest of the bunch.

We’re open to feedback as this is still very much a work in progress, and was mostly built to simplify integration with Pure Data via hvcc.

We also plan to make a graphical editor at some point to further simplify the process of getting started with custom hardware.

Hello @antisvin, @shensley,

Maybe a better way to ask this should have been:
What is the best way to bring up a board with custom pin-outs? :slight_smile: I am wondering what the best way to get my custom hardware up and going.

Here is the visual of my pin-out for my “core test” version of my hardware bring up:

Do I need a JASON file if I am going to use c/c++ for this?
I was looking to use Oopsy for a while (and may go back to this in the future), but I decided for this hardware bring up that I would switch to the c/c++ code using Visual Studio Code as I will have to do some driver development for one of the i2C GPIO devices I chose to use for this project.

Thus, do you have a good pointer on how best to enable the pins?

Sorry if this is a noob question overall, but I know enough to get the project going but I am just missing a few details on how to fully connect the dots end-to-end.

Thank you for your time and help with all of this.
Brett

Have a look how existing boards in root of libDaisy repo are defined: libDaisy/src at master · electro-smith/libDaisy · GitHub

You can write your own board definition file from scratch or use the aforementioned generator which would be much faster.

You don’t have to enable pins manually, this is done by driver initialization code in libDaisy. I don’t think you can go very far with custom board/drivers without understanding how libDaisy works, so I’d suggest to spend some time reading its code. Adding your own drivers will likely be quite similar to what’s done for existing hardware, so you can find some example in dev directory. And there’s code for several I2C sensors added in pull requests just a few days ago.

@antisvin,

Awesome! I have started looking at a few drivers already as I am looking to enable a TI GPIO device that looks similar to the TI LED Driver that is supported on the Daisy Field.

I will continue to do some reading and download the configuration tool.

Thank you for the help.
Brett

1 Like

Hi @antisvin @shensley,

A few things after looking through this a bit more today:

  1. I am not really even a noob to python
  2. Setting up python on Windows 10 ran into some snags where the Windows store is broken and saying “I have 10 systems installed”, when in reality I only have 1 linked to my account so I could not use the Windows Store to install python.
  3. I tried to install python 3.x.x from the download and install on Windows 10.
  4. When I tried to follow the instructions on the json2daisy it notes to use “python3” in part of the directions but there is no python3 in the install, but there is python.
  5. I wanted to start by just removing a section at a time from the Daisy Field version where it just leaves the LED driver to run 3 RGB LEDs off of the same LED Driver that is in the Daisy field (I may try the Daisy Pod instead).

As I started to look at some of the errors it is not clear to me if I have the command line incorrect, if I am missing some files that are needed beyond just the minimal version of the json file.

Let me start with a few questions:

  1. How do the “component_defaults” work with this system?
  2. There is a line that says ‘“SOM”:“seed”’, do I need a reference / file for the seed?
  3. In some of the files I am observing a section of “defines”, how would I know what defines to use?

Sorry for all of these questions but the last time I did any embeded work I was using the crosworks complier on some NXP chips about 8 years ago and the pin setup and driver setup felt a little simpler. Thus, I am looking to understand how to create the correct setup.

Overall I will be using:

  1. two PCA9685 off the I2C bus on pins 10, 11 to drive a set of RGB Leds
  2. one MAX11300 DAC running off the SPI bus to drive 4 analog outs.
  3. One GPIO devices based off of the PCAL9555APW chip to capture encoder and swtich data in the closer to final design.

I am sorry for all of these questions but really, I was trying to get to the point where I could create a version of the JSON file that could bring up the RGB LEDs and move froward from there. :slight_smile:

Thus, if there is something a little more than just the code I could read to understand the layering it would be a huge help to me.

Thank you for any further help you may have here for me.

Again, sorry for all the noob questions here, but I am really not quite sure what the next steps here.

Thanks,
Brett

Hey Brett.

Sorry for the confusion regarding the proper version of python, etc. but I’ve never had any success with the Windows store version of the software. I usually download/install python from here.

There is some disconnect between the python command on windows, and other OSes. On some OSes, python still means python 2. The important thing is that python --version or python3 --version returns anything 3.7.0 or higher to use the json2daisy module.


To address your specific questions:

  1. The default components are used internally to configure the Initialization of the components/devices added in the json file.
  2. The SOM field is just to specify between seed based boards, and patch_sm (an upcoming piece of hardware). No additional files are needed.
  3. Most, if not all of the defines are carried over for support with the current implementation of oopsy (max/msp~ gen support). Unless you plan on using that integration you don’t need to worry about the defines much.

As you suspected you could strip most of what you need from the field.json template that’s in the repo.

I didn’t test it through the script, but something like this should generate a structure with Initialization code for a single LED Driver with the ADDR pins set to 0.

{
  "name": "led_board",
  "som": "seed",
  "display": {},
  "audio": {
    "channels": 2
  },
  "parents": {
    "i2c": {
      "component": "i2c",
      "pin": {
        "scl": 11,
        "sda": 12
      }
    },
    "led_driver": {
      "component": "PCA9685",
      "address": "{0x00}",
      "parent": "i2c",
      "driver_count": 1
    }
  },
  "components" : {
    "led_key_b1": {
      "component": "PCA9685Led",
      "index": 0,
      "parent": "led_driver"
    },
    "led_key_b2": {
      "component": "PCA9685Led",
      "index": 1,
      "parent": "led_driver"
    },
    "led_key_b3": {
      "component": "PCA9685Led",
      "index": 2,
      "parent": "led_driver"
    },
  }
}

You could also use the DaisyPetal or DaisyField class in libDaisy as a starting point for own class in c++ (bypassing the json altogether).

We do have some documentation for libDaisy on the web, but it is very much a work in progress.

We’re hoping to provide better documentation specifically for working with external devices, and writing some guides for writing code for custom hardware over the next few months. In the meantime, I hope some of the above is useful, and helpful! :slight_smile:

@shensley,

Thank you for the above info, it is super helpful.

After doing a little more debugging on my JSON file today I believe that the setup of the jason2daisy isn’t correct and/or I am using it incorrectly.

I copied over the pod.json and called is seq16.json and changed the name to “seq16”.

I then ran the following:
python -m json2daisy resources\SEQ16.json

And I got this:

C:\Users\direc\Documents\GitHub\Daisy\json2daisy\src\json2daisy>python -m json2daisy resources\SEQ16.json
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\site-packages\pkg_resources\__init__.py", line 344, in get_provider
    module = sys.modules[moduleOrReq]
KeyError: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\direc\Documents\GitHub\Daisy\json2daisy\src\json2daisy\json2daisy.py", line 294, in <module>
    header, info = generate_header_from_file(args.source)
  File "C:\Users\direc\Documents\GitHub\Daisy\json2daisy\src\json2daisy\json2daisy.py", line 259, in generate_header_from_file
    return generate_header(daisy_description)
  File "C:\Users\direc\Documents\GitHub\Daisy\json2daisy\src\json2daisy\json2daisy.py", line 196, in generate_header
    license_string = pkg_resources.resource_string(__package__, 'resources/LICENSE').decode('utf-8')
  File "C:\Program Files\Python310\lib\site-packages\pkg_resources\__init__.py", line 1142, in resource_string
    return get_provider(package_or_requirement).get_resource_string(
  File "C:\Program Files\Python310\lib\site-packages\pkg_resources\__init__.py", line 346, in get_provider
    __import__(moduleOrReq)
ValueError: Empty module name

I really like the idea of JSON file, I am wondering if there is an option to add the python install as part of the toolchain install. That way all the pieces you need are there and in a known state to work.

I have started looking at the seed.h & seed.cpp along with the pod.h/pod.cpp files as well.

I am looking forward to sending out a post of my hardware blinking an LED and working forward from there! :slight_smile:

Thank you for all of your help thus far.
I greatly appreciate it.

Brett

The dev that put the json2daisy utility together is out of the office today, but I can go over this a bit with them tomorrow, and make sure there isn’t an issue with using the tool on it’s own.

And yes! That’s exactly why we wanted to put together a utility like this. The goal is to have easily portable, and updatable code. Obviously we’re still working on the “easy” part of that.

And yeah, we’re currently working on a few things with the DaisyToolchain installation. We’ve made some good progress on an actual GUI installer for the current toolchain, that we’ll probably release in the next few weeks. And we’re already looking into adding an optional python install as well.

As soon as I’ve had a chance to go over the standalone usage of json2daisy a bit, I’ll chime back in.

@shensley,

Thank you, it is all very much appreciated.

Currently I just created a version of my SEQ16 from the Daisy Field.h/cpp to see if I can get that to compile. It is great to be able to dig and see what I can going without the json2daisy, but I do look forward to having the updated json2daisy in the future.

I am really looking forward to the next few days and overall, the next few months of getting this project to a point where I can start to get more limited user feedback, from there look at rolling out a product on this device.

I really like this platform and I am very happy with the platform so far. My goal is to launch a product based on this device. :smiley: This type of help is great so that I can continue to make progress.

Thank you again for your and the team’s help!
Brett

1 Like

Hi @BHAudio

We’ve just made a new release to fix the issues with standalone mode.

You can update with:

python -m pip install json2daisy --upgrade

I gave it a quick test on my end by just copying the field.json file and running:

python -m json2daisy file.json

That should generate a similar file to what you’ve been putting together using the libDaisy sources.

The header will contain a few similar functions as well as a few new ones, with comments in place on where to place them (i.e. PostProcess() should go at the end of the AudioCallback, and LoopProcess() should be placed in the main while() loop.

Let me know if you have any questions!