Skip to content

Commit

Permalink
Some Remote-related enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
realA10001986 authored Oct 8, 2024
1 parent 3ffd11e commit d545a45
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 135 deletions.
144 changes: 20 additions & 124 deletions timecircuits-A10001986/speeddisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,27 +310,26 @@ static const struct dispConf {
uint8_t colon_pos; // Pos of center colon in 16bit buffer (255 = no colon)
uint16_t colon_bit; // The bitmask for the center colon
uint8_t num_digs; // total number of digits/letters
uint8_t buf_packed; // 2 digits in one buffer pos? (0=no, 1=yes) (for 7seg only)
uint8_t bufPosArr[4]; // The buffer positions of each of the digits from left to right
uint8_t bufShftArr[4]; // Shift-value for each digit from left to right
const uint16_t *fontSeg; // Pointer to font
} displays[SP_NUM_TYPES] = {
{ true, 0, 1, 0, 8, 1, 8, 255, 0, 2, 0, { 0, 1 }, { 0, 8 }, font7segGeneric }, // CircuitSetup Speedo+GPS add-on
{ true, 3, 4, 0, 0, 4, 0, 2, 0x0002, 4, 0, { 0, 1, 3, 4 }, { 0, 0, 0, 0 }, font7segGeneric }, // SP_ADAF_7x4 0.56" (right) (ADA-878/877/5599;879/880/881/1002/5601/5602/5603/5604)
{ true, 0, 1, 0, 0, 1, 0, 2, 0x0002, 4, 0, { 0, 1, 3, 4 }, { 0, 0, 0, 0 }, font7segGeneric }, // SP_ADAF_7x4L 0.56" (left) (ADA-878/877/5599;879/880/881/1002/5601/5602/5603/5604)
{ true, 3, 4, 0, 0, 4, 0, 2, 0x0002, 4, 0, { 0, 1, 3, 4 }, { 0, 0, 0, 0 }, font7segGeneric }, // SP_ADAF_B7x4 1.2" (right) (ADA-1270/1271;1269)
{ true, 0, 1, 0, 0, 1, 0, 2, 0x0002, 4, 0, { 0, 1, 3, 4 }, { 0, 0, 0, 0 }, font7segGeneric }, // SP_ADAF_B7x4L 1.2" (left) (ADA-1270/1271;1269)
{ false, 2, 3, 0, 0, 3, 0, 255, 0, 4, 0, { 0, 1, 2, 3 }, { 0, 0, 0, 0 }, font14segGeneric }, // SP_ADAF_14x4 0.56" (right) (ADA-1911/1910;1912/2157/2158/2160)
{ false, 0, 1, 0, 0, 1, 0, 255, 0, 4, 0, { 0, 1, 2, 3 }, { 0, 0, 0, 0 }, font14segGeneric }, // SP_ADAF_14x4L 0.56" (left) (ADA-1911/1910;1912/2157/2158/2160)
{ false, 2, 1, 0, 0, 1, 0, 255, 0, 2, 0, { 2, 1 }, { 0, 0, 0, 0 }, font14segGrove }, // SP_GROVE_2DIG14
{ false, 3, 4, 0, 0, 4, 0, 5, 0x2080, 4, 0, { 1, 2, 3, 4 }, { 0, 0, 0, 0 }, font144segGrove }, // SP_GROVE_4DIG14 (right)
{ false, 1, 2, 0, 0, 2, 0, 5, 0x2080, 4, 0, { 1, 2, 3, 4 }, { 0, 0, 0, 0 }, font144segGrove }, // SP_GROVE_4DIG14 (left)
{ false, 0, 1, 0, 0, 1, 0, 255, 0, 2, 0, { 0, 1 }, { 0, 0, 0, 0 }, font14segGeneric }, // like SP_ADAF_14x4L(ADA-1911), but left tube only (TW wall clock)
{ true, 0, 1, 0, 0, 1, 0, 255, 0, 2, 0, { 0, 1 }, { 0, 0, 0, 0 }, font7segGeneric }, // like SP_ADAF_7x4L(ADA-878), but left tube only (TW speedo replica) - needs rewiring
{ true, 0, 1, 0, 8, 1, 8, 255, 0, 2, { 0, 1 }, { 0, 8 }, font7segGeneric }, // CircuitSetup Speedo+GPS add-on
{ true, 3, 4, 0, 0, 4, 0, 2, 0x0002, 4, { 0, 1, 3, 4 }, { 0, 0, 0, 0 }, font7segGeneric }, // SP_ADAF_7x4 0.56" (right) (ADA-878/877/5599;879/880/881/1002/5601/5602/5603/5604)
{ true, 0, 1, 0, 0, 1, 0, 2, 0x0002, 4, { 0, 1, 3, 4 }, { 0, 0, 0, 0 }, font7segGeneric }, // SP_ADAF_7x4L 0.56" (left) (ADA-878/877/5599;879/880/881/1002/5601/5602/5603/5604)
{ true, 3, 4, 0, 0, 4, 0, 2, 0x0002, 4, { 0, 1, 3, 4 }, { 0, 0, 0, 0 }, font7segGeneric }, // SP_ADAF_B7x4 1.2" (right) (ADA-1270/1271;1269)
{ true, 0, 1, 0, 0, 1, 0, 2, 0x0002, 4, { 0, 1, 3, 4 }, { 0, 0, 0, 0 }, font7segGeneric }, // SP_ADAF_B7x4L 1.2" (left) (ADA-1270/1271;1269)
{ false, 2, 3, 0, 0, 3, 0, 255, 0, 4, { 0, 1, 2, 3 }, { 0, 0, 0, 0 }, font14segGeneric }, // SP_ADAF_14x4 0.56" (right) (ADA-1911/1910;1912/2157/2158/2160)
{ false, 0, 1, 0, 0, 1, 0, 255, 0, 4, { 0, 1, 2, 3 }, { 0, 0, 0, 0 }, font14segGeneric }, // SP_ADAF_14x4L 0.56" (left) (ADA-1911/1910;1912/2157/2158/2160)
{ false, 2, 1, 0, 0, 1, 0, 255, 0, 2, { 2, 1 }, { 0, 0, 0, 0 }, font14segGrove }, // SP_GROVE_2DIG14
{ false, 3, 4, 0, 0, 4, 0, 5, 0x2080, 4, { 1, 2, 3, 4 }, { 0, 0, 0, 0 }, font144segGrove }, // SP_GROVE_4DIG14 (right)
{ false, 1, 2, 0, 0, 2, 0, 5, 0x2080, 4, { 1, 2, 3, 4 }, { 0, 0, 0, 0 }, font144segGrove }, // SP_GROVE_4DIG14 (left)
{ false, 0, 1, 0, 0, 1, 0, 255, 0, 2, { 0, 1 }, { 0, 0, 0, 0 }, font14segGeneric }, // like SP_ADAF_14x4L(ADA-1911), but left tube only (TW wall clock)
{ true, 0, 1, 0, 0, 1, 0, 255, 0, 2, { 0, 1 }, { 0, 0, 0, 0 }, font7segGeneric }, // like SP_ADAF_7x4L(ADA-878), but left tube only (TW speedo replica) - needs rewiring
// .... for testing only:
//{ true, 7, 7, 0, 8, 7, 8, 255, 0, 2, 1, { 7 }, { 0, 8 }, font7segGeneric }, // SP_TCD_TEST7
//{ false, 1, 2, 0, 0, 2, 0, 255, 0, 3, 0, { 0, 1, 2 }, { 0, 0, 0 }, font14segGeneric }, // SP_TCD_TEST14 right
//{ false, 0, 1, 0, 0, 1, 0, 255, 0, 3, 0, { 0, 1, 2 }, { 0, 0, 0 }, font14segGeneric } // SP_TCD_TEST14 left
//{ true, 7, 7, 0, 8, 7, 8, 255, 0, 2, { 7, 7 }, { 0, 8 }, font7segGeneric }, // SP_TCD_TEST7
//{ false, 1, 2, 0, 0, 2, 0, 255, 0, 3, { 0, 1, 2 }, { 0, 0, 0 }, font14segGeneric }, // SP_TCD_TEST14 right
//{ false, 0, 1, 0, 0, 1, 0, 255, 0, 3, { 0, 1, 2 }, { 0, 0, 0 }, font14segGeneric } // SP_TCD_TEST14 left
};

// Grove 4-digit special handling
Expand Down Expand Up @@ -373,7 +372,6 @@ bool speedDisplay::begin(int dispType)
_colon_pos = displays[dispType].colon_pos;
_colon_bm = displays[dispType].colon_bit;
_num_digs = displays[dispType].num_digs;
_buf_packed = displays[dispType].buf_packed;
_bufPosArr = displays[dispType].bufPosArr;
_bufShftArr = displays[dispType].bufShftArr;

Expand Down Expand Up @@ -545,30 +543,20 @@ void speedDisplay::show()
// ignored.)
void speedDisplay::setText(const char *text)
{
int idx = 0, pos = 0, dgt = 0;
int idx = 0, pos = 0;
int temp = 0;

clearBuf();

if(_is7seg) {
while(text[idx] && (pos < (_num_digs / (1<<_buf_packed)))) {
temp = getLEDChar(text[idx]) << (*(_bufShftArr + dgt));
while(text[idx] && (pos < _num_digs)) {
temp = getLEDChar(text[idx]) << (*(_bufShftArr + pos));
idx++;
if(text[idx] == '.') {
temp |= (getLEDChar('.') << (*(_bufShftArr + dgt)));
temp |= (getLEDChar('.') << (*(_bufShftArr + pos)));
idx++;
}
dgt++;
if(_buf_packed && text[idx]) {
temp |= (getLEDChar(text[idx]) << (*(_bufShftArr + dgt)));
idx++;
if(text[idx] == '.') {
temp |= (getLEDChar('.') << (*(_bufShftArr + dgt)));
idx++;
}
dgt++;
}
_displayBuffer[*(_bufPosArr + pos)] = temp;
_displayBuffer[*(_bufPosArr + pos)] |= temp;
pos++;
}
} else {
Expand Down Expand Up @@ -706,98 +694,6 @@ bool speedDisplay::getColon()
return _colon;
}

// Special purpose -------------------------------------------------------------

#if 0 // Currently unused

// Clears the display RAM and only shows the given text
// does not use the buffer, writes directly to display
// (clears colon; dots work like the buffer version.)
void speedDisplay::showTextDirect(const char *text)
{
int idx = 0, pos = 0, dgt = 0;
int temp = 0;
uint16_t tt = 0, spec = 0;
bool commaAdded = false;

clearDisplay();

if(_is7seg) {
while(text[idx] && (pos < (_num_digs / (1<<_buf_packed)))) {
commaAdded = false;
temp = getLEDChar(text[idx]) << (*(_bufShftArr + dgt));
idx++;
if(text[idx] == '.') {
temp |= (getLEDChar('.') << (*(_bufShftArr + dgt)));
idx++;
commaAdded = true;
}
dgt++;
if(_buf_packed && text[idx]) {
temp |= (getLEDChar(text[idx]) << (*(_bufShftArr + dgt)));
idx++;
if(text[idx] == '.') {
temp |= (getLEDChar('.') << (*(_bufShftArr + dgt)));
idx++;
}
dgt++;
}
directCol(*(_bufPosArr + pos), temp);
switch(_dispType) {
case SP_ADAF_B7x4:
case SP_ADAF_B7x4L:
if(pos == 2 && commaAdded) {
spec |= 0x10;
}
break;
}
pos++;
}
} else {
while(text[idx] && pos < _num_digs) {
tt = getLEDChar(text[idx]);
idx++;
if(text[idx] == '.') {
tt |= getLEDChar('.');
idx++;
}
directCol(*(_bufPosArr + pos), tt);
switch(_dispType) {
case SP_GROVE_4DIG14:
case SP_GROVE_4DIG14L:
spec |= ((tt & 0x2) ? gr4_sh1[pos] : 0);
spec |= ((tt & 0x4) ? gr4_sh2[pos] : 0);
break;
}
pos++;
}
}

switch(_dispType) {
case SP_ADAF_B7x4:
case SP_ADAF_B7x4L:
case SP_GROVE_4DIG14:
case SP_GROVE_4DIG14L:
directCol(_colon_pos, spec);
}
}

void speedDisplay::setColonDirect(bool colon)
{
uint16_t t = _lastBufPosCol;

_colon = colon;

if(_colon_pos < 255) {
if(_colon) t |= _colon_bm;
else t &= (~_colon_bm);

directCol(_colon_pos, t);
}
}

#endif // if 0

// Private functions ###########################################################


Expand Down
5 changes: 0 additions & 5 deletions timecircuits-A10001986/speeddisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ class speedDisplay {
bool getDot();
bool getColon();

#if 0
void showTextDirect(const char *text);
void setColonDirect(bool colon);
#endif

private:

void handleColon();
Expand Down
4 changes: 2 additions & 2 deletions timecircuits-A10001986/tc_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
// '0'-'9', 'A'-'Z', '(', ')', '.', '_', '-' or space
#define TC_VERSION "V3.1.0" // 13 chars max
#ifndef IS_ACAR_DISPLAY
#define TC_VERSION_EXTRA "SEP282024" // 13 chars max
#define TC_VERSION_EXTRA "OCT032024" // 13 chars max
#else // A-Car
#define TC_VERSION_EXTRA "09282024" // 12 chars max
#define TC_VERSION_EXTRA "10032024" // 12 chars max
#endif

//#define TC_DBG // debug output on Serial
Expand Down
16 changes: 12 additions & 4 deletions timecircuits-A10001986/tc_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,9 +1817,9 @@ void time_setup()

if(waitForFakePowerButton) {
fakePowerOnKey.scan();
myIntroDelay(100); // Bridge debounce time
myIntroDelay(70); // Bridge debounce/longpress time
fakePowerOnKey.scan();
if(!isFPBKeyChange) {
if(!isFPBKeyPressed) {
leds_off();
FPBUnitIsOn = false;
bootNow = false;
Expand Down Expand Up @@ -4321,8 +4321,16 @@ static void updAndDispRemoteSpeed()
if(now - lastRemSpdUpd > remSpdCatchUpDelay) {
if(bttfnRemCurSpd < bttfnRemoteSpeed) {
bttfnRemCurSpd++;
remSpdCatchUpDelay = bttfnRemCurSpd < 88 ? // ttP0TimeFactor
(unsigned long)(((float)(tt_p0_delays[bttfnRemCurSpd])) / 4.2) : 40;
if(bttfnRemCurSpd < 88) {
float nD = (float)tt_p0_delays[bttfnRemCurSpd]; // 4.2
int sD = bttfnRemoteSpeed - bttfnRemCurSpd;
if(sD > 4) nD /= 4.2;
else if(sD > 1) nD /= (float)sD;
else nD /= 2.0;
remSpdCatchUpDelay = (unsigned long)nD;
} else {
remSpdCatchUpDelay = 40;
}
} else {
remSpdCatchUpDelay = 40;
bttfnRemCurSpd--;
Expand Down
4 changes: 4 additions & 0 deletions timecircuits-A10001986/timecircuits-A10001986.ino
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@

/* Changelog
*
* 2024/10/03 (A10001986)
* - Smoothen speedo's catch-up to Remote speed
* 2024/10/02 (A10001986)
* - Speedo: Minor (cosmetic) changes
* 2024/09/28 (A10001986)
* - Revisit UTF8 filtering for MQTT messages and ID3 data.
* - Properly truncate UTF8 strings (MQTT user/topics) if beyond buffer
Expand Down

0 comments on commit d545a45

Please sign in to comment.