v2.0b6 add Buzzer
This commit is contained in:
parent
090a3feabd
commit
891880dac3
15 changed files with 2558 additions and 2243 deletions
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
| [TH05_V1.3](https://pvvx.github.io/TH05-v1.3) | [TH05_V1.4](https://pvvx.github.io/TH-05) | [TH05F](https://pvvx.github.io/TH05F) | [KEY2](https://pvvx.github.io/iSearching) |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| <img src="https://pvvx.github.io/TH05-v1.3/img/TH05-V1.3.jpg" width="120"/> | <img src="https://pvvx.github.io/TH-05/img/TH05V14.jpg" width="120"/> | <img src="https://pvvx.github.io/TH05F/img/TH05F.jpg" width="120"/> | <img src="https://pvvx.github.io/iSearching/img/key2.jpg" width="120"/> |
|
||||
| <img src="https://pvvx.github.io/TH05-v1.3/img/TH05-V1.3.jpg" width="120"/> | <img src="https://pvvx.github.io/TH-05/img/TH05V14.jpg" width="120"/> | <img src="https://pvvx.github.io/TH05F/img/TH05F.jpg" width="120"/> | <img src="https://pvvx.github.io/iSearching/img/keys.jpg" width="120"/> |
|
||||
| | | | Поддерживает "FindMy" |
|
||||
|
||||
Прошивки работают с [Home Assistant](https://www.home-assistant.io/) и другим программным обеспечением, работающим в формате [BTHome](https://bthome.io/).
|
||||
|
|
@ -100,7 +100,7 @@ LCD имеет разную разводку сегментов в зависи
|
|||
| 1.7 | <ul><li>Исправление ошибки (> 42 C) для сенсора CHT8305</li></ul> |
|
||||
| 1.8 | <ul><li>Добавлено отображение температуры в градусах Фаренгейта</li></ul> |
|
||||
| 1.9 | <ul><li>Исправлена ошибка восстановления измененного имени устройства после сброса питания</li></ul> |
|
||||
| 2.0beta5 | <ul><li>Добавлена обработка датчика CHT832x (поддержка платы TH05Y_v3.1)</li><li>Исправление ошибки в bin-файлах BOOT OTA</li><li>Добавлена функция сна при полном разряде батареи.</li><li>Добавлена опытная прошивка для брелков [iSearching](https://pvvx.github.io/iSearching) на чипе ST17H66B с поддержкой FindMy</li></ul> |
|
||||
| 2.0 | <ul><li>Добавлена обработка датчика CHT832x (поддержка платы TH05Y_v3.1)</li><li>Исправление ошибки в bin-файлах BOOT OTA</li><li>Добавлена функция сна при полном разряде батареи.</li><li>Добавлена опытная прошивка для брелков [iSearching](https://pvvx.github.io/iSearching) на чипе ST17H66B с поддержкой FindMy</li></ul> |
|
||||
|
||||
## Прошивка
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Custom firmware for Tuya devices based on the PHY622x2 chipset.
|
|||
|
||||
| [TH05_V1.3](https://pvvx.github.io/TH05-v1.3) | [TH05_V1.4](https://pvvx.github.io/TH-05) | [TH05F](https://pvvx.github.io/TH05F) | [KEY2](https://pvvx.github.io/iSearching) |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| <img src="https://pvvx.github.io/TH05-v1.3/img/TH05-V1.3.jpg" width="120"/> | <img src="https://pvvx.github.io/TH-05/img/TH05V14.jpg" width="120"/> | <img src="https://pvvx.github.io/TH05F/img/TH05F.jpg" width="120"/> | <img src="https://pvvx.github.io/iSearching/img/key2.jpg" width="120"/> |
|
||||
| <img src="https://pvvx.github.io/TH05-v1.3/img/TH05-V1.3.jpg" width="120"/> | <img src="https://pvvx.github.io/TH-05/img/TH05V14.jpg" width="120"/> | <img src="https://pvvx.github.io/TH05F/img/TH05F.jpg" width="120"/> | <img src="https://pvvx.github.io/iSearching/img/keys.jpg" width="120"/> |
|
||||
| | | | Support "FindMy" |
|
||||
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ The sensors are detected automatically, but have different ports depending on th
|
|||
| 1.7 | <ul><li>Fixed en error (> 42 C) for sensor CHT8305</li></ul> |
|
||||
| 1.8 | <ul><li>Added display of temperature in degrees Fahrenheit</li></ul> |
|
||||
| 1.9 | <ul><li>Fixed the bug of restoring the changed device name after power reset</li></ul> |
|
||||
| 2.0beta5 | <ul><li>Added processing of the CHT832x sensor (Support board TH05Y_v3.1)</li><li>Fixing a bug in BOOT OTA bin files</li><li>Added sleep function when battery is completely discharged</li><li>Added experimental firmware for [iSearching](https://pvvx.github.io/iSearching) key fobs on ST17H66B chip (support "FindMy")</li></ul> |
|
||||
| 2.0 | <ul><li>Added processing of the CHT832x sensor (Support board TH05Y_v3.1)</li><li>Fixing a bug in BOOT OTA bin files</li><li>Added sleep function when battery is completely discharged</li><li>Added experimental firmware for [iSearching](https://pvvx.github.io/iSearching) key fobs on ST17H66B chip (support "FindMy")</li></ul> |
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
BIN
bin/KEY2_v20.bin
BIN
bin/KEY2_v20.bin
Binary file not shown.
|
|
@ -31,6 +31,7 @@ SRC_PRJ += lcd_th05f.c
|
|||
SRC_PRJ += lcd_thb1.c
|
||||
SRC_PRJ += ble_ota.c
|
||||
SRC_PRJ += logger.c
|
||||
SRC_PRJ += buzzer.c
|
||||
|
||||
INCLUDES = -I$(SRC_PATH)
|
||||
|
||||
|
|
|
|||
206
bthome_phy6222/source/buzzer.c
Normal file
206
bthome_phy6222/source/buzzer.c
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
* buzzer.c
|
||||
*
|
||||
* Created on: 13 дек. 2024 г.
|
||||
* Author: pvvx
|
||||
*/
|
||||
#include "rom_sym_def.h"
|
||||
#include "types.h"
|
||||
#include "config.h"
|
||||
|
||||
#if defined(GPIO_BUZZER) && defined(PWM_CHL_BUZZER)
|
||||
|
||||
#include "pwm.h"
|
||||
#include "OSAL.h"
|
||||
#include "OSAL_PwrMgr.h"
|
||||
#include "pwrmgr.h"
|
||||
#include "thb2_main.h"
|
||||
|
||||
#define NOTE_VOLUME0 0x00 // min x1
|
||||
#define NOTE_VOLUME1 0x40 // x2
|
||||
#define NOTE_VOLUME2 0x80 // x4
|
||||
#define NOTE_VOLUME3 0xC0 // max x8
|
||||
|
||||
#define NOTE_VOLUME NOTE_VOLUME3
|
||||
|
||||
#define NOTE_REST 0xff
|
||||
|
||||
|
||||
#define NOTE_C4 0x20+NOTE_VOLUME
|
||||
#define NOTE_CS4 0x21+NOTE_VOLUME
|
||||
#define NOTE_D4 0x22+NOTE_VOLUME
|
||||
#define NOTE_DS4 0x23+NOTE_VOLUME
|
||||
#define NOTE_E4 0x24+NOTE_VOLUME
|
||||
#define NOTE_F4 0x25+NOTE_VOLUME
|
||||
#define NOTE_FS4 0x26+NOTE_VOLUME
|
||||
#define NOTE_G4 0x27+NOTE_VOLUME
|
||||
#define NOTE_GS4 0x28+NOTE_VOLUME
|
||||
#define NOTE_A4 0x29+NOTE_VOLUME
|
||||
#define NOTE_AS4 0x2A+NOTE_VOLUME
|
||||
#define NOTE_B4 0x2B+NOTE_VOLUME
|
||||
|
||||
#define NOTE_C5 0x10+NOTE_VOLUME
|
||||
#define NOTE_CS5 0x11+NOTE_VOLUME
|
||||
#define NOTE_D5 0x12+NOTE_VOLUME
|
||||
#define NOTE_DS5 0x13+NOTE_VOLUME
|
||||
#define NOTE_E5 0x14+NOTE_VOLUME
|
||||
#define NOTE_F5 0x15+NOTE_VOLUME
|
||||
#define NOTE_FS5 0x16+NOTE_VOLUME
|
||||
#define NOTE_G5 0x17+NOTE_VOLUME
|
||||
#define NOTE_GS5 0x18+NOTE_VOLUME
|
||||
#define NOTE_A5 0x19+NOTE_VOLUME
|
||||
#define NOTE_AS5 0x1A+NOTE_VOLUME
|
||||
#define NOTE_B5 0x1B+NOTE_VOLUME
|
||||
|
||||
#define NOTE_C6 0x00+NOTE_VOLUME
|
||||
#define NOTE_CS6 0x01+NOTE_VOLUME
|
||||
#define NOTE_D6 0x02+NOTE_VOLUME
|
||||
#define NOTE_DS6 0x03+NOTE_VOLUME
|
||||
#define NOTE_E6 0x04+NOTE_VOLUME
|
||||
#define NOTE_F6 0x05+NOTE_VOLUME
|
||||
#define NOTE_FS6 0x06+NOTE_VOLUME
|
||||
#define NOTE_G6 0x07+NOTE_VOLUME
|
||||
#define NOTE_GS6 0x08+NOTE_VOLUME
|
||||
#define NOTE_A6 0x09+NOTE_VOLUME
|
||||
#define NOTE_AS6 0x0A+NOTE_VOLUME
|
||||
#define NOTE_B6 0x0B+NOTE_VOLUME
|
||||
|
||||
#define NOTE_C7 0x0C+NOTE_VOLUME
|
||||
#define NOTE_CS7 0x0D+NOTE_VOLUME
|
||||
#define NOTE_D7 0x0E+NOTE_VOLUME
|
||||
#define NOTE_DS7 0x0F+NOTE_VOLUME
|
||||
|
||||
|
||||
#define N_T32 1 // 1/16
|
||||
#define N_T16 2 // 1/16
|
||||
#define N_T16N 3 // 1.5/16
|
||||
#define N_T8 4 // 1/8
|
||||
#define N_T8N 6 // 1.5/8
|
||||
#define N_T4 8 // 1/4
|
||||
#define N_T4N 12 // 1.5/4
|
||||
|
||||
#define NOTE_TEMP 55
|
||||
|
||||
const uint8_t melody[] = { // Note, Time in 10 ms
|
||||
NOTE_A5, N_T16, NOTE_D5, N_T16, NOTE_AS5, N_T16, NOTE_D5, N_T16, NOTE_A5, N_T16, NOTE_D5, N_T16, NOTE_G5, N_T16, NOTE_D5, N_T16,
|
||||
NOTE_A5, N_T16, NOTE_D5, N_T16, NOTE_AS5, N_T16, NOTE_D5, N_T16, NOTE_C6, N_T16, NOTE_D5, N_T16, NOTE_AS5, N_T16, NOTE_D5, N_T16,
|
||||
NOTE_A5, N_T16, NOTE_D5, N_T16, NOTE_F5, N_T16, NOTE_D5, N_T16, NOTE_A5, N_T16, NOTE_D5, N_T16, NOTE_G5, N_T16, NOTE_D5, N_T16,
|
||||
NOTE_C6, N_T16, NOTE_C6, N_T16, NOTE_F6, N_T16, NOTE_D6, N_T8, NOTE_REST, N_T16, NOTE_REST, N_T8,
|
||||
|
||||
NOTE_REST, 30,
|
||||
|
||||
NOTE_FS5,N_T8, NOTE_FS5,N_T8,NOTE_D5,N_T8, NOTE_B4,N_T8, NOTE_REST,N_T8, NOTE_B4,N_T8, NOTE_REST,N_T8, NOTE_E5,N_T8,
|
||||
NOTE_REST,N_T8, NOTE_E5,N_T8, NOTE_REST,N_T8, NOTE_E5,N_T8, NOTE_GS5,N_T4, NOTE_A5,N_T8, NOTE_B5,N_T8,
|
||||
NOTE_A5,N_T8, NOTE_A5,N_T8, NOTE_A5,N_T8, NOTE_E5,N_T8, NOTE_REST,N_T8, NOTE_D5,N_T8, NOTE_REST,N_T8, NOTE_FS5,N_T8,
|
||||
NOTE_REST,N_T8, NOTE_FS5,N_T8, NOTE_REST,N_T8, NOTE_FS5,N_T8, NOTE_E5,N_T4, NOTE_FS5,N_T8, NOTE_E5,N_T8,
|
||||
NOTE_FS5,N_T4,NOTE_D5,N_T8, NOTE_B4,N_T8, NOTE_REST,N_T8, NOTE_B4,N_T8, NOTE_REST,N_T8, NOTE_E5,N_T8,
|
||||
|
||||
NOTE_REST,N_T8, NOTE_E5,N_T8, NOTE_REST,N_T8, NOTE_E5,N_T8, NOTE_GS5,N_T4, NOTE_A5,N_T8, NOTE_B5,N_T8,
|
||||
NOTE_A5,N_T4N, NOTE_E5,N_T8, NOTE_REST,N_T8, NOTE_D5,N_T8, NOTE_REST,N_T8, NOTE_FS5,N_T8,
|
||||
NOTE_REST,N_T8, NOTE_FS5,N_T8, NOTE_REST,N_T8, NOTE_FS5,N_T8, NOTE_E5,N_T4, NOTE_FS5,N_T8, NOTE_E5,N_T8,
|
||||
NOTE_FS5,N_T4, NOTE_D5,N_T8, NOTE_B4,N_T8, NOTE_REST,N_T8, NOTE_B4,N_T8, NOTE_REST,N_T8, NOTE_E5,N_T8,
|
||||
NOTE_REST,N_T8, NOTE_E5,N_T8, NOTE_REST,N_T8, NOTE_E5,N_T8, NOTE_GS5,N_T4, NOTE_A5,N_T8, NOTE_B5,N_T8,
|
||||
|
||||
NOTE_A5,N_T4N, NOTE_E5,N_T8, NOTE_REST,N_T8, NOTE_D5,N_T8, NOTE_REST,N_T8, NOTE_FS5,N_T8,
|
||||
NOTE_REST,N_T8, NOTE_FS5,N_T8, NOTE_REST,N_T8, NOTE_FS5,N_T8, NOTE_E5,N_T4, NOTE_FS5,N_T8, NOTE_E5,N_T8,
|
||||
|
||||
NOTE_REST, 30
|
||||
};
|
||||
|
||||
|
||||
static const uint16_t buzzer_tone[] = {
|
||||
160000000/20930, //0 C7 2093.0 Hz 10465
|
||||
160000000/22174, //1 C#7 11087
|
||||
160000000/23492, //2 D7 11746
|
||||
160000000/24890, //3 D#7 12445
|
||||
160000000/26370, //4 E7 13185
|
||||
160000000/27938, //5 F7 13969
|
||||
160000000/29600, //6 F#7 14800
|
||||
160000000/31360, //7 G7 15680
|
||||
160000000/33324, //8 G#7 16662
|
||||
160000000/34400, //9 A7 17200
|
||||
160000000/37292, //A A#7 18646
|
||||
160000000/39510, //B B7 19755
|
||||
160000000/41860, //C C8 20930
|
||||
160000000/44348, //D C#8 22174
|
||||
160000000/46984, //E D8 23492
|
||||
160000000/49780 //F D#8 24890
|
||||
};
|
||||
|
||||
/* tone:
|
||||
* bit[0:3] - Note: 0..15 (C..D#)
|
||||
* bit[4:5] - Octave: 0..3
|
||||
* bit[6:7] - Volume: 0..3
|
||||
*/
|
||||
uint8_t pwm_buzzer_enable = 0;
|
||||
uint16_t pwm_buzzer_note_idx;
|
||||
|
||||
static void set_buzzer_pwm(uint8_t tone) {
|
||||
PWM_DISABLE_CH(PWM_CHL_BUZZER);
|
||||
uint32_t pwmDiv = ((tone >> 4) & 0x3);
|
||||
uint32_t cmpVal = (64 << (tone >> 6)) >> pwmDiv;
|
||||
|
||||
PWM_SET_DIV(PWM_CHL_BUZZER, pwmDiv);
|
||||
// hal_pwm_set_count_val(PWM_CHL_BUZZER, cmpVal, cntTopVal);
|
||||
PWM_NO_LOAD_CH(PWM_CHL_BUZZER);
|
||||
PWM_SET_CMP_VAL(PWM_CHL_BUZZER, cmpVal);
|
||||
PWM_SET_TOP_VAL(PWM_CHL_BUZZER, buzzer_tone[tone & 0x0f]);
|
||||
PWM_LOAD_CH(PWM_CHL_BUZZER);
|
||||
PWM_ENABLE_CH(PWM_CHL_BUZZER);
|
||||
}
|
||||
|
||||
static void pwm_buzzer_note(uint8_t tone) {
|
||||
if(tone == NOTE_REST) {
|
||||
hal_gpio_pull_set(GPIO_BUZZER, GPIO_PULL_UP | BUZZER_ON);
|
||||
hal_gpio_fmux(GPIO_BUZZER, Bit_DISABLE);
|
||||
PWM_DISABLE_ALL;
|
||||
hal_clk_gate_disable(MOD_PWM);
|
||||
hal_pwrmgr_unlock(MOD_PWM);
|
||||
pwm_buzzer_enable = 0;
|
||||
} else {
|
||||
if(!pwm_buzzer_enable) {
|
||||
hal_pwrmgr_register(MOD_PWM, NULL, NULL);
|
||||
hal_pwrmgr_lock(MOD_PWM);
|
||||
hal_clk_gate_enable(MOD_PWM);
|
||||
set_buzzer_pwm(tone);
|
||||
PWM_SET_MODE(PWM_CHL_BUZZER, PWM_CNT_UP);
|
||||
PWM_SET_POL(PWM_CHL_BUZZER, BUZZER_ON);
|
||||
PWM_INSTANT_LOAD_CH(PWM_CHL_BUZZER);
|
||||
|
||||
hal_gpio_pull_set(GPIO_BUZZER, GPIO_FLOATING);
|
||||
hal_gpio_fmux_set(GPIO_BUZZER, (gpio_fmux_e)(FMUX_PWM0 + PWM_CHL_BUZZER));
|
||||
|
||||
PWM_ENABLE_ALL;
|
||||
pwm_buzzer_enable = 1;
|
||||
} else {
|
||||
set_buzzer_pwm(tone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pwm_buzzer_event(void) {
|
||||
pwm_buzzer_note(melody[pwm_buzzer_note_idx*2]);
|
||||
osal_start_timerEx(simpleBLEPeripheral_TaskID, BUZZER_TONE_EVT, melody[pwm_buzzer_note_idx*2 + 1] * NOTE_TEMP);
|
||||
if(++pwm_buzzer_note_idx >= sizeof(melody)/2)
|
||||
pwm_buzzer_note_idx = 0;
|
||||
}
|
||||
|
||||
|
||||
void pwm_buzzer_start(void) {
|
||||
osal_stop_timerEx(simpleBLEPeripheral_TaskID, BUZZER_TONE_EVT);
|
||||
pwm_buzzer_note_idx = 0;
|
||||
pwm_buzzer_event();
|
||||
}
|
||||
|
||||
void pwm_buzzer_stop(void) {
|
||||
PWM_DISABLE_ALL;
|
||||
hal_pwrmgr_unlock(MOD_PWM);
|
||||
hal_clk_gate_disable(MOD_PWM);
|
||||
pwm_buzzer_enable = 0;
|
||||
hal_gpio_pull_set(GPIO_BUZZER, GPIO_PULL_UP | BUZZER_ON);
|
||||
osal_stop_timerEx(simpleBLEPeripheral_TaskID, BUZZER_TONE_EVT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // GPIO_BUZZER
|
||||
16
bthome_phy6222/source/buzzer.h
Normal file
16
bthome_phy6222/source/buzzer.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* buzzer.h
|
||||
*
|
||||
* Created on: 13 дек. 2024 г.
|
||||
* Author: pvvx
|
||||
*/
|
||||
|
||||
#ifndef SOURCE_BUZZER_H_
|
||||
#define SOURCE_BUZZER_H_
|
||||
|
||||
void pwm_buzzer_event(void);
|
||||
void pwm_buzzer_start(void);
|
||||
void pwm_buzzer_stop(void);
|
||||
|
||||
|
||||
#endif /* SOURCE_BUZZER_H_ */
|
||||
|
|
@ -261,6 +261,14 @@ int cmd_parser(uint8_t * obuf, uint8_t * ibuf, uint32_t len) {
|
|||
obuf[1] = 0xff;
|
||||
olen = 2;
|
||||
}
|
||||
#endif
|
||||
#if defined(GPIO_BUZZER) && defined(PWM_CHL_BUZZER)
|
||||
} else if (cmd == CMD_ID_BUZZER) {
|
||||
if(len == 2 && ibuf[1] == 0)
|
||||
pwm_buzzer_stop();
|
||||
else
|
||||
pwm_buzzer_start();
|
||||
olen = 2;
|
||||
#endif
|
||||
} else if (cmd == CMD_ID_SERIAL) {
|
||||
memcpy(&obuf[1], devInfoSerialNumber, sizeof(devInfoSerialNumber)-1);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ typedef enum {
|
|||
CMD_ID_FIX_MAC = 0x11, // Fixed MAC (не безопасная операция, переписывает сектор 0x0 Flash)
|
||||
CMD_ID_BKEY = 0x18, // Get/Set beacon bindkey in EEP
|
||||
CMD_ID_FDMKEY = 0x19, // Get/Set FindMy key in EEP
|
||||
CMD_ID_BUZZER = 0x1A, // Get/Set Buzzer tone
|
||||
CMD_ID_COMFORT = 0x20, // Get/Set comfort parameters
|
||||
CMD_ID_EXTDATA = 0x22, // Get/Set show ext. data
|
||||
CMD_ID_UTC_TIME = 0x23, // Get/Set utc time (if USE_CLOCK = 1)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
#define DEVICE_KEY2 30
|
||||
|
||||
#ifndef DEVICE
|
||||
#define DEVICE DEVICE_THB2
|
||||
#define DEVICE DEVICE_KEY2
|
||||
#endif
|
||||
|
||||
// supported services by the device (bits)
|
||||
|
|
@ -385,6 +385,7 @@
|
|||
#define LED_OFF 0
|
||||
|
||||
#define GPIO_BUZZER GPIO_P09
|
||||
#define PWM_CHL_BUZZER PWM_CH0
|
||||
#define BUZZER_ON 1
|
||||
#define BUZZER_OFF 0
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ typedef struct __attribute__((packed)) _adv_bthome_noencrypt_t {
|
|||
uint8_t end;
|
||||
} adv_findmy_t, * padv_findmy_t;
|
||||
|
||||
static uint8 findmy_head[] = {
|
||||
static const uint8 findmy_head[] = {
|
||||
0x1e, /* Length (30) */
|
||||
0xff, /* Manufacturer Specific Data (type 0xff) */
|
||||
0x4c, 0x00, /* Company ID (Apple) */
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include "OSAL_PwrMgr.h"
|
||||
#include "gatt.h"
|
||||
#include "hci.h"
|
||||
#include "buzzer.h"
|
||||
#include "gapgattserver.h"
|
||||
#include "gattservapp.h"
|
||||
#include "devinfoservice.h"
|
||||
|
|
@ -196,6 +197,8 @@ static void set_serial_number(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern gapPeriConnectParams_t periConnParameters;
|
||||
extern uint16_t gapParameters[];
|
||||
static void set_adv_interval(uint16_t advInt);
|
||||
|
|
@ -320,19 +323,19 @@ static void adv_measure(void) {
|
|||
adv_wrk.new_battery = 0;
|
||||
check_battery();
|
||||
}
|
||||
#ifdef GPIO_BUZZER
|
||||
#if defined(GPIO_BUZZER) && (!defined(PWM_CHL_BUZZER))
|
||||
hal_gpio_write(GPIO_BUZZER, BUZZER_ON);
|
||||
#endif
|
||||
measured_data.count++;
|
||||
#ifdef GPIO_BUZZER
|
||||
#if defined(GPIO_BUZZER) && (!defined(PWM_CHL_BUZZER))
|
||||
hal_gpio_write(GPIO_BUZZER, BUZZER_OFF);
|
||||
#endif
|
||||
LL_SetAdvData(bthome_data_beacon((void *) gapRole_AdvertData), gapRole_AdvertData);
|
||||
#ifdef GPIO_BUZZER
|
||||
#if defined(GPIO_BUZZER) && (!defined(PWM_CHL_BUZZER))
|
||||
hal_gpio_write(GPIO_BUZZER, BUZZER_ON);
|
||||
#endif
|
||||
adv_wrk.adv_event = 0;
|
||||
#ifdef GPIO_BUZZER
|
||||
#if defined(GPIO_BUZZER) && (!defined(PWM_CHL_BUZZER))
|
||||
hal_gpio_write(GPIO_BUZZER, BUZZER_OFF);
|
||||
#endif
|
||||
set_new_adv_interval(DEF_EVENT_ADV_INERVAL);
|
||||
|
|
@ -717,6 +720,12 @@ uint16_t BLEPeripheral_ProcessEvent( uint8_t task_id, uint16_t events )
|
|||
gatrole_advert_enable(TRUE);
|
||||
return ( events ^ SBP_RESET_ADV_EVT );
|
||||
}
|
||||
#if defined(GPIO_BUZZER) && defined(PWM_CHL_BUZZER)
|
||||
if( events & BUZZER_TONE_EVT) {
|
||||
pwm_buzzer_event();
|
||||
return ( events ^ BUZZER_TONE_EVT);
|
||||
}
|
||||
#endif
|
||||
if( events & TIMER_BATT_EVT) {
|
||||
LOG("TIMER_EVT\n");
|
||||
get_utc_time_sec(); // счет UTC timestamp
|
||||
|
|
@ -791,6 +800,10 @@ uint16_t BLEPeripheral_ProcessEvent( uint8_t task_id, uint16_t events )
|
|||
}
|
||||
measured_data.flg.pin_input = 1;
|
||||
} else {
|
||||
#if defined(GPIO_BUZZER) && defined(PWM_CHL_BUZZER)
|
||||
pwm_buzzer_stop();
|
||||
#endif
|
||||
|
||||
// if(measured_data.flg.pin_input)
|
||||
// ev = 1;
|
||||
measured_data.flg.pin_input = 0;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ extern "C"
|
|||
#define ADV_BROADCAST_EVT 0x0020 // Advent. Event Done Notice
|
||||
#define WRK_NOTIFY_EVT 0x0040 // work notify
|
||||
#define PIN_INPUT_EVT 0x0080 // pin input event
|
||||
#define BUZZER_TONE_EVT 0x0100 // Buzzer new tone
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
|
|
|
|||
|
|
@ -949,10 +949,12 @@ function auxControls(state)
|
|||
$('tblButton').style.display = "block";
|
||||
$('trMeasStep').style.display = "none";
|
||||
$('divFindMyKey').style.display = "block";
|
||||
$('tblBuzzer').style.display = "block";
|
||||
} else {
|
||||
$('tblButton').style.display = "none";
|
||||
$('trMeasStep').style.display = "block";
|
||||
$('divFindMyKey').style.display = "none";
|
||||
$('tblBuzzer').style.display = "none";
|
||||
}
|
||||
if (devSrv.services & SERVICE_HISTORY) {
|
||||
$('trHistStep').style.display = "block";
|
||||
|
|
@ -2101,6 +2103,11 @@ function setBindKey() {
|
|||
addLog(`${i18n.getTag('INVALID_BINDKEY_LENGTH')}!`)
|
||||
}
|
||||
}
|
||||
function setBuzzer(m) {
|
||||
if(cmdCharacteristic != null) {
|
||||
cmdCharacteristic.writeValue(new Uint8Array([0x1A,m])).catch(error => { addLog("setBuzzer() Error: " + error); });
|
||||
}
|
||||
}
|
||||
function getGetFindMyKey() {
|
||||
if(cmdCharacteristic != null) {
|
||||
cmdCharacteristic.writeValue(new Uint8Array([0x19,1])).catch(error => { addLog("getFindmyKey() Error: " + error); });
|
||||
|
|
@ -2476,7 +2483,6 @@ window.onload = function() {
|
|||
<td><label><input type="checkbox" id="chkCfgFindMy"/>FindMy</label></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
|
|
@ -2529,6 +2535,12 @@ window.onload = function() {
|
|||
<td><label id="lbDeltaTime"></label></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="tblBuzzer">
|
||||
<tr>
|
||||
<td><button type="button" id="btnBuzzerOn" onclick="setBuzzer(1)">Buzzer On</button></td>
|
||||
<td><button type="button" id="btnBuzzerOOff" onclick="setBuzzer(0)">Buzzer Off</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="hrPres">
|
||||
<hr>
|
||||
<table id="tblComfort">
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue