Skip to content

Commit

Permalink
IMU info in README, enum isDstNS for quad state answers
Browse files Browse the repository at this point in the history
Added information to README about what toggling IMU on and off does and about IMU hardware and board design change in May 2020

Added in a quad state enum isDStNS for isDstSouth() and a new isDstNorth()
  • Loading branch information
johnheenan committed May 13, 2020
1 parent 2d6144d commit e5f0970
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ Brief press changes screen and a key press of one second chooses an action

So IMU can be toggled on or off by holding down the the button on the battery screen

## What toggling IMU on or off does

When IMU is toggled on you can view two extra screens (Compass Degrees and Temperature). You can also use movement gestures to wake the watch up from deep sleep.

Currently when the IMU is toggled off battery drain is reduced substantially, increasing the time required between battery recharges. This is for reasons: battery current in deep sleep is reduced with IMU off and the chance of accidental wake ups is reduced. When woken up the current used is dramatically increased compared to when in deep sleep, so accidental wake ups are a battery drain issue.

When IMU is off you can use the button to wake up.

There is relevant information at https://github.com/TioRuben/TTGO-T-Wristband/issues/5

In May 2020 a new hardware version of the T-Wristband went on sale with a different IMU and without a pullup resistor on an interrupt line. The pullup resistor on the previous version drains current unnecessarily in deep sleep due to keeping the interrupt line low during deep sleep.

With the hardware changes mentioned above and software changes in the future, toggling the IMU off may not be as big an issue.

## Key Press Behaviour Changes For UTC and DST Menus

The behaviour of key presses change changes in the UTC action to change DST Regions or UTC Offsets
Expand Down
5 changes: 4 additions & 1 deletion include/clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ bool isNothernHemispere();
void initNTP();
RTC_Date syncTime();

enum isDstNS_t {DST_FALSE, DST_TRUE, DST_NA, DST_OPP}; // for north or south DST. NA for not applicable as no DST offset difference, OPP for opposite in case asked for south or north, is not NA and is in other hemisphere

class NTP2
{ // Any class named NTP2 has been declared a friend of the NTP class to get access to private declarations of NTP.
public: // this minimises changes to the NTP class and also avoids unnecessary duplication here from the NTP class
NTP2(NTP &ntp) : ntp(ntp) {}
NTP &ntp;
bool isDST(time_t utc);
bool isDSTSouth();
isDstNS_t isDSTSouth();
isDstNS_t isDSTNorth();
void setUtcDst(time_t utcNow);
};
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ build_flags =
-DEEPROM_VER=5 # doco must be defined to build. change this to ensure eeprom is wiped over with new upload data
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE # todo jh appears to have no effect on log_e and log_i
-DDEBUG_PORT=Serial # see hal.hpp as there is no configuration.h file
-DWM_DEBUG_LEVEL=0 # todo jh test this does not spill out excessive details from WiFiManager
-DTZ_USES_DST
-DTZ_OFFSET=480 # in minutes of 30 minute increments, for example 210 for 3 hours 30 minutes = 3*60 + 30
-DDST_REGION="\"Europe, Central\""
Expand Down
34 changes: 26 additions & 8 deletions src/hardware/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

/*
doco
doco the DST, STD convention of DST earlier than STD is retained for the southern hemisphere because the maths work
doco the DST, STD convention of DST earlier than STD is retained for the southern hemisphere because the maths works
doco so please do not call this a bug. If there is a bug it is that the names do not mean what they imply.
doco it is a pointless exercise to change variable names when the intention is clear for those in the Northern hemisphere
doco it is a pointless exercise to change variable names when the intention is clear for those in the northern hemisphere
doco and users are not exposed to the issue
doco ntp.isDST() ntp2.isDST(utc) answer the queston is it DST in the Northern Hemisphere
doco ntp.isDST() ntp2.isDST(utc) answer the boolean queston is it DST in the Northern Hemisphere
doco ntp2.isDstSouth() and ntp2.isDstNorth() give a quad state type answer instead of a boolean answer, see enum isDstNS_t
doco the answer is correct even if a Southern Hemisphere DST is in use
doco to find if it is summertime in the Southern Hemisphere call function ntp2.isDSTSouth()
doco
Expand Down Expand Up @@ -142,27 +143,44 @@ RTC_Date syncTime()
{
RTC_Date datetime = RTC_Date();
initNTP();
if (ntp.begin(10, true))
if (ntp.begin(800, true))
datetime = RTC_Date(ntp.year(), ntp.month(), ntp.day(), ntp.hours(), ntp.minutes(), ntp.seconds());
ntp.stop();
return datetime;
}

bool NTP2::isDST(time_t utc) //answers is it DST in the northern hemisphere, see next function for southern hemisphere
bool NTP2::isDST(time_t utc) //answers is it DST in the northern hemisphere, see next two functions for an alternative
{
if ((utc > ntp.utcDST) && (utc <= ntp.utcSTD))
return true;
else
return false;
}

bool NTP2::isDSTSouth() //only works if offsets are different in table
isDstNS_t NTP2::isDSTSouth()
{
if (dst_array[dst_index].dst_offset == dst_array[dst_index].std_offset)
return DST_NA;
bool dst = ntp.isDST();
if (isNothernHemispere())
return dst;
return DST_OPP;
if (dst)
return DST_FALSE;
else
return !dst;
return DST_TRUE;
}

isDstNS_t NTP2::isDSTNorth()
{
if (dst_array[dst_index].dst_offset == dst_array[dst_index].std_offset)
return DST_NA;
bool dst = ntp.isDST();
if (!isNothernHemispere())
return DST_OPP;
if (dst)
return DST_TRUE;
else
return DST_FALSE;
}

void NTP2::setUtcDst(time_t utcNow)
Expand Down

0 comments on commit e5f0970

Please sign in to comment.