Skip to content
Snippets Groups Projects
Commit 409c760c authored by Kevin Lyda's avatar Kevin Lyda :speech_balloon:
Browse files

Add time setting function.

parent 7a6589b4
Branches
No related tags found
No related merge requests found
Pipeline #
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
package geiger package geiger
import "time"
// New creates a new Counter instance // New creates a new Counter instance
func New(c Config) (Counter, error) { func New(c Config) (Counter, error) {
switch c.Model { switch c.Model {
...@@ -32,8 +34,7 @@ type Counter interface { ...@@ -32,8 +34,7 @@ type Counter interface {
GetConfiguration() GetConfiguration()
SetConfiguration() SetConfiguration()
ResetConfiguration() ResetConfiguration()
SetDate(date string) SetTime(t time.Time)
SetTime(time string)
} }
// Config contain the configuration for a Geiger Counter // Config contain the configuration for a Geiger Counter
......
...@@ -268,41 +268,28 @@ func (gc *GQGMCCounter) ResetConfiguration() { ...@@ -268,41 +268,28 @@ func (gc *GQGMCCounter) ResetConfiguration() {
//communicate(erase_cfg_cmd, ret_char, retsize); //communicate(erase_cfg_cmd, ret_char, retsize);
} }
// SetDate sets the date - format of YYYYMMDD // SetTime sets the time
func (gc *GQGMCCounter) SetDate(date string) { func (gc *GQGMCCounter) SetTime(t time.Time) {
//setMonthCmd = "<SETDATEMM"; cmd := make([]byte, 13)
//setMonthCmd += uint8_t(month); var timeCmds = []struct {
//setMonthCmd += ">>"; cmd string
//communicate(setMonthCmd, ret_char, retsize); unit int
}{
//setDayCmd = "<SETDATEDD"; {"<SETDATEYY", t.Year()},
//setDayCmd += uint8_t(day); {"<SETDATEMM", int(t.Month())},
//setDayCmd += ">>"; {"<SETDATEDD", t.Day()},
//communicate(setDayCmd, ret_char, retsize); {"<SETTIMEHH", t.Hour()},
{"<SETTIMEMM", t.Minute()},
// year - last two digits {"<SETTIMESS", t.Second()},
//setYearCmd = "<SETDATEYY"; }
//setYearCmd += uint8_t(year);
//setYearCmd += ">>"; for _, c := range timeCmds {
//communicate(setYearCmd, ret_char, retsize); copy(cmd[:], c.cmd)
} cmd[10] = uint8(c.unit)
copy(cmd[11:], ">>")
// SetTime sets the time (HH:MM:SS) gc.port.Write(cmd)
func (gc *GQGMCCounter) SetTime(time string) { gc.readCmd(1)
//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);
} }
func (gc *GQGMCCounter) communicate(cmd string, length uint32) ([]byte, error) { func (gc *GQGMCCounter) communicate(cmd string, length uint32) ([]byte, error) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment