Skip to content

Commit

Permalink
Added automatic time-zone setting for UV390.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatuschek committed Dec 22, 2019
1 parent 37b36bb commit cd892a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/uv390_codeplug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "channel.hh"
#include "gpssystem.hh"
#include "config.h"
#include <QTimeZone>


#define NCHAN 3000
Expand Down Expand Up @@ -684,7 +685,7 @@ UV390Codeplug::general_settings_t::clear() {
group_call_match = 1;
private_call_match = 1;
_unused107_4 = 1;
time_zone = 0x0c;
setTimeZone();

_unused108 = 0xffffffff;

Expand Down Expand Up @@ -713,6 +714,21 @@ UV390Codeplug::general_settings_t::clear() {
_unused_160_7 = 1;
}

QTimeZone
UV390Codeplug::general_settings_t::getTimeZone() const {
return QTimeZone((int(time_zone)-12)*3600);
}

void
UV390Codeplug::general_settings_t::setTimeZone() {
setTimeZone(QTimeZone::systemTimeZone());
}

void
UV390Codeplug::general_settings_t::setTimeZone(const QTimeZone &ts) {
time_zone = 12 + ts.offsetFromUtc(QDateTime::currentDateTime())/3600;
}

uint32_t
UV390Codeplug::general_settings_t::getRadioId() const {
return decode_dmr_id_bin(radio_id);
Expand Down Expand Up @@ -793,6 +809,7 @@ UV390Codeplug::general_settings_t::fromConfigObj(const Config *conf) {
setRadioId(conf->id());
setIntroLine1(conf->introLine1());
setIntroLine2(conf->introLine2());
setTimeZone();
mic_level = conf->micLevel()/2;
channel_voice_announce = (conf->speech() ? 1 : 0);
}
Expand Down
5 changes: 5 additions & 0 deletions lib/uv390_codeplug.hh
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ protected:
/** Resets this general settings. */
void clear();

QTimeZone getTimeZone() const;
void setTimeZone();
void setTimeZone(const QTimeZone &tz);

/** Returns the radio DMR ID. */
uint32_t getRadioId() const;
/** Sets the radio DMR ID. */
Expand Down Expand Up @@ -550,6 +554,7 @@ protected:
QString getIntroLine2() const;
/** Sets the second intro line. */
void setIntroLine2(const QString &text);

/** Updates the generic configuration from this general settings. */
bool updateConfigObj(Config *conf) const;
/** Updates this codeplug general settings from the generic configuration. */
Expand Down

0 comments on commit cd892a6

Please sign in to comment.