void network_config_load (void) { /* load settings from eeprom */ #ifdef EEPROM_SUPPORT eeprom_restore (mac, uip_ethaddr.addr, 6); #else #if defined(BOOTLOADER_SUPPORT) && BOOTLOADER_START_ADDRESS > UINT16_MAX uint_farptr_t src = pgm_get_far_address (conf_mac); uint8_t *dst = uip_ethaddr.addr; for (uint8_t i = 6; i; i--) *dst++ = pgm_read_byte_far (src++); #else memcpy_P (uip_ethaddr.addr, conf_mac, 6); #endif #endif #if (defined(IPV4_SUPPORT) && !defined(BOOTP_SUPPORT) && !defined(DHCP_SUPPORT)) || defined(IPV6_STATIC_SUPPORT) uip_ipaddr_t ip; /* Configure the IP address. */ #ifdef EEPROM_SUPPORT /* Please Note: ip and &ip are NOT the same (cpp hell) */ eeprom_restore_ip (ip, &ip); #else set_CONF_ETHERRAPE_IP (&ip); #endif uip_sethostaddr (&ip); /* Configure prefix length (IPv6). */ #ifdef IPV6_SUPPORT uip_setprefixlen (CONF_ENC_IP6_PREFIX_LEN); #endif #ifdef IPV4_SUPPORT /* Configure the netmask (IPv4). */ #ifdef EEPROM_SUPPORT /* Please Note: ip and &ip are NOT the same (cpp hell) */ eeprom_restore_ip (netmask, &ip); #else set_CONF_ETHERRAPE_IP4_NETMASK (&ip); #endif uip_setnetmask (&ip); #endif /* IPV4_SUPPORT */ /* Configure the default gateway */ #ifdef EEPROM_SUPPORT /* Please Note: ip and &ip are NOT the same (cpp hell) */ eeprom_restore_ip (gateway, &ip); #else set_CONF_ETHERRAPE_GATEWAY (&ip); #endif uip_setdraddr (&ip); #endif /* No autoconfiguration. */ }
//------------------------------------------------------------------------------------------------------------------------>> // TEACH TBS UNIT FOR ENCODER CONTROL //------------------------------------------------------------------------------------------------------------------------>> void OP_TBS::TeachEncoder(void) { char buffer[30]; // This needs to be large enough to hold any string from our sound_descr_table (see OP_TBS.h) uint32_t soundNameTableAddress = pgm_get_far_address(_sound_descr_table_); // This is the starting address of our sound names table in far progmem. // Before you run this routine, the TBS Mini needs to be placed in the TEACH mode by pushing the button on the sound unit. // This is handled in the sketch, as well as some other preliminary steps Serial.println("Start - Teaching:"); // Whenever they pressed the TBS button, the neutral positions were already recorded Serial.println(F("...Neutral")); delay(1000); // Move throttle to just moving TBSProp->writeMicroseconds(PROP1, PROP1_JUST_MOVING); Serial.println(F("...Just moving")); PulseDelayProp3(1); // Doesn't matter what signal we send here delay(1000); // Now move throttle to full speed TBSProp->writeMicroseconds(PROP1, PROP1_FULL_SPEED); Serial.println(F("...Full speed")); PulseDelayProp3(1); // Doesn't matter what signal we send here delay(1000); // Probably doesn't matter, but let's put throttle back to idle TBSProp->writeMicroseconds(PROP1, PROP1_IDLE); // From here on out, we will be teaching the 12 positions. According to the TBS instructions, // we go to position 1, "push the encoder button" which means briefly send the PWM value associated // with position 1 to Prop3, then return Prop3 back to the default state of center (1500). Then // wait two seconds, and repeat for all 12 "encoder" positions for (int i=1; i<=12; i++) { // Example: // ...Sound 1: Cannon Fire Serial.print(F("...Sound ")); Serial.print(i); Serial.print(F(": ")); // Using the string table in FAR program memory requires the use of a special function to retrieve the data. strcpy_PFAR(buffer, soundNameTableAddress, i*SOUNDNAME_CHARS); Serial.println(buffer); // Now send the signal for this sound number briefly, then wait two seconds before sending the next one (according to TBS teaching specs) PulseDelayProp3(i); } }