Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kevin Lyda
gqgmc
Commits
409c760c
Commit
409c760c
authored
Jan 31, 2017
by
Kevin Lyda
💬
Browse files
Add time setting function.
parent
7a6589b4
Pipeline
#1202
failed with stage
in 1 minute and 7 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
devices/geiger/geiger.go
View file @
409c760c
...
...
@@ -7,6 +7,8 @@
package
geiger
import
"time"
// New creates a new Counter instance
func
New
(
c
Config
)
(
Counter
,
error
)
{
switch
c
.
Model
{
...
...
@@ -32,8 +34,7 @@ type Counter interface {
GetConfiguration
()
SetConfiguration
()
ResetConfiguration
()
SetDate
(
date
string
)
SetTime
(
time
string
)
SetTime
(
t
time
.
Time
)
}
// Config contain the configuration for a Geiger Counter
...
...
devices/geiger/gqgmc.go
View file @
409c760c
...
...
@@ -268,41 +268,28 @@ func (gc *GQGMCCounter) ResetConfiguration() {
//communicate(erase_cfg_cmd, ret_char, retsize);
}
// SetDate sets the date - format of YYYYMMDD
func
(
gc
*
GQGMCCounter
)
SetDate
(
date
string
)
{
//setMonthCmd = "<SETDATEMM";
//setMonthCmd += uint8_t(month);
//setMonthCmd += ">>";
//communicate(setMonthCmd, ret_char, retsize);
//setDayCmd = "<SETDATEDD";
//setDayCmd += uint8_t(day);
//setDayCmd += ">>";
//communicate(setDayCmd, ret_char, retsize);
// year - last two digits
//setYearCmd = "<SETDATEYY";
//setYearCmd += uint8_t(year);
//setYearCmd += ">>";
//communicate(setYearCmd, ret_char, retsize);
}
// SetTime sets the time
func
(
gc
*
GQGMCCounter
)
SetTime
(
t
time
.
Time
)
{
cmd
:=
make
([]
byte
,
13
)
var
timeCmds
=
[]
struct
{
cmd
string
unit
int
}{
{
"<SETDATEYY"
,
t
.
Year
()},
{
"<SETDATEMM"
,
int
(
t
.
Month
())},
{
"<SETDATEDD"
,
t
.
Day
()},
{
"<SETTIMEHH"
,
t
.
Hour
()},
{
"<SETTIMEMM"
,
t
.
Minute
()},
{
"<SETTIMESS"
,
t
.
Second
()},
}
// SetTime sets the time (HH:MM:SS)
func
(
gc
*
GQGMCCounter
)
SetTime
(
time
string
)
{
//setHourCmd = "<SETTIMEHH";
//setHourCmd += uint8_t(hour);
//setHourCmd += ">>";
//communicate(setHourCmd, ret_char, retsize);
//setMinuteCmd = "<SETTIMEMM";
//setMinuteCmd += uint8_t(minute);
//setMinuteCmd += ">>";
//communicate(setMinuteCmd, ret_char, retsize);
//setSecondCmd = "<SETTIMESS";
//setSecondCmd += uint8_t(second);
//setSecondCmd += ">>";
//communicate(setSecondCmd, ret_char, retsize);
for
_
,
c
:=
range
timeCmds
{
copy
(
cmd
[
:
],
c
.
cmd
)
cmd
[
10
]
=
uint8
(
c
.
unit
)
copy
(
cmd
[
11
:
],
">>"
)
gc
.
port
.
Write
(
cmd
)
gc
.
readCmd
(
1
)
}
}
func
(
gc
*
GQGMCCounter
)
communicate
(
cmd
string
,
length
uint32
)
([]
byte
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment