Skip to content
Snippets Groups Projects
Commit 8c6b03e5 authored by Jake Read's avatar Jake Read
Browse files

stash before new hardware drivers for new circuits

parent 64cdefa2
Branches
No related tags found
No related merge requests found
## Ponyo Dev Log
**2019 12 02**
Alexandre Kaspar from Fab Class (TA), after seeing my painful include-if-def cases in Ponyo, sent this along:
```
Here’s a sample I was thinking about when you came in EDS this afternoon:
https://github.com/wjakob/nori/blob/master/include/nori/object.h
The macro of interest for C++ is NORI_REGISTER_CLASS(cls, name)
- name is the string for querying the class name as a variable.
- cls is the actual class name in C++ for the macro.
This creates two things:
- a factory function that can be used to generate an instance of that class: cls *cls##_create(const PropertyList &list) where cls##_create creates an identifier where cls is taken from the macro
- a static struct whose constructor calls the factory method for registering the class as part of the automated factory system (NoriObjectFactory), which is actually instantiated in-place, and thus the constructor is called (exactly once).
The only trick is you don’t get the knowledge of when the instantiation happens (its order), you just know it’ll happen before main is called typically.
This is not needed for the students for this week, but it’s a neat thing to know in case you want to make it look fancy.
The whether it’s instantiated or not is simply decided by whether you are actually linking the object (or not).
You don’t need to include it with C++.
```
Bless you Alexandre. This will be something to check in on / take a day with, as ponyo progresses.
**2019 11 06**
For build / include / etc:
......@@ -8,6 +34,8 @@ For build / include / etc:
- init code is for turning hardware on, and now classes can report whether they need to be singletons, or what hardwares they need, etc. we can use their string name from the class declaration as well, etc. hardware startups are only allowed on init(), ok
- great, that's much easier haha
I.E. here I was basically thinking to include some static code at each object, including the ponyo singleton, and then running ponyo->include(thing); and then thing includes a factory for itself...
**2019 10 21**
Today I think I will take my time on the compile-time build/sys for Ponyo. Answering questions like:
- how do I \#define classes so that they don't compile when I build an instance for a particular device?
......
......@@ -82,6 +82,10 @@ the name switch doesn't have to live in manager,
#include "hunks/driver/hunk_errlight.h"
#include "hunks/driver/hunk_spindlePWM.h"
#include "hunks/pins/hunk_pin_localring.h"
#include "hunks/pins/hunk_pin_pa10_input.h"
#include "hunks/pins/hunk_pin_pa12_output.h"
// ------------------------------------------------------- //
// ------------------ OPTION HUNK LIST ------------------ //
// ------------------------------------------------------- //
......@@ -165,6 +169,18 @@ Hunk* allocateHunkByType(String type){
if(type == "driver/spindlePWM"){
ret = new Hunk_SpindlePWM();
}
hunklist[hlc++] = "pins/localring";
if(type == "pins/localring"){
ret = new LocalRing();
}
hunklist[hlc++] = "pins/pa10_input";
if(type == "pins/pa10_input"){
ret = new PA10_Input();
}
hunklist[hlc++] = "pins/pa12_output";
if(type == "pins/pa12_output"){
ret = new PA12_Output();
}
#ifdef BUILD_INCLUDES_HUNK_STEPPER
hunklist[hlc++] = "driver/stepper";
if (type == "driver/stepper"){
......@@ -377,12 +393,6 @@ Hunk* allocateHunkByType(String type){
// regardless, this doesn't have to be the master-blaster yet, just make some
// machines jog ...
/*
#include "hunks/pins/hunk_pin_localring.h"
#include "hunks/pins/hunk_pin_pa10_input.h"
#include "hunks/pins/hunk_pin_pa12_output.h"
*/
/*
#include "hunks/hunk_loadcell.h"
*/
......
......@@ -27,6 +27,8 @@ LocalRing::LocalRing(){
}
void LocalRing::init(void){
PIN_OUTPUT_PORT.DIRSET.reg = PIN_OUTPUT_BM;
PIN_OUTPUT_PORT.OUTSET.reg = PIN_OUTPUT_BM;
// set inp
PIN_INPUT_PORT.DIRCLR.reg = PIN_INPUT_BM;
PIN_INPUT_PORT.PINCFG[PIN_INPUT_NUM].reg = PORT_PINCFG_INEN;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment