Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Fri Oct 18 07:25:03 2013 +0000
Revision:
42:5f21a710ebc5
Parent:
40:3ba2b0ea9f33
Child:
43:1dd4cfc30788
lots of problems, in particular it seems I cannot add new objects without clearing the whole scene first!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 40:3ba2b0ea9f33 1 #include "WrapperFunctions.h"
mbedalvaro 40:3ba2b0ea9f33 2 #include "textData.h" // this just contains a special switch/case function to load an array of data, so as to store data in FLASH.
mbedalvaro 40:3ba2b0ea9f33 3
mbedalvaro 40:3ba2b0ea9f33 4 using namespace std;
mbedalvaro 40:3ba2b0ea9f33 5
mbedalvaro 40:3ba2b0ea9f33 6 extern LaserRenderer lsr;
mbedalvaro 40:3ba2b0ea9f33 7 extern Scene scene;
mbedalvaro 40:3ba2b0ea9f33 8 extern laserSensingDisplay lsd;
mbedalvaro 40:3ba2b0ea9f33 9
mbedalvaro 40:3ba2b0ea9f33 10 bool previousLsdState; //local scope - only used in this file.
mbedalvaro 40:3ba2b0ea9f33 11
mbedalvaro 40:3ba2b0ea9f33 12 // ================================= BASIC "OPENGL-like" object/scene builders and query functions ("sense") ==========================================
mbedalvaro 40:3ba2b0ea9f33 13
mbedalvaro 40:3ba2b0ea9f33 14 void clearScene() // THIS SHOULD BE CALLED WHENEVER we want to create a new scene from scratch.
mbedalvaro 40:3ba2b0ea9f33 15 {
mbedalvaro 40:3ba2b0ea9f33 16 // This is delicate: first, we have to STOP the displaying engine, then we clear the scene and we are ready to add objects (begin/end, or primitive builders)
mbedalvaro 40:3ba2b0ea9f33 17 // BUT WE NEED TO LET THE DISPLAYING ENGINE FINISH THE WORK IT'S DOING on the current buffer. TWO WAYS: DOUBLE BUFFERING, or wait:
mbedalvaro 40:3ba2b0ea9f33 18 // Check in which point of the drawing we are:
mbedalvaro 40:3ba2b0ea9f33 19 if (lsd.isRunning()) {
mbedalvaro 40:3ba2b0ea9f33 20 lsd.startDisplayCheck();
mbedalvaro 40:3ba2b0ea9f33 21 while(!lsd.isDisplayingOver());
mbedalvaro 40:3ba2b0ea9f33 22 stopDisplay();
mbedalvaro 40:3ba2b0ea9f33 23 } else { //do nothing, the display engine is not working (we don't need to wait for the display to end!)
mbedalvaro 40:3ba2b0ea9f33 24 }
mbedalvaro 40:3ba2b0ea9f33 25 scene.clear();
mbedalvaro 42:5f21a710ebc5 26 //updateScene();
mbedalvaro 40:3ba2b0ea9f33 27 }
mbedalvaro 40:3ba2b0ea9f33 28
mbedalvaro 42:5f21a710ebc5 29 void updateScene() // THIS SHOULD BE CALLED WHENEVER we ended CREATING or MODIFYING a scene
mbedalvaro 42:5f21a710ebc5 30 {
mbedalvaro 42:5f21a710ebc5 31 // In fact, the only thing this routine does is to indicate to the (dormant!) displaying engine that the scene STRUCTURE has changed.
mbedalvaro 42:5f21a710ebc5 32 // NOTE:
mbedalvaro 42:5f21a710ebc5 33 lsd.setSceneToDisplay(&scene); // this will compute the number of objects, points, etc, to prepare the displaying engine
mbedalvaro 42:5f21a710ebc5 34 resumeDisplay();// this will resume display IF it was displaying before.
mbedalvaro 42:5f21a710ebc5 35 }
mbedalvaro 42:5f21a710ebc5 36
mbedalvaro 42:5f21a710ebc5 37
mbedalvaro 40:3ba2b0ea9f33 38 void deleteObject(int _id) {
mbedalvaro 40:3ba2b0ea9f33 39 if (lsd.isRunning()) {
mbedalvaro 40:3ba2b0ea9f33 40 lsd.startDisplayCheck();
mbedalvaro 40:3ba2b0ea9f33 41 while(!lsd.isDisplayingOver());
mbedalvaro 40:3ba2b0ea9f33 42 stopDisplay();
mbedalvaro 40:3ba2b0ea9f33 43 } else { //do nothing, the display engine is not working (we don't need to wait for the display to end!)
mbedalvaro 40:3ba2b0ea9f33 44 }
mbedalvaro 40:3ba2b0ea9f33 45 // DELETE THE OBJECT and update the scene:
mbedalvaro 40:3ba2b0ea9f33 46 scene.deleteObject(_id);
mbedalvaro 40:3ba2b0ea9f33 47 updateScene();
mbedalvaro 40:3ba2b0ea9f33 48 }
mbedalvaro 40:3ba2b0ea9f33 49
mbedalvaro 40:3ba2b0ea9f33 50 // Object creation ("openGL-style").
mbedalvaro 40:3ba2b0ea9f33 51 // NOTE: returning the pointer will make it possible to create COLLECTIONS of objects (by creating a vector<BaseObject*> firstCollection, which is a SUBSET of the
mbedalvaro 40:3ba2b0ea9f33 52 // scene collection. In the future, I will make a "collection" class with specific sensing methods, but for the time being this can be done by hand.
mbedalvaro 40:3ba2b0ea9f33 53 BaseObject* begin(unsigned char _id=0)
mbedalvaro 40:3ba2b0ea9f33 54 {
mbedalvaro 40:3ba2b0ea9f33 55 // This will add a new object. In the future, we can have modes - lines, bezier, and points - as well as specification of the type of object (enum)
mbedalvaro 40:3ba2b0ea9f33 56 // TO DO interesting feature: MERGING OF OBJECTS if they have the same ID? Note that if we DON'T specify an ID, the index will grow automatically starting from 0.
mbedalvaro 40:3ba2b0ea9f33 57 // for (int i=0; i<scene.totalObjects(); i++) if ((scene.objectArray[i]->ID())==_id) ptr_object=scene.objectArray[i];
mbedalvaro 40:3ba2b0ea9f33 58
mbedalvaro 40:3ba2b0ea9f33 59 BaseObject* ptr_newObject=new BaseObject(_id); // note: I cannot simply do: BaseObject newObject(_id) because this would be a LOCAL object, deallocated at the exit of this function.
mbedalvaro 40:3ba2b0ea9f33 60 // NOTE: by allocating the memory for the object pointed by ptr_newObject using new BaseObject, we lost the possibility of intantiating CHILD objects.
mbedalvaro 40:3ba2b0ea9f33 61 // One possibility is to have a parameter in the begin() method to indicate the type of object (for instance: GENERIC_OBJECT, LETTER, etc...). This way,
mbedalvaro 40:3ba2b0ea9f33 62 // we can properly instantiate the object. Another possiblity is to
mbedalvaro 40:3ba2b0ea9f33 63
mbedalvaro 40:3ba2b0ea9f33 64 if (ptr_newObject) { // check to see if we could allocate memory
mbedalvaro 40:3ba2b0ea9f33 65 scene.ptr_currentObject=ptr_newObject; // type casting "slices" the child object (but in principle, "scene" WON'T use derived methods)
mbedalvaro 40:3ba2b0ea9f33 66 ptr_newObject->setColor(lsr.color); // use current color in state machine
mbedalvaro 40:3ba2b0ea9f33 67 //pc.printf("Could allocate object: %d", _id);
mbedalvaro 40:3ba2b0ea9f33 68 } else {
mbedalvaro 40:3ba2b0ea9f33 69 //pc.printf("Could not allocate object: %d", _id);
mbedalvaro 40:3ba2b0ea9f33 70 }
mbedalvaro 40:3ba2b0ea9f33 71 return(ptr_newObject);
mbedalvaro 40:3ba2b0ea9f33 72 }
mbedalvaro 40:3ba2b0ea9f33 73
mbedalvaro 40:3ba2b0ea9f33 74 void vertex(V3& _v3)
mbedalvaro 40:3ba2b0ea9f33 75 {
mbedalvaro 40:3ba2b0ea9f33 76 // Add a 3d point to the "current" object (ie, the latest added object in principle!), but do not RENDER it yet (no final projection computed).
mbedalvaro 40:3ba2b0ea9f33 77 // NOTE: the point WILL however be added by transforming it with the current MODELVIEW matrix. This way, we can create a whole 3d "scene" before rendering,
mbedalvaro 40:3ba2b0ea9f33 78 // that can be rotated again without the need to rebuilt it.
mbedalvaro 40:3ba2b0ea9f33 79
mbedalvaro 40:3ba2b0ea9f33 80 scene.ptr_currentObject->addVertex(_v3, lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 81 // Or, to avoid using ptr_currentObject: scene.objectArray.back()->addVertex(_v3, lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 82
mbedalvaro 40:3ba2b0ea9f33 83 // Another way: ptr_currentObject->vertexArray.push_back(lsr.RT*_v3);
mbedalvaro 40:3ba2b0ea9f33 84 // yet another way: use a method of lsr that "transform" a 3d point. Too heavy...
mbedalvaro 40:3ba2b0ea9f33 85 }
mbedalvaro 40:3ba2b0ea9f33 86
mbedalvaro 40:3ba2b0ea9f33 87 void vertex(float x, float y, float z)
mbedalvaro 40:3ba2b0ea9f33 88 {
mbedalvaro 40:3ba2b0ea9f33 89 V3 v(x, y, z);
mbedalvaro 40:3ba2b0ea9f33 90 vertex(v); // why I cannot do: vertex(V3(x, y, z)) ? because vertex(V3& _v3) needs a REFERENCE to an object that has larger scope that this method itself!
mbedalvaro 40:3ba2b0ea9f33 91 }
mbedalvaro 40:3ba2b0ea9f33 92
mbedalvaro 40:3ba2b0ea9f33 93 void vertexArray(vector<V3>& _vertexArray) {
mbedalvaro 40:3ba2b0ea9f33 94 for (int i=0; i<_vertexArray.size(); i++) {
mbedalvaro 40:3ba2b0ea9f33 95 vertex(_vertexArray[i]);
mbedalvaro 40:3ba2b0ea9f33 96 }
mbedalvaro 40:3ba2b0ea9f33 97 }
mbedalvaro 40:3ba2b0ea9f33 98
mbedalvaro 40:3ba2b0ea9f33 99 void end() // add the object to the current scene (we could add to a specific scene in the future...)
mbedalvaro 40:3ba2b0ea9f33 100 {
mbedalvaro 40:3ba2b0ea9f33 101 // note: the current object pointerd by ptr_newObject can be BaseObject or any child class. This is not a problem as long as the methods applied to the
mbedalvaro 40:3ba2b0ea9f33 102 // scene vector array don't use child methods (then we can do a dynamic cast before including in the array: pb = dynamic_cast<CBase*>(&d); ). IF we want
mbedalvaro 40:3ba2b0ea9f33 103 // the scene class to be able to use child methods, then we need to make BaseObject polymorphic, by declaring all usable methods VIRTUAL.
mbedalvaro 40:3ba2b0ea9f33 104 scene.addCurrentObject(); // add the currently tracked object to the vector array
mbedalvaro 40:3ba2b0ea9f33 105 //scene.addObject(scene.ptr_newObject); // use Scene method to add object to the scene (global).
mbedalvaro 40:3ba2b0ea9f33 106 // NOTE: scene structure changed, BUT we don't need to inform the displaying engine if we don't want (the new object won't be displayed though)
mbedalvaro 40:3ba2b0ea9f33 107 }
mbedalvaro 40:3ba2b0ea9f33 108
mbedalvaro 40:3ba2b0ea9f33 109 // Sensing methods (query and process sensed data for all objects):
mbedalvaro 40:3ba2b0ea9f33 110 // Objects: we can query the object by their ID or by just giving the object pointer. Now, since we are using begin/end to create objects (at least for now), it will
mbedalvaro 40:3ba2b0ea9f33 111 // be better to query by ID (and assume also that their IDs are different). Now, note that matching the ID may be costly (well, I assume they are not more than ten or so objects).
mbedalvaro 40:3ba2b0ea9f33 112 bool senseObject(int _id)
mbedalvaro 40:3ba2b0ea9f33 113 {
mbedalvaro 40:3ba2b0ea9f33 114 BaseObject* ptr_object=NULL;
mbedalvaro 40:3ba2b0ea9f33 115 for (int i=0; i<scene.totalObjects(); i++) if ((scene.objectArray[i]->ID())==_id) ptr_object=scene.objectArray[i];
mbedalvaro 40:3ba2b0ea9f33 116 if (ptr_object!=NULL) return(ptr_object->sense());
mbedalvaro 40:3ba2b0ea9f33 117 else return(false); // if there is no object with this ID, return false (convention)
mbedalvaro 40:3ba2b0ea9f33 118 }
mbedalvaro 40:3ba2b0ea9f33 119
mbedalvaro 40:3ba2b0ea9f33 120 bool senseScene()
mbedalvaro 40:3ba2b0ea9f33 121 {
mbedalvaro 40:3ba2b0ea9f33 122 return(scene.sense());
mbedalvaro 40:3ba2b0ea9f33 123 }
mbedalvaro 40:3ba2b0ea9f33 124
mbedalvaro 40:3ba2b0ea9f33 125 // ================================= "GLOBAL" TRANSFORMATIONS (i.e. "viewing transforms") ON OBJECTS and SCENE without rebuilding them ============================================================
mbedalvaro 40:3ba2b0ea9f33 126 // NOTE: There are two ways of doing this: (1) one is to apply the required transformation on the object/scene 3d points themselves; (2) the other is to mantain the 3d points values, but apply
mbedalvaro 40:3ba2b0ea9f33 127 // the transformation FOR rendering only. The advantage of this last technique is that there will not be any drifting of the values because
mbedalvaro 40:3ba2b0ea9f33 128 // of approximations after a while; the disadvantage is that we cannot easily track an "incremental" interactive transformation (say, scrolling a sphere). But this can be solved by using
mbedalvaro 40:3ba2b0ea9f33 129 // an "accumulator" tranformation matrix (or a quaternion). Also, the second methodology closely matches the OpenGL philosophy: defining the "modelview transformation" and the "viewing transformation",
mbedalvaro 40:3ba2b0ea9f33 130 // even though these transformations apply to the same modelview matrix.
mbedalvaro 40:3ba2b0ea9f33 131 // I will implement both, because even the first option can be useful (to create more complex scenes by rotating already created objects for instance - but it will be trickier to understand though)
mbedalvaro 40:3ba2b0ea9f33 132
mbedalvaro 40:3ba2b0ea9f33 133 // (1) applying a transformation on the 3d points (NOTE: we could also apply transformations on the projected points! this is however a work for the "viewport").
mbedalvaro 40:3ba2b0ea9f33 134 // NOTE: I am not going to create new transform methods (rotation and translations), but instead use the lsr stack. So, I assume the user has set RT to what she wants. Then, we will
mbedalvaro 40:3ba2b0ea9f33 135 // just apply RT to the object or whole scene. This method can be used to RESIZE the object (in particular when it is centered).
mbedalvaro 40:3ba2b0ea9f33 136 //(a) Objects:
mbedalvaro 40:3ba2b0ea9f33 137 void trasformObject(int _id) // use maps in the future!!!
mbedalvaro 40:3ba2b0ea9f33 138 {
mbedalvaro 40:3ba2b0ea9f33 139 BaseObject* ptr_object=NULL;
mbedalvaro 40:3ba2b0ea9f33 140 for (int i=0; i<scene.totalObjects(); i++) if ((scene.objectArray[i]->ID())==_id) ptr_object=scene.objectArray[i];
mbedalvaro 40:3ba2b0ea9f33 141 if (ptr_object!=NULL) {
mbedalvaro 40:3ba2b0ea9f33 142 // Apply the current RT transformation:
mbedalvaro 40:3ba2b0ea9f33 143 ptr_object->transform(lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 144 // Them RENDER the object? no, this will be done only when drawing: the reason is that ON TOP of this transform, we may have the GLOBAL MODELVIEW matrix to apply
mbedalvaro 40:3ba2b0ea9f33 145 //lsr.renderObject(ptr_object);
mbedalvaro 40:3ba2b0ea9f33 146 }
mbedalvaro 40:3ba2b0ea9f33 147 }
mbedalvaro 40:3ba2b0ea9f33 148 // If we know the object already (this is the output of "begin" method for instance), we can apply the transformation without having to match the ID:
mbedalvaro 40:3ba2b0ea9f33 149 void transformObject(BaseObject* ptr_object)
mbedalvaro 40:3ba2b0ea9f33 150 {
mbedalvaro 40:3ba2b0ea9f33 151 ptr_object->transform(lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 152 // lsr.renderObject(ptr_object);
mbedalvaro 40:3ba2b0ea9f33 153 }
mbedalvaro 40:3ba2b0ea9f33 154 // (b) Whole scene:
mbedalvaro 40:3ba2b0ea9f33 155 void transformScene()
mbedalvaro 40:3ba2b0ea9f33 156 {
mbedalvaro 40:3ba2b0ea9f33 157 scene.transform(lsr.RT); // or equialently: for (int i=0; i<scene.totalObjects(); i++) scene.objectArray[i]->transform(lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 158 // lsr.renderScene(&scene);
mbedalvaro 40:3ba2b0ea9f33 159 }
mbedalvaro 40:3ba2b0ea9f33 160
mbedalvaro 40:3ba2b0ea9f33 161 //(2) Apply current RT transformation and render but KEEPING the original values of the 3d points:
mbedalvaro 40:3ba2b0ea9f33 162 //(a) Objects:
mbedalvaro 40:3ba2b0ea9f33 163 void drawObject(int _id) // use maps in the future!!!
mbedalvaro 40:3ba2b0ea9f33 164 {
mbedalvaro 40:3ba2b0ea9f33 165 BaseObject* ptr_object=NULL;
mbedalvaro 40:3ba2b0ea9f33 166 for (int i=0; i<scene.totalObjects(); i++) if ((scene.objectArray[i]->ID())==_id) ptr_object=scene.objectArray[i];
mbedalvaro 40:3ba2b0ea9f33 167 if (ptr_object!=NULL) {
mbedalvaro 40:3ba2b0ea9f33 168 // We don't apply the current RT transformation (ptr_object->transform(lsr.RT)), but instead we directly RENDER it with a pre-transformation:
mbedalvaro 40:3ba2b0ea9f33 169 lsr.renderObject(ptr_object, lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 170 }
mbedalvaro 40:3ba2b0ea9f33 171 }
mbedalvaro 40:3ba2b0ea9f33 172 // If we know the object already (this is the output of "begin" method for instance), we can apply the transformation without having to match the ID:
mbedalvaro 40:3ba2b0ea9f33 173 void drawObject(BaseObject* ptr_object)
mbedalvaro 40:3ba2b0ea9f33 174 {
mbedalvaro 40:3ba2b0ea9f33 175 //ptr_object->transform(lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 176 lsr.renderObject(ptr_object, lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 177 }
mbedalvaro 40:3ba2b0ea9f33 178 // (b) Whole scene:
mbedalvaro 40:3ba2b0ea9f33 179 // ATTENTION: we may need START the display engine the FIRST time or nothing will be seeing (this is done by calling startDisplay()).
mbedalvaro 40:3ba2b0ea9f33 180 void drawScene()
mbedalvaro 40:3ba2b0ea9f33 181 {
mbedalvaro 40:3ba2b0ea9f33 182 //NOTE: there is no need, AND IT IS better NOT to stop/resume the display engine (detaching and reattaching the ISR).
mbedalvaro 40:3ba2b0ea9f33 183 // There is no need in principle, because we only call drawScene AFTER the scene to draw has been passed to the laserSensingDisplay object. This means
mbedalvaro 40:3ba2b0ea9f33 184 // that the number of objects and points per object did NOT change.
mbedalvaro 40:3ba2b0ea9f33 185 //scene.transform(lsr.RT); // or equialently: for (int i=0; i<scene.totalObjects(); i++) scene.objectArray[i]->transform(lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 186 lsr.renderScene(&scene, lsr.RT);
mbedalvaro 40:3ba2b0ea9f33 187 }
mbedalvaro 40:3ba2b0ea9f33 188
mbedalvaro 40:3ba2b0ea9f33 189 // Color attribute transformation (for the time being, only to the whole scene):
mbedalvaro 40:3ba2b0ea9f33 190 void changeColorScene(unsigned char _color) {
mbedalvaro 40:3ba2b0ea9f33 191 for (int i=0; i<scene.totalObjects(); i++) scene.objectArray[i]->setColor(_color);
mbedalvaro 40:3ba2b0ea9f33 192 }
mbedalvaro 40:3ba2b0ea9f33 193
mbedalvaro 40:3ba2b0ea9f33 194 // ================================= OBJECT PRIMITIVES (this could be in a different file) ============================================================
mbedalvaro 40:3ba2b0ea9f33 195 // NOTE: these methods will not create new objects, unless we explicitly say so (by preceding them with "begin" and ending by "end".
mbedalvaro 40:3ba2b0ea9f33 196 // Instead, they will add the vertices to the "current object" being created.
mbedalvaro 40:3ba2b0ea9f33 197
mbedalvaro 40:3ba2b0ea9f33 198 // A line:
mbedalvaro 40:3ba2b0ea9f33 199 void line(V3& v0, V3& v1, int npoints)
mbedalvaro 40:3ba2b0ea9f33 200 {
mbedalvaro 40:3ba2b0ea9f33 201 V3 stepVector=(v1-v0)/(npoints-1);
mbedalvaro 40:3ba2b0ea9f33 202 for (int i=0; i<npoints; i++) {
mbedalvaro 40:3ba2b0ea9f33 203 V3 v(v0+stepVector*i); // vertex added to the current object
mbedalvaro 40:3ba2b0ea9f33 204 vertex(v);
mbedalvaro 40:3ba2b0ea9f33 205 }
mbedalvaro 40:3ba2b0ea9f33 206 }
mbedalvaro 40:3ba2b0ea9f33 207 void line(float x0, float y0, float z0, float x1, float y1, float z1, int npoints)
mbedalvaro 40:3ba2b0ea9f33 208 {
mbedalvaro 40:3ba2b0ea9f33 209 // NOTE: we don't clear the current modelview, but use it's current value.
mbedalvaro 40:3ba2b0ea9f33 210 V3 A(x0, y0, z0), B(x1, y1, z1);
mbedalvaro 40:3ba2b0ea9f33 211 line(A, B, npoints);
mbedalvaro 40:3ba2b0ea9f33 212 }
mbedalvaro 40:3ba2b0ea9f33 213 // A line in the z=0 plane:
mbedalvaro 40:3ba2b0ea9f33 214 void line(float x0, float y0, float x1, float y1, int npoints)
mbedalvaro 40:3ba2b0ea9f33 215 {
mbedalvaro 40:3ba2b0ea9f33 216 // NOTE: we don't clear the current modelview, but use it's current value.
mbedalvaro 40:3ba2b0ea9f33 217 V3 A(x0, y0, 0), B(x1, y1, 0);
mbedalvaro 40:3ba2b0ea9f33 218 line(A, B, npoints);
mbedalvaro 40:3ba2b0ea9f33 219 }
mbedalvaro 40:3ba2b0ea9f33 220
mbedalvaro 40:3ba2b0ea9f33 221 // A square in the z=0 plane
mbedalvaro 40:3ba2b0ea9f33 222 void square(float sideSize, int npointsSide)
mbedalvaro 40:3ba2b0ea9f33 223 {
mbedalvaro 40:3ba2b0ea9f33 224 V3 A(0,0, 0), B(sideSize, 0, 0);
mbedalvaro 40:3ba2b0ea9f33 225 line(A, B, npointsSide);
mbedalvaro 40:3ba2b0ea9f33 226 A.x = sideSize;
mbedalvaro 40:3ba2b0ea9f33 227 A.y = sideSize;
mbedalvaro 40:3ba2b0ea9f33 228 line(B, A, npointsSide);
mbedalvaro 40:3ba2b0ea9f33 229 B.x = 0;
mbedalvaro 40:3ba2b0ea9f33 230 B.y = sideSize;
mbedalvaro 40:3ba2b0ea9f33 231 line(A, B, npointsSide);
mbedalvaro 40:3ba2b0ea9f33 232 A.x = 0;
mbedalvaro 40:3ba2b0ea9f33 233 A.y = 0;
mbedalvaro 40:3ba2b0ea9f33 234 line(B, A, npointsSide);
mbedalvaro 40:3ba2b0ea9f33 235 }
mbedalvaro 40:3ba2b0ea9f33 236
mbedalvaro 40:3ba2b0ea9f33 237 // A rectangle in the z=0 plane
mbedalvaro 40:3ba2b0ea9f33 238 void rectangle(float sideSizeX, float sideSizeY, int interPointDistance)
mbedalvaro 40:3ba2b0ea9f33 239 // note: interPointDistance (degrees per point) would be the equivalent of "pixels" separation for the laser projector
mbedalvaro 40:3ba2b0ea9f33 240 {
mbedalvaro 40:3ba2b0ea9f33 241 V3 A(0,0, 0), B(sideSizeX, 0, 0);
mbedalvaro 40:3ba2b0ea9f33 242 line(A, B, sideSizeX/interPointDistance);
mbedalvaro 40:3ba2b0ea9f33 243 A.x = sideSizeX;
mbedalvaro 40:3ba2b0ea9f33 244 A.y = sideSizeY;
mbedalvaro 40:3ba2b0ea9f33 245 line(B, A, sideSizeY/interPointDistance);
mbedalvaro 40:3ba2b0ea9f33 246 B.x = 0;
mbedalvaro 40:3ba2b0ea9f33 247 B.y = sideSizeY;
mbedalvaro 40:3ba2b0ea9f33 248 line(A, B, sideSizeX/interPointDistance);
mbedalvaro 40:3ba2b0ea9f33 249 A.x = 0;
mbedalvaro 40:3ba2b0ea9f33 250 A.y = 0;
mbedalvaro 40:3ba2b0ea9f33 251 line(B, A, sideSizeY/interPointDistance);
mbedalvaro 40:3ba2b0ea9f33 252 }
mbedalvaro 40:3ba2b0ea9f33 253
mbedalvaro 40:3ba2b0ea9f33 254
mbedalvaro 40:3ba2b0ea9f33 255
mbedalvaro 40:3ba2b0ea9f33 256 void circle(float radius, int numpoints)
mbedalvaro 40:3ba2b0ea9f33 257 {
mbedalvaro 40:3ba2b0ea9f33 258 float angleStep=360.0/numpoints;
mbedalvaro 40:3ba2b0ea9f33 259 lsr.pushPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 260 for (int i=0; i<numpoints; i++) {
mbedalvaro 40:3ba2b0ea9f33 261 vertex(radius, 0, 0);
mbedalvaro 40:3ba2b0ea9f33 262 lsr.rotateZ(angleStep);
mbedalvaro 40:3ba2b0ea9f33 263 }
mbedalvaro 40:3ba2b0ea9f33 264 // Redo the first point to close the cirlce:
mbedalvaro 40:3ba2b0ea9f33 265 vertex(radius, 0, 0);
mbedalvaro 40:3ba2b0ea9f33 266 lsr.popPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 267 }
mbedalvaro 40:3ba2b0ea9f33 268
mbedalvaro 40:3ba2b0ea9f33 269 // A "cube" (with one corner at the origin):
mbedalvaro 40:3ba2b0ea9f33 270 void cube(float sideSize, int nbpointsSide)
mbedalvaro 40:3ba2b0ea9f33 271 {
mbedalvaro 40:3ba2b0ea9f33 272 lsr.pushPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 273 square(sideSize, nbpointsSide);
mbedalvaro 40:3ba2b0ea9f33 274 line(0,0,0,0,0,sideSize, nbpointsSide);
mbedalvaro 40:3ba2b0ea9f33 275 lsr.translate(0,0,sideSize);
mbedalvaro 40:3ba2b0ea9f33 276 square(sideSize, nbpointsSide);
mbedalvaro 40:3ba2b0ea9f33 277 lsr.popPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 278 }
mbedalvaro 40:3ba2b0ea9f33 279
mbedalvaro 40:3ba2b0ea9f33 280 // LETTERS and STRINGS:
mbedalvaro 40:3ba2b0ea9f33 281 // NOTE: for the time being, these letters are not special object. I will just add the vertex of the letter to a normal BaseObject.
mbedalvaro 40:3ba2b0ea9f33 282 void letter3d(char _letter, float width, float height)
mbedalvaro 40:3ba2b0ea9f33 283 {
mbedalvaro 40:3ba2b0ea9f33 284 unsigned char numpoints=fillAuxBuffer(_letter);
mbedalvaro 40:3ba2b0ea9f33 285 lsr.pushPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 286 lsr.resize(0.1*width, 1.0/15.0*height, 1); // note: letter size as defined in textData.h is: width = 10, height = 15
mbedalvaro 40:3ba2b0ea9f33 287 for (int i=0; i<numpoints; i++ ) vertex(auxbuffer[2*i], auxbuffer[2*i+1], 0);
mbedalvaro 40:3ba2b0ea9f33 288 lsr.popPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 289 }
mbedalvaro 40:3ba2b0ea9f33 290
mbedalvaro 40:3ba2b0ea9f33 291 // To create a string: either as a single object, or separate objects. In the later case, we should NOT call to "begin/end", because this will be done
mbedalvaro 40:3ba2b0ea9f33 292 // in THIS wrapping function... how to indicate this? and which index? So, for the time being, I will consider the FIRST case only. If we want to have
mbedalvaro 40:3ba2b0ea9f33 293 // separate objects, we will need to do this explicitly, basically copying this code and interspeeding it with "begin/end" and numbering the objects (cool
mbedalvaro 40:3ba2b0ea9f33 294 // for detecting individual touched letters).
mbedalvaro 40:3ba2b0ea9f33 295 void string3d(string _text, float totalWidth, float height)
mbedalvaro 40:3ba2b0ea9f33 296 {
mbedalvaro 40:3ba2b0ea9f33 297 float stepX=1.0*totalWidth/_text.length(); // this is just fontWidth, or some percentage of it
mbedalvaro 40:3ba2b0ea9f33 298 lsr.pushPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 299 for (unsigned short i=0; i<_text.length(); i++) {
mbedalvaro 40:3ba2b0ea9f33 300 char ch=_text.at(i);
mbedalvaro 40:3ba2b0ea9f33 301 lsr.translate(1.3*stepX,0,0); // slightly larger than the fontWidth...
mbedalvaro 40:3ba2b0ea9f33 302 if (ch!=' ') letter3d(ch, stepX, height);
mbedalvaro 40:3ba2b0ea9f33 303 }
mbedalvaro 40:3ba2b0ea9f33 304 lsr.popPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 305 }
mbedalvaro 40:3ba2b0ea9f33 306
mbedalvaro 40:3ba2b0ea9f33 307
mbedalvaro 40:3ba2b0ea9f33 308
mbedalvaro 40:3ba2b0ea9f33 309 // ========= MULTI OBJECTS ==================================================================================
mbedalvaro 40:3ba2b0ea9f33 310
mbedalvaro 40:3ba2b0ea9f33 311 // A simple "normalized" grid on the z=0 plane (with points, repeated to get them more "clear").
mbedalvaro 40:3ba2b0ea9f33 312 // Also, it may be interesting to make each group of points a separate object (for switching off laser, but also querying touch)
mbedalvaro 40:3ba2b0ea9f33 313 // Corner of the grid at the origin.
mbedalvaro 40:3ba2b0ea9f33 314 // NOTE: this is an example of a "multi-object" that does NOT need "begin/end" in the main
mbedalvaro 40:3ba2b0ea9f33 315 void grid(int nx, int ny, int repeatpoint)
mbedalvaro 40:3ba2b0ea9f33 316 {
mbedalvaro 40:3ba2b0ea9f33 317 float px=1.0/(nx-1), py=1.0/(ny-1);
mbedalvaro 40:3ba2b0ea9f33 318 //lsr.pushPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 319 for (int i=0; i<ny; i++) {
mbedalvaro 40:3ba2b0ea9f33 320 // pc.printf("\n");
mbedalvaro 40:3ba2b0ea9f33 321 if (i%2==0) { // to do zig-zag...
mbedalvaro 40:3ba2b0ea9f33 322 for (int j=0; j<nx; j++) {
mbedalvaro 40:3ba2b0ea9f33 323 begin(ny*i+j);
mbedalvaro 40:3ba2b0ea9f33 324 for (int k=0; k<repeatpoint; k++)
mbedalvaro 40:3ba2b0ea9f33 325 //vertex(1.0*j*px,1.0*i*py,0); // faster than using translations...
mbedalvaro 40:3ba2b0ea9f33 326 vertex(1.0*i*py,1.0*j*px,0);
mbedalvaro 40:3ba2b0ea9f33 327 end();
mbedalvaro 40:3ba2b0ea9f33 328 //pc.printf("%4.2f ", 1.0*j*px);
mbedalvaro 40:3ba2b0ea9f33 329 }
mbedalvaro 40:3ba2b0ea9f33 330 } else { // odd line:
mbedalvaro 40:3ba2b0ea9f33 331 for (int j=nx-1; j>=0; j--) {
mbedalvaro 40:3ba2b0ea9f33 332 begin(ny*i+j);
mbedalvaro 40:3ba2b0ea9f33 333 for (int k=0; k<repeatpoint; k++)
mbedalvaro 40:3ba2b0ea9f33 334 // vertex(1.0*j*px,1.0*i*py,0); // faster than using translations...
mbedalvaro 40:3ba2b0ea9f33 335 vertex(1.0*i*py,1.0*j*px,0);
mbedalvaro 40:3ba2b0ea9f33 336 end();
mbedalvaro 40:3ba2b0ea9f33 337 //pc.printf("%4.2f ", 1.0*j*px);
mbedalvaro 40:3ba2b0ea9f33 338 }
mbedalvaro 40:3ba2b0ea9f33 339 }
mbedalvaro 40:3ba2b0ea9f33 340 }
mbedalvaro 40:3ba2b0ea9f33 341 //lsr.popPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 342 }
mbedalvaro 40:3ba2b0ea9f33 343
mbedalvaro 40:3ba2b0ea9f33 344 // A simple "muti-object" grid, not normalized (this is just for convenience):
mbedalvaro 40:3ba2b0ea9f33 345 void grid(float sizeX, float sizeY, int nx, int ny, int repeatpoint)
mbedalvaro 40:3ba2b0ea9f33 346 {
mbedalvaro 40:3ba2b0ea9f33 347 lsr.pushPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 348 lsr.resize(sizeX, sizeY, 1);
mbedalvaro 40:3ba2b0ea9f33 349 grid(nx, ny, repeatpoint);
mbedalvaro 40:3ba2b0ea9f33 350 lsr.popPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 351 }
mbedalvaro 40:3ba2b0ea9f33 352
mbedalvaro 40:3ba2b0ea9f33 353 //Normalized grid of circles:
mbedalvaro 40:3ba2b0ea9f33 354 void gridCircles(int nx, int ny, float radius, int nbpointsCircle)
mbedalvaro 40:3ba2b0ea9f33 355 {
mbedalvaro 40:3ba2b0ea9f33 356 float px=1.0/(nx-1), py=1.0/(ny-1);
mbedalvaro 40:3ba2b0ea9f33 357 lsr.pushPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 358 for (int i=0; i<ny; i++) {
mbedalvaro 40:3ba2b0ea9f33 359 if (i%2==0) { // to do zig-zag...
mbedalvaro 40:3ba2b0ea9f33 360 for (int j=0; j<nx; j++) {
mbedalvaro 40:3ba2b0ea9f33 361 begin(ny*i+j);
mbedalvaro 40:3ba2b0ea9f33 362 circle(radius, nbpointsCircle);
mbedalvaro 40:3ba2b0ea9f33 363 end();
mbedalvaro 40:3ba2b0ea9f33 364 lsr.translate(px, 0, 0);
mbedalvaro 40:3ba2b0ea9f33 365 }
mbedalvaro 40:3ba2b0ea9f33 366 } else { // odd line:
mbedalvaro 40:3ba2b0ea9f33 367 for (int j=nx-1; j>=0; j--) {
mbedalvaro 40:3ba2b0ea9f33 368 begin(ny*i+j);
mbedalvaro 40:3ba2b0ea9f33 369 circle(radius, nbpointsCircle);
mbedalvaro 40:3ba2b0ea9f33 370 end();
mbedalvaro 40:3ba2b0ea9f33 371 lsr.translate(-px, 0, 0);
mbedalvaro 40:3ba2b0ea9f33 372 }
mbedalvaro 40:3ba2b0ea9f33 373 }
mbedalvaro 40:3ba2b0ea9f33 374 lsr.translate(0, py, 0);
mbedalvaro 40:3ba2b0ea9f33 375 }
mbedalvaro 40:3ba2b0ea9f33 376 lsr.popPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 377 }
mbedalvaro 40:3ba2b0ea9f33 378
mbedalvaro 40:3ba2b0ea9f33 379 // Not normalized grid of circles:
mbedalvaro 40:3ba2b0ea9f33 380 void gridCircles(float sizeX, float sizeY, int nx, int ny, float radius, int nbpointsCircle)
mbedalvaro 40:3ba2b0ea9f33 381 {
mbedalvaro 40:3ba2b0ea9f33 382 float px=sizeX/(nx-1), py=sizeY/(ny-1);
mbedalvaro 40:3ba2b0ea9f33 383 lsr.pushPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 384 for (int i=0; i<ny; i++) {
mbedalvaro 40:3ba2b0ea9f33 385 if (i%2==0) { // to do zig-zag...
mbedalvaro 40:3ba2b0ea9f33 386 for (int j=0; j<nx; j++) {
mbedalvaro 40:3ba2b0ea9f33 387 begin(ny*i+j);
mbedalvaro 40:3ba2b0ea9f33 388 circle(radius, nbpointsCircle);
mbedalvaro 40:3ba2b0ea9f33 389 end();
mbedalvaro 40:3ba2b0ea9f33 390 lsr.translate(px, 0, 0);
mbedalvaro 40:3ba2b0ea9f33 391 }
mbedalvaro 40:3ba2b0ea9f33 392 } else { // odd line:
mbedalvaro 40:3ba2b0ea9f33 393 for (int j=nx-1; j>=0; j--) {
mbedalvaro 40:3ba2b0ea9f33 394 lsr.translate(-px, 0, 0);
mbedalvaro 40:3ba2b0ea9f33 395 begin(ny*i+j);
mbedalvaro 40:3ba2b0ea9f33 396 circle(radius, nbpointsCircle);
mbedalvaro 40:3ba2b0ea9f33 397 end();
mbedalvaro 40:3ba2b0ea9f33 398 }
mbedalvaro 40:3ba2b0ea9f33 399 }
mbedalvaro 40:3ba2b0ea9f33 400 lsr.translate(0, py, 0);
mbedalvaro 40:3ba2b0ea9f33 401 }
mbedalvaro 40:3ba2b0ea9f33 402 lsr.popPoseMatrix();
mbedalvaro 40:3ba2b0ea9f33 403 }
mbedalvaro 40:3ba2b0ea9f33 404
mbedalvaro 40:3ba2b0ea9f33 405 // WRAPPERS TO CREATE ARBITRARY OBJECTS FROM SENT DATA POINTS (V3 array) =============================================
mbedalvaro 40:3ba2b0ea9f33 406 void createShapeObject(int idobject, vector<V3> &arrayVertices) {
mbedalvaro 40:3ba2b0ea9f33 407 begin(idobject);
mbedalvaro 40:3ba2b0ea9f33 408 vertexArray(arrayVertices);
mbedalvaro 40:3ba2b0ea9f33 409 end();
mbedalvaro 40:3ba2b0ea9f33 410 }
mbedalvaro 40:3ba2b0ea9f33 411
mbedalvaro 40:3ba2b0ea9f33 412 // WRAPPERS TO LOAD OBJECTS FROM SYSTEM FILE =========================================================================
mbedalvaro 40:3ba2b0ea9f33 413 // ... to do
mbedalvaro 40:3ba2b0ea9f33 414
mbedalvaro 40:3ba2b0ea9f33 415 // WRAPPERS TO LOAD MATRICES FROM SYSTEM FILE ==========================================================================
mbedalvaro 40:3ba2b0ea9f33 416 // ...to do
mbedalvaro 40:3ba2b0ea9f33 417
mbedalvaro 40:3ba2b0ea9f33 418 // ================================= WRAPPERS FOR MORE BASIC IO FUNCTIONS =================================
mbedalvaro 40:3ba2b0ea9f33 419 void showLimitsMirrors(unsigned short pointsPerLine, unsigned short durationSecs)
mbedalvaro 40:3ba2b0ea9f33 420 {
mbedalvaro 40:3ba2b0ea9f33 421 // Stop the display engine and lasers:
mbedalvaro 40:3ba2b0ea9f33 422 stopDisplay();
mbedalvaro 40:3ba2b0ea9f33 423 // but we need to ensure that the DISPLAYING lasers are ON:
mbedalvaro 40:3ba2b0ea9f33 424 IO.setRGBPower(0x07);
mbedalvaro 40:3ba2b0ea9f33 425 IO.showLimitsMirrors(pointsPerLine, durationSecs);
mbedalvaro 40:3ba2b0ea9f33 426 resumeDisplay();
mbedalvaro 40:3ba2b0ea9f33 427 }
mbedalvaro 40:3ba2b0ea9f33 428
mbedalvaro 40:3ba2b0ea9f33 429 void scanSerial(unsigned short pointsPerLine)
mbedalvaro 40:3ba2b0ea9f33 430 {
mbedalvaro 40:3ba2b0ea9f33 431 // Stop the display engine and lasers:
mbedalvaro 40:3ba2b0ea9f33 432 stopDisplay();
mbedalvaro 40:3ba2b0ea9f33 433 // ...but we need to ensure that the sensing laser is ON:
mbedalvaro 40:3ba2b0ea9f33 434 IO.setLaserLockinPower(1);
mbedalvaro 40:3ba2b0ea9f33 435 IO.scan_serial(pointsPerLine);
mbedalvaro 40:3ba2b0ea9f33 436 resumeDisplay();
mbedalvaro 40:3ba2b0ea9f33 437 }
mbedalvaro 40:3ba2b0ea9f33 438
mbedalvaro 40:3ba2b0ea9f33 439 void recomputeLookUpTable()
mbedalvaro 40:3ba2b0ea9f33 440 {
mbedalvaro 40:3ba2b0ea9f33 441 // Stop the display engine and lasers:
mbedalvaro 40:3ba2b0ea9f33 442 stopDisplay();
mbedalvaro 40:3ba2b0ea9f33 443 // but we need to ensure that the sensing laser is ON:
mbedalvaro 40:3ba2b0ea9f33 444 IO.setLaserLockinPower(1);
mbedalvaro 40:3ba2b0ea9f33 445 IO.scanLUT(); // this recreates and SAVES the LUT table
mbedalvaro 40:3ba2b0ea9f33 446 resumeDisplay();
mbedalvaro 40:3ba2b0ea9f33 447 }
mbedalvaro 40:3ba2b0ea9f33 448
mbedalvaro 40:3ba2b0ea9f33 449 // This is a special function that needs to be called at least once to set the displaying engine ON, thus setting the current state of the engine:
mbedalvaro 40:3ba2b0ea9f33 450 void startDisplay() {
mbedalvaro 40:3ba2b0ea9f33 451 IO.setLaserLockinPower(1);
mbedalvaro 40:3ba2b0ea9f33 452 lsd.run();
mbedalvaro 40:3ba2b0ea9f33 453 }
mbedalvaro 40:3ba2b0ea9f33 454
mbedalvaro 40:3ba2b0ea9f33 455 void stopDisplay() // save previous displaying status, stops the displaying engine, and switch off lasers
mbedalvaro 40:3ba2b0ea9f33 456 {
mbedalvaro 40:3ba2b0ea9f33 457 previousLsdState=lsd.isRunning();
mbedalvaro 40:3ba2b0ea9f33 458 lsd.stop();
mbedalvaro 40:3ba2b0ea9f33 459 // also, switch off lasers:
mbedalvaro 40:3ba2b0ea9f33 460 IO.setLaserLockinPower(0);
mbedalvaro 40:3ba2b0ea9f33 461 IO.switchOffDisplayLasers();
mbedalvaro 40:3ba2b0ea9f33 462 }
mbedalvaro 40:3ba2b0ea9f33 463
mbedalvaro 40:3ba2b0ea9f33 464 void resumeDisplay() // go back to previous state of displaying engine
mbedalvaro 40:3ba2b0ea9f33 465 // and set the sensing laser ON (no need to explicitly switch the DISPLAYING lasers ON - this is done in the displaying engine ISR).
mbedalvaro 40:3ba2b0ea9f33 466 {
mbedalvaro 40:3ba2b0ea9f33 467 if (previousLsdState) {
mbedalvaro 40:3ba2b0ea9f33 468 //switch on sensing lasers:
mbedalvaro 40:3ba2b0ea9f33 469 IO.setLaserLockinPower(1);
mbedalvaro 40:3ba2b0ea9f33 470 lsd.run();
mbedalvaro 40:3ba2b0ea9f33 471 // rem: no need to set the displaying lasers: this is done per-object basis
mbedalvaro 40:3ba2b0ea9f33 472 }
mbedalvaro 40:3ba2b0ea9f33 473 }
mbedalvaro 40:3ba2b0ea9f33 474
mbedalvaro 40:3ba2b0ea9f33 475 // =============================== HARDWARE KNOBS: switches, potentiometers... =================================================
mbedalvaro 40:3ba2b0ea9f33 476 void hardwareKnobs()
mbedalvaro 40:3ba2b0ea9f33 477 {
mbedalvaro 40:3ba2b0ea9f33 478 // Potentiometer, switches, etc:
mbedalvaro 40:3ba2b0ea9f33 479 //(1) Check for change of threshold mode button (switch one):
mbedalvaro 40:3ba2b0ea9f33 480 //!!! ATTENTION: this does not work very well to say the truth: bouncing+adc settings problems...
mbedalvaro 40:3ba2b0ea9f33 481 bool stateswitch;
mbedalvaro 40:3ba2b0ea9f33 482 if (IO.switchOneCheck(stateswitch)) {
mbedalvaro 40:3ba2b0ea9f33 483 if (stateswitch) pc.printf("Set: AUTO threshold mode\n");
mbedalvaro 40:3ba2b0ea9f33 484 else pc.printf("Set: FIXED threshold mode\n");
mbedalvaro 40:3ba2b0ea9f33 485 for (int i=0; i< scene.totalObjects(); i++) scene.objectArray[i]->displaySensingBuffer.setThresholdMode((stateswitch? 1 : 0));
mbedalvaro 40:3ba2b0ea9f33 486 }
mbedalvaro 40:3ba2b0ea9f33 487 //(2) Check the current pot value and update the "fixed threshold" when pressing second switch (I don't care if the threshold mode
mbedalvaro 40:3ba2b0ea9f33 488 // is fixed or not - this will set the VALUE of the fixed threshold)
mbedalvaro 40:3ba2b0ea9f33 489 // NOTE: as thresholding mode CAN be object dependent though, but this is a simple hardware command that set the fixed threshold for all the objects.
mbedalvaro 40:3ba2b0ea9f33 490 if (IO.switchTwoCheck(stateswitch)) {
mbedalvaro 40:3ba2b0ea9f33 491 IO.updatePotValue();
mbedalvaro 40:3ba2b0ea9f33 492 for (int i=0; i< scene.totalObjects(); i++) scene.objectArray[i]->displaySensingBuffer.setFixedThreshold(IO.potValue);
mbedalvaro 40:3ba2b0ea9f33 493 pc.printf("Fixed Threshold :%d\n", IO.potValue);
mbedalvaro 40:3ba2b0ea9f33 494 }
mbedalvaro 40:3ba2b0ea9f33 495 }
mbedalvaro 40:3ba2b0ea9f33 496