Terminator004 3 / 2 / 1 Регистрация: 14.09.2016 Сообщений: 501 |
||||
1 |
||||
24.03.2018, 02:23. Показов 3729. Ответов 2 Метки нет (Все метки)
Добрый вечер, у меня не работает sleep. Пробовал найти в гугле решение, но ничего не помогло!
Помогите
__________________
0 |
nd2 3433 / 2812 / 1249 Регистрация: 29.01.2016 Сообщений: 9,426 |
||||
24.03.2018, 02:31 |
2 |
|||
0 |
3 / 2 / 1 Регистрация: 14.09.2016 Сообщений: 501 |
|
24.03.2018, 02:35 [ТС] |
3 |
#include <windows.h> Да, спсибо большое, работает! И у меня, так-же, sleep был из маленьхой буквы
0 |
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Open
wangzheqie opened this issue
Jun 6, 2017
· 21 comments
Comments
find that file,and add the following codes to it:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
cvemeki, Ankita-Singh-21, VegetarianLion258, janchk, bbibbd, tejalbarnwal, vincentcartillier, and billma98 reacted with heart emoji
@wangzheqie Why did it work before, but now trying to reinstall I need to add it to nearly all the files?
so to me, I add it to all files needed without second thinking. And they all work.
Thanks a lot. Why is this not already in the repo though?
Why do I need to add this?
I mean I can compile my code on Linux (CentOS 6) perfectly, but why do I need to add this includes when I’m using cygwin, ?
Works, but I had to add it to a bunch of files.
Was necessary to add in 11 files!
But thank you, worked
How does the developers solve this issue?
An easier way is to add #include <unistd.h>
in System.h
.
vdorbala-nokia, JADGardner, darren-harton, dwindy, ikramullahniazi, robin-shaun, Goh-tsen, balisujohn, lydiaCS, Cryptum169, and 8 more reacted with heart emoji
@Aceralon Thanks your method just sorted issue really quickly
@Aceralon
Were you able to run this on a camera feed?
@wangzheqie thanks it solved my error after adding this headers in several files…
But why did I need to do this. ? What is the reason.?
I added this for my cygwin project in windows 10 for Code::Blocks
#ifdef _CYGWIN_
#include <sys/unistd.h>
#endif // CYGWIN
and the include path of cygwin c:/cygwin/usr/include should be in search path of compiler. Where
c:/cygwin is the install root of cygwin. And in settings of compilerof cygwin, add _CYGWIN_ in user defined files «#define». You can do this in project level or in global level.
I have replicated that ORB_SLAM2 won’t compile on several systems without adding #include <unistd.h> to System.h, as @Aceralon suggested, even after commit #577. Can we incorporate this into the master branch? It seems like it is a simple change?
B10215037
added a commit
to B10215037/ORB_SLAM2
that referenced
this issue
Dec 30, 2018
I had to add it to a bunch of files. But it works . thanks @wangzheqie
rFalque
added a commit
to rFalque/ORB_SLAM2
that referenced
this issue
Nov 16, 2019
I have replicated that ORB_SLAM2 won’t compile on several systems without adding #include <unistd.h> to System.h, as @Aceralon suggested, even after commit #577. Can we incorporate this into the master branch? It seems like it is a simple change?
Why is this suggestion still not incorporated?
@Aceralon
Were you able to run this on a camera feed?
Yes
I have replicated that ORB_SLAM2 won’t compile on several systems without adding #include <unistd.h> to System.h, as @Aceralon suggested, even after commit #577. Can we incorporate this into the master branch? It seems like it is a simple change?
Why is this suggestion still not incorporated?
Because the repo is dead. Author is lost somewhere
didrod
added a commit
to didrod/ORB_SLAM2
that referenced
this issue
Jun 8, 2020
An easier way is to add
#include <unistd.h>
inSystem.h
.
it works well! Thank u
An easier way is to add
#include <unistd.h>
inSystem.h
.
This worked for me; thanks for your help!
balisujohn
added a commit
to balisujohn/ORB_SLAM2
that referenced
this issue
Mar 21, 2021
Dkaka
added a commit
to Dkaka/ORB_SLAM2
that referenced
this issue
Feb 21, 2022
-
В программировании я полный ноль.Вчера в первые взял ардуину в руки.Начал как и все с опытов со светодиодами.Даже смог сам написать скетч светофор.Но вот одного не пойму как сделать две независимые друг от друга функции.Например есть простой скетч для 1 светика в него дописал красным для второго светика.Но второй светик не загорится пока первый не выполнит свои действия.Например хочу сделать чтоб 1 светик просто моргал а второй висел на шиме и управлялся переменником.Собрал работает всё но только пока 1 светик не погаснет и снова загорится яркость второго не меняется.
void setup()
{
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}void loop()
{
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(900);
} -
Для этого надо сделать нечто вроде параллельного исполнения задач, для чего в свою очередь придется перейти на использование millis вместо delay
Что-то вроде.unsigned long last_state_change_time12=0;
unsigned long last_state_change_time13=0;
int laststate12=LOW;
int laststate13=LOW;void setup()
{
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(12, HIGH); // начальное состояние
digitalWrite(13, HIGH); // начальное состояние
laststate12=HIGH;
laststate13=HIGH;
}void loop()
{
if ((laststate12==LOW)&&(millis()-last_state_change_time12>100)) {
digitalWrite(12, HIGH);
last_state_change_time12=millis();
laststate12=HIGH;
} else if ((laststate12==HIGH)&&(millis()-last_state_change_time12>100)) {
digitalWrite(12, LOW);
last_state_change_time12=millis();
laststate12=LOW;
}
if ((laststate13==LOW)&&(millis()-last_state_change_time13>900)) {
digitalWrite(13, HIGH);
last_state_change_time13=millis();
laststate13=HIGH;
} else if ((laststate13==HIGH)&&(millis()-last_state_change_time13>100)) {
digitalWrite(13, LOW);
last_state_change_time13=millis();
laststate13=LOW;
}
}Если второй диод должен управляться шимом, то его надо переключить на пин, поддерживающий шим, например. 11=й. Потенциометр, предположим, подключен к A0.
Код будет примерно такой:unsigned long last_state_change_time13=0;
int laststate13=LOW;void setup()
{
pinMode(11, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH); // начальное состояние
laststate13=HIGH;
}void loop()
{
int val = analogRead(0); // read the input pin
analogWrite(11, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255if ((laststate13==LOW)&&(millis()-last_state_change_time13>900)) {
digitalWrite(13, HIGH);
last_state_change_time13=millis();
laststate13=HIGH;
} else if ((laststate13==HIGH)&&(millis()-last_state_change_time13>100)) {
digitalWrite(13, LOW);
last_state_change_time13=millis();
laststate13=LOW;
}
} -
Спасибо большое сам бы не когда до этого не дошел
Выглядит всё очень сложно и совсем не понятно тёмный лес.Буду разбираться может что то пойму.И ещё вопросик есть модуль RTC DS3231 а скетч не заливается пишет ошибку и выделяет строку setSyncProvider(RTC.get);
sketch_aug25a.ino: In function ‘void setup()’:
sketch_aug25a:7: error: ‘class DS1307RTC’ has no member named ‘get’
sketch_aug25a:7: error: ‘setSyncProvider’ was not declared in this scope
sketch_aug25a:10: error: ‘setTime’ was not declared in this scope
sketch_aug25a:12: error: ‘now’ was not declared in this scope
sketch_aug25a.ino: In function ‘void loop()’:
sketch_aug25a:16: error: ‘sleep’ was not declared in this scope#Подключаем библиотеки:
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h>void setup() {
setSyncProvider(RTC.get);//Устанавливаем время в формате://Часы, минуты, секунды, день, месяц, год
setTime(14,50,0,12,4,2014);
//Применяем:
RTC.set(now());
}
void loop()
{
sleep(100);
} -
Тут надо разбираться с конкретной библиотекой. Возможно, что она просто другая, с другими функциями.
Компилятор сообщает, что у класса DS1307RTC нет метода get.
Глядя на строку, на которой вылазит это сообщение, видим, что, скорее всего, RTC является переменной класса DS1307RTC (которые, в смысле переменная и класс, объявлены в одном из подключаемых заголовочных файлов, скорее всего DS1307RTC.h). И у этого класса нет метода get. Отсюда следует вывод, что стоит либо поискать библиотеку, соответствующую описанию, согласно которому была написана эта строка, либо ознакомиться с методами класса реально подключенной библиотеки и переписать все согласно ее требованиям.
То же можно сказать относительно следующих трех сообщений, в именно что ни в одной из подключенных библиотек не объявлены функции setSyncProvider, setTime и now, т.е. надо смотреть, на основании чего были написаны эти вызовы, в какой библиотеке они должны быть, и не надо ли посмотреть описание подключенной библиотеки, чтобы заменить эти вызовы на аналоги, в ней имеющиеся.
Более подробно по этому ничего не скажу. поскольку с этой библиотекой (требующей включения DS1307RTC.h) не сталкивался.А с этим предельно понятно. Не sleep, а delay. -
Ясно спасибо за ответы.На сайте где этот скетч взял его тестили на DS3231 и этот скетч к нему подходит.Только у меня он чёт не работает да и много других перепробывал тоже ничего не вышло.Пока оставлю этот rtc и буду изучать опыты на светиках.
-
Наигравшись со светиками решил вновь вернуться к часикам за одно и подключил дисплей)
Библиотеку ds3231 нашел из примеров которые в нём ни чё не работает.Собрал я вот такой скетч всё работает только время при отключении питания сбивается.Батарейка в норме проблема 100% в скетче.#include <Wire.h>
#include <DS3231.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte year, month, date, DoW, hour, minute, second;void setup()
{
Wire.begin();
lcd.begin(20, 4);
lcd.clear();
lcd.setBacklight(HIGH);Clock.setSecond(50);//Set the second
Clock.setMinute(59);//Set the minute
Clock.setHour(10); //Set the hour
Clock.setDoW(7); //Set the day of the week
Clock.setDate(7); //Set the date of the month
Clock.setMonth(10); //Set the month of the year
Clock.setYear(14); //Set the year (Last two digits of the year)
}void loop()
{
int second,minute,hour,date,month,year,temperature;year=Clock.getYear();
month=Clock.getMonth(Century);
date=Clock.getDate();
hour=Clock.getHour(h12,PM);
minute=Clock.getMinute();
second=Clock.getSecond();
temperature=Clock.getTemperature();lcd.print(«Date «);
if (date<10) lcd.print(‘0’);
lcd.print(date,DEC);
lcd.print(‘-‘);
if (month<10) lcd.print(‘0’);
lcd.print(month,DEC);
lcd.print(‘-‘);
lcd.print(«20»);
lcd.print(year,DEC);
lcd.setCursor(11, 3);
lcd.print(» Vcore1.7″);lcd.setCursor(0, 1);
lcd.print(«Time»);
lcd.setCursor(6, 1);
if (hour<10) lcd.print(‘0’);
lcd.print(hour,DEC);
lcd.print(‘:’);
if (minute<10) lcd.print(‘0’);
lcd.print(minute,DEC);
lcd.print(‘:’);
if (second<10) lcd.print(‘0’);
lcd.print(second,DEC);
lcd.print(‘ ‘);
lcd.setCursor(0, 3);
lcd.print(«Temp:»);
lcd.print(temperature);
delay(1);
lcd.setCursor(0,0);
} -
В setup:
Clock.setSecond(50);//Set the second
Clock.setMinute(59);//Set the minute
Clock.setHour(10); //Set the hour
Clock.setDoW(7); //Set the day of the week
Clock.setDate(7); //Set the date of the month
Clock.setMonth(10); //Set the month of the year
Clock.setYear(14); //Set the year (Last two digits of the year)Получается, что время устанавливается на часах при каждых включении и ресете .
-
Спасибо за подсказку.Чёт я сам не догадался.Взял просто удалил со скетча эти строки и теперь время не сбивается
Ещё вопрос есть вот такие функции.Как сделать чтоб от отдельной кнопки управлять сразу 2мя пинами с одной кнопки?buttonState = digitalRead(buttonPin);
if (buttonState == LOW){
digitalWrite(ledPin, HIGH);
}
else{
digitalWrite(ledPin, LOW);
}
{
buttonState = digitalRead(buttonPin1);
if (buttonState == LOW){
digitalWrite(ledPin1, HIGH);
}
else {
digitalWrite(ledPin1, LOW);
}Пробовал так но при нажатии на кнопку диод моргает еле видно
buttonState = digitalRead(buttonPin2);
if (buttonState == LOW){
digitalWrite(ledPin, HIGH), digitalWrite(ledPin1, HIGH);
}
else{
digitalWrite(ledPin, LOW), digitalWrite(ledPin1, LOW);
}
{
buttonState = digitalRead(buttonPin);
if (buttonState == LOW){
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
{
buttonState = digitalRead(buttonPin1);
if (buttonState == LOW){
digitalWrite(ledPin1, HIGH);
}
else {
digitalWrite(ledPin1, LOW);
} -
Есть одиночное, двойное , длительное нажатие кнопки. Вот по этому принципу и управляйте пинами. Например одиночные нажатия — один пин, длительные — второй.