diff --git a/CHANGELOG.md b/CHANGELOG.md index c7e3b92..85d90d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] + - Added offline copy EM card uid for btnpress.(@nemanjan00) - Added offline copy ic card uid for btnpress.(@xianglin1998) - Added `hw settings btnpress` to get and set button press function.(@xianglin1998) - Added `hw battery` to get battery informartion (@xianglin1998) diff --git a/firmware/application/src/app_main.c b/firmware/application/src/app_main.c index 5a36c4d..ff1425d 100644 --- a/firmware/application/src/app_main.c +++ b/firmware/application/src/app_main.c @@ -511,6 +511,34 @@ static void btn_fn_copy_ic_uid(void) { nfc_tag_14a_coll_res_entity_t* antres; + if(tag_type[1] == TAG_TYPE_EM410X) { + uint8_t status; + + bool is_reader_mode_now = get_device_mode() == DEVICE_MODE_READER; + // first, we need switch to reader mode. + if (!is_reader_mode_now) { + // enter reader mode + reader_mode_enter(); + bsp_delay_ms(8); + NRF_LOG_INFO("Start reader mode to offline copy.") + } + + uint8_t id_buffer[5] = { 0x00 }; + status = PcdScanEM410X(id_buffer); + + if(status == LF_TAG_OK) { + tag_data_buffer_t* buffer = get_buffer_by_tag_type(TAG_TYPE_EM410X); + memcpy(buffer->buffer, id_buffer, LF_EM410X_TAG_ID_SIZE); + tag_emulation_load_by_buffer(TAG_TYPE_EM410X, false); + + // keep reader mode or exit reader mode. + } + + if (!is_reader_mode_now) { + tag_mode_enter(); + } + } + switch(tag_type[0]) { case TAG_TYPE_MIFARE_Mini: case TAG_TYPE_MIFARE_1024: diff --git a/firmware/application/src/rfid/nfctag/tag_emulation.c b/firmware/application/src/rfid/nfctag/tag_emulation.c index b65da99..800b328 100644 --- a/firmware/application/src/rfid/nfctag/tag_emulation.c +++ b/firmware/application/src/rfid/nfctag/tag_emulation.c @@ -7,6 +7,7 @@ #include "fds_util.h" #include "tag_emulation.h" #include "tag_persistence.h" +#include "rgb_marquee.h" #define NRF_LOG_MODULE_NAME tag_emu @@ -458,6 +459,7 @@ uint8_t tag_emulation_get_slot(void) { */ void tag_emulation_set_slot(uint8_t index) { slotConfig.config.activated = index; // 重设到新切换的卡槽上 + rgb_marquee_reset(); // force animation color refresh according to new slot } /** diff --git a/firmware/application/src/rgb_marquee.c b/firmware/application/src/rgb_marquee.c index 9003982..335983b 100644 --- a/firmware/application/src/rgb_marquee.c +++ b/firmware/application/src/rgb_marquee.c @@ -50,6 +50,12 @@ void rgb_marquee_stop(void){ ledblink1_step = 0; } +// reset RGB state machines to force a refresh of the LED color +void rgb_marquee_reset(void){ + ledblink6_step = 0; + ledblink1_step = 0; +} + // 亮度转PWM值 uint16_t get_pwmduty(uint8_t light_level){ return PWM_MAX-(PWM_MAX*pow(((double)light_level/LIGHT_LEVEL_MAX),2.2)); diff --git a/firmware/application/src/rgb_marquee.h b/firmware/application/src/rgb_marquee.h index a6702ff..0af8a41 100644 --- a/firmware/application/src/rgb_marquee.h +++ b/firmware/application/src/rgb_marquee.h @@ -7,6 +7,7 @@ void rgb_marquee_init(void); void rgb_marquee_stop(void); +void rgb_marquee_reset(void); bool is_rgb_marquee_enable(void); void ledblink1(uint8_t color,uint8_t dir); void ledblink2(uint8_t color,uint8_t dir, uint8_t end);