void csc_servo_set(uint8_t id, uint32_t val) { if(id > 3) return; #ifdef CSC_MOTORS_I2C Actuator(id) = val; #else switch(id){ case 0: Actuator(0) = val; break; case 1: Actuator(5) = val; break; case 2: Actuator(4) = val; break; case 3: Actuator(3) = val; break; } #endif }
Leg::Leg(Controller* parent, Vec3f center, float rotation, boolean flipped, int pwmPins[], int potPins[], bool simulate) { this->parent = parent; this->center = center; this->centerOfRotation = center; this->rotation = rotation; this->flipped = flipped; if(pwmPins[0] >= 0 && potPins[0] >= 0) // Local, or just simulated this->remote = false; else { this->remote = true; this->remotePort = abs(potPins[0]) - 1; this->remoteIndex = abs(pwmPins[0]) - 1; } bool flip; for(int i=0; i<3; i++) { if((flipped && i != 1) || (!flipped && i == 1)) flip = true; else flip = false; //actuators[i] = Actuator(this, 0,0, 353, 499, simulate); actuators[i] = Actuator(this, pwmPins[i], potPins[i], 353, 499, flip, simulate || remote); } solveFK(); setTarget(foot, true); }
void csc_servos_set(int32_t* val) { #ifdef CSC_MOTORS_I2C Actuator(0) = val[0]; Actuator(1) = val[1]; Actuator(2) = val[2]; Actuator(3) = val[3]; #else Actuator(0) = val[0]; Actuator(5) = val[1]; Actuator(4) = val[2]; Actuator(3) = val[3]; #endif csc_servos_commit(); }
void setup() { // debugging channel Serial1.begin(57600); while (!Serial1) { delay(100); } Serial1.print( "RAM at setup " ); Serial1.println( freeRam() ); // ALRAM pinMode(ALARM_LED_PIN, OUTPUT); digitalWrite( ALARM_LED_PIN, LOW ); // must "begin" the button to get proper pin assignment/muxing b.begin(); // initializing ADC channels. The channels 0...7 are assigned to the // pins A0...A7. Note that the display and the config.txt files, as well as // the shield's silk layer use enumeration 1 to 8 ADCs[0] = AdcChannel(A0); ADCs[1] = AdcChannel(A1); ADCs[2] = AdcChannel(A2); ADCs[3] = AdcChannel(A3); ADCs[4] = AdcChannel(A4); ADCs[5] = AdcChannel(A5); ADCs[6] = AdcChannel(A6); ADCs[7] = AdcChannel(A7); // initializing actuators. The Id is 0 to 7, a bit number in // actuator byte of the ADC channel. The mapping to the pin is // pin = A8 + Id Actuators[0] = Actuator(0, true); Actuators[1] = Actuator(1, true); Actuators[2] = Actuator(2, true); Actuators[3] = Actuator(3, true); Actuators[4] = Actuator(4, true); Actuators[5] = Actuator(5, true); Actuators[6] = Actuator(6, true); Actuators[7] = Actuator(7, false); // the last actuator is not connected through ULN2003 but directly // The Real Time Clock rtc.begin(); // returns bool, but is never false Serial1.print( "RAM after rtc.begin " ); Serial1.println( freeRam() ); if(rtc.isrunning()) Serial1.println("RTC is running"); else { Serial1.println("RTC is NOT running"); rtc.adjust(DateTime(__DATE__, __TIME__)); // setup the current date and time initially } DateTime now = rtc.now(); Serial1.print(now.year(), DEC); Serial1.print('/'); Serial1.print(now.month(), DEC); Serial1.print('/'); Serial1.print(now.day(), DEC); Serial1.print(" ("); Serial1.print(daysOfTheWeek[now.dayOfTheWeek()]); Serial1.print(") "); Serial1.print(now.hour(), DEC); Serial1.print(':'); Serial1.print(now.minute(), DEC); Serial1.print(':'); Serial1.print(now.second(), DEC); Serial1.println(); // activate LCD module lcd.begin (16,2); // for 16 x 2 LCD module lcd.setBacklightPin(3,POSITIVE); lcd.setBacklight(HIGH); Serial1.print( "RAM after lcd.begin " ); Serial1.println( freeRam() ); if(!Store.begin()) { Serial1.println("Error initializing the storage"); digitalWrite( ALARM_LED_PIN, HIGH ); } Serial1.print( "RAM after Storage.begin " ); Serial1.println( freeRam() ); // the below makes sure the 1st active item is displayed upon start up. Otherwise // the item 0 is displayed, even if inactive Store.mIndex = CHANNEL_COUNT-1; Store.Advance(); }
Actuator DataClass::actuator( String name, byte pin, Timer time) { return Actuator(name, pin, time); }
/** Actuator **/ Actuator DataClass::actuator( String name, byte pin) { return Actuator(name, pin, _timer); }