Browse Source

update

3lead_uart_test_ok_version
zhaohe 1 year ago
parent
commit
02667963f4
  1. 7
      app/main.c
  2. 15
      app/src/basic/ssd1306/driver_ssd1306_basic.c
  3. 3
      app/src/basic/ssd1306/fontlib.c
  4. 2
      app/src/basic/ssd1306/fontlib.h
  5. 7
      app/src/one_conduction/display_manager.c
  6. 11
      app/src/one_conduction/one_conduction_board.c
  7. 6
      app/src/one_conduction/one_conduction_board.h
  8. 141
      app/src/one_conduction/one_conduction_main.c
  9. 2
      libznordic

7
app/main.c

@ -12,7 +12,9 @@
#include "basic/ssd1306/driver_ssd1306_basic.h"
#include "basic\zdatachannel_service.h"
#include "one_conduction/one_conduction_board.h"
#include "one_conduction/one_conduction_main.h"
#include "three_lead\three_lead_board.h"
#if defined(UART_PRESENT)
#include "nrf_uart.h"
#endif
@ -22,5 +24,8 @@
#if 1
void main() { one_conduction_main(); }
int main() {
one_conduction_main();
return 0;
}
#endif

15
app/src/basic/ssd1306/driver_ssd1306_basic.c

@ -519,21 +519,12 @@ uint8_t ssd1306_basic_draw_screen(const char *img) {
for (size_t i = 0; i < 1024; i++) {
gs_handle.gram[i % 128][i / 128] = img[i];
}
return 0;
}
uint8_t ssd1306_basic_gram_update() { ssd1306_gram_update(&gs_handle); }
uint8_t ssd1306_basic_gram_update() { return ssd1306_gram_update(&gs_handle); }
#include "znordic.h"
uint8_t ssd1306_basic_draw_one_chr(uint8_t xs, uint8_t ys, char *str, FontLibrary_t *frontlib) {
uint8_t ssd1306_basic_draw_one_chr(uint8_t xs, uint8_t ys, const char *str, FontLibrary_t *frontlib) {
const uint8_t *frontbuf = NULL;
bool is_ascii = false;
uint8_t charsize = 1;
is_ascii = str_is_ascii(str);
if (is_ascii) {
charsize = 1;
} else {
charsize = 3; // utf8 ±àÂëÖÐÎÄ??3¸ö×Ö??
}
FontLibrary_findchar(frontlib, str, &frontbuf);
if (!frontbuf) return 1;

3
app/src/basic/ssd1306/fontlib.c

@ -7,6 +7,7 @@ uint8_t str_iterator_start(StrIterator_t *iterator, FontCode_t code, const char
iterator->str = chr;
iterator->nowoff = 0;
iterator->code = code;
return 0;
}
uint8_t str_iterator_isend(StrIterator_t *iterator) { return iterator->str[iterator->nowoff] == '\0'; }
void str_iterator_next(StrIterator_t *iterator, const char **nowchr) {
@ -79,4 +80,4 @@ void FontLibrary_findchar(FontLibrary_t *lib, const char *chr, const uint8_t **f
}
}
bool str_is_ascii(uint8_t *chr) { return chr[0] < 0x80; }
bool str_is_ascii(const char *chr) { return chr[0] < 0x80; }

2
app/src/basic/ssd1306/fontlib.h

@ -34,7 +34,7 @@ typedef struct {
uint8_t str_iterator_start(StrIterator_t *iterator, FontCode_t code, const char *chr);
uint8_t str_iterator_isend(StrIterator_t *iterator);
void str_iterator_next(StrIterator_t *iterator, const char **nowchr);
bool str_is_ascii(uint8_t *chr);
bool str_is_ascii(const char *chr);
void FontLibrary_regsiter(FontLibrary_t *lib);
FontLibrary_t *FontLibrary_findlib(FontCode_t fontcode, uint8_t widthPixel, uint8_t heightPixel, bool isAscii);

7
app/src/one_conduction/display_manager.c

@ -39,7 +39,7 @@ uint32_t dsp_mgr_get_page_elapsed_time_s(void) { //
void dsp_mgr_schedule(void) {}
PageState_t* dsp_mgr_get_state(void) {}
PageState_t* dsp_mgr_get_state(void) { return NULL;}
void dsp_mgr_change_to_poweroff() {
/**
@ -61,7 +61,7 @@ void dsp_mgr_change_to_welcome() {
*/
// ssd1306_basic_string(0, 0, "123456789123456789123", 21, 0, SSD1306_FONT_12);
ssd1306_basic_draw_screen(gImage_logo_mono);
ssd1306_basic_draw_screen((const char*)gImage_logo_mono);
ssd1306_basic_gram_update();
dsp_mgr_change_to_page(kPage_welcome);
}
@ -125,8 +125,7 @@ void dsp_mgr_change_to_sampling() { //
wave_drawer_init(&wave_drawer, 1, 1, 120, 40);
wave_drawer_draw_border(&wave_drawer);
uint8_t x = 0;
uint8_t y = 0;
uint8_t xchange, ychange;
ssd1306_basic_draw_progress(1, 47, 80, 8, 50, 30);

11
app/src/one_conduction/one_conduction_board.c

@ -178,13 +178,20 @@ void SingleLeadECG_led_blue_set_state(bool state) {
* ecg *
*******************************************************************************/
/**
* @brief
* PLOD: 01
*/
void SingleLeadECG_ecg_init() {
nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(ECG_ADC_PIN);
channel_config.acq_time = NRF_SAADC_ACQTIME_40US;
ZERROR_CHECK(nrfx_saadc_channel_init(ECG_ADC_CHANNEL, &channel_config));
}
nrf_gpio_cfg_sense_input(ECG_NLOD_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
nrf_gpio_cfg_sense_input(ECG_PLOD_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
void SingleLeadECG_ecg_io_init() {
nrf_gpio_cfg_sense_input(ECG_NLOD_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_NOSENSE);
nrf_gpio_cfg_sense_input(ECG_PLOD_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_NOSENSE);
}
uint32_t SingleLeadECG_ecg_nlod_get_connected_state() { return nrf_gpio_pin_read(ECG_NLOD_PIN); }

6
app/src/one_conduction/one_conduction_board.h

@ -33,7 +33,7 @@ void SingleLeadECG_beep_set_state(bool state);
#define EEPROM_PAGE 256
void SingleLeadECG_eeprom_init();
void SingleLeadECG_eeprom_uninit();
void SingleLeadECG_eeprom_write(uint32_t page, const uint8_t *data, uint16_t len);
void SingleLeadECG_eeprom_write(uint32_t page, const uint8_t* data, uint16_t len);
void SingleLeadECG_eeprom_read(uint32_t add, uint8_t* data, uint16_t len);
/*******************************************************************************
@ -55,6 +55,9 @@ void SingleLeadECG_led_blue_set_state(bool state);
*******************************************************************************/
void SingleLeadECG_ecg_init();
void SingleLeadECG_ecg_io_init();
uint32_t SingleLeadECG_ecg_nlod_get_connected_state();
uint32_t SingleLeadECG_ecg_plod_get_connected_state();
int16_t SingleLeadECG_ecg_plod_get_ecg_val();
@ -62,6 +65,5 @@ int16_t SingleLeadECG_ecg_plod_get_ecg_val();
/*******************************************************************************
* BATTERY *
*******************************************************************************/
void SingleLeadECG_battery_init();
int16_t SingleLeadECG_battery_get_adc_val();

141
app/src/one_conduction/one_conduction_main.c

@ -7,54 +7,107 @@
#include "sample_data_manager.h"
#include "znordic.h"
ZDATACHANNEL_DEF(m_zhrs, 2 /*鍥炶皟浜嬩欢浼樺厛??*/, 1 /*client num*/);
/*******************************************************************************
* GLOBAL *
*******************************************************************************/
ZDATACHANNEL_DEF(m_zhrs, 2 /*优先级*/, 1 /*client num*/); //
APP_TIMER_DEF(m_state_machine_driver_tmr); //
APP_TIMER_DEF(m_plod_state_event_detect_tmr); //
extern uint32_t g_nrf_log_tx_pin;
#define SCHED_MAX_EVENT_DATA_SIZE APP_TIMER_SCHED_EVENT_DATA_SIZE /**< Maximum size of scheduler events. */
typedef enum {
kplod_connected_event = 0, //
kplod_disconnected_event, //
kplod_connecting_event, //
} app_event_type_t;
typedef struct {
app_event_type_t eventType;
union {
uint32_t plod_connected_accumulation_time; //
} val;
} app_event_t;
/*******************************************************************************
* *
*******************************************************************************/
//
static void app_event_process_cb(void* p_event_data, uint16_t event_size);
/*******************************************************************************
* *
*******************************************************************************/
//
static void m_plod_state_event_detect_tmr_cb(void* p_context) { //
static uint32_t connecte_state_trigger_cnt = 0;
static uint32_t connecte_state_trigger_cnt_last_val = 0;
static app_event_t appevent;
memset(&appevent, 0, sizeof(appevent));
connecte_state_trigger_cnt_last_val = connecte_state_trigger_cnt;
if (!SingleLeadECG_ecg_plod_get_connected_state()) {
connecte_state_trigger_cnt++;
} else {
connecte_state_trigger_cnt = 0;
}
if (connecte_state_trigger_cnt == 5) {
//
appevent.eventType = kplod_connected_event;
app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb);
} else if (connecte_state_trigger_cnt_last_val >= 5 && connecte_state_trigger_cnt == 0) {
//
appevent.eventType = kplod_disconnected_event;
app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb);
} else if (connecte_state_trigger_cnt >= 10 && connecte_state_trigger_cnt % 10 == 0) {
//
appevent.eventType = kplod_connecting_event;
appevent.val.plod_connected_accumulation_time = connecte_state_trigger_cnt / 10;
app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb);
}
}
/*******************************************************************************
* TOOLS *
* *
*******************************************************************************/
static void app_event_process_cb(void* p_event_data, uint16_t event_size) {
if (!p_event_data) return;
app_event_t* p_event = (app_event_t*)p_event_data;
if (p_event->eventType == kplod_connected_event) {
ZLOGI("plod connected");
} else if (p_event->eventType == kplod_disconnected_event) {
ZLOGI("plod disconnected");
} else if (p_event->eventType == kplod_connecting_event) {
ZLOGI("plod connecting %d", p_event->val.plod_connected_accumulation_time);
}
}
/**
* @brief
*/
void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
/**
* @brief ??
* @brief
*/
if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length));
}
}
static void test_tx_timer_cb(void* p_context) {
#if 0
/*******************************************************************************
* EEPROM读写测试 *
*******************************************************************************/
sample_data_mgr_init();
static sample_data_filename_t filename = {0x00, 0x02, 0x03, 0x04, 0x05};
static uint8_t wd[256];
static uint8_t rdcache[256];
int fd = sample_data_mgr_open(&filename, kwrflag_write_only);
for (size_t i = 0; i < 10; i++) {
for (size_t j = 0; j < 256; j++) wd[j] = j + i;
sample_data_mgr_write(fd, wd, 256);
}
sample_data_mgr_close(fd);
fd = sample_data_mgr_open(&filename, kwrflag_read_only);
for (size_t i = 0; i < 10; i++) {
sample_data_mgr_read(fd, rdcache, 256);
NRF_LOG_HEXDUMP_INFO(rdcache, 256);
}
sample_data_mgr_dump_fileinfo_list();
sample_data_mgr_uninit();
#endif
/**
* @brief
*/
static void state_machine_driver_tmr_cb(void* p_context) { //
}
extern uint32_t g_nrf_log_tx_pin;
APP_TIMER_DEF(m_drawpoint_timer);
/*******************************************************************************
* INIT *
* MAIN_CODE *
*******************************************************************************/
void on_service_init(void) {
ZLOGI("init zdatachannel service");
@ -65,9 +118,9 @@ void on_service_init(void) {
}
void one_conduction_main() {
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, 20);
g_nrf_log_tx_pin = 41;
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
znordic_init(0, 20);
NRF_LOG_INFO("compile time :%s", __TIME__);
NRF_LOG_INFO("Version :%d", VERSION);
@ -79,17 +132,17 @@ void one_conduction_main() {
.on_service_init = on_service_init,
};
zble_module_init(&cfg);
zble_module_start_adv();
dsp_mgr_init();
dsp_mgr_poweron();
dsp_mgr_change_to_sampling();
// SingleLeadECG_eeprom_write(0, eepromw_test_data, 256);
ZERROR_CHECK(app_timer_create(&m_drawpoint_timer, APP_TIMER_MODE_SINGLE_SHOT, test_tx_timer_cb));
ZERROR_CHECK(app_timer_start(m_drawpoint_timer, APP_TIMER_TICKS(100), NULL));
SingleLeadECG_ecg_io_init();
ZERROR_CHECK(app_timer_create(&m_state_machine_driver_tmr, APP_TIMER_MODE_REPEATED, state_machine_driver_tmr_cb));
ZERROR_CHECK(app_timer_create(&m_plod_state_event_detect_tmr, APP_TIMER_MODE_REPEATED, m_plod_state_event_detect_tmr_cb));
ZERROR_CHECK(app_timer_start(m_plod_state_event_detect_tmr, APP_TIMER_TICKS(100), NULL));
znordic_loop();
}
// ZERROR_CHECK(app_timer_start(m_state_machine_driver_tmr, APP_TIMER_TICKS(5), NULL));
// zble_module_start_adv();
// dsp_mgr_init();
// dsp_mgr_poweron();
// dsp_mgr_change_to_sampling();

2
libznordic

@ -1 +1 @@
Subproject commit e16602d90ecda24a2033df814b5aabf86f360e8b
Subproject commit 1b529960c77d5fd828c1b3c8fcf975ed80de145c
Loading…
Cancel
Save