![]() |
|
|
#11 |
|
Junior Member
Регистрация: 25.03.2013
Адрес: Санкт-Петербург
Сообщений: 1
Вес репутации: 0 ![]() |
Добрый день! Установил Code Blocks для Arduino. После непродолжительных танцев с бубном он даже заработал
К сожалению, не смог разобраться как добавить в проект библиотеки помимо тех, что уже присутствуют. Подскажите, пожалуйста, как это можно сделать?
|
|
|
|
|
|
#12 |
|
Member
|
тоже столкнулся с этим
|
|
|
|
|
|
#13 |
|
Junior Member
Регистрация: 29.10.2014
Сообщений: 1
Вес репутации: 0 ![]() |
Библиотеки кинул в папку проекта, оттуда их видит.
Не могу понять как работать в code blocks с функциями. В wiring код компилируется, а в code blocks нехочет, пишет error: 'timer_secodns' was not declared in this scope| #include <Arduino.h> volatile long Decimal=0; volatile byte temp[9];// на 7 цифр разложим число void setup() {} void loop() { timer_secodns(Decimal); //error: 'timer_secodns' was not declared in this scope| } void timer_secodns(long)// расклад на часы минуты и секунды переменной decimal { int hour=Decimal/3600;//// Decimal %= 3600;// остаток деления на 3600 byte minutes=Decimal/60;// 3 byte seconds= Decimal %= 60;// остаток от деления на 60 temp[8] = hour/100; hour %= 100;//остаток (176) temp[7] = hour/10; temp[6] = hour % 10; temp[5]= 11;// clear razryad temp[4]=minutes/10; temp[3]=(minutes % 10); temp[2]=seconds/10; temp[1]=seconds % 10; }// на выхоте имееем в temp[] разложенные секунды ччч_ммсс Последний раз редактировалось Olm; 29.10.2014 в 13:08. Причина: убрал пробелы |
|
|
|
|
|
#14 |
|
Senior Member
Регистрация: 02.04.2012
Адрес: Питер
Сообщений: 1,125
Вес репутации: 1312 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Он пишет что функция не объявлена. Объявите её.
|
|
|
|
|
|
#15 |
|
Senior Member
Регистрация: 06.11.2012
Сообщений: 153
Вес репутации: 0 ![]() |
проблема с CodeBlocks - не хочет компилировать код, который нормально работает
в Arduino IDE. подключаю два термодатчика как рассказано здесь: http://arduino-project.net/podklyuch...18b20-arduino/ код - стандартный example "Multiple" из DallasTemperature, немного измененный - все дополнительные функции объявлены выше void setup(), иначе, как уже тут было сказано - получаем ошибку "was not declared in this scope". Это связано с тем, что Arduino IDE перед компиляцией сначала проходит весь код и автоматически добавляет объявление функций, но вот в CodeBlock нужно это делать самостоятельно. Итак сам код: Код:
#include <Arduino.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 10 on the Arduino
#define ONE_WIRE_BUS 10
#define TEMPERATURE_PRECISION 9
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;
// Объявление функций.
//********************************
// function to print a device address
void printAddress(DeviceAddress deviceAddress);
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress);
// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress);
// main function to print information about a device
void printData(DeviceAddress deviceAddress);
//*******************************
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
// locate devices on the bus
Serial.print("Locating devices...");
Serial.print("Found ");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" devices.");
// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");
// assign address manually. the addresses below will beed to be changed
// to valid device addresses on your bus. device address can be retrieved
// by using either oneWire.search(deviceAddress) or individually via
// sensors.getAddress(deviceAddress, index)
//insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
//outsideThermometer = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };
// search for devices on the bus and assign based on an index. ideally,
// you would do this to initially discover addresses on the bus and then
// use those addresses and manually assign them (see above) once you know
// the devices on your bus (and assuming they don't change).
//
// method 1: by index
if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");
// method 2: search()
// search() looks for the next device. Returns 1 if a new address has been
// returned. A zero might mean that the bus is shorted, there are no devices,
// or you have already retrieved all of them. It might be a good idea to
// check the CRC to make sure you didn't get garbage. The order is
// deterministic. You will always get the same devices in the same order
//
// Must be called before search()
//oneWire.reset_search();
// assigns the first address found to insideThermometer
//if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
// assigns the seconds address found to outsideThermometer
//if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");
// show the addresses we found on the bus
Serial.print("Device 0 Address: ");
printAddress(insideThermometer);
Serial.println();
Serial.print("Device 1 Address: ");
printAddress(outsideThermometer);
Serial.println();
// set the resolution to 9 bit
sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);
Serial.print("Device 0 Resolution: ");
Serial.print(sensors.getResolution(insideThermometer), DEC);
Serial.println();
Serial.print("Device 1 Resolution: ");
Serial.print(sensors.getResolution(outsideThermometer), DEC);
Serial.println();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print("Requesting temperatures...");
sensors.requestTemperatures();
Serial.println("DONE");
// print the device information
printData(insideThermometer);
printData(outsideThermometer);
}
//********************************
// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
// zero pad the address if necessary
if (deviceAddress[i] < 16) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
}
}
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
Serial.print("Temp C: ");
Serial.print(tempC);
Serial.print(" Temp F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
Serial.print("Resolution: ");
Serial.print(sensors.getResolution(deviceAddress));
Serial.println();
}
// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
Serial.print("Device Address: ");
printAddress(deviceAddress);
Serial.print(" ");
printTemperature(deviceAddress);
Serial.println();
}
//*******************************
и получаю такие ошибки: Код:
arduino\libraries\OneWire\OneWire.cpp|470|warning: only initialized variables can be placed into program memory area| ||=== Build: Arduino Duemilanove (328) in sensors (compiler: GNU AVR GCC Compiler) ===| build\sensors.o||In function `global constructors keyed to oneWire':| sensors.ino:(.text._GLOBAL__I_oneWire+0x16)||undefined reference to `DallasTemperature::DallasTemperature(OneWire*)'| build\sensors.o||In function `printTemperature(unsigned char*)':| sensors.ino:(.text._Z16printTemperaturePh+0x12)||undefined reference to `DallasTemperature::getTempC(unsigned char*)'| sensors.ino:(.text._Z16printTemperaturePh+0x44)||undefined reference to `DallasTemperature::toFahrenheit(float)'| build\sensors.o||In function `loop':| sensors.ino:(.text.loop+0x16)||undefined reference to `DallasTemperature::requestTemperatures()'| build\sensors.o||In function `setup':| sensors.ino:(.text.setup+0x20)||undefined reference to `DallasTemperature::begin()'| sensors.ino:(.text.setup+0x40)||undefined reference to `DallasTemperature::getDeviceCount()'| sensors.ino:(.text.setup+0x6e)||undefined reference to `DallasTemperature::isParasitePowerMode()'| sensors.ino:(.text.setup+0x8e)||undefined reference to `DallasTemperature::getAddress(unsigned char*, unsigned char)'| sensors.ino:(.text.setup+0xa2)||undefined reference to `DallasTemperature::getAddress(unsigned char*, unsigned char)'| sensors.ino:(.text.setup+0xf8)||undefined reference to `DallasTemperature::setResolution(unsigned char*, unsigned char)'| sensors.ino:(.text.setup+0x106)||undefined reference to `DallasTemperature::setResolution(unsigned char*, unsigned char)'| sensors.ino:(.text.setup+0x11e)||undefined reference to `DallasTemperature::getResolution(unsigned char*)'| sensors.ino:(.text.setup+0x14c)||undefined reference to `DallasTemperature::getResolution(unsigned char*)'| ||=== Build failed: 13 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===| повторюсь - именно этот код (уже измененный) в Arduino IDE работает нормально.. |
|
|
|
|
|
#16 |
|
Senior Member
Регистрация: 06.11.2012
Сообщений: 153
Вес репутации: 0 ![]() |
разобрался.
решение тут: http://freematics.com/forum/viewtopic.php?f=6&t=1573 1. скопировать все .cpp и .h файлы библиотек в каталог с проектом. 2. добавить эти файлы в сам проект в CodeBlock. и да, не забывайте добавлять #include <Arduino.h> в начало кода. |
|
|
|
|
|
#17 |
|
Junior Member
Регистрация: 17.11.2015
Сообщений: 4
Вес репутации: 0 ![]() |
Может кто подсказать ответ на такой вопрос: потребовалось мне внести изменения в стандартную библиотеку Ethernet (кол-во сокетов уменьшил с 4 до 2, зато объем буфера у сокета увеличил с 2 до 4 кБ). Все отлично работает, но в другом проекте мне нужно стандартные возможности библиотеки, каждый раз подменять файлы библиотеки как то не красиво и не удобно. Поэтому хочу определить в коде специальный литерал, например TX_RX_MAX_BUF_SIZE_4096, а в библиотечных файлах прописать соответствующие изменения в конструкцию типа:
Код:
#if defined(TX_RX_MAX_BUF_SIZE_4096) // если определен литерал TX_RX_MAX_BUF_SIZE_4096 #define TX_RX_MAX_BUF_SIZE 4096 #else #define TX_RX_MAX_BUF_SIZE 2048 #endif -DTX_RX_MAX_BUF_SIZE_4096 ? |
|
|
|
![]() |
| Здесь присутствуют: 1 (пользователей: 0 , гостей: 1) | |
|
|