B4R Question InLine C for the Time-Librarie

newbie

Member
Licensed User
Longtime User
Hello,

i try to implemet functions of the time-librarie with in line c.
I have found some code-snippets in the form and have try to change this
for my use.
But i get a lot of compiler-errors for the inline-c.
...
sketch\b4r_timework.cpp: In function 'void tMinute(B4R::Object*)':
b4r_timework.cpp:18: error: '_minute' is not a member of 'b4r_main'
b4r_main::_minute = minute();
^
b4r_timework.cpp:18: error: 'minute' was not declared in this scope
b4r_main::_minute = minute();
^

....

The code is following:

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'Public variables can be accessed from all modules.
   Private Year As Int
   Private Month As Int
   Private Day As Int
   Private WeekDay As Int
   Private Hour As Int
   Private Minute As Int
   Private Second As Int
End Sub

Sub GetMinute As Int
   RunNative("tSecond", Null)
   Return Minute
End Sub

Sub GetSecond As Int
   RunNative("tSecond", Null)
   Return Second
End Sub

Sub SetTime
   RunNative("tSetTime", Null)
End Sub



#If C
#include <Time.h>

void tMinute(B4R::Object* o) {
 b4r_main::_minute = minute();
}
void tSecond(B4R::Object* o) {
 b4r_main::_second = second();
}
void tSetTime(B4R::Object* o) {
 settime(b4r_main::_hour,b4r_main::_minute,b4r_main::_second,b4r_main::_day,b4r_main::_month,b4r_main::_year);
}
#End If
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are no such methods in Time.h that is included in the Arduino IDE.

1. Install the Time library in Arduino IDE (Sketch - Include Library - Manager):

SS-2016-10-18_10.58.56.png


2. Change the include to:
B4X:
#include <TimeLib.h>

3. change settime to setTime.
 
Upvote 0

newbie

Member
Licensed User
Longtime User
There are no such methods in Time.h that is included in the Arduino IDE.

1. Install the Time library in Arduino IDE (Sketch - Include Library - Manager):

SS-2016-10-18_10.58.56.png


2. Change the include to:
B4X:
#include <TimeLib.h>

3. change settime to setTime.

hello erel,

that is a mistake, i use a Librarie named "Time" that is in the arduino directory (see the clip).
Or have i don´t understand some basics ? Can i not use any librarie ?
The error messages ar .. not a member of, undeclared ...

Please help me also in my previous thread .. wire-problem

kind regards
gerd
 

Attachments

  • Clip1.jpg
    Clip1.jpg
    54.3 KB · Views: 246
Upvote 0

newbie

Member
Licensed User
Longtime User
Open Time.h. You will see that there are no such methods.

okay, a very short answer.
I use this librarie and the methods more than one year in my projects from the arduino ide and i do not understand it to implement this in b4r :-(
Than please a little example (so that a stupid old man this can understand) how to implement function from this librarie
 

Attachments

  • Time.zip
    5.5 KB · Views: 237
Upvote 0

newbie

Member
Licensed User
Longtime User
Hello Erel,
as Information : now it works. Thanks

There was 2 problems
- the time-librarie i used works with arduino ide 1.5 and 1.7 but not with 1.6
- i have used b4r_main instead of b4r_<current Module> --> very stupid !!

Sorry for the efford !

!!!! please a help for my othe thread from Monday about wire
 
Upvote 0
Top