the following examples should show how super easy the programming is. Thanks to the many prepared functions, even complex applications can be written quickly.
The programming is done in C language with the normal board tools of a Raspberry PI, without special libraries.
In this example the rotation of a rotary encoder is output directly to a stepper motor:
// assign two input ports to the rotary encoder init_rotencoder(KEY0, KEY1, -1,-1,-1,-1); // assign ports for step and direction to the stepper motor PA int stepid = create_stepper(OUT0, OUT1, OUT2, 0, 10, -1, -1); while(1) // endless loop { int steps = getEncSteps(0); // read Encoder // if the encoder was actuated // Output the number of steps to the stepper motor PA if(steps != 0) move_stepper(stepid,abs(steps),(steps>0)?1:0,1); }
same example as before, but for three axes
// assign two input ports each to the three rotary encoders init_rotencoder(KEY0, KEY1, KEY2, KEY3, IN4, IN5); // assign the three stepper motor PA ports for step and direction int stepidX = create_stepper(OUT0, OUT1, OUT2, 0, 10, -1, -1); int stepidY = create_stepper(OUT3, OUT4, OUT5, 0, 10, -1, -1); int stepidZ = create_stepper(OUT6, OUT7, OUT8, 0, 10, -1, -1); while(1) // endless loop { int stepsX = getEncSteps(0); int stepsY = getEncSteps(1); int stepsZ = getEncSteps(2); if(stepsX != 0) move_stepper(stepidX,abs(stepsX),(stepsX>0)?1:0,1); if(stepsY != 0) move_stepper(stepidY,abs(stepsY),(stepsY>0)?1:0,1); if(stepsZ != 0) move_stepper(stepidZ,abs(stepsZ),(stepsZ>0)?1:0,1); }
gps_open(NULL, NULL, B4800); // use serial IF on RPI board while(1) { int az, elev; getSunPos(&az, &elev); char text[200]; sprintf(s,"Sun is at azimuth:%d deg and elevation:%d deg",az,elev); draw_font(text,10,50,1,RED,20); sleep(1); }