Skip to content

Commit

Permalink
Latest Release RM0304-0317-0.98.4-bddaa62 on PATREON - UPD DCF77
Browse files Browse the repository at this point in the history
+ FMT
+ Fix FuriHalRtcDateTime to DateTime
  • Loading branch information
RogueMaster committed Mar 4, 2024
1 parent beb63fa commit d60979c
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 204 deletions.
2 changes: 2 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ This software is for experimental purposes only and is not meant for any illegal
- [Added Memory Chip passport background (By Kuronons With Changes By RogueMaster) + Passport: Move text for better display (By Kuronons)](https://github.com/Kuronons/FZ_graphics/blob/main/Passport%20background/Passports%20(.png%20files%20-%20128x64px)/passport_MNTM.png)
- Updated: [Air Labyrinth v0.1 (By jamisonderek)](https://github.com/jamisonderek/flipper-zero-tutorials/tree/main/vgm/apps/air_labyrinth) `Req: Video Game Module By Flipper Devices` [AirLabyrinth: Fix build on gcc12 (By Willy-JL)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/a10148803fca00aff8ff58c1c767e00862159413)
- OFW: [Parser for Santiago, Chile BIP transit card #3456 (By rbasoalto)](https://github.com/flipperdevices/flipperzero-firmware/pull/3456)
- Added: [DCF77 Clock Sync v1.2 (By mdaskalov)](https://github.com/mdaskalov/dcf77-clock-sync)

<a name="release">

Expand Down Expand Up @@ -356,6 +357,7 @@ $ ./fbt dolphin_ext
- [Crypto Dictionary v0.1 (By armixz)](https://github.com/armixz/Flipper-Zero-Crypto-Dictionary)
- [Dab Timer v1.9.1 (By RogueMaster)](https://github.com/RogueMaster/flipperzero-dabtimer)
- [DAP Link v1.2 (By DrZlo13)-OFW](https://github.com/flipperdevices/flipperzero-firmware/pull/1897)
- [DCF77 Clock Sync v1.2 (By mdaskalov)](https://github.com/mdaskalov/dcf77-clock-sync)
- [DCF77 Transmitter v1.1 (By arha)](https://github.com/arha/flipper-dcf77)
- [Deauther PWNDTOOLS V2.6.0 (By HEX0DAYS)](https://github.com/HEX0DAYS/FlipperZero-PWNDTOOLS) `Req: ESP8266` [Original](https://github.com/SpacehuhnTech/esp8266_deauther)
- [Device Info (By hedger)](https://github.com/hedger/flipperdevinfo)
Expand Down
10 changes: 4 additions & 6 deletions applications/external/dcf77_clock/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ App(
name="DCF77 Clock Sync",
apptype=FlipperAppType.EXTERNAL,
entry_point="dcf77_clock_sync_app_main",
requires=["gui"],
stack_size=1 * 1024,
order=10,
fap_icon="icons/app_10x10.png",
fap_category="Tools",
fap_author="@mdaskalov",
fap_weburl="https://github.com/mdaskalov/dcf77-clock-sync.git",
fap_version="1.1",
fap_category="RFID",
fap_author="mdaskalov",
fap_weburl="https://github.com/mdaskalov/dcf77-clock-sync",
fap_version="1.2",
fap_description="Emulate DCF77 time signal on the RFID antena and the A4 GPIO pin",
)
101 changes: 48 additions & 53 deletions applications/external/dcf77_clock/dcf77.c
Original file line number Diff line number Diff line change
@@ -1,69 +1,64 @@
#include <furi_hal.h>

#define DST_BIT 17
#define MIN_BIT 21
#define HOUR_BIT 29
#define DAY_BIT 36
#define DST_BIT 17
#define MIN_BIT 21
#define HOUR_BIT 29
#define DAY_BIT 36
#define WEEKDAY_BIT 42
#define MONTH_BIT 45
#define YEAR_BIT 50
#define MONTH_BIT 45
#define YEAR_BIT 50

static uint8_t dcf77_bits[] = {
0, // 00: Start of minute
0, // 00: Start of minute
8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 01: Weather broadcast / Civil warning bits
8, // 15: Call bit: abnormal transmitter operation
0, // 16: Summer time announcement. Set during hour before change
0, 1, // 17: 01=CET, 10=CEST
0, // 19: Leap second announcement. Set during hour before leap second
1, // 20: Start of encoded time
8, 0, 0, 0, 0, 0, 0, 0, // 21: Minutes (7bit + parity, 00-59)
8, 0, 0, 0, 0, 0, 0, // 29: Hours (6bit + parity, 0-23)
8, 0, 0, 0, 0, 0, // 36: Day of month (6bit, 1-31)
8, 0, 0, // 42: Day of week (3bit, 1-7, Monday=1)
8, 0, 0, 0, 0, // 45: Month number (5bit, 1-12)
8, 0, 0, 0, 0, 0, 0, 0, 0, // 50: Year within century (8bit + parity, 00-99)
0 // 59: Not used
8, // 15: Call bit: abnormal transmitter operation
0, // 16: Summer time announcement. Set during hour before change
0, 1, // 17: 01=CET, 10=CEST
0, // 19: Leap second announcement. Set during hour before leap second
1, // 20: Start of encoded time
8, 0, 0, 0, 0, 0, 0, 0, // 21: Minutes (7bit + parity, 00-59)
8, 0, 0, 0, 0, 0, 0, // 29: Hours (6bit + parity, 0-23)
8, 0, 0, 0, 0, 0, // 36: Day of month (6bit, 1-31)
8, 0, 0, // 42: Day of week (3bit, 1-7, Monday=1)
8, 0, 0, 0, 0, // 45: Month number (5bit, 1-12)
8, 0, 0, 0, 0, 0, 0, 0, 0, // 50: Year within century (8bit + parity, 00-99)
0 // 59: Not used
};

void dcf77_encode(int start, int len, int val, int par)
{
uint8_t parity = (par != -1 ? par : dcf77_bits[start]) & 1;
uint8_t byte = ((val / 10) << 4) + (val % 10);
for (int bit = 0; bit < len; bit++) {
uint8_t dcf77_bit = (byte >> bit) & 1;
parity ^= dcf77_bit;
dcf77_bits[start + bit] = (dcf77_bits[start + bit] & 0x0E) + dcf77_bit;
}
dcf77_bits[start + len] = (dcf77_bits[start + len] & 0xE) + (parity & 1);
void dcf77_encode(int start, int len, int val, int par) {
uint8_t parity = (par != -1 ? par : dcf77_bits[start]) & 1;
uint8_t byte = ((val / 10) << 4) + (val % 10);
for(int bit = 0; bit < len; bit++) {
uint8_t dcf77_bit = (byte >> bit) & 1;
parity ^= dcf77_bit;
dcf77_bits[start + bit] = (dcf77_bits[start + bit] & 0x0E) + dcf77_bit;
}
dcf77_bits[start + len] = (dcf77_bits[start + len] & 0xE) + (parity & 1);
}

void set_dcf77_time(FuriHalRtcDateTime *dt, bool is_dst)
{
dcf77_encode(DST_BIT, 2, is_dst > 0 ? 1 : 2, 1); // parity = leap second -> 0
dcf77_encode(MIN_BIT, 7, dt->minute, 0);
dcf77_encode(HOUR_BIT, 6, dt->hour, 0);
dcf77_encode(DAY_BIT, 6, dt->day, 0);
dcf77_encode(WEEKDAY_BIT, 3, dt->weekday, -1);
dcf77_encode(MONTH_BIT, 5, dt->month, -1);
dcf77_encode(YEAR_BIT, 8, dt->year % 100, -1);
void set_dcf77_time(DateTime* dt, bool is_dst) {
dcf77_encode(DST_BIT, 2, is_dst > 0 ? 1 : 2, 1); // parity = leap second -> 0
dcf77_encode(MIN_BIT, 7, dt->minute, 0);
dcf77_encode(HOUR_BIT, 6, dt->hour, 0);
dcf77_encode(DAY_BIT, 6, dt->day, 0);
dcf77_encode(WEEKDAY_BIT, 3, dt->weekday, -1);
dcf77_encode(MONTH_BIT, 5, dt->month, -1);
dcf77_encode(YEAR_BIT, 8, dt->year % 100, -1);
}

bool get_dcf77_bit(int sec)
{
return dcf77_bits[sec % 60] & 1;
bool get_dcf77_bit(int sec) {
return dcf77_bits[sec % 60] & 1;
}

char *get_dcf77_data(int sec)
{
static char data[70];
char* get_dcf77_data(int sec) {
static char data[70];

int idx = 0;
int start = sec > 25 ? sec - 25 : 0;
for (int bit = start; bit <= sec; bit++) {
if (dcf77_bits[bit] & 8)
data[idx++] = '-';
data[idx++] = '0' + (dcf77_bits[bit] & 1);
}
data[idx] = 0;
return data;
int idx = 0;
int start = sec > 25 ? sec - 25 : 0;
for(int bit = start; bit <= sec; bit++) {
if(dcf77_bits[bit] & 8) data[idx++] = '-';
data[idx++] = '0' + (dcf77_bits[bit] & 1);
}
data[idx] = 0;
return data;
}
6 changes: 3 additions & 3 deletions applications/external/dcf77_clock/dcf77.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

#include <furi_hal.h>

void set_dcf77_time(FuriHalRtcDateTime *dt, bool is_dst);
int get_dcf77_bit(int sec);
char *get_dcf77_data(int sec);
void set_dcf77_time(DateTime* dt, bool is_dst);
int get_dcf77_bit(int sec);
char* get_dcf77_data(int sec);
Loading

0 comments on commit d60979c

Please sign in to comment.