diff --git a/.vscode/settings.json b/.vscode/settings.json index 76e327d..44c3e63 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -212,7 +212,8 @@ "ecg_data_mgr.h": "c", "mutex": "cpp", "nrf_atomic.h": "c", - "beep_ctrl.h": "c" + "beep_ctrl.h": "c", + "hardware_power_mgr.h": "c" }, "files.encoding": "gbk" } \ No newline at end of file diff --git a/README.md b/README.md index 23e31e8..c152ee4 100644 --- a/README.md +++ b/README.md @@ -1,114 +1,55 @@ # one_lead_ecg ``` -V3: - 1. 添加心率检测 - 2. 添加心率波形自动放大 - 3. 添加充电检测 - 4. 调整UI显示效果 - 5. 调慢心跳动速度 -V4: - 1. 修改单手唤醒改为双手唤醒 -V5: - 1. 在系统启动的初期就初始化看门狗 - 2. 优化静态功耗到300ua - -V6: - 1. 优化显示心电波形效果 - 2. 优化电池电量显示 - -V7: - 1. 优化电池电量显示 - -V8: - 1. 优化心电波形显示 - 2. 优化心率显示 - 3. 解决存储不自动清空的BUG。 - 4. 解决偶尔关机时,设备启动失败的异常。 - 5. 优化电池电量范围 - -V9: - 1.读取头部信息包添加checksum字段,向前兼容 - 2.修正文件系统读取时,读取的数据长度不正确的问题 - 3.修正数据上传时,数据长度不正确的问题 -V10: - 1.修改ify_hrs_protocol版本 - 2.更新SDK版本 - -测试: -1. 电池电量测试 -2. 充电插入检测 -3. 检查各个延时时间是否正确 -... - - -``` -代码修改思路: - -临时版本: - 1. 开机初始化ads129x - 2. 永不进入深度休眠 - 3. ECG连接状态一直标注为1 - 4. 不存储数据 - - -ECG连接状态一直标注为1 - - - -board_init - 1. 没有深度睡眠 - - poweroff - app_power_state_change_to poweroff +开发板功耗测试: + 1. 连接无通信: + (20-75)*1.25 170ua + (50-75)*1.25 100ua - poweron - app_power_state_change_to poweron - + 2. 慢广播: + 8HZ-RTC/2s一次广播 平局功耗18ua,广播时800ua - 服务本身没有低功耗的概念,所有低功耗的操作,均直接对硬件进行操作。 - 服务内部调用方法,都假设初始化已经均完成。 - - 指示灯初始化 - - - onStateChange - onState + 3. 不广播: + 8HZ-RTC 平局功耗11ua 每8s一次500us的高功耗 + 320HZ-RTC 平局功耗71ua 每8s一次500us的高功耗 + + 4. 深度睡眠 : 3ua +最精简程序(不初始化任何外设) + 单导联 3.2v 162ua + 开发板 3ua +... +``` +程序烧录 + .\scripter\build_app.bat ; .\scripter\flash.bat +``` -README: - 外设 ---> 初始化 - 使用 +``` + onTimer + pushEvent. - app_board(在状态切换的时候,切换) - -------> - 切换状态 + onCommand + pushEvent. + onConnect + loadDevice + doSomeThing. + block?how_to_do? - - 实时切换状态并使用 依然归类到整机状态中去 - ------> + onDisconnect + unloadDevice + onCharging - 1. 外设状态 <---> 系统状态绑定 - - 外设临时状态切换 - 调用方法 - + onChargEnd -1. 外设的切换发生在系统状态机的切换: - 1. 外设再被调用时,检查自己的状态,如果状态不满足打印警报或者错误日志。 - 2. 外设再被调用时,检查自己的状态,如果状态不满足,但允许自行切换状态,则自行进行状态切换 - 3. 服务本身不负责状态的切换。 + startCapture + stopCapture -``` -``` -TODO: - 1. 每次蓝牙连接,连接上之后默认关闭预览 ``` \ No newline at end of file diff --git a/app/config/sdk_config.h b/app/config/sdk_config.h index 0286b42..a29e30b 100644 --- a/app/config/sdk_config.h +++ b/app/config/sdk_config.h @@ -1,9 +1,13 @@ #pragma once -#define NRF_LOG_ENABLED 1 -#define NRF_LOG_BACKEND_UART_ENABLED 1 -#define NRF_LOG_BACKEND_UART_TX_PIN 41 +#define NRF_LOG_ENABLED 1 +#define NRF_LOG_BACKEND_UART_ENABLED 1 +#define NRF_LOG_BACKEND_UART_TX_PIN 41 +// #define NRF_LOG_BACKEND_UART_TX_PIN 6 + #define APP_TIMER_CONFIG_USE_SCHEDULER 1 -#define NRF_LOG_BACKEND_UART_BAUDRATE 268435456 +// #define NRF_LOG_BACKEND_UART_BAUDRATE 121634816 // 400800 baud +#define NRF_LOG_BACKEND_UART_BAUDRATE 268435456 // 1000000 baud + +#include "libznordic/zsdk_config/zsdk_ble_slave_config.h" -#include "libznordic/zsdk_config/zsdk_ble_slave_config.h" \ No newline at end of file diff --git a/app/src/_board/ads129x/ads129x.c b/app/src/_board/ads129x/ads129x.c deleted file mode 100644 index a0d613a..0000000 --- a/app/src/_board/ads129x/ads129x.c +++ /dev/null @@ -1,294 +0,0 @@ -#include "ads129x.h" - -#include "ads129x_type.h" -#include "nrf_drv_gpiote.h" -#include "znordic.h" - -/** - * @brief ads129x 使用注意事项 - * - * ads129x SPI 通信格式 - * - * [cmd 8bit] [data nbit] - * - * - * ads129x 支持的指令如下 - * 唤醒 (0x02) - * 待机 (0x04) - * 复位 (0x06) - * 开始转换 (0x08) - * 停止 (0x0A) - * 通道偏移校准 (0x1A) - * 使能数据连续读模式 (0x10) - * 停止数据连续读模式 (0x11) - * 读数据 (0x12) - * 读寄存器 (0x2x) - * 写寄存器 (0x4x) - * - * - * 注意事项: - * 1. 当ads129x处于连续读模式下,寄存器读写指令失效 - * 2. 不进入连续模式下,可以通过[读数据]指令,读取数据,此时寄存器操作指令是有效的 - * - */ - -static ads129x_cfg_t* ads129x_cfg; - -#define ADS129X_CS_SET() nrf_gpio_pin_set(ads129x_cfg->cspin); -#define ADS129X_CS_RESET() nrf_gpio_pin_clear(ads129x_cfg->cspin); -#define ADS129X_START_SET() nrf_gpio_pin_set(ads129x_cfg->startpin); -#define ADS129X_START_RESET() nrf_gpio_pin_clear(ads129x_cfg->startpin); -#define ADS129X_REST_SET() nrf_gpio_pin_set(ads129x_cfg->pwdnpin); -#define ADS129X_REST_RESET() nrf_gpio_pin_clear(ads129x_cfg->pwdnpin); -#define ADS129X_DRDY_GET() nrf_gpio_pin_read(ads129x_cfg->drdypin) - -static void port_ads129x_delay_us(uint32_t us) { nrf_delay_us(us); } -static void port_ads129x_delay_ms(uint32_t ms) { nrf_delay_ms(ms); } - -#define port_delay_ms port_ads129x_delay_ms - -/*********************************************************************************************************************** - * BASE_FUNCTION_IMPL * - ***********************************************************************************************************************/ - -uint8_t port_spi_transmit_receive(uint8_t tx) { - uint8_t data; - nrf_drv_spi_transfer(ads129x_cfg->spi, &tx, 1, &data, 1); - return data; -} - -/* ads129X发送指令 */ -uint8_t ads129x_send_cmd(uint8_t cmd) { - uint8_t rx = 0; - - ADS129X_CS_RESET(); /* 选中设备 */ - port_ads129x_delay_us(100); - - rx = port_spi_transmit_receive(cmd); - - port_ads129x_delay_us(100); - ADS129X_CS_SET(); /* 释放设备 */ - - return rx; -} - -/* ads129X读写寄存器,自动根据指令类型区分读和写操作 */ -uint8_t ads129x_rw_reg(uint8_t cmd, uint8_t data) { - uint8_t rx = 0; - - ADS129X_CS_RESET(); /* 选中设备 */ - port_ads129x_delay_us(1); - - port_spi_transmit_receive(cmd); /* 发送读写指令 */ - port_spi_transmit_receive(0X00); /* 只写一个数据 */ - - if ((cmd & ADS129X_COMMAND_RREG) == ADS129X_COMMAND_RREG) /* 判断指令类型 */ - rx = port_spi_transmit_receive(0X00); /* 返回寄存器值 */ - else - rx = port_spi_transmit_receive(data); /* 写入数值 */ - - port_ads129x_delay_us(1); - ADS129X_CS_SET(); /* 释放设备 */ - - return rx; -} - -/* 从指定寄存器开始读写一定数量的寄存器 */ -void ads129X_write_multiregs(uint8_t reg, uint8_t* ch, uint8_t size) { - uint8_t i; - - ADS129X_CS_RESET(); /* 选中设备 */ - port_ads129x_delay_us(100); - - port_spi_transmit_receive(ADS129X_COMMAND_WREG | reg); - port_ads129x_delay_us(100); - port_spi_transmit_receive(size - 1); - - for (i = 0; i < size; i++) { - port_ads129x_delay_us(100); - port_spi_transmit_receive(*ch); - ch++; - } - - port_ads129x_delay_us(100); - ADS129X_CS_SET(); -} - -/* 从指定寄存器开始读写一定数量的寄存器 */ -void ads129X_read_multiregs(uint8_t reg, uint8_t* ch, uint8_t size) { - uint8_t i; - - ADS129X_CS_RESET(); /* 选中设备 */ - port_ads129x_delay_us(100); - - port_spi_transmit_receive(ADS129X_COMMAND_RREG | reg); - port_ads129x_delay_us(100); - port_spi_transmit_receive(size - 1); - - for (i = 0; i < size; i++) { - port_ads129x_delay_us(100); - *ch = port_spi_transmit_receive(0); - ch++; - } - - port_ads129x_delay_us(100); - ADS129X_CS_SET(); -} - -static void ads129x_readback_regs(ads129x_regs_t* regcache) { ads129X_read_multiregs(ADS129X_REG_ID, (uint8_t*)regcache, sizeof(ads129x_regs_t)); } -static void ads129x_dump_regs(ads129x_regs_t* regcache) { - ZLOGI("id : %x", regcache->id); - ZLOGI("cfg1 : %x", regcache->cfg1); - ZLOGI("cfg2 : %x", regcache->cfg2); - ZLOGI("loff : %x", regcache->loff); - ZLOGI("ch1set : %x", regcache->ch1set); - ZLOGI("ch2set : %x", regcache->ch2set); - ZLOGI("rld_sens : %x", regcache->rld_sens); - ZLOGI("loff_sens : %x", regcache->loff_sens); - ZLOGI("loff_stat : %x", regcache->loff_stat); - ZLOGI("resp1 : %x", regcache->resp1); - ZLOGI("resp2 : %x", regcache->resp2); - ZLOGI("gpio : %x", regcache->gpio); -} - -static bool ads129x_write_regs(ads129x_regs_t* writeval) { - static ads129x_regs_t rdbak; - ads129X_write_multiregs(ADS129X_REG_ID, (uint8_t*)writeval, sizeof(ads129x_regs_t)); - ads129X_read_multiregs(ADS129X_REG_ID, (uint8_t*)&rdbak, sizeof(ads129x_regs_t)); - - writeval->id = 0; - writeval->loff_stat = writeval->loff_stat & (0x01 << 6); - - rdbak.id = 0; - rdbak.loff_stat = rdbak.loff_stat & (0x01 << 6); - - if (memcmp(writeval, &rdbak, sizeof(ads129x_regs_t)) != 0) { - ZLOGE("ads129x_write_reg reg fail"); - return false; - } - ZLOGI("ads129x_write_reg reg success"); - return true; -} - -/*********************************************************************************************************************** - * EXTERN * - ***********************************************************************************************************************/ -void ads129x_read_data_loop() { - // app_timer_pause(); - - // ads129x_capture_data_t capture_data; - // while (true) { - // ads129x_read_data(&capture_data); - // ZLOGI("%d {%d} %x", ADS129X_DRDY_GET(), capture_data.ch1data, capture_data.loffstate); - // znordic_force_flush_log(); - // } -} - -uint8_t ads129x_init(ads129x_cfg_t* cfg) { - /** - * @brief - */ - ads129x_cfg = cfg; - ZASSERT(nrfx_gpiote_is_init()); - - ADS129X_CS_SET(); - - ADS129X_REST_RESET(); - ADS129X_START_RESET(); - port_ads129x_delay_ms(1000); - ADS129X_REST_SET(); - port_ads129x_delay_ms(100); /* 硬件复位 */ - - ads129x_send_cmd(ADS129X_COMMAND_SDATAC); /* 软件复位,并停止连续读状态 */ - port_ads129x_delay_ms(100); - ads129x_send_cmd(ADS129X_COMMAND_RESET); - port_ads129x_delay_ms(1000); - ads129x_send_cmd(ADS129X_COMMAND_SDATAC); - port_ads129x_delay_ms(100); - - static ads129x_regs_t regcache; - ads129x_readback_regs(®cache); - ads129x_dump_regs(®cache); - regcache.cfg1 = 0x02; - regcache.cfg2 = 0xE0; - regcache.loff = 0xF0; - regcache.ch1set = 0x00; - regcache.ch2set = 0x00; - regcache.rld_sens = 0x20; - regcache.loff_sens = 0x03; - ads129x_write_regs(®cache); - - nrf_gpio_pin_set(ads129x_cfg->pwdnpin); - return 0; -} - -uint8_t ads129x_read_reg(uint8_t add) { return ads129x_rw_reg(ADS129X_COMMAND_RREG | add, 0); } - -void ads129x_write_reg(uint8_t add, uint8_t data) { - ZLOGI("ads129x_write_reg %x %x", add, data); - static ads129x_regs_t regcache; - ads129x_readback_regs(®cache); - uint8_t* reg = (uint8_t*)®cache; - reg[add] = data; - ads129x_write_regs(®cache); -} - -uint8_t ads129x_start_capture() { - ads129x_send_cmd(ADS129X_COMMAND_START); /* 发送开始数据转换(等效于拉高START引脚) */ - return 0; -} - -uint8_t ads129x_stop_capture() { - ads129x_send_cmd(ADS129X_COMMAND_STOP); /* 发送停止数据转换(等效于拉低START引脚) */ - return 0; -} - -static int32_t i24toi32(uint8_t* p_i32) { - int32_t rev = 0; - rev = (((int32_t)p_i32[0]) << 16) | (((int32_t)p_i32[1]) << 8) | ((int32_t)p_i32[2]); - if ((p_i32[0] & 0x80) == 0x80) { - rev |= 0xFF000000; - } - return rev; -} - -void ads129x_read_data(ads129x_capture_data_t* capture_data) { - uint8_t rddata[9]; - - ADS129X_CS_RESET(); /* 选中设备 */ - port_ads129x_delay_us(10); - - port_spi_transmit_receive(ADS129X_COMMAND_RDATA); - port_ads129x_delay_us(1); - for (int i = 0; i < 9; i++) { - rddata[i] = port_spi_transmit_receive(0); - } - ADS129X_CS_SET(); - - /** - * @brief - * - * 回读数据格式(datasheet page 42) - * 24bit status (1100 + LOFF_STAT[4:0] + GPIO[1:0] + 13`b0) - * 24bit ch0 MSB - * 24bit ch1 MSB - * - */ - uint32_t status = (((uint32_t)rddata[0]) << 16) | (((uint32_t)rddata[1]) << 8) | ((uint32_t)rddata[2]); - - capture_data->loffstate = (status >> (13 + 2)) & 0x1f; - capture_data->gpio0 = status >> (14); - capture_data->gpio1 = status >> (13); - - capture_data->ch1data = i24toi32(&rddata[3]); - capture_data->ch2data = i24toi32(&rddata[6]); -} - -uint8_t ads129x_get_lead_off_state() { - // FLIP2,FLIP1,LOFF2N,LOFF2P,LOFF1N,LOFF1P - uint8_t leadoffstate = ads129x_read_reg(ADS129X_REG_LOFFSTAT); - return leadoffstate; -} - -uint8_t ads129x_enter_low_power_mode() { return 0; } -uint8_t ads129x_enter_lead_off_detect_mode() { return 0; } diff --git a/app/src/_board/ads129x/ads129x.h b/app/src/_board/ads129x/ads129x.h deleted file mode 100644 index 202ac06..0000000 --- a/app/src/_board/ads129x/ads129x.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif -#include -#include - -#include "znordic.h" -typedef struct { - /** - * @brief - * - * loffstate:[4:0] RLD_STAT IN2N_OFF IN2P_OFF IN1N_OFF IN1P_OFF - * ch1data: 有符号数据 - * ch2data: 有符号数据 - */ - - uint8_t loffstate; - - uint8_t gpio0; - uint8_t gpio1; - - uint32_t ch1data; - uint32_t ch2data; -} ads129x_capture_data_t; - -typedef struct { - nrf_drv_spi_t* spi; - uint32_t cspin; - uint32_t startpin; - uint32_t drdypin; - uint32_t pwdnpin; -} ads129x_cfg_t; - -/** - * @brief 初始化SPI - */ -uint8_t ads129x_init(ads129x_cfg_t* cfg); - -// uint8_t ads129x_start_capture(bool test); -uint8_t ads129x_stop_capture(); -uint8_t ads129x_start_capture(); - -void ads129x_write_reg(uint8_t addr, uint8_t val); -uint8_t ads129x_read_reg(uint8_t addr); - -void ads129x_read_data(ads129x_capture_data_t* rddata); - -uint8_t ads129x_get_lead_off_state(); - -#ifdef __cplusplus -} -#endif diff --git a/app/src/_board/ads129x/ads129x_type.h b/app/src/_board/ads129x/ads129x_type.h deleted file mode 100644 index d3a5cf6..0000000 --- a/app/src/_board/ads129x/ads129x_type.h +++ /dev/null @@ -1,286 +0,0 @@ -#pragma once -#include -#ifdef __cplusplus -extern "C" { -#endif -typedef enum { - ADS129X_REG_ID = 0x00, - ADS129X_REG_CONFIG1 = 0x01, - ADS129X_REG_CONFIG2 = 0x02, - ADS129X_REG_LOFF = 0x03, - ADS129X_REG_CH1SET = 0x04, - ADS129X_REG_CH2SET = 0x05, - ADS129X_REG_RLDSENS = 0x06, - ADS129X_REG_LOFFSENS = 0x07, - ADS129X_REG_LOFFSTAT = 0x08, - ADS129X_REG_RESP1 = 0x09, - ADS129X_REG_RESP2 = 0x0A, - ADS129X_REG_GPIO = 0x0B -} ADS129X_REG_E; - -typedef struct { - uint8_t id; /* id,ads1292r固定为0x73 */ - uint8_t cfg1; /* 设置寄存器 */ - uint8_t cfg2; /* 设置寄存器 */ - uint8_t loff; /* 导联 */ - uint8_t ch1set; /* 通道一设置 */ - uint8_t ch2set; /* 通道二设置 */ - uint8_t rld_sens; /* 右腿驱动 */ - uint8_t loff_sens; /* 导联 */ - uint8_t loff_stat; /* 导联 */ - uint8_t resp1; /* 呼吸 */ - uint8_t resp2; /* 呼吸 */ - uint8_t gpio; /* gpio1,2的控制 */ -} ads129x_regs_t; - -#define ADS129X_REG_SIZE_MAX 12 /* ADS1291寄存器数量 */ -#define ADS129X_ID 0x52 - -/* 属于ADS129X_REG_CONFIG1的寄存器设置 */ -#define ADS129X_SINGLE_SHOT_OFF 0 /* 连续转换模式,默认 */ -#define ADS129X_SINGLE_SHOT_ON 1 /* 单次转换模式 */ -/* 采样率,该模块采用fclk为512k,0分频模式,其他配置下采样率会改变 */ -#define ADS129X_OVERSAMPLING_125SPS 0 -#define ADS129X_OVERSAMPLING_250SPS 1 -#define ADS129X_OVERSAMPLING_500SPS 2 /* 默认 */ -#define ADS129X_OVERSAMPLING_1000SPS 3 -#define ADS129X_OVERSAMPLING_2000SPS 4 -#define ADS129X_OVERSAMPLING_4000SPS 5 -#define ADS129X_OVERSAMPLING_8000SPS 6 -#define ADS129X_OVERSAMPLING_NONESPS 7 - -/* 属于ADS129X_REG_CONFIG2的寄存器设置 */ -#define ADS129X_PDB_LOFF_COMP_OFF 0 /* 导联脱落比较器关,默认 */ -#define ADS129X_PDB_LOFF_COMP_ON 1 /* 导联脱落比较器开 */ -#define ADS129X_PDB_REFBUF_OFF 0 /* 内部参考电压关,默认 */ -#define ADS129X_PDB_REFBUF_ON 1 /* 内部参考电压开 */ -#define ADS129X_VREF_2420MV 0 /* 选择参考电压为2.42v,默认 */ -#define ADS129X_VREF_4033MV 1 /* 选择参考电压为4.033v */ -#define ADS129X_CLK_OUTPUT_OFF 0 /* 时钟输出关,默认 */ -#define ADS129X_CLK_OUTPUT_ON 1 /* 时钟输出开 */ -#define ADS129X_INT_TEST_OFF 0 /* 内部测试电压关,默认 */ -#define ADS129X_INT_TEST_ON 1 /* 内部测试电压开 */ -#define ADS129X_INT_FREQ_DC 0 /* 直流,默认 */ -#define ADS129X_INT_FREQ_AC 1 /* 1HZ方波 */ - -/* 属于ADS129X_REG_LOFF的寄存器设置 */ - -/* 属于ADS129X_REG_CH1SET,与ADS129X_REG_CH2SET的寄存器设置 */ -#define ADS129X_CHx_OFF 1 /* 禁止使用通道一 */ -#define ADS129X_CHx_ON 0 /* 使用通道一,默认 */ - -#define ADS129X_GAIN_6 0 /* 使用通道一6倍增益,默认 */ -#define ADS129X_GAIN_1 1 /* 使用通道一1倍增益 */ -#define ADS129X_GAIN_2 2 /* 使用通道一2倍增益 */ -#define ADS129X_GAIN_3 3 /* 使用通道一3倍增益 */ -#define ADS129X_GAIN_4 4 /* 使用通道一4倍增益 */ -#define ADS129X_GAIN_8 5 /* 使用通道一8倍增益 */ -#define ADS129X_GAIN_12 6 /* 使用通道一12倍增益 */ -/* 选择通道一的输入 */ -#define ADS129X_CHx_INPUT_NORMAL 0 /* 正常电极输入,默认 */ -#define ADS129X_CHx_INPUT_SHORTED 1 /* 短路,测偏执用 */ -#define ADS129X_CHx_INPUT_RLD 2 /* 右腿驱动 */ -/* For channel 1, (MVDDP – MVDDN) is [0.5(AVDD + AVSS)]; for channel 2, (MVDDP – MVDDN) is DVDD / 4. */ -/* For channel 2,VDD / 2 for supply measurement */ -#define ADS129X_CHx_INPUT_MVDD 3 -#define ADS129X_CHx_INPUT_TEMP 4 /* 板载温度 */ -#define ADS129X_CHx_INPUT_TEST 5 /* 内部测试信号 */ -#define ADS129X_CHx_INPUT_RLDDRP 6 -#define ADS129X_CHx_INPUT_RLDDRM 7 -#define ADS129X_CHx_INPUT_RLDDRPM 8 -#define ADS129X_CHx_INPUT_ROUTE 9 /* 连接到通道三 */ -#define ADS129X_CHx_INPUT_RESERVED 10 /* 预留 */ - -/* 属于ADS129X_REG_RLDSENS的寄存器设置 */ -#define ADS129X_CHOP_FREQ_DIV4 3 /* PGA斩波频率未fMOD/4 */ -#define ADS129X_PDB_RLD_OFF 0 /* 右腿驱动电源关,默认 */ -#define ADS129X_PDB_RLD_ON 1 /* 右腿驱动电源开 */ -#define ADS129X_PDB_RLD_SENSE_OFF 0 /* 右腿驱动导联脱落检测关,默认 */ -#define ADS129X_PDB_RLD_SENSE_ON 1 /* 右腿驱动导联脱落检测开 */ -#define ADS129X_RLD2N_OFF 0 /* 通道二负极为右腿输入关,默认 */ -#define ADS129X_RLD2N_ON 1 /* 通道二负极为右腿输入开 */ -#define ADS129X_RLD2P_OFF 0 /* 通道二正极为右腿输入关,默认 */ -#define ADS129X_RLD2P_ON 1 /* 通道二正极为右腿输入开 */ -#define ADS129X_RLD1N_OFF 0 /* 通道一负极为右腿输入关,默认 */ -#define ADS129X_RLD1N_ON 1 /* 通道一负极为右腿输入开 */ -#define ADS129X_RLD1P_OFF 0 /* 通道一正极为右腿输入关,默认 */ -#define ADS129X_RLD1P_ON 1 /* 通道一正极为右腿输入开 */ - -/* 属于ADS129X_REG_LOFFSENS的寄存器设置 */ -#define ADS129X_FLIP2_OFF 0 /* 导联脱落检测通道二电流方向关,默认 */ -#define ADS129X_FLIP2_ON 1 /* 导联脱落检测通道二电流方向开 */ -#define ADS129X_FLIP1_OFF 0 /* 导联脱落检测通道一电流方向关,默认 */ -#define ADS129X_FLIP1_ON 1 /* 导联脱落检测通道一电流方向开 */ -#define ADS129X_LOFF2N_OFF 0 /* 通道二负极导联脱落检测关,默认 */ -#define ADS129X_LOFF2N_ON 1 /* 通道二负极导联脱落检测开 */ -#define ADS129X_LOFF2P_OFF 0 /* 通道二正极导联脱落检测关,默认 */ -#define ADS129X_LOFF2P_ON 1 /* 通道二正极导联脱落检测开 */ -#define ADS129X_LOFF1N_OFF 0 /* 通道一负极导联脱落检测关,默认 */ -#define ADS129X_LOFF1N_ON 1 /* 通道一负极导联脱落检测开 */ -#define ADS129X_LOFF1P_OFF 0 /* 通道一正极导联脱落检测关,默认 */ -#define ADS129X_LOFF1P_ON 1 /* 通道一正极导联脱落检测开 */ - -/* 属于ADS129X_REG_LOFFSTAT的寄存器设置 */ -#define ADS129X_CLK_DIV4 0 /* 0 = fMOD = fCLK / 4 (default, use when fCLK = 512 kHz) */ -#define ADS129X_CLK_DIV16 1 /* 1 = fMOD = fCLK / 16 (use when fCLK = 2.048 MHz) */ - -/* 属于ADS129X_REG_RESP1的寄存器设置 */ -#define ADS129X_DEMOD_EN1_OFF 0 /* 通道一上的呼吸解调电路关,默认 */ -#define ADS129X_DEMOD_EN1_ON 1 /* 通道一上的呼吸解调电路开 */ -#define ADS129X_DEMOD_EN_OFF 0 /* 通道一上的呼吸调制电路关,默认 */ -#define ADS129X_DEMOD_EN_ON 1 /* 通道一上的呼吸调制电路开 */ -#define ADS129X_RESPPH_0 0 /* 解调信号相位偏移0,默认 */ -#define ADS129X_RESPPH_135 0x0c /* 解调信号相位偏移135度 */ -#define ADS129X_RESP_CTRL_INT 0 /* 内部呼吸内部时钟,默认 */ -#define ADS129X_RESP_CTRL_EXT 1 /* 内部呼吸外部时钟 */ - -/* 属于ADS129X_REG_RESP2的寄存器设置 */ -#define ADS129X_CALIB_ON_OFF 0 /* 校准关,默认 */ -#define ADS129X_CALIB_ON_ON 1 /* 校准开 */ -#define ADS129X_RESP_FREQ_36 0 /* 通道一上的呼吸调制电路关,默认 */ -#define ADS129X_RESP_FREQ_64 1 /* 通道一上的呼吸调制电路开 */ -#define ADS129X_RLDREF_EXT 0 /* 右腿驱动参考电压选择外部反馈,默认 */ -#define ADS129X_RLDREF_INT 1 /* 右腿驱动参考电压选择内部信号 */ - -/* 属于ADS129X_REG_GPIO的寄存器设置 */ -/** - * @} - */ - -/** @addtogroup ADS129X_TYP_REG_MASK ADS1291 TYP Reg Mask - * @brief 各寄存器值与位置掩码,被ADS129X_GET_BITS与ADS129X_SET_BITS函数调用 - * @{ - */ -#define ADS129X_ID_POS 0 -#define ADS129X_ID_MASK 0xFF - -#define ADS129X_SINGLE_SHOT_POS 7 -#define ADS129X_SINGLE_SHOT_MASK 0x80 -#define ADS129X_DR_POS 0 -#define ADS129X_DR_MASK 0x07 - -#define ADS129X_PDB_LOFF_COMP_POS 6 -#define ADS129X_PDB_LOFF_COMP_MASK 0x40 -#define ADS129X_PDB_REFBUF_POS 5 -#define ADS129X_PDB_REFBUF_MASK 0x20 -#define ADS129X_VREF_4V_POS 4 -#define ADS129X_VREF_4V_MASK 0x10 -#define ADS129X_CLK_EN_POS 3 -#define ADS129X_CLK_EN_MASK 0x80 -#define ADS129X_INT_TEST_POS 1 -#define ADS129X_INT_TEST_MASK 0x02 -#define ADS129X_INT_FREQ_POS 0 -#define ADS129X_INT_FREQ_MASK 0x01 - -#define ADS129X_PDx_POS 7 -#define ADS129X_PDx_MASK 0x80 -#define ADS129X_GAINx_POS 4 -#define ADS129X_GAINx_MASK 0x70 -#define ADS129X_MUXx_POS 0 -#define ADS129X_MUXx_MASK 0x0F - -#define ADS129X_CHOP_POS 6 -#define ADS129X_CHOP_MASK 0xC0 -#define ADS129X_PDB_RLD_POS 5 -#define ADS129X_PDB_RLD_MASK 0x20 -#define ADS129X_RLD_LOFF_SENSE_POS 4 -#define ADS129X_RLD_LOFF_SENSE_MASK 0x10 -#define ADS129X_RLD2N_POS 3 -#define ADS129X_RLD2N_MASK 0x08 -#define ADS129X_RLD2P_POS 2 -#define ADS129X_RLD2P_MASK 0x04 -#define ADS129X_RLD1N_POS 1 -#define ADS129X_RLD1N_MASK 0x02 -#define ADS129X_RLD1P_POS 0 -#define ADS129X_RLD1P_MASK 0x01 - -#define ADS129X_FLIP2_POS 5 -#define ADS129X_FLIP2_MASK 0x20 -#define ADS129X_FLIP1_POS 4 -#define ADS129X_FLIP1_MASK 0x10 -#define ADS129X_LOFF2N_POS 3 -#define ADS129X_LOFF2N_MASK 0x08 -#define ADS129X_LOFF2P_POS 2 -#define ADS129X_LOFF2P_MASK 0x04 -#define ADS129X_LOFFN_POS 1 -#define ADS129X_LOFF1N_MASK 0x02 -#define ADS129X_LOFF1P_POS 0 -#define ADS129X_LOFF1P_MASK 0x01 - -#define ADS129X_CLK_DIV_POS 6 -#define ADS129X_CLK_DIV_MASK 0x40 - -#define ADS129X_RESP_DEMOD_EN1_POS 7 -#define ADS129X_RESP_DEMOD_EN1_MASK 0x80 -#define ADS129X_RESP_MOD_EN_POS 6 -#define ADS129X_RESP_MOD_EN_MASK 0x40 -#define ADS129X_RESP_PH_POS 2 -#define ADS129X_RESP_PH_MASK 0x3c -#define ADS129X_RESP_CTRL_POS 0 -#define ADS129X_RESP_CTRL_MASK 0x01 - -#define ADS129X_CALIB_ON_POS 7 -#define ADS129X_CALIB_ON_MASK 0x80 -#define ADS129X_RESP_FREQ_POS 2 -#define ADS129X_RESP_FREQ_MASK 0x04 -#define ADS129X_RLDREF_INT_POS 1 -#define ADS129X_RLDREF_INT_MASK 0x02 - -/** - * @} - */ - -/** @addtogroup ADS129X_TYP_COMMAND ADS1291 TYP COMMAND - * @brief 命令 - * @{ - */ -/* System Commands */ -#define ADS129X_COMMAND_WAKEUP 0x02 // Wake-up from standby mode -#define ADS129X_COMMAND_STANDBY 0x04 // Enter standby mode -#define ADS129X_COMMAND_RESET 0x06 // Reset the device -#define ADS129X_COMMAND_START 0x08 // Start or restart (synchronize) conversion -#define ADS129X_COMMAND_STOP 0x0A // Stop conversion -#define ADS129X_COMMAND_OFFSETCAL 0x1A // Channel offset calibration - -/* Data Read Commands */ -#define ADS129X_COMMAND_RDATAC 0x10 // Enable Read Data Continuous mode. This mode is the default mode at power-up.(1) -#define ADS129X_COMMAND_SDATAC 0x11 // Stop Read Data Continuously mode -#define ADS129X_COMMAND_RDATA 0x12 // Read data by command; supports multiple read back - -/* Register Read Commands,最后5位为读写的地址 */ -#define ADS129X_COMMAND_RREG 0x20 // Read n nnnn registers starting at address r rrrr -#define ADS129X_COMMAND_WREG 0x40 // Write n nnnn registers starting at address r rrrr -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/* Exported macro ------------------------------------------------------------*/ -/** @brief 读取ADS1291的指定寄存器的指定位 - * @details - * @param[in] bitname 位名字 - * @param[in] reg 寄存器名字 - * @retval 该位的值 - */ -#define ADS129X_GET_BITS(bitname, reg) ((reg & bitname##_MASK) >> bitname##_POS) - -/** @brief 设置ADS1291的指定寄存器的指定位 - * @details - * @param[in] reg 寄存器名字 - * @param[in] bitname 位名字 - * @param[in] val 要设置的值 - * @retval NONE - */ -#define ADS129X_SET_BITS(reg, bitname, val) ((reg & ~bitname##_MASK) | ((val << bitname##_POS) & bitname##_MASK)) -/* Exported functions --------------------------------------------------------*/ - -#ifdef __cplusplus -} -#endif diff --git a/app/src/_board/board_battery_state.c b/app/src/_board/board_battery_state.c deleted file mode 100644 index 44d1601..0000000 --- a/app/src/_board/board_battery_state.c +++ /dev/null @@ -1,100 +0,0 @@ - -#include "board_battery_state.h" - -#include "app_basic_service/app_event.h" -#include "board_adc_module_ctrl.h" -/******************************************************************************* - * Battery * - *******************************************************************************/ -APP_TIMER_DEF(battery_state_detect_tmr); // -static bool m_battery_is_chargeing = false; // - -static bool battery_get_chargeing_state() { return !nrf_gpio_pin_read(BATTERY_CHARGE_DETECT_PIN); } -static void module_tmr_cb(void *context) { // - bool chargeing_state = battery_get_chargeing_state(); - if (chargeing_state != m_battery_is_chargeing) { - app_event_t event; - memset(&event, 0, sizeof(event)); - if (chargeing_state) { - ZLOGI("battery is charging"); - event.eventType = kbattery_start_charge_event; - } else { - ZLOGI("battery end charging"); - event.eventType = kbattery_end_charge_event; - } - AppEvent_pushEvent(&event); - } - m_battery_is_chargeing = chargeing_state; -} - -void BoardBattery_init() { - /** - * @brief 500ms启动定时器500ms检查一次当前是否正在充电 - */ - nrf_gpio_cfg_sense_input(BATTERY_CHARGE_DETECT_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_NOSENSE); - app_timer_create(&battery_state_detect_tmr, APP_TIMER_MODE_REPEATED, module_tmr_cb); - app_timer_start(battery_state_detect_tmr, APP_TIMER_TICKS(500), NULL); -} -void BoardBattery_load() { BoardAdc_load(); } -void BoardBattery_unload() { BoardAdc_unload(); } - -int16_t BoardBattery_sence_gpio_init_before_sleep() { nrf_gpio_cfg_sense_input(BATTERY_CHARGE_DETECT_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW); } - -int16_t BoardBattery_get_adc_val() { - int16_t val = BoardAdc_get_val(BATTERY_ADC_CHANNEL); - return val; -} -int16_t BoardBattery_get_charging_state() { // - return !nrf_gpio_pin_read(BATTERY_CHARGE_DETECT_PIN); -} - -static int16_t battery_level_filter(int16_t nowlevel) { - static int16_t lastlevel = 0; - if (abs(nowlevel - lastlevel) >= 5) { - lastlevel = nowlevel; - } else if (nowlevel >= 95) { - lastlevel = 100; - } else if (nowlevel <= 5) { - lastlevel = nowlevel; - } - - int16_t retlevel = lastlevel; - retlevel = retlevel / 5 * 5; - return retlevel; -} - -int16_t BoardBattery_get_battery_level() { - static const float maxv = 4.15; - static const float minv = 3.75; - - int16_t rawval = BoardBattery_get_adc_val(); - - float voltage = rawval / 4096.0 * 3.6 / 2.0 * 3; - // if (voltage > maxv) voltage = maxv; - // if (voltage < minv) voltage = minv; - - float percent = (voltage - minv) / (maxv - minv) * 100 + (float)0.1 /*加0.1是为了避免999.999时显示电量为90*/; - int16_t percent_int = (int16_t)percent; - - if (battery_get_chargeing_state()) { - percent_int = percent_int - 10; - } - - if (percent_int < 0) { - percent_int = 0; - } else if (percent_int > 100) { - percent_int = 100; - } - - return battery_level_filter(percent_int); - // return percent_int; -} - -int16_t BoardBattery_selfTest() { - nrf_gpio_cfg_sense_input(BATTERY_CHARGE_DETECT_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW); - BoardAdc_load(); - while (true) { - ZLOGI_BLOCK("adc raw:%d %d", BoardBattery_get_adc_val(), nrf_gpio_pin_read(BATTERY_CHARGE_DETECT_PIN)); - nrf_delay_ms(1000); - } -} diff --git a/app/src/_board/board_battery_state.h b/app/src/_board/board_battery_state.h deleted file mode 100644 index 54825c6..0000000 --- a/app/src/_board/board_battery_state.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include - -#include "aproject_config/config.h" -#include "znordic.h" - -void BoardBattery_init(); -void BoardBattery_load(); -void BoardBattery_unload(); - -int16_t BoardBattery_get_adc_val(); -int16_t BoardBattery_get_battery_level(); // 0->100 -int16_t BoardBattery_get_charging_state(); - -int16_t BoardBattery_sence_gpio_init_before_sleep(); - - -int16_t BoardBattery_selfTest(); - diff --git a/app/src/_board/board_eeprom_driver.c b/app/src/_board/board_eeprom_driver.c deleted file mode 100644 index e1948a5..0000000 --- a/app/src/_board/board_eeprom_driver.c +++ /dev/null @@ -1,133 +0,0 @@ - -#include "board_eeprom_driver.h" - -#include "znordic.h" -// -#include "app_timer.h" -#include "diskio_blkdev.h" -#include "ff.h" -#include "nrf_block_dev_sdc.h" -#include "nrf_delay.h" -#include "nrf_drv_pwm.h" -#include "nrf_drv_saadc.h" -#include "nrf_drv_twi.h" -#include "nrf_drv_wdt.h" -#include "nrf_gpio.h" -// - -#define EEPROM_I2C_SCL_M 15 // I2C SCL引脚 -#define EEPROM_I2C_SDA_M 17 // I2C SDA引脚 -#define EEPROM_I2C_INSTANCE 1 // I2C使用的硬件控制器ID - -/******************************************************************************* - * eeprom * - *******************************************************************************/ -static const nrf_drv_twi_t m_eeprom_twi_master = NRF_DRV_TWI_INSTANCE(EEPROM_I2C_INSTANCE); - -void board_eeprom_init() { - nrf_drv_twi_config_t config = NRF_DRV_TWI_DEFAULT_CONFIG; - - config.scl = EEPROM_I2C_SCL_M; - config.sda = EEPROM_I2C_SDA_M; - config.frequency = NRF_DRV_TWI_FREQ_400K; - ZERROR_CHECK(nrf_drv_twi_init(&m_eeprom_twi_master, &config, NULL, NULL)); - nrf_drv_twi_enable(&m_eeprom_twi_master); -} - -void board_eeprom_uninit() { - nrf_drv_twi_disable(&m_eeprom_twi_master); - nrf_drv_twi_uninit(&m_eeprom_twi_master); -} - -static uint8_t eeprom_cache[EEPROM_PAGE + 2]; - -static void assign_i2c_add(uint32_t add, bool wr, uint8_t *i2cadd, uint8_t *memadd0, uint8_t *memadd1) { - // DEVICE SELECT - // bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 - // 1 0 1 0 E2 A17 A16 RW(W=0) - // - // PS: E2 参考原理图中的电平为0,所以bit3为0 - // - // MEM0 - // bit15 bit14 bit13 bit12 bit11 bit10 bit9 bit8 - // MEM1 - // bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 - // - - *i2cadd = 0xA0; - uint8_t a16a17 = (add >> 16) & 0x03; - *i2cadd |= a16a17 << 1; - *i2cadd = *i2cadd >> 1; - - *memadd0 = add >> 8; - *memadd1 = add & 0xFF; -} - -void board_eeprom_write(uint32_t addr, const uint8_t *data, uint16_t len) { // - // uint32_t addr = page * EEPROM_PAGE; - // len = len > EEPROM_PAGE ? EEPROM_PAGE : len; - - // ZASSERT(len == EEPROM_PAGE); - ZASSERT((addr % EEPROM_PAGE) == 0); - // ZLOGI_BLOCK("eeprom_write %d %d", addr, len); - uint8_t deviceSelect = 0; - - assign_i2c_add(addr, true, &deviceSelect, &eeprom_cache[0], &eeprom_cache[1]); - memcpy(&eeprom_cache[2], data, len); - - ret_code_t ecode = nrf_drv_twi_tx(&m_eeprom_twi_master, deviceSelect, eeprom_cache, len + 2, false); - if (ecode != NRF_SUCCESS) { - ZLOGE("nrf_drv_twi_tx error %x", ecode); - NRF_LOG_INTERNAL_FLUSH(); - } -} -/** - * @brief 用来检测读取整个eeprom是否正常 - */ -void board_eeprom_wr_check() { - /** - * @brief - * 256kbyte - * 写入数据,回读检查数据是否正确 - */ - - static uint8_t wdata_cache[256]; - static uint8_t rdata_cache[256]; -#define CHECKCODE (i % 21) - - for (uint32_t i = 0; i < 1024; i++) { - uint32_t addr = i * EEPROM_PAGE; - for (uint32_t j = 0; j < EEPROM_PAGE; j++) { - wdata_cache[j] = CHECKCODE; - } - ZLOGI_BLOCK("write %d", i); - board_eeprom_write(addr, wdata_cache, EEPROM_PAGE); - nrf_delay_ms(15); - } - - for (uint32_t i = 0; i < 1024; i++) { - uint32_t addr = i * EEPROM_PAGE; - ZLOGI_BLOCK("check %d", i); - board_eeprom_read(addr, rdata_cache, EEPROM_PAGE); - for (uint32_t j = 0; j < EEPROM_PAGE; j++) { - if (rdata_cache[j] != (CHECKCODE)) { - ZLOGE("eeprom_wr_check error %d %d %d", i, j, rdata_cache[j]); - } - } - } - ZLOGD_BLOCK("eeprom_wr_check ok,block here"); - while (true) { - nrf_delay_ms(10); - } -} - -void board_eeprom_read(uint32_t add, uint8_t *data, uint16_t len) { - uint8_t deviceSelect = 0; - uint8_t wadd[2] = {0}; - - assign_i2c_add(add, false, &deviceSelect, &wadd[0], &wadd[1]); - nrf_drv_twi_tx(&m_eeprom_twi_master, deviceSelect, wadd, 2, false); - - deviceSelect |= 0x01; // read - nrf_drv_twi_rx(&m_eeprom_twi_master, deviceSelect, data, len); -} diff --git a/app/src/_board/board_eeprom_driver.h b/app/src/_board/board_eeprom_driver.h deleted file mode 100644 index 27910bc..0000000 --- a/app/src/_board/board_eeprom_driver.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -/******************************************************************************* - * INCLUDE * - *******************************************************************************/ -#include -#include "znordic.h" - -/** - * - * PageSize 256byte - * - */ -#define EEPROM_PAGE 256 -void board_eeprom_init(); -void board_eeprom_uninit(); -void board_eeprom_write(uint32_t page, const uint8_t* data, uint16_t len); -void board_eeprom_read(uint32_t add, uint8_t* data, uint16_t len); - -void board_eeprom_wr_check(); \ No newline at end of file diff --git a/app/src/_board/board_light_ctrl.c b/app/src/_board/board_light_ctrl.c deleted file mode 100644 index 0bc64ea..0000000 --- a/app/src/_board/board_light_ctrl.c +++ /dev/null @@ -1,213 +0,0 @@ -#include "board_light_ctrl.h" -#include "aproject_config/config.h" -#include "znordic.h" -#include "nrf_gpio.h" - -#define BLINK_CNT 1 -#define BLINK_PERIOD_MS (100) -#define QUICK_BLINK_PERIOD_MS (100) -#define SLOW_BLINK_PERIOD_MS (2000) -// LED_GREEN_PIN -#if 0 -typedef struct { - nrf_drv_pwm_t driver; - nrf_pwm_values_individual_t seq_values; - nrf_pwm_sequence_t seq; - nrf_drv_pwm_config_t config; -} pwm_light_ctrl_t; -static pwm_light_ctrl_t light_ctrl = { - .driver = NRF_DRV_PWM_INSTANCE(LIGHT_PWM_INSTANCE), - .seq_values = {0}, - .seq = - { - .values.p_individual = &light_ctrl.seq_values, - .length = NRF_PWM_VALUES_LENGTH(light_ctrl.seq_values), - .repeats = 0, - .end_delay = 0, - }, - .config = - { - - .output_pins = - { - LED_BLUE_PIN, // - NRF_DRV_PWM_PIN_NOT_USED, - NRF_DRV_PWM_PIN_NOT_USED, - NRF_DRV_PWM_PIN_NOT_USED, - }, - .irq_priority = APP_IRQ_PRIORITY_LOWEST, - .base_clock = NRF_PWM_CLK_250kHz, - .count_mode = NRF_PWM_MODE_UP, - .top_value = 100, // 125kHz / 46 = 2.717k - .load_mode = NRF_PWM_LOAD_INDIVIDUAL, - .step_mode = NRF_PWM_STEP_AUTO, - - }, -}; - -static LightEffect_t m_light_effect; -static bool m_led_green_light_state; -static int m_blink_cnt; -APP_TIMER_DEF(m_green_light_effect_tmr); - -static bool m_boardlight_greenlightstate = false; - -void BoardLight_toggleGreenLightState() { BoardLight_setGreenLightState(!m_boardlight_greenlightstate); } -void BoardLight_setGreenLightState(bool state) { - m_boardlight_greenlightstate = state; - if (state) { - light_ctrl.seq_values.channel_0 = 90; // 设置占空比,数值最大不超过 top_value - nrfx_pwm_simple_playback(&light_ctrl.driver, &light_ctrl.seq, 1, NRF_DRV_PWM_FLAG_LOOP); - } else { - nrfx_pwm_stop(&light_ctrl.driver, true); - } -} - -static void BoardLight_effect_tmr_handler(void* p_context) { // - if (m_light_effect == kLightEffect_close) { - if (m_led_green_light_state) { - BoardLight_setGreenLightState(false); - } - } else if (m_light_effect == kLightEffect_open) { - if (!m_led_green_light_state) { - BoardLight_setGreenLightState(true); - } - } else if (m_light_effect == kLightEffect_slowFlash) { - if (m_blink_cnt < 2) { - if (m_blink_cnt % 2 == 0) { - BoardLight_setGreenLightState(true); - } else if (m_blink_cnt % 2 == 1) { - BoardLight_setGreenLightState(false); - } - } else { - if (BLINK_PERIOD_MS * m_blink_cnt >= SLOW_BLINK_PERIOD_MS) { - m_blink_cnt = 0; - return; - } - } - } else if (m_light_effect == kLightEffect_quickFlash) { - if (BLINK_PERIOD_MS * m_blink_cnt >= QUICK_BLINK_PERIOD_MS) { - BoardLight_toggleGreenLightState(); - m_blink_cnt = 0; - return; - } - } - m_blink_cnt++; -} - -void BoardLight_Init() { - ZERROR_CHECK(app_timer_create(&m_green_light_effect_tmr, APP_TIMER_MODE_REPEATED, BoardLight_effect_tmr_handler)); -} -static bool m_boardlight_loaded = false; - -void BoardLight_load() { - // if (m_boardlight_loaded) { - // return; - // } - // m_boardlight_loaded = true; - nrfx_pwm_init(&light_ctrl.driver, &light_ctrl.config, NULL); - BoardLight_setGreenLightState(false); -} -void BoardLight_unload() { - // if (!m_boardlight_loaded) { - // return; - // } - m_boardlight_loaded = false; - BoardLight_setGreenLightEffect(kLightEffect_close); - nrfx_pwm_uninit(&light_ctrl.driver); -} - -void BoardLight_setGreenLightEffect(LightEffect_t effect) { - if (m_light_effect == effect) return; - m_light_effect = effect; - - switch (effect) { - case kLightEffect_close: - app_timer_stop(m_green_light_effect_tmr); - BoardLight_setGreenLightState(false); - break; - case kLightEffect_open: - app_timer_stop(m_green_light_effect_tmr); - BoardLight_setGreenLightState(true); - break; - case kLightEffect_slowFlash: - app_timer_start(m_green_light_effect_tmr, APP_TIMER_TICKS(BLINK_PERIOD_MS), NULL); - break; - case kLightEffect_quickFlash: - app_timer_start(m_green_light_effect_tmr, APP_TIMER_TICKS(BLINK_PERIOD_MS), NULL); - break; - default: - break; - } - return; -} - -void BoardLight_blockFlash(int times, int periodms) { - for (int i = 0; i < times; i++) { - BoardLight_setGreenLightState(true); - nrf_delay_ms(periodms); - BoardLight_setGreenLightState(false); - nrf_delay_ms(periodms); - } -} - -#endif - -void BoardLight_Init() { - // LED_GREEN_PIN - // LED_BLUE_PIN - // LED_RED_PIN - - znrf_gpio_cfg_output(LED_GREEN_PIN, NRF_GPIO_PIN_NOPULL); - znrf_gpio_cfg_output(LED_BLUE_PIN, NRF_GPIO_PIN_NOPULL); - znrf_gpio_cfg_output(LED_RED_PIN, NRF_GPIO_PIN_NOPULL); -} -void BoardLight_load() {} -void BoardLight_unload() {} - -void BoardLight_setGreenLightState(bool state) { - if (state) { - nrf_gpio_pin_set(LED_GREEN_PIN); - } else { - nrf_gpio_pin_clear(LED_GREEN_PIN); - } -} -void BoardLight_setRedLightState(bool state) { - if (state) { - nrf_gpio_pin_set(LED_RED_PIN); - } else { - nrf_gpio_pin_clear(LED_RED_PIN); - } -} -void BoardLight_setBlueLightState(bool state) { - if (state) { - nrf_gpio_pin_set(LED_BLUE_PIN); - } else { - nrf_gpio_pin_clear(LED_BLUE_PIN); - } -} - -void BoardLight_toggleGreenLightState() {} - -void BoardLight_setGreenLightEffect(LightEffect_t effect) {} -void BoardLight_blockFlash(int times, int periodms) {} - -void BoardLight_selftest() { - BoardLight_Init(); - while (true) { - BoardLight_setGreenLightState(true); - nrf_delay_ms(1000); - BoardLight_setGreenLightState(false); - nrf_delay_ms(1000); - - BoardLight_setRedLightState(true); - nrf_delay_ms(1000); - BoardLight_setRedLightState(false); - nrf_delay_ms(1000); - - BoardLight_setBlueLightState(true); - nrf_delay_ms(1000); - BoardLight_setBlueLightState(false); - nrf_delay_ms(1000); - } -} diff --git a/app/src/_board/board_light_ctrl.h b/app/src/_board/board_light_ctrl.h deleted file mode 100644 index 31ed0a4..0000000 --- a/app/src/_board/board_light_ctrl.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include -#include - -#include "aproject_config/config.h" - -typedef enum { - kLightEffect_unset, - kLightEffect_close, - kLightEffect_open, - kLightEffect_slowFlash, - kLightEffect_quickFlash, -} LightEffect_t; - -void BoardLight_Init(); // main中初始化一遍 -void BoardLight_load(); -void BoardLight_unload(); - -void BoardLight_setGreenLightState(bool state); -void BoardLight_setRedLightState(bool state); -void BoardLight_setBlueLightState(bool state); - -void BoardLight_toggleGreenLightState(); - - -void BoardLight_setGreenLightEffect(LightEffect_t effect); -void BoardLight_blockFlash(int times, int periodms); - - -void BoardLight_selftest(); diff --git a/app/src/_board/board_power_mgr.c b/app/src/_board/board_power_mgr.c deleted file mode 100644 index 0d16e16..0000000 --- a/app/src/_board/board_power_mgr.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "board_power_mgr.h" - -#define SCREEN_RESET_PIN 7 - -void board_power_mgr_init() { // - znrf_gpio_cfg_output(SCREEN_RESET_PIN, NRF_GPIO_PIN_NOPULL); -} - -void board_power_mgr_deinit() { // - nrf_gpio_cfg_default(SCREEN_RESET_PIN); -} -void board_power_mgr_main_power_supply_set(bool val) { - if (val) { - nrf_gpio_pin_set(SCREEN_RESET_PIN); - } else { - nrf_gpio_pin_clear(SCREEN_RESET_PIN); - } -} diff --git a/app/src/_board/board_power_mgr.h b/app/src/_board/board_power_mgr.h deleted file mode 100644 index 973879a..0000000 --- a/app/src/_board/board_power_mgr.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -/******************************************************************************* - * INCLUDE * - *******************************************************************************/ -#include - -#include "znordic.h" - -void board_power_mgr_init(); -void board_power_mgr_deinit(); -void board_power_mgr_main_power_supply_set(bool val); \ No newline at end of file diff --git a/app/src/_board/board_ssd1306_interface.c b/app/src/_board/board_ssd1306_interface.c deleted file mode 100644 index f914fb6..0000000 --- a/app/src/_board/board_ssd1306_interface.c +++ /dev/null @@ -1,98 +0,0 @@ -#include "board_ssd1306_interface.h" - -#include - -#include "znordic.h" -// -#include "app_timer.h" -#include "ff.h" -#include "nrf_block_dev_sdc.h" -#include "nrf_delay.h" -#include "nrf_gpio.h" -// -#include "ssd1306/driver_ssd1306.h" -#include "ssd1306/driver_ssd1306_basic.h" -#include "ssd1306/driver_ssd1306_interface.h" - -#define SCREEN_SPI_INSTANCE 0 -#define SCREEN_RESET_PIN 20 -#define SCREEN_POWER_PIN 30 -#define SCREEN_A0PIN 31 -#define SCREEN_CS_PIN 29 -#define SCREEN_CLK_PIN 4 -#define SCREEN_MOSI_PIN 11 - -/******************************************************************************* - * SCREEN * - *******************************************************************************/ - -static const nrf_drv_spi_t m_screen_spi = NRF_DRV_SPI_INSTANCE(SCREEN_SPI_INSTANCE); /**< SPI instance. */ - -void board_screen_init() { - znrf_gpio_cfg_output(SCREEN_RESET_PIN, NRF_GPIO_PIN_NOPULL); - znrf_gpio_cfg_output(SCREEN_POWER_PIN, NRF_GPIO_PIN_NOPULL); - znrf_gpio_cfg_output(SCREEN_A0PIN, NRF_GPIO_PIN_NOPULL); - - nrf_gpio_pin_set(SCREEN_POWER_PIN); - // 参考 - // OLED驱动程序 : https://iflytop1.feishu.cn/wiki/OQ4Iwv0DpiQDJvkjftjcQHJBnCg - // nRF5_SDK-使用手册: https://iflytop1.feishu.cn/wiki/ThaAwZEGVi2bspkfGU9cbl9Enqd - nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG; - spi_config.ss_pin = SCREEN_CS_PIN; // NRF_DRV_SPI_PIN_NOT_USED - spi_config.miso_pin = NRF_DRV_SPI_PIN_NOT_USED; - spi_config.mosi_pin = SCREEN_MOSI_PIN; - spi_config.sck_pin = SCREEN_CLK_PIN; - spi_config.frequency = NRF_DRV_SPI_FREQ_8M; - spi_config.mode = NRF_DRV_SPI_MODE_3; - ZERROR_CHECK(nrf_drv_spi_init(&m_screen_spi, &spi_config, NULL, NULL)); - ssd1306_basic_init(SSD1306_INTERFACE_SPI, SSD1306_ADDR_SA0_0); -} - -void board_screen_deinit() { - nrf_gpio_cfg_default(SCREEN_RESET_PIN); - nrf_gpio_cfg_default(SCREEN_POWER_PIN); - nrf_gpio_cfg_default(SCREEN_A0PIN); - - ssd1306_basic_deinit(); - nrf_drv_spi_uninit(&m_screen_spi); -} - -uint8_t board_screen_spi_write_cmd(uint8_t *buf, uint16_t len) { // - ZERROR_CHECK(nrf_drv_spi_transfer(&m_screen_spi, buf, len, NULL, 0)); - return 0; -} -void board_screen_delay_ms(uint32_t ms) { nrf_delay_ms(ms); } -uint8_t board_spi_cmd_data_gpio_write(uint8_t value) { - if (value) { - nrf_gpio_pin_set(SCREEN_A0PIN); - } else { - nrf_gpio_pin_clear(SCREEN_A0PIN); - } - return 0; -} -uint8_t board_reset_gpio_write(uint8_t value) { - if (value) { - nrf_gpio_pin_set(SCREEN_RESET_PIN); - } else { - nrf_gpio_pin_clear(SCREEN_RESET_PIN); - } - return 0; -} - -/*********************************************************************************************************************** - * 对接 * - ***********************************************************************************************************************/ -uint8_t ssd1306_interface_iic_init(void) { return 0; } -uint8_t ssd1306_interface_iic_deinit(void) { return 0; } -uint8_t ssd1306_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len) { return 0; } -uint8_t ssd1306_interface_spi_init(void) { return 0; } -uint8_t ssd1306_interface_spi_deinit(void) { return 0; } -uint8_t ssd1306_interface_spi_write_cmd(uint8_t *buf, uint16_t len) { return board_screen_spi_write_cmd(buf, len); } -void ssd1306_interface_delay_ms(uint32_t ms) { board_screen_delay_ms(ms); } -void ssd1306_interface_debug_print(const char *const fmt, ...) {} -uint8_t ssd1306_interface_spi_cmd_data_gpio_init(void) { return 0; } -uint8_t ssd1306_interface_spi_cmd_data_gpio_deinit(void) { return 0; } -uint8_t ssd1306_interface_spi_cmd_data_gpio_write(uint8_t value) { return board_spi_cmd_data_gpio_write(value); } -uint8_t ssd1306_interface_reset_gpio_init(void) { return 0; } -uint8_t ssd1306_interface_reset_gpio_deinit(void) { return 0; } -uint8_t ssd1306_interface_reset_gpio_write(uint8_t value) { return board_reset_gpio_write(value); } diff --git a/app/src/_board/board_ssd1306_interface.h b/app/src/_board/board_ssd1306_interface.h deleted file mode 100644 index bbb2c9b..0000000 --- a/app/src/_board/board_ssd1306_interface.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -/******************************************************************************* - * INCLUDE * - *******************************************************************************/ -#include - -#include "znordic.h" -#include "board/ssd1306/driver_ssd1306.h" -#include "board/ssd1306/driver_ssd1306_basic.h" -#include "board/ssd1306/wave_drawer.h" - - -void board_screen_init(); -void board_screen_deinit(); diff --git a/app/src/_board/soc_public_res_mgr.c b/app/src/_board/soc_public_res_mgr.c deleted file mode 100644 index e69de29..0000000 diff --git a/app/src/_board/soc_public_res_mgr.h b/app/src/_board/soc_public_res_mgr.h deleted file mode 100644 index 6f70f09..0000000 --- a/app/src/_board/soc_public_res_mgr.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/app/src/_board/ssd1306/driver_ssd1306.c b/app/src/_board/ssd1306/driver_ssd1306.c deleted file mode 100644 index ba880cb..0000000 --- a/app/src/_board/ssd1306/driver_ssd1306.c +++ /dev/null @@ -1,2353 +0,0 @@ -/** - * Copyright (c) 2015 - present LibDriver All rights reserved - * - * The MIT License (MIT) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * @file driver_ssd1306.c - * @brief driver ssd1306 source file - * @version 2.0.0 - * @author Shifeng Li - * @date 2021-03-30 - * - *

history

- * - *
Date Version Author Description - *
2021/03/30 2.0 Shifeng Li format the code - *
2020/12/10 1.0 Shifeng Li first upload - *
- */ - -#include "driver_ssd1306.h" -#include "driver_ssd1306_font.h" - -/** - * @brief chip information definition - */ -#define CHIP_NAME "Solomon Systech SSD1306" /**< chip name */ -#define MANUFACTURER_NAME "Solomon Systech" /**< manufacturer name */ -#define SUPPLY_VOLTAGE_MIN 1.65f /**< chip min supply voltage */ -#define SUPPLY_VOLTAGE_MAX 3.3f /**< chip max supply voltage */ -#define MAX_CURRENT 0.78f /**< chip max current */ -#define TEMPERATURE_MIN -40.0f /**< chip min operating temperature */ -#define TEMPERATURE_MAX 85.0f /**< chip max operating temperature */ -#define DRIVER_VERSION 2000 /**< driver version */ - -/** - * @brief chip command data definition - */ -#define SSD1306_CMD 0 /**< command */ -#define SSD1306_DATA 1 /**< data */ - -/** - * @brief chip command definition - */ -#define SSD1306_CMD_LOWER_COLUMN_START_ADDRESS 0x00 /**< command lower column start address */ -#define SSD1306_CMD_HIGHER_COLUMN_START_ADDRESS 0x10 /**< command higher column start address */ -#define SSD1306_CMD_MEMORY_ADDRESSING_MODE 0x20 /**< command memory addressing mode */ -#define SSD1306_CMD_SET_COLUMN_ADDRESS 0x21 /**< command set column address */ -#define SSD1306_CMD_SET_PAGE_ADDRESS 0x22 /**< command set page address */ -#define SSD1306_CMD_SET_FADE_OUT_AND_BLINKING 0x23 /**< command set fade out and blinking */ -#define SSD1306_CMD_RIGHT_HORIZONTAL_SCROLL 0x26 /**< command right horizontal scroll */ -#define SSD1306_CMD_LEFT_HORIZONTAL_SCROLL 0x27 /**< command left horizontal scroll */ -#define SSD1306_CMD_VERTICAL_RIGHT_HORIZONTAL_SCROLL 0x29 /**< command vertical right horizontal scroll */ -#define SSD1306_CMD_VERTICAL_LEFT_HORIZONTAL_SCROLL 0x2A /**< command vertical left horizontal scroll */ -#define SSD1306_CMD_DEACTIVATE_SCROLL 0x2E /**< command deactivate scroll */ -#define SSD1306_CMD_ACTIVATE_SCROLL 0x2F /**< command activate scroll */ -#define SSD1306_CMD_DISPLAY_START_LINE 0x40 /**< command display start line */ -#define SSD1306_CMD_CONTRAST_CONTROL 0x81 /**< command contrast control */ -#define SSD1306_CMD_CHARGE_PUMP_SETTING 0x8D /**< command charge pump setting */ -#define SSD1306_CMD_COLUMN_0_MAPPED_TO_SEG0 0xA0 /**< command column 0 mapped to seg 0 */ -#define SSD1306_CMD_COLUMN_127_MAPPED_TO_SEG0 0xA1 /**< command column 127 mapped to seg 0 */ -#define SSD1306_CMD_VERTICAL_SCROLL_AREA 0xA3 /**< command vertical scroll area */ -#define SSD1306_CMD_ENTIRE_DISPLAY_OFF 0xA4 /**< command entire display off */ -#define SSD1306_CMD_ENTIRE_DISPLAY_ON 0xA5 /**< command entire display on */ -#define SSD1306_CMD_NORMAL_DISPLAY 0xA6 /**< command normal display */ -#define SSD1306_CMD_INVERSE_DISPLAY 0xA7 /**< command inverse display */ -#define SSD1306_CMD_MULTIPLEX_RATIO 0xA8 /**< command multiplex ratio */ -#define SSD1306_CMD_DISPLAY_OFF 0xAE /**< command display off */ -#define SSD1306_CMD_DISPLAY_ON 0xAF /**< command display on */ -#define SSD1306_CMD_PAGE_ADDR 0xB0 /**< command page address */ -#define SSD1306_CMD_SCAN_DIRECTION_COM0_START 0xC0 /**< command scan direction com 0 start */ -#define SSD1306_CMD_SCAN_DIRECTION_COMN_1_START 0xC8 /**< command scan direction com n-1 start */ -#define SSD1306_CMD_DISPLAY_OFFSET 0xD3 /**< command display offset */ -#define SSD1306_CMD_DISPLAY_CLOCK_DIVIDE 0xD5 /**< command display clock divide */ -#define SSD1306_CMD_SET_ZOOM_IN 0xD6 /**< command set zoom in */ -#define SSD1306_CMD_PRE_CHARGE_PERIOD 0xD9 /**< command pre charge period */ -#define SSD1306_CMD_COM_PINS_CONF 0xDA /**< command com pins conf */ -#define SSD1306_CMD_COMH_DESLECT_LEVEL 0xDB /**< command comh deslect level */ -#define SSD1306_CMD_NOP 0xE3 /**< command nop */ - -/** - * @brief write one byte - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] data is the write data - * @param[in] cmd is the command or data type - * @return status code - * - 0 success - * - 1 write failed - * @note none - */ -static uint8_t a_ssd1306_write_byte(ssd1306_handle_t *handle, uint8_t data, uint8_t cmd) -{ - uint8_t res; - - if (handle->iic_spi == SSD1306_INTERFACE_IIC) /* if iic */ - { - if (cmd != 0) /* if data */ - { - if (handle->iic_write(handle->iic_addr, 0x40, &data, 1) != 0) /* write data */ - { - return 1; /* return error */ - } - else - { - return 0; /* success return 0 */ - } - } - else - { - if (handle->iic_write(handle->iic_addr, 0x00, &data, 1) != 0) /* write command */ - { - return 1; /* return error */ - } - else - { - return 0; /* success return 0 */ - } - } - } - else if (handle->iic_spi == SSD1306_INTERFACE_SPI) /* if spi */ - { - res = handle->spi_cmd_data_gpio_write(cmd); /* write data command */ - if (res != 0) /* check error */ - { - return 1; /* return error */ - } - - if (handle->spi_write_cmd(&data, 1) != 0) /* write command */ - { - return 1; /* return error */ - } - else - { - return 0; /* success return 0 */ - } - } - else - { - return 1; /* return error */ - } -} - -/** - * @brief write multiple bytes - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] *data points to a data buffer - * @param[in] len is the data length - * @param[in] cmd is the command or data type - * @return status code - * - 0 success - * - 1 write failed - * @note none - */ -static uint8_t a_ssd1306_multiple_write_byte(ssd1306_handle_t *handle, uint8_t *data, uint8_t len, uint8_t cmd) -{ - uint8_t res; - - if (handle->iic_spi == SSD1306_INTERFACE_IIC) /* if iic */ - { - if (cmd != 0) /* if data */ - { - if (handle->iic_write(handle->iic_addr, 0x40, data, len) != 0) /* write data */ - { - return 1; /* return error */ - } - else - { - return 0; /* success return 0 */ - } - } - else - { - if (handle->iic_write(handle->iic_addr, 0x00, data, len) != 0) /* write command */ - { - return 1; /* return error */ - } - else - { - return 0; /* success return 0 */ - } - } - } - else if (handle->iic_spi == SSD1306_INTERFACE_SPI) /* if spi */ - { - res = handle->spi_cmd_data_gpio_write(cmd); /* write data command */ - if (res != 0) /* check error */ - { - return 1; /* return error */ - } - - if (handle->spi_write_cmd(data, len) != 0) /* write command */ - { - return 1; /* return error */ - } - else - { - return 0; /* success return 0 */ - } - } - else - { - return 1; /* return error */ - } -} - -/** - * @brief draw a point in gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] data is the write data - * @return status code - * - 0 success - * - 1 gram draw point failed - * @note none - */ -static uint8_t a_ssd1306_gram_draw_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t data) -{ - uint8_t pos; - uint8_t bx; - uint8_t temp = 0; - - pos = y / 8; /* get y page */ - bx = y % 8; /* get y point */ - temp = 1 << bx; /* set data */ - if (data != 0) /* if 1 */ - { - handle->gram[x][pos] |= temp; /* set 1 */ - } - else - { - handle->gram[x][pos] &= ~temp; /* set 0 */ - } - - return 0; /* success return 0 */ -} - -/** - * @brief draw a char in gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] chr is the write char - * @param[in] size is the char size - * @param[in] mode is the display mode - * @return status code - * - 0 success - * - 1 gram show char failed - * @note none - */ -static uint8_t a_ssd1306_gram_show_char(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t chr, uint8_t size, uint8_t mode) -{ - uint8_t temp, t, t1; - uint8_t y0 = y; - uint8_t csize = (size / 8 + ((size % 8) ? 1 : 0)) * (size / 2); /* get size */ - - chr = chr - ' '; /* get index */ - for (t = 0; t < csize; t++) /* write size */ - { - if (size == 12) /* if size 12 */ - { - temp = gsc_ssd1306_ascii_1206[chr][t]; /* get ascii 1206 */ - } - else if (size == 16) /* if size 16 */ - { - temp = gsc_ssd1306_ascii_1608[chr][t]; /* get ascii 1608 */ - } - else if(size == 24) /* if size 24 */ - { - temp = gsc_ssd1306_ascii_2412[chr][t]; /* get ascii 2412 */ - } - else - { - return 1; /* return error */ - } - for (t1 = 0; t1 < 8; t1++) /* write one line */ - { - if ((temp & 0x80) != 0) /* if 1 */ - { - if (a_ssd1306_gram_draw_point(handle, x, y, mode) != 0) /* draw point */ - { - return 1; /* return error */ - } - } - else - { - if (a_ssd1306_gram_draw_point(handle, x, y, !mode) != 0) /* draw point */ - { - return 1; /* return error */ - } - } - temp <<= 1; /* left shift 1 */ - y++; - if ((y - y0) == size) /* reset size */ - { - y = y0; /* set y */ - x++; /* x++ */ - - break; /* break */ - } - } - } - - return 0; /* success return 0 */ -} - -/** - * @brief clear the screen - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 clear failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_clear(ssd1306_handle_t *handle) -{ - uint8_t i; - uint8_t n; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - for (i = 0; i < 8; i++) /* write 8 page */ - { - if (a_ssd1306_write_byte(handle, SSD1306_CMD_PAGE_ADDR+i, SSD1306_CMD) != 0) /* set page */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - if (a_ssd1306_write_byte(handle, SSD1306_CMD_LOWER_COLUMN_START_ADDRESS, SSD1306_CMD) != 0) /* set lower column 0 */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - if (a_ssd1306_write_byte(handle, SSD1306_CMD_HIGHER_COLUMN_START_ADDRESS, SSD1306_CMD) != 0) /* set higher column 0 */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - for (n = 0; n < 128; n++) /* write 128 */ - { - handle->gram[n][i] = 0x00; /* set black */ - if (a_ssd1306_write_byte(handle, handle->gram[n][i], SSD1306_DATA) != 0) /* write data */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - } - } - - return 0; /* success return 0 */ -} - -/** - * @brief update the gram data - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 gram update failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_gram_update(ssd1306_handle_t *handle) -{ - uint8_t i; - uint8_t n; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - for (i = 0; i < 8; i++) /* write 8 page */ - { - if (a_ssd1306_write_byte(handle, SSD1306_CMD_PAGE_ADDR+i, SSD1306_CMD) != 0) /* set page */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - if (a_ssd1306_write_byte(handle, SSD1306_CMD_LOWER_COLUMN_START_ADDRESS, SSD1306_CMD) != 0) /* set lower column 0 */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - if (a_ssd1306_write_byte(handle, SSD1306_CMD_HIGHER_COLUMN_START_ADDRESS, SSD1306_CMD) != 0) /* set higher column 0 */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - for (n = 0; n < 128; n++) /* write 128 */ - { - // handle->delay_ms(100); - if (a_ssd1306_write_byte(handle, handle->gram[n][i], SSD1306_DATA) != 0) /* write data */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - } - } - - return 0; /* success return 0 */ -} - -/** - * @brief write a point - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] data is the write data - * @return status code - * - 0 success - * - 1 write point failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_write_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t data) -{ - uint8_t pos; - uint8_t bx; - uint8_t temp = 0; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if ((x > 127) || (y > 63)) /* check x, y */ - { - - return 4; /* return error */ - } - - pos = y / 8; /* get y page */ - bx = y % 8; /* get y point */ - temp = 1 << bx; /* set data */ - if (data != 0) /* check the data */ - { - handle->gram[x][pos] |= temp; /* set 1 */ - } - else - { - handle->gram[x][pos] &= ~temp; /* set 0 */ - } - #if 1 - if (a_ssd1306_write_byte(handle, SSD1306_CMD_PAGE_ADDR + pos, SSD1306_CMD) != 0) /* write page addr */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - if (a_ssd1306_write_byte(handle, SSD1306_CMD_LOWER_COLUMN_START_ADDRESS|(x&0x0F), SSD1306_CMD) != 0) /* write lower column */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - if (a_ssd1306_write_byte(handle, SSD1306_CMD_HIGHER_COLUMN_START_ADDRESS|((x>>4)&0x0F), SSD1306_CMD) != 0) /* write higher column */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - return 1; /* return error */ - } - if (a_ssd1306_write_byte(handle, handle->gram[x][pos], SSD1306_DATA) != 0) /* write data */ - { - handle->debug_print("ssd1306: write byte failed.\n"); /* write byte failed */ - - return 1; /* return error */ - } - else - { - return 0; /* success return 0 */ - } - #endif - return 0; -} - -/** - * @brief read a point - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[out] *data points to a data buffer - * @return status code - * - 0 success - * - 1 read point failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_read_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data) -{ - uint8_t pos; - uint8_t bx; - uint8_t temp = 0; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if ((x > 127) || (y > 63)) /* check x, y */ - { - - return 4; /* return error */ - } - - pos = y / 8; /* get y page */ - bx = y % 8; /* get y point */ - temp = 1 << bx; /* set data */ - if ((handle->gram[x][pos] & temp) != 0) /* get data */ - { - *data = 1; /* set 1 */ - } - else - { - *data = 0; /* set 0 */ - } - - return 0; /* success return 0 */ -} - -/** - * @brief write a point in the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] data is the write data - * @return status code - * - 0 success - * - 1 gram write point failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_gram_write_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t data) -{ - uint8_t pos; - uint8_t bx; - uint8_t temp = 0; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if ((x > 127) || (y > 63)) /* check x, y */ - { - return 4; /* return error */ - } - - pos = y / 8; /* get y page */ - bx = y % 8; /* get y point */ - temp = 1 << bx; /* set data */ - if (data != 0) /* if 1 */ - { - handle->gram[x][pos] |= temp; /* set 1 */ - } - else - { - handle->gram[x][pos] &= ~temp; /* set 0 */ - } - - return 0; /* success return 0 */ -} - -/** - * @brief read a point from the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[out] *data points to a data buffer - * @return status code - * - 0 success - * - 1 gram read point failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_gram_read_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data) -{ - uint8_t pos; - uint8_t bx; - uint8_t temp = 0; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if ((x > 127) || (y > 63)) /* check x, y */ - { - - return 4; /* return error */ - } - - pos = y / 8; /* get y page */ - bx = y % 8; /* get y point */ - temp = 1 << bx; /* set data */ - if ((handle->gram[x][pos] & temp) != 0) /* get data */ - { - *data = 1; /* set 1 */ - } - else - { - *data = 0; /* set 0 */ - } - - return 0; /* success return 0 */ -} - -/** - * @brief draw a string in the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] *str points to a write string address - * @param[in] len is the length of the string - * @param[in] color is the display color - * @param[in] font is the display font size - * @return status code - * - 0 success - * - 1 gram write string failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_gram_write_string(ssd1306_handle_t *handle, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t color, ssd1306_font_t font) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if((x > 127) || (y > 63)) /* check x, y */ - { - - return 4; /* return error */ - } - - while ((len != 0) && (*str <= '~') && (*str >= ' ')) /* write all string */ - { - if (x > (127 - (font / 2))) /* check x point */ - { - x = 0; /* set x */ - y += (uint8_t)font; /* set next row */ - } - if (y > (63 - font)) /* check y pont */ - { - y = x = 0; /* reset to 0,0 */ - } - if (a_ssd1306_gram_show_char(handle, x, y, *str, font, color) != 0) /* show a char */ - { - return 1; /* return error */ - } - x += (uint8_t)(font / 2); /* x + font/2 */ - str++; /* str address++ */ - len--; /* str length-- */ - } - - return 0; /* success return 0 */ -} - -/** - * @brief fill a rectangle in the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] left is the left coordinate x - * @param[in] top is the top coordinate y - * @param[in] right is the right coordinate x - * @param[in] bottom is the bottom coordinate y - * @param[in] color is the display color - * @return status code - * - 0 success - * - 1 gram fill rect failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 left or top is invalid - * - 5 right or bottom is invalid - * - 6 left > right or top > bottom - * @note none - */ -uint8_t ssd1306_gram_fill_rect(ssd1306_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color) -{ - uint8_t x, y; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if ((left > 127) || (top > 63)) /* check left top */ - { - handle->debug_print("ssd1306: left or top is invalid.\n"); /* left or top is invalid */ - - return 4; /* return error */ - } - if ((right > 127) || (bottom > 63)) /* check right bottom */ - { - handle->debug_print("ssd1306: right or bottom is invalid.\n"); /* right or bottom is invalid */ - - return 5; /* return error */ - } - if ((left > right) || (top > bottom)) /* check left right top bottom */ - { - handle->debug_print("ssd1306: left > right or top > bottom.\n"); /* left > right or top > bottom */ - - return 6; /* return error */ - } - - for (x = left; x <= right; x++) /* write x */ - { - for (y = top; y <= bottom; y++) /* write y */ - { - if (a_ssd1306_gram_draw_point(handle, x, y, color) != 0) /* draw point */ - { - return 1; /* return error */ - } - } - } - - return 0; /* return error */ -} - -/** - * @brief draw a picture in the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] left is the left coordinate x - * @param[in] top is the top coordinate y - * @param[in] right is the right coordinate x - * @param[in] bottom is the bottom coordinate y - * @param[in] *img points to an image buffer - * @return status code - * - 0 success - * - 1 gram draw picture failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 left or top is invalid - * - 5 right or bottom is invalid - * - 6 left > right or top > bottom - * @note none - */ -uint8_t ssd1306_gram_draw_picture(ssd1306_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img) -{ - uint8_t x, y; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if ((left > 127) || (top > 63)) /* check left top */ - { - handle->debug_print("ssd1306: left or top is invalid.\n"); /* left or top is invalid */ - - return 4; /* return error */ - } - if ((right > 127) || (bottom > 63)) /* check right bottom */ - { - handle->debug_print("ssd1306: right or bottom is invalid.\n"); /* right or bottom is invalid */ - - return 5; /* return error */ - } - if ((left > right) || (top > bottom)) /* check left right top bottom */ - { - handle->debug_print("ssd1306: left > right or top > bottom.\n"); /* left > right or top > bottom */ - - return 6; /* return error */ - } - - for (x = left; x <= right; x++) /* write x */ - { - for (y = top; y <= bottom; y++) /* write y */ - { - if (a_ssd1306_gram_draw_point(handle, x, y, *img) != 0) /* draw point */ - { - return 1; /* return error */ - } - img++; /* img++ */ - } - } - - return 0; /* succeed return 0 */ -} - -/** - * @brief initialize the chip - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 iic or spi initialization failed - * - 2 handle is NULL - * - 3 linked functions is NULL - * - 4 reset failed - * - 5 command && data init failed - * - 6 interface param is invalid - * @note none - */ -uint8_t ssd1306_init(ssd1306_handle_t *handle) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->debug_print == NULL) /* check debug_print */ - { - return 3; /* return error */ - } - if (handle->iic_init == NULL) /* check iic_init */ - { - handle->debug_print("ssd1306: iic_init is null.\n"); /* iic_init is null */ - - return 3; /* return error */ - } - if (handle->iic_deinit == NULL) /* check iic_deinit */ - { - handle->debug_print("ssd1306: iic_deinit is null.\n"); /* iic_deinit is null */ - - return 3; /* return error */ - } - if (handle->iic_write == NULL) /* check iic_write */ - { - handle->debug_print("ssd1306: iic_write is null.\n"); /* iic_write is null */ - - return 3; /* return error */ - } - if (handle->spi_init == NULL) /* check spi_init */ - { - handle->debug_print("ssd1306: spi_init is null.\n"); /* spi_init is null */ - - return 3; /* return error */ - } - if (handle->spi_deinit == NULL) /* check spi_deinit */ - { - handle->debug_print("ssd1306: spi_deinit is null.\n"); /* spi_deinit is null */ - - return 3; /* return error */ - } - if (handle->spi_write_cmd == NULL) /* check spi_write_cmd */ - { - handle->debug_print("ssd1306: spi_write_cmd is null.\n"); /* spi_write_cmd is null */ - - return 3; /* return error */ - } - if (handle->delay_ms == NULL) /* check delay_ms */ - { - handle->debug_print("ssd1306: delay_ms is null.\n"); /* delay_ms is null */ - - return 3; /* return error */ - } - if (handle->spi_cmd_data_gpio_init == NULL) /* check spi_cmd_data_gpio_init */ - { - handle->debug_print("ssd1306: spi_cmd_data_gpio_init is null.\n"); /* spi_cmd_data_gpio_init is null */ - - return 3; /* return error */ - } - if (handle->spi_cmd_data_gpio_deinit == NULL) /* check spi_cmd_data_gpio_deinit */ - { - handle->debug_print("ssd1306: spi_cmd_data_gpio_deinit is null.\n"); /* spi_cmd_data_gpio_deinit is null */ - - return 3; /* return error */ - } - if (handle->spi_cmd_data_gpio_write == NULL) /* check spi_cmd_data_gpio_write */ - { - handle->debug_print("ssd1306: spi_cmd_data_gpio_write is null.\n"); /* spi_cmd_data_gpio_write is null */ - - return 3; /* return error */ - } - if (handle->reset_gpio_init == NULL) /* check reset_gpio_init */ - { - handle->debug_print("ssd1306: reset_gpio_init is null.\n"); /* reset_gpio_init is null */ - - return 3; /* return error */ - } - if (handle->reset_gpio_deinit == NULL) /* check reset_gpio_deinit */ - { - handle->debug_print("ssd1306: reset_gpio_deinit is null.\n"); /* reset_gpio_deinit is null */ - - return 3; /* return error */ - } - if(handle->reset_gpio_write == NULL) /* check reset_gpio_write */ - { - handle->debug_print("ssd1306: reset_gpio_write is null.\n"); /* reset_gpio_write is null */ - - return 3; /* return error */ - } - - if (handle->spi_cmd_data_gpio_init() != 0) /* check spi_cmd_data_gpio_init */ - { - handle->debug_print("ssd1306: spi cmd data gpio init failed.\n"); /* spi cmd data gpio init failed */ - - return 5; /* return error */ - } - if (handle->reset_gpio_init() != 0) /* reset gpio init */ - { - handle->debug_print("ssd1306: reset gpio init failed.\n"); /* reset gpio init failed */ - (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */ - - return 4; /* return error */ - } - if (handle->reset_gpio_write(0) != 0) /* write 0 */ - { - handle->debug_print("ssd1306: reset gpio write failed.\n"); /* reset gpio write failed */ - (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */ - (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */ - - return 4; /* return error */ - } - handle->delay_ms(100); /* delay 100 ms */ - if (handle->reset_gpio_write(1) != 0) /* write 1 */ - { - handle->debug_print("ssd1306: reset gpio write failed.\n"); /* reset gpio write failed */ - (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */ - (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */ - - return 4; /* return error */ - } - if (handle->iic_spi == SSD1306_INTERFACE_IIC) /* if iic interface */ - { - if (handle->iic_init() != 0) /* iic init */ - { - handle->debug_print("ssd1306: iic init failed.\n"); /* iic init failed */ - (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */ - (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */ - - return 1; /* return error */ - } - } - else if (handle->iic_spi == SSD1306_INTERFACE_SPI) /* if spi interface */ - { - if (handle->spi_init() != 0) /* spi init */ - { - handle->debug_print("ssd1306: spi init failed.\n"); /* spi init failed */ - (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */ - (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */ - - return 1; /* return error */ - } - } - else - { - handle->debug_print("ssd1306: interface is invalid.\n"); /* interface is invalid */ - (void)handle->spi_cmd_data_gpio_deinit(); /* spi_cmd_data_gpio_deinit */ - (void)handle->reset_gpio_deinit(); /* reset_gpio_deinit */ - - return 6; /* return error */ - } - handle->inited = 1; /* flag inited */ - - return 0; /* success return 0 */ -} - -/** - * @brief close the chip - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 iic or spi deinit failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 power down failed - * - 5 reset gpio deinit failed - * - 6 command && data deinit failed - * - 7 interface param is invalid - * @note none - */ -uint8_t ssd1306_deinit(ssd1306_handle_t *handle) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - buf[0] = SSD1306_CMD_CHARGE_PUMP_SETTING; /* charge pump off */ - buf[1] = 0x10 | (0 << 2); /* set charge pump */ - if (a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD) != 0) /* write command */ - { - handle->debug_print("ssd1306: write command failed.\n"); /* write command failed */ - - return 4; /* return error */ - } - if (a_ssd1306_write_byte(handle, SSD1306_CMD_DISPLAY_OFF, SSD1306_CMD) != 0) /* write display off */ - { - handle->debug_print("ssd1306: write command failed.\n"); /* write command failed */ - - return 4; /* return error */ - } - if (handle->reset_gpio_deinit() != 0) /* reset gpio deinit */ - { - handle->debug_print("ssd1306: reset gpio deinit failed.\n"); /* reset gpio deinit failed */ - - return 5; /* return error */ - } - if (handle->spi_cmd_data_gpio_deinit() != 0) /* spi cmd data gpio deinit */ - { - handle->debug_print("ssd1306: spi cmd data gpio deinit failed.\n"); /* spi cmd data gpio deinit failed */ - - return 6; /* return error */ - } - if (handle->iic_spi == SSD1306_INTERFACE_IIC) /* if iic interface */ - { - if (handle->iic_deinit() != 0) /* iic deinit */ - { - handle->debug_print("ssd1306: iic deinit failed.\n"); /* iic deinit failed */ - - return 1; /* return error */ - } - } - else if (handle->iic_spi == SSD1306_INTERFACE_SPI) /* if spi interface */ - { - if (handle->spi_deinit() != 0) /* spi deinit */ - { - handle->debug_print("ssd1306: spi deinit failed.\n"); /* spi deinit failed */ - - return 1; /* return error */ - } - } - else - { - handle->debug_print("ssd1306: interface is invalid.\n"); /* interface is invalid */ - - return 7; /* return error */ - } - handle->inited = 0; /* flag close */ - - return 0; /* success return 0 */ -} - -/** - * @brief set the chip interface - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] interface is the chip interface - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_set_interface(ssd1306_handle_t *handle, ssd1306_interface_t ifhandler) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - - handle->iic_spi = (uint8_t)ifhandler; /* set interface */ - - return 0; /* success return 0 */ -} - -/** - * @brief get the chip interface - * @param[in] *handle points to an ssd1306 handle structure - * @param[out] *interface points to a chip interface buffer - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_get_interface(ssd1306_handle_t *handle, ssd1306_interface_t *ifhandler) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - - *ifhandler = (ssd1306_interface_t)(handle->iic_spi); /* get interface */ - - return 0; /* success return 0 */ -} - -/** - * @brief set the chip iic address - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] addr_pin is the iic address - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_set_addr_pin(ssd1306_handle_t *handle, ssd1306_address_t addr_pin) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - - handle->iic_addr = (uint8_t)addr_pin; /* set addr pin */ - - return 0; /* success return 0 */ -} - -/** - * @brief get the chip iic address - * @param[in] *handle points to an ssd1306 handle structure - * @param[out] *addr_pin points to an iic address buffer - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_get_addr_pin(ssd1306_handle_t *handle, ssd1306_address_t *addr_pin) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - - *addr_pin = (ssd1306_address_t)(handle->iic_addr); /* set address */ - - return 0; /* success return 0 */ -} - -/** - * @brief set the low column start address - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] addr is the low column start address - * @return status code - * - 0 success - * - 1 set low column start address failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 addr is invalid - * @note addr <= 0xF - */ -uint8_t ssd1306_set_low_column_start_address(ssd1306_handle_t *handle, uint8_t addr) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (addr > 0x0F) /* check addr */ - { - handle->debug_print("ssd1306: addr is invalid.\n"); /* addr is invalid */ - - return 4; /* return error */ - } - - return a_ssd1306_write_byte(handle, SSD1306_CMD_LOWER_COLUMN_START_ADDRESS|(addr&0x0F), SSD1306_CMD); /* write command */ -} - -/** - * @brief set the high column start address - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] addr is the high column start address - * @return status code - * - 0 success - * - 1 set high column start address failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 addr is invalid - * @note addr <= 0xF - */ -uint8_t ssd1306_set_high_column_start_address(ssd1306_handle_t *handle, uint8_t addr) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (addr > 0x0F) /* check addr */ - { - handle->debug_print("ssd1306: addr is invalid.\n"); /* addr is invalid */ - - return 4; /* return error */ - } - - return a_ssd1306_write_byte(handle, SSD1306_CMD_HIGHER_COLUMN_START_ADDRESS|(addr&0x0F), SSD1306_CMD); /* write command */ -} - -/** - * @brief set the memory addressing mode - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] mode is the memory addressing mode - * @return status code - * - 0 success - * - 1 set memory addressing mode failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_memory_addressing_mode(ssd1306_handle_t *handle, ssd1306_memory_addressing_mode_t mode) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - buf[0] = SSD1306_CMD_MEMORY_ADDRESSING_MODE; /* set command mode */ - buf[1] = mode; /* set mode */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the column address range - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_addr is the column start address - * @param[in] end_addr is the column end address - * @return status code - * - 0 success - * - 1 set column address range failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start addr is invalid - * - 5 end addr is invalid - * @note start addr and end addr can't be over 0x7F - */ -uint8_t ssd1306_set_column_address_range(ssd1306_handle_t *handle, uint8_t start_addr, uint8_t end_addr) -{ - uint8_t buf[3]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (start_addr > 0x7F) /* check start addr */ - { - handle->debug_print("ssd1306: start addr is invalid.\n"); /* start addr is invalid */ - - return 4; /* return error */ - } - if (end_addr > 0x7F) /* check end addr */ - { - handle->debug_print("ssd1306: end addr is invalid.\n"); /* end addr is invalid */ - - return 5; /* return error */ - } - - buf[0] = SSD1306_CMD_SET_COLUMN_ADDRESS; /* set command */ - buf[1] = start_addr & 0x7F; /* set start address */ - buf[2] = end_addr & 0x7F; /* set end address */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 3, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the page address range - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_addr is the page start address - * @param[in] end_addr is the page end address - * @return status code - * - 0 success - * - 1 set page address range failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start addr is invalid - * - 5 end addr is invalid - * @note start addr and end addr can't be over 0x07 - */ -uint8_t ssd1306_set_page_address_range(ssd1306_handle_t *handle, uint8_t start_addr, uint8_t end_addr) -{ - uint8_t buf[3]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (start_addr > 0x07) /* check start addr */ - { - handle->debug_print("ssd1306: start addr is invalid.\n"); /* start addr is invalid */ - - return 4; /* return error */ - } - if (end_addr > 0x07) /* check end addr */ - { - handle->debug_print("ssd1306: end addr is invalid.\n"); /* end_addr is invalid */ - - return 5; /* return error */ - } - - buf[0] = SSD1306_CMD_SET_PAGE_ADDRESS; /* set command */ - buf[1] = start_addr & 0x07; /* set start address */ - buf[2] = end_addr & 0x07; /* set end address */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 3, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the fade blinking mode - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] mode is the fade blinking mode - * @param[in] frames is the fade or blinking frames - * @return status code - * - 0 success - * - 1 set fade blinking mode failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 frames is invalid - * @note frames max is 0x0F and div is (frames + 1) * 8 - */ -uint8_t ssd1306_set_fade_blinking_mode(ssd1306_handle_t *handle, ssd1306_fade_blinking_mode_t mode, uint8_t frames) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (frames> 0x0F) /* check frames */ - { - handle->debug_print("ssd1306: frames is invalid.\n"); /* frames is invalid */ - - return 4; /* return error */ - } - - buf[0] = SSD1306_CMD_SET_FADE_OUT_AND_BLINKING; /* set command */ - buf[1] = (uint8_t)((mode << 4) | (frames & 0x0F)); /* set mode */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the right horizontal scroll - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_page_addr is the start page address - * @param[in] end_page_addr is the end page address - * @param[in] frames is the scroll frames - * @return status code - * - 0 success - * - 1 set right horizontal scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start page addr is invalid - * - 5 end page addr is invalid - * @note start_page_addr <= 0x07, end_page_addr <= 0x07 - */ -uint8_t ssd1306_set_right_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, - ssd1306_scroll_frame_t frames) -{ - uint8_t buf[7]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (start_page_addr > 0x07) /* check start_page_addr */ - { - handle->debug_print("ssd1306: start page addr is invalid.\n"); /* start page addr is invalid */ - - return 4; /* return error */ - } - if (end_page_addr > 0x07) /* check end_page_addr */ - { - handle->debug_print("ssd1306: end page addr is invalid.\n"); /* end page addr is invalid */ - - return 5; /* return error */ - } - - buf[0] = SSD1306_CMD_RIGHT_HORIZONTAL_SCROLL; /* set command */ - buf[1] = 0x00; /* set null */ - buf[2] = start_page_addr & 0x07; /* set start page address */ - buf[3] = frames & 0x07; /* set frames */ - buf[4] = end_page_addr & 0x07; /* set end page address */ - buf[5] = 0x00; /* set null */ - buf[6] = 0xFF; /* set frame end */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 7, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the left horizontal scroll - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_page_addr is the start page address - * @param[in] end_page_addr is the end page address - * @param[in] frames is the scroll frames - * @return status code - * - 0 success - * - 1 set left horizontal scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start_page_addr is invalid - * - 5 end_page_addr is invalid - * @note start_page_addr <= 0x07, end_page_addr <= 0x07 - */ -uint8_t ssd1306_set_left_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, - ssd1306_scroll_frame_t frames) -{ - uint8_t buf[7]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (start_page_addr > 0x07) /* check start_page_addr */ - { - handle->debug_print("ssd1306: start_page_addr is invalid.\n"); /* start_page_addr is invalid */ - - return 4; /* return error */ - } - if (end_page_addr > 0x07) /* check end_page_addr */ - { - handle->debug_print("ssd1306: end_page_addr is invalid.\n"); /* end_page_addr is invalid */ - - return 5; /* return error */ - } - - buf[0] = SSD1306_CMD_LEFT_HORIZONTAL_SCROLL; /* set command */ - buf[1] = 0x00; /* set null */ - buf[2] = start_page_addr & 0x07; /* set end page addr */ - buf[3] = frames & 0x07; /* set frames */ - buf[4] = end_page_addr & 0x07; /* set end page addr */ - buf[5] = 0x00; /* set null */ - buf[6] = 0xFF; /* set frame end */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 7, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the vertical right horizontal scroll - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_page_addr is the start page address - * @param[in] end_page_addr is the end page address - * @param[in] rows is the row address - * @param[in] frames is the scroll frames - * @return status code - * - 0 success - * - 1 set vertical right horizontal scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start_page_addr is invalid - * - 5 end_page_addr is invalid - * - 6 rows is invalid - * @note start_page_addr <= 0x07, end_page_addr <= 0x07, rows <= 0x3F - */ -uint8_t ssd1306_set_vertical_right_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, - uint8_t rows, ssd1306_scroll_frame_t frames) -{ - uint8_t buf[6]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (start_page_addr > 0x07) /* check start_page_addr */ - { - handle->debug_print("ssd1306: start_page_addr is invalid.\n"); /* start_page_addr is invalid */ - - return 4; /* return error */ - } - if (end_page_addr > 0x07) /* check end page addr */ - { - handle->debug_print("ssd1306: end_page_addr is invalid.\n"); /* end_page_addr is invalid */ - - return 5; /* return error */ - } - if (rows > 0x3F) /* check rows */ - { - handle->debug_print("ssd1306: rows is invalid.\n"); /* rows is invalid */ - - return 6; /* return error */ - } - - buf[0] = SSD1306_CMD_VERTICAL_RIGHT_HORIZONTAL_SCROLL; /* set command */ - buf[1] = 0x00; /* set null */ - buf[2] = start_page_addr & 0x07; /* set start page addr */ - buf[3] = frames & 0x07; /* set frames */ - buf[4] = end_page_addr & 0x07; /* set end page addr */ - buf[5] = rows & 0x3F; /* set rows */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 6, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the vertical left horizontal scroll - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_page_addr is the start page address - * @param[in] end_page_addr is the end page address - * @param[in] rows is the row address - * @param[in] frames is the scroll frames - * @return status code - * - 0 success - * - 1 set vertical left horizontal scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start_page_addr is invalid - * - 5 end_page_addr is invalid - * - 6 rows is invalid - * @note start_page_addr <= 0x07, end_page_addr <= 0x07, rows <= 0x3F - */ -uint8_t ssd1306_set_vertical_left_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, - uint8_t rows, ssd1306_scroll_frame_t frames) -{ - uint8_t buf[6]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (start_page_addr > 0x07) /* check start_page_addr */ - { - handle->debug_print("ssd1306: start_page_addr is invalid.\n"); /* start_page_addr is invalid */ - - return 4; /* return error */ - } - if (end_page_addr > 0x07) /* check end_page_addr */ - { - handle->debug_print("ssd1306: end_page_addr is invalid.\n"); /* end_page_addr is invalid */ - - return 5; /* return error */ - } - if (rows > 0x3F) /* check rows */ - { - handle->debug_print("ssd1306: rows is invalid.\n"); /* rows is invalid */ - - return 6; /* return error */ - } - - buf[0] = SSD1306_CMD_VERTICAL_LEFT_HORIZONTAL_SCROLL; /* set command */ - buf[1] = 0x00; /* set null */ - buf[2] = start_page_addr & 0x07; /* set start page addr */ - buf[3] = frames & 0x07; /* set frames */ - buf[4] = end_page_addr & 0x07; /* set end page addr */ - buf[5] = rows & 0x3F; /* set rows */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 6, SSD1306_CMD); /* write command */ -} - -/** - * @brief deactivate the scroll - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 deactivate scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_deactivate_scroll(ssd1306_handle_t *handle) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - return a_ssd1306_write_byte(handle, SSD1306_CMD_DEACTIVATE_SCROLL, SSD1306_CMD); /* write command */ -} - -/** - * @brief activate the scroll - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 activate scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_activate_scroll(ssd1306_handle_t *handle) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - return a_ssd1306_write_byte(handle, SSD1306_CMD_ACTIVATE_SCROLL, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the display start line - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] l is the start line - * @return status code - * - 0 success - * - 1 set display start line failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 line is invalid - * @note line <= 0x3F - */ -uint8_t ssd1306_set_display_start_line(ssd1306_handle_t *handle, uint8_t l) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (l > 0x3F) /* check line */ - { - handle->debug_print("ssd1306: line is invalid.\n"); /* line is invalid */ - - return 4; /* return error */ - } - - return a_ssd1306_write_byte(handle, SSD1306_CMD_DISPLAY_START_LINE|(l&0x3F), SSD1306_CMD); /* write command */ -} - -/** - * @brief set the display contrast - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] contrast is the display contrast - * @return status code - * - 0 success - * - 1 set contrast failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_contrast(ssd1306_handle_t *handle, uint8_t contrast) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - buf[0] = SSD1306_CMD_CONTRAST_CONTROL; /* set command */ - buf[1] = contrast; /* set contrast */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief enable or disable the charge pump - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] enable is a bool value - * @return status code - * - 0 success - * - 1 set charge pump failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_charge_pump(ssd1306_handle_t *handle, ssd1306_charge_pump_t enable) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - buf[0] = SSD1306_CMD_CHARGE_PUMP_SETTING; /* set command */ - buf[1] = (uint8_t)(0x10 | (enable << 2)); /* set charge pump */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the segment remap - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] remap is the segment remap param - * @return status code - * - 0 success - * - 1 set segment remap failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_segment_remap(ssd1306_handle_t *handle, ssd1306_segment_column_remap_t remap) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - if (remap != 0) /* check remap */ - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_COLUMN_127_MAPPED_TO_SEG0, SSD1306_CMD); /* write remap */ - } - else - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_COLUMN_0_MAPPED_TO_SEG0, SSD1306_CMD); /* write remap */ - } -} - -/** - * @brief set the vertical scroll area - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_row is the start row - * @param[in] end_row is the end row - * @return status code - * - 0 success - * - 1 set vertical scroll area failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start_row is invalid - * - 5 end_row is invalid - * - 6 end_row > start_row - * @note start_row <= 0x3F, end_row <= 0x7F, start_row >= end_row - */ -uint8_t ssd1306_set_vertical_scroll_area(ssd1306_handle_t *handle, uint8_t start_row, uint8_t end_row) -{ - uint8_t buf[3]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (start_row > 0x3F) /* check start row */ - { - handle->debug_print("ssd1306: start_row is invalid.\n"); /* start_row is invalid */ - - return 4; /* return error */ - } - if (end_row > 0x7F) /* check end_row */ - { - handle->debug_print("ssd1306: end_row is invalid.\n"); /* end_row is invalid */ - - return 5; /* return error */ - } - if (end_row > start_row) /* check start_row and end_row */ - { - handle->debug_print("ssd1306: end_row > start_row.\n"); /* end_row > start_row */ - - return 6; /* return error */ - } - - buf[0] = SSD1306_CMD_VERTICAL_SCROLL_AREA; /* set command */ - buf[1] = start_row; /* set start row */ - buf[2] = end_row; /* set end row */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 3, SSD1306_CMD); /* write command */ -} - -/** - * @brief enable or disable the entire display - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] enable is a bool value - * @return status code - * - 0 success - * - 1 set entire display failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_entire_display(ssd1306_handle_t *handle, ssd1306_entire_display_t enable) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - if (enable != 0) /* if enable */ - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_ENTIRE_DISPLAY_ON, SSD1306_CMD); /* write command */ - } - else - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_ENTIRE_DISPLAY_OFF, SSD1306_CMD); /* write command */ - } -} - -/** - * @brief set the display mode - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] mode is the display mode - * @return status code - * - 0 success - * - 1 set display mode failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_display_mode(ssd1306_handle_t *handle, ssd1306_display_mode_t mode) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - if (mode != 0) /* check mode */ - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_INVERSE_DISPLAY, SSD1306_CMD); /* write command */ - } - else - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_NORMAL_DISPLAY, SSD1306_CMD); /* write command */ - } -} - -/** - * @brief set the multiplex ratio - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] multiplex is the multiplex ratio - * @return status code - * - 0 success - * - 1 set multiplex ratio failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 multiplex is too small - * - 5 multiplex is too large - * @note multiplex must be over 0x0E and less than 0x40 - */ -uint8_t ssd1306_set_multiplex_ratio(ssd1306_handle_t *handle, uint8_t multiplex) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (multiplex < 0x0F) /* check multiplex */ - { - handle->debug_print("ssd1306: multiplex is too small.\n"); /* multiplex is too small */ - - return 4; /* return error */ - } - if (multiplex > 0x3F) /* check multiplex */ - { - handle->debug_print("ssd1306: multiplex is too large.\n"); /* multiplex is too large */ - - return 5; /* return error */ - } - - buf[0] = SSD1306_CMD_MULTIPLEX_RATIO ; /* set command */ - buf[1] = multiplex; /* set multiplex */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief enable or disable the display - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] on_off is a bool value - * @return status code - * - 0 success - * - 1 set display failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_display(ssd1306_handle_t *handle, ssd1306_display_t on_off) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - if (on_off != 0) /* check on off */ - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_DISPLAY_ON, SSD1306_CMD); /* write command */ - } - else - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_DISPLAY_OFF, SSD1306_CMD); /* write command */ - } -} - -/** - * @brief set the page address - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] addr is the page address - * @return status code - * - 0 success - * - 1 set page address failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 addr is invalid - * @note addr <= 0x07 - */ -uint8_t ssd1306_set_page_address(ssd1306_handle_t *handle, uint8_t addr) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (addr > 0x07) /* check addr */ - { - handle->debug_print("ssd1306: addr is invalid.\n"); /* addr is invalid */ - - return 4; /* return error */ - } - - return a_ssd1306_write_byte(handle, SSD1306_CMD_PAGE_ADDR|(addr&0x07), SSD1306_CMD); /* write command */ -} - -/** - * @brief set the scan direction - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] dir is the scan direction - * @return status code - * - 0 success - * - 1 set scan direction failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_scan_direction(ssd1306_handle_t *handle, ssd1306_scan_direction_t dir) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - if (dir != 0) /* choose dir */ - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_SCAN_DIRECTION_COMN_1_START, SSD1306_CMD); /* write command */ - } - else - { - return a_ssd1306_write_byte(handle, SSD1306_CMD_SCAN_DIRECTION_COM0_START, SSD1306_CMD); /* write command */ - } -} - -/** - * @brief set the display offset - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] offset is the display offset - * @return status code - * - 0 success - * - 1 set display offset failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 offset is invalid - * @note offset <= 0x3F - */ -uint8_t ssd1306_set_display_offset(ssd1306_handle_t *handle, uint8_t offset) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (offset > 0x3F) /* check offset */ - { - handle->debug_print("ssd1306: offset is invalid.\n"); /* offset is invalid */ - - return 4; /* return error */ - } - - buf[0] = SSD1306_CMD_DISPLAY_OFFSET ; /* set command */ - buf[1] = offset; /* set offset */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the display clock - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] oscillator_frequency is the oscillator frequency - * @param[in] clock_divide is the clock divide - * @return status code - * - 0 success - * - 1 set display clock failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 oscillator frequency is invalid - * - 5 clock divide is invalid - * @note oscillator_frequency <= 0x0F, clock_divide <= 0x0F - */ -uint8_t ssd1306_set_display_clock(ssd1306_handle_t *handle, uint8_t oscillator_frequency, uint8_t clock_divide) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (oscillator_frequency> 0x0F) /* check oscillator_frequency */ - { - handle->debug_print("ssd1306: oscillator frequency is invalid.\n"); /* oscillator frequency is invalid */ - - return 4; /* return error */ - } - if (clock_divide> 0x0F) /* check clock_divide */ - { - handle->debug_print("ssd1306: clock divide is invalid.\n"); /* clock divide is invalid */ - - return 5; /* return error */ - } - - buf[0] = SSD1306_CMD_DISPLAY_CLOCK_DIVIDE ; /* set command */ - buf[1] = (oscillator_frequency<<4) | clock_divide; /* set oscillator frequency and clock divide */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the display zoom in - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] zoom is the display zoom in - * @return status code - * - 0 success - * - 1 set zoom in failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_zoom_in(ssd1306_handle_t *handle, ssd1306_zoom_in_t zoom) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - buf[0] = SSD1306_CMD_SET_ZOOM_IN ; /* set command */ - buf[1] = zoom; /* set zoom */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the pre charge period - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] phase1_period is the phase1 period - * @param[in] phase2_period is the phase2 period - * @return status code - * - 0 success - * - 1 set pre charge period failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 phase1 period is invalid - * - 5 phase2 period is invalid - * @note phase1_period <= 0x0F, phase2_period <= 0x0F - */ -uint8_t ssd1306_set_precharge_period(ssd1306_handle_t *handle, uint8_t phase1_period, uint8_t phase2_period) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - if (phase1_period> 0x0F) /* check phase1 period */ - { - handle->debug_print("ssd1306: phase1 period is invalid.\n"); /* phase1 period is invalid */ - - return 4; /* return error */ - } - if (phase2_period> 0x0F) /* check phase2 period */ - { - handle->debug_print("ssd1306: phase2 period is invalid.\n"); /* phase2 period is invalid */ - - return 5; /* return error */ - } - - buf[0] = SSD1306_CMD_PRE_CHARGE_PERIOD; /* set command */ - buf[1] = (phase2_period << 4) | phase1_period; /* set period */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the hardware com pins - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] conf is the pin conf - * @param[in] remap is the left right remap - * @return status code - * - 0 success - * - 1 set com pins hardware conf failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_com_pins_hardware_conf(ssd1306_handle_t *handle, ssd1306_pin_conf_t conf, ssd1306_left_right_remap_t remap) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - buf[0] = SSD1306_CMD_COM_PINS_CONF; /* set command */ - buf[1] = (uint8_t)((conf<<4) | (remap<<5) |0x02); /* set com pins */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief set the deselect level - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] level is the deselect level - * @return status code - * - 0 success - * - 1 set deselect level failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_deselect_level(ssd1306_handle_t *handle, ssd1306_deselect_level_t level) -{ - uint8_t buf[2]; - - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - buf[0] = SSD1306_CMD_COMH_DESLECT_LEVEL; /* set command */ - buf[1] = (uint8_t)(level << 4); /* set level */ - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, 2, SSD1306_CMD); /* write command */ -} - -/** - * @brief write the register command - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] *buf points to a data buffer - * @param[in] len is the data length - * @return status code - * - 0 success - * - 1 write failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_write_cmd(ssd1306_handle_t *handle, uint8_t *buf, uint8_t len) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, len, SSD1306_CMD); /* write command */ -} - -/** - * @brief write the register data - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] *buf points to a data buffer - * @param[in] len is the data length - * @return status code - * - 0 success - * - 1 write failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_write_data(ssd1306_handle_t *handle, uint8_t *buf, uint8_t len) -{ - if (handle == NULL) /* check handle */ - { - return 2; /* return error */ - } - if (handle->inited != 1) /* check handle initialization */ - { - return 3; /* return error */ - } - - return a_ssd1306_multiple_write_byte(handle, (uint8_t *)buf, len, SSD1306_DATA); /* write data */ -} - -/** - * @brief get chip's information - * @param[out] *info points to an ssd1306 info structure - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_info(ssd1306_info_t *info) -{ - if (info == NULL) /* check handle */ - { - return 2; /* return error */ - } - - memset(info, 0, sizeof(ssd1306_info_t)); /* initialize ssd1306 info structure */ - strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */ - strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */ - strncpy(info->ifname, "IIC SPI", 8); /* copy interface name */ - info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */ - info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */ - info->max_current_ma = MAX_CURRENT; /* set maximum current */ - info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */ - info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */ - info->driver_version = DRIVER_VERSION; /* set driver version */ - - return 0; /* success return 0 */ -} diff --git a/app/src/_board/ssd1306/driver_ssd1306.h b/app/src/_board/ssd1306/driver_ssd1306.h deleted file mode 100644 index fa65147..0000000 --- a/app/src/_board/ssd1306/driver_ssd1306.h +++ /dev/null @@ -1,1105 +0,0 @@ -/** - * Copyright (c) 2015 - present LibDriver All rights reserved - * - * The MIT License (MIT) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * @file driver_ssd1306.h - * @brief driver ssd1306 header file - * @version 2.0.0 - * @author Shifeng Li - * @date 2021-03-30 - * - *

history

- * - *
Date Version Author Description - *
2021/03/30 2.0 Shifeng Li format the code - *
2020/12/10 1.0 Shifeng Li first upload - *
- */ - -#ifndef DRIVER_SSD1306_H -#define DRIVER_SSD1306_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -/** - * @defgroup ssd1306_driver ssd1306 driver function - * @brief ssd1306 driver modules - * @{ - */ - -/** - * @addtogroup ssd1306_base_driver - * @{ - */ - -/** - * @brief ssd1306 interface enumeration definition - */ -typedef enum -{ - SSD1306_INTERFACE_IIC = 0x00, /**< interface iic */ - SSD1306_INTERFACE_SPI = 0x01, /**< interface spi */ -} ssd1306_interface_t; - -/** - * @brief ssd1306 address pin enumeration definition - */ -typedef enum -{ - SSD1306_ADDR_SA0_0 = 0x78, /**< address pin GND */ - SSD1306_ADDR_SA0_1 = 0x7A, /**< address pin VCC */ -} ssd1306_address_t; - -/** - * @brief ssd1306 memory addressing mode enumeration definition - */ -typedef enum -{ - SSD1306_MEMORY_ADDRESSING_MODE_HORIZONTAL = 0x00, /**< horizontal addressing mode */ - SSD1306_MEMORY_ADDRESSING_MODE_VERTICAL = 0x01, /**< vertical addressing mode */ - SSD1306_MEMORY_ADDRESSING_MODE_PAGE = 0x02, /**< page addressing mode */ -} ssd1306_memory_addressing_mode_t; - -/** - * @brief ssd1306 fade blinking mode enumeration definition - */ -typedef enum -{ - SSD1306_FADE_BLINKING_MODE_DISABLE = 0x00, /**< disable fade blinking mode */ - SSD1306_FADE_BLINKING_MODE_FADE_OUT = 0x02, /**< fade out fade blinking mode */ - SSD1306_FADE_BLINKING_MODE_BLINKING = 0x03, /**< blinking fade blinking mode */ -} ssd1306_fade_blinking_mode_t; - -/** - * @brief ssd1306 scroll frame enumeration definition - */ -typedef enum -{ - SSD1306_SCROLL_FRAME_2 = 0x07, /**< scroll frame 2 */ - SSD1306_SCROLL_FRAME_3 = 0x04, /**< scroll frame 3 */ - SSD1306_SCROLL_FRAME_4 = 0x05, /**< scroll frame 4 */ - SSD1306_SCROLL_FRAME_5 = 0x00, /**< scroll frame 5 */ - SSD1306_SCROLL_FRAME_25 = 0x06, /**< scroll frame 25 */ - SSD1306_SCROLL_FRAME_64 = 0x01, /**< scroll frame 64 */ - SSD1306_SCROLL_FRAME_128 = 0x02, /**< scroll frame 128 */ - SSD1306_SCROLL_FRAME_256 = 0x03, /**< scroll frame 256 */ -} ssd1306_scroll_frame_t; - -/** - * @brief ssd1306 charge pump enumeration definition - */ -typedef enum -{ - SSD1306_CHARGE_PUMP_DISABLE = 0x00, /**< charge pump disable */ - SSD1306_CHARGE_PUMP_ENABLE = 0x01, /**< charge pump enable */ -} ssd1306_charge_pump_t; - -/** - * @brief ssd1306 segment column remap enumeration definition - */ -typedef enum -{ - SSD1306_SEGMENT_COLUMN_ADDRESS_0 = 0x00, /**< segment column remap address 0 */ - SSD1306_SEGMENT_COLUMN_ADDRESS_127 = 0x01, /**< segment column remap address 127 */ -} ssd1306_segment_column_remap_t; - -/** - * @brief ssd1306 entire display enumeration definition - */ -typedef enum -{ - SSD1306_ENTIRE_DISPLAY_OFF = 0x00, /**< entire display off */ - SSD1306_ENTIRE_DISPLAY_ON = 0x01, /**< entire display on */ -} ssd1306_entire_display_t; - -/** - * @brief ssd1306 display mode enumeration definition - */ -typedef enum -{ - SSD1306_DISPLAY_MODE_NORMAL = 0x00, /**< display mode normal */ - SSD1306_DISPLAY_MODE_INVERSE = 0x01, /**< display mode inverse */ -} ssd1306_display_mode_t; - -/** - * @brief ssd1306 display enumeration definition - */ -typedef enum -{ - SSD1306_DISPLAY_OFF = 0x00, /**< close display */ - SSD1306_DISPLAY_ON = 0x01, /**< open display */ -} ssd1306_display_t; - -/** - * @brief ssd1306 scan direction enumeration definition - */ -typedef enum -{ - SSD1306_SCAN_DIRECTION_COM0_START = 0x00, /**< scan direction com 0 start */ - SSD1306_SCAN_DIRECTION_COMN_1_START = 0x01, /**< scan direction com N-1 start */ -} ssd1306_scan_direction_t; - -/** - * @brief ssd1306 zoom in enumeration definition - */ -typedef enum -{ - SSD1306_ZOOM_IN_DISABLE = 0x00, /**< disable zoom in */ - SSD1306_ZOOM_IN_ENABLE = 0x01, /**< enable zoom in */ -} ssd1306_zoom_in_t; - -/** - * @brief ssd1306 pin conf enumeration definition - */ -typedef enum -{ - SSD1306_PIN_CONF_SEQUENTIAL = 0x00, /**< pin conf sequential */ - SSD1306_PIN_CONF_ALTERNATIVE = 0x01, /**< pin conf alternative */ -} ssd1306_pin_conf_t; - -/** - * @brief ssd1306 left right remap enumeration definition - */ -typedef enum -{ - SSD1306_LEFT_RIGHT_REMAP_DISABLE = 0x00, /**< disable left right remap */ - SSD1306_LEFT_RIGHT_REMAP_ENABLE = 0x01, /**< enable left right remap */ -} ssd1306_left_right_remap_t; - -/** - * @brief ssd1306 deselect level enumeration definition - */ -typedef enum -{ - SSD1306_DESELECT_LEVEL_0P65 = 0x00, /**< deselect level 0.65 */ - SSD1306_DESELECT_LEVEL_0P77 = 0x02, /**< deselect level 0.77 */ - SSD1306_DESELECT_LEVEL_0P83 = 0x03, /**< deselect level 0.83 */ -} ssd1306_deselect_level_t; - -/** - * @brief ssd1306 font enumeration definition - */ -typedef enum -{ - SSD1306_FONT_12 = 0x0C, /**< font 12 */ - SSD1306_FONT_16 = 0x10, /**< font 16 */ - SSD1306_FONT_24 = 0x18, /**< font 24 */ -} ssd1306_font_t; - -/** - * @brief ssd1306 handle structure definition - */ -typedef struct ssd1306_handle_s -{ - uint8_t (*iic_init)(void); /**< point to an iic_init function address */ - uint8_t (*iic_deinit)(void); /**< point to an iic_deinit function address */ - uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len); /**< point to an iic_write function address */ - uint8_t (*spi_init)(void); /**< point to a spi_init function address */ - uint8_t (*spi_deinit)(void); /**< point to a spi_deinit function address */ - uint8_t (*spi_write_cmd)(uint8_t *buf, uint16_t len); /**< point to a spi_write_cmd function address */ - uint8_t (*spi_cmd_data_gpio_init)(void); /**< point to a spi_cmd_data_gpio_init function address */ - uint8_t (*spi_cmd_data_gpio_deinit)(void); /**< point to a spi_cmd_data_gpio_deinit function address */ - uint8_t (*spi_cmd_data_gpio_write)(uint8_t value); /**< point to a spi_cmd_data_gpio_write function address */ - uint8_t (*reset_gpio_init)(void); /**< point to a reset_gpio_init function address */ - uint8_t (*reset_gpio_deinit)(void); /**< point to a reset_gpio_deinit function address */ - uint8_t (*reset_gpio_write)(uint8_t value); /**< point to a reset_gpio_write function address */ - void (*debug_print)(const char *const fmt, ...); /**< point to a debug_print function address */ - void (*delay_ms)(uint32_t ms); /**< point to a delay_ms function address */ - uint8_t inited; /**< inited flag */ - uint8_t iic_addr; /**< iic address */ - uint8_t iic_spi; /**< iic spi type */ - uint8_t gram[128][8]; /**< gram buffer */ -} ssd1306_handle_t; - -/** - * @brief ssd1306 information structure definition - */ -typedef struct ssd1306_info_s -{ - char chip_name[32]; /**< chip name */ - char manufacturer_name[32]; /**< manufacturer name */ - char ifname[8]; /**< chip interface name */ - float supply_voltage_min_v; /**< chip min supply voltage */ - float supply_voltage_max_v; /**< chip max supply voltage */ - float max_current_ma; /**< chip max current */ - float temperature_min; /**< chip min operating temperature */ - float temperature_max; /**< chip max operating temperature */ - uint32_t driver_version; /**< driver version */ -} ssd1306_info_t; - -/** - * @} - */ - -/** - * @defgroup ssd1306_link_driver ssd1306 link driver function - * @brief ssd1306 link driver modules - * @ingroup ssd1306_driver - * @{ - */ - -/** - * @brief initialize ssd1306_handle_t structure - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] STRUCTURE is ssd1306_handle_t - * @note none - */ -#define DRIVER_SSD1306_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE)) - -/** - * @brief link iic_init function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to an iic_init function address - * @note none - */ -#define DRIVER_SSD1306_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC - -/** - * @brief link iic_deinit function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to an iic_deinit function address - * @note none - */ -#define DRIVER_SSD1306_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC - -/** - * @brief link iic_write function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to an iic_write function address - * @note none - */ -#define DRIVER_SSD1306_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC - -/** - * @brief link spi_init function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a spi_init function address - * @note none - */ -#define DRIVER_SSD1306_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC - -/** - * @brief link spi_deinit function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a spi_deinit function address - * @note none - */ -#define DRIVER_SSD1306_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC - -/** - * @brief link spi_write_cmd function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a spi_write_cmd function address - * @note none - */ -#define DRIVER_SSD1306_LINK_SPI_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->spi_write_cmd = FUC - -/** - * @brief link spi_cmd_data_gpio_init function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a spi_cmd_data_gpio_init function address - * @note none - */ -#define DRIVER_SSD1306_LINK_SPI_COMMAND_DATA_GPIO_INIT(HANDLE, FUC) (HANDLE)->spi_cmd_data_gpio_init = FUC - -/** - * @brief link spi_cmd_data_gpio_deinit function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a spi_cmd_data_gpio_deinit function address - * @note none - */ -#define DRIVER_SSD1306_LINK_SPI_COMMAND_DATA_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->spi_cmd_data_gpio_deinit = FUC - -/** - * @brief link spi_cmd_data_gpio_write function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a spi_cmd_data_gpio_write function address - * @note none - */ -#define DRIVER_SSD1306_LINK_SPI_COMMAND_DATA_GPIO_WRITE(HANDLE, FUC) (HANDLE)->spi_cmd_data_gpio_write = FUC - -/** - * @brief link reset_gpio_init function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a reset_gpio_init function address - * @note none - */ -#define DRIVER_SSD1306_LINK_RESET_GPIO_INIT(HANDLE, FUC) (HANDLE)->reset_gpio_init = FUC - -/** - * @brief link reset_gpio_deinit function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a reset_gpio_deinit function address - * @note none - */ -#define DRIVER_SSD1306_LINK_RESET_GPIO_DEINIT(HANDLE, FUC) (HANDLE)->reset_gpio_deinit = FUC - -/** - * @brief link reset_gpio_write function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a reset_gpio_write function address - * @note none - */ -#define DRIVER_SSD1306_LINK_RESET_GPIO_WRITE(HANDLE, FUC) (HANDLE)->reset_gpio_write = FUC - -/** - * @brief link delay_ms function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a delay_ms function address - * @note none - */ -#define DRIVER_SSD1306_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC - -/** - * @brief link debug_print function - * @param[in] HANDLE points to an ssd1306 handle structure - * @param[in] FUC points to a debug_print function address - * @note none - */ -#define DRIVER_SSD1306_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC - -/** - * @} - */ - -/** - * @defgroup ssd1306_base_driver ssd1306 base driver function - * @brief ssd1306 base driver modules - * @ingroup ssd1306_driver - * @{ - */ - -/** - * @brief get chip's information - * @param[out] *info points to an ssd1306 info structure - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_info(ssd1306_info_t *info); - -/** - * @brief set the chip interface - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] interface is the chip interface - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_set_interface(ssd1306_handle_t *handle, ssd1306_interface_t ifhandler); - -/** - * @brief get the chip interface - * @param[in] *handle points to an ssd1306 handle structure - * @param[out] *interface points to a chip interface buffer - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_get_interface(ssd1306_handle_t *handle, ssd1306_interface_t *ifhandler); - -/** - * @brief set the chip iic address - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] addr_pin is the iic address - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_set_addr_pin(ssd1306_handle_t *handle, ssd1306_address_t addr_pin); - -/** - * @brief get the chip iic address - * @param[in] *handle points to an ssd1306 handle structure - * @param[out] *addr_pin points to an iic address buffer - * @return status code - * - 0 success - * - 2 handle is NULL - * @note none - */ -uint8_t ssd1306_get_addr_pin(ssd1306_handle_t *handle, ssd1306_address_t *addr_pin); - -/** - * @brief initialize the chip - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 iic or spi initialization failed - * - 2 handle is NULL - * - 3 linked functions is NULL - * - 4 reset failed - * - 5 command && data init failed - * - 6 interface param is invalid - * @note none - */ -uint8_t ssd1306_init(ssd1306_handle_t *handle); - -/** - * @brief close the chip - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 iic or spi deinit failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 power down failed - * - 5 reset gpio deinit failed - * - 6 command && data deinit failed - * - 7 interface param is invalid - * @note none - */ -uint8_t ssd1306_deinit(ssd1306_handle_t *handle); - -/** - * @brief clear the screen - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 clear failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_clear(ssd1306_handle_t *handle); - -/** - * @brief update the gram data - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 gram update failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_gram_update(ssd1306_handle_t *handle); - -/** - * @brief write a point - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] data is the write data - * @return status code - * - 0 success - * - 1 write point failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_write_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t data); - -/** - * @brief read a point - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[out] *data points to a data buffer - * @return status code - * - 0 success - * - 1 read point failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_read_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data); - -/** - * @brief write a point in the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] data is the write data - * @return status code - * - 0 success - * - 1 gram write point failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_gram_write_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t data); - -/** - * @brief read a point from the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[out] *data points to a data buffer - * @return status code - * - 0 success - * - 1 gram read point failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_gram_read_point(ssd1306_handle_t *handle, uint8_t x, uint8_t y, uint8_t *data); - -/** - * @brief draw a string in the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] *str points to a write string address - * @param[in] len is the length of the string - * @param[in] color is the display color - * @param[in] font is the display font size - * @return status code - * - 0 success - * - 1 gram write string failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 x or y is invalid - * @note none - */ -uint8_t ssd1306_gram_write_string(ssd1306_handle_t *handle, uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t color, ssd1306_font_t font); - -/** - * @brief fill a rectangle in the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] left is the left coordinate x - * @param[in] top is the top coordinate y - * @param[in] right is the right coordinate x - * @param[in] bottom is the bottom coordinate y - * @param[in] color is the display color - * @return status code - * - 0 success - * - 1 gram fill rect failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 left or top is invalid - * - 5 right or bottom is invalid - * - 6 left > right or top > bottom - * @note none - */ -uint8_t ssd1306_gram_fill_rect(ssd1306_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color); - -/** - * @brief draw a picture in the gram - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] left is the left coordinate x - * @param[in] top is the top coordinate y - * @param[in] right is the right coordinate x - * @param[in] bottom is the bottom coordinate y - * @param[in] *img points to an image buffer - * @return status code - * - 0 success - * - 1 gram draw picture failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 left or top is invalid - * - 5 right or bottom is invalid - * - 6 left > right or top > bottom - * @note none - */ -uint8_t ssd1306_gram_draw_picture(ssd1306_handle_t *handle, uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img); - -/** - * @brief set the low column start address - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] addr is the low column start address - * @return status code - * - 0 success - * - 1 set low column start address failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 addr is invalid - * @note addr <= 0xF - */ -uint8_t ssd1306_set_low_column_start_address(ssd1306_handle_t *handle, uint8_t addr); - -/** - * @brief set the high column start address - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] addr is the high column start address - * @return status code - * - 0 success - * - 1 set high column start address failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 addr is invalid - * @note addr <= 0xF - */ -uint8_t ssd1306_set_high_column_start_address(ssd1306_handle_t *handle, uint8_t addr); - -/** - * @brief set the memory addressing mode - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] mode is the memory addressing mode - * @return status code - * - 0 success - * - 1 set memory addressing mode failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_memory_addressing_mode(ssd1306_handle_t *handle, ssd1306_memory_addressing_mode_t mode); - -/** - * @brief set the column address range - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_addr is the column start address - * @param[in] end_addr is the column end address - * @return status code - * - 0 success - * - 1 set column address range failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start addr is invalid - * - 5 end addr is invalid - * @note start addr and end addr can't be over 0x7F - */ -uint8_t ssd1306_set_column_address_range(ssd1306_handle_t *handle, uint8_t start_addr, uint8_t end_addr); - -/** - * @brief set the page address range - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_addr is the page start address - * @param[in] end_addr is the page end address - * @return status code - * - 0 success - * - 1 set page address range failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start addr is invalid - * - 5 end addr is invalid - * @note start addr and end addr can't be over 0x07 - */ -uint8_t ssd1306_set_page_address_range(ssd1306_handle_t *handle, uint8_t start_addr, uint8_t end_addr); - -/** - * @brief set the fade blinking mode - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] mode is the fade blinking mode - * @param[in] frames is the fade or blinking frames - * @return status code - * - 0 success - * - 1 set fade blinking mode failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 frames is invalid - * @note frames max is 0x0F and div is (frames + 1) * 8 - */ -uint8_t ssd1306_set_fade_blinking_mode(ssd1306_handle_t *handle, ssd1306_fade_blinking_mode_t mode, uint8_t frames); - -/** - * @brief set the right horizontal scroll - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_page_addr is the start page address - * @param[in] end_page_addr is the end page address - * @param[in] frames is the scroll frames - * @return status code - * - 0 success - * - 1 set right horizontal scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start page addr is invalid - * - 5 end page addr is invalid - * @note start_page_addr <= 0x07, end_page_addr <= 0x07 - */ -uint8_t ssd1306_set_right_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, - ssd1306_scroll_frame_t frames); - -/** - * @brief set the left horizontal scroll - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_page_addr is the start page address - * @param[in] end_page_addr is the end page address - * @param[in] frames is the scroll frames - * @return status code - * - 0 success - * - 1 set left horizontal scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start_page_addr is invalid - * - 5 end_page_addr is invalid - * @note start_page_addr <= 0x07, end_page_addr <= 0x07 - */ -uint8_t ssd1306_set_left_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, - ssd1306_scroll_frame_t frames); - -/** - * @brief set the vertical right horizontal scroll - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_page_addr is the start page address - * @param[in] end_page_addr is the end page address - * @param[in] rows is the row address - * @param[in] frames is the scroll frames - * @return status code - * - 0 success - * - 1 set vertical right horizontal scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start_page_addr is invalid - * - 5 end_page_addr is invalid - * - 6 rows is invalid - * @note start_page_addr <= 0x07, end_page_addr <= 0x07, rows <= 0x3F - */ -uint8_t ssd1306_set_vertical_right_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, - uint8_t rows, ssd1306_scroll_frame_t frames); - -/** - * @brief set the vertical left horizontal scroll - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_page_addr is the start page address - * @param[in] end_page_addr is the end page address - * @param[in] rows is the row address - * @param[in] frames is the scroll frames - * @return status code - * - 0 success - * - 1 set vertical left horizontal scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start_page_addr is invalid - * - 5 end_page_addr is invalid - * - 6 rows is invalid - * @note start_page_addr <= 0x07, end_page_addr <= 0x07, rows <= 0x3F - */ -uint8_t ssd1306_set_vertical_left_horizontal_scroll(ssd1306_handle_t *handle, uint8_t start_page_addr, uint8_t end_page_addr, - uint8_t rows, ssd1306_scroll_frame_t frames); - -/** - * @brief deactivate the scroll - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 deactivate scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_deactivate_scroll(ssd1306_handle_t *handle); - -/** - * @brief activate the scroll - * @param[in] *handle points to an ssd1306 handle structure - * @return status code - * - 0 success - * - 1 activate scroll failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_activate_scroll(ssd1306_handle_t *handle); - -/** - * @brief set the display start line - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] l is the start line - * @return status code - * - 0 success - * - 1 set display start line failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 line is invalid - * @note line <= 0x3F - */ -uint8_t ssd1306_set_display_start_line(ssd1306_handle_t *handle, uint8_t l); - -/** - * @brief set the display contrast - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] contrast is the display contrast - * @return status code - * - 0 success - * - 1 set contrast failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_contrast(ssd1306_handle_t *handle, uint8_t contrast); - -/** - * @brief enable or disable the charge pump - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] enable is a bool value - * @return status code - * - 0 success - * - 1 set charge pump failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_charge_pump(ssd1306_handle_t *handle, ssd1306_charge_pump_t enable); - -/** - * @brief set the segment remap - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] remap is the segment remap param - * @return status code - * - 0 success - * - 1 set segment remap failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_segment_remap(ssd1306_handle_t *handle, ssd1306_segment_column_remap_t remap); - -/** - * @brief set the vertical scroll area - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] start_row is the start row - * @param[in] end_row is the end row - * @return status code - * - 0 success - * - 1 set vertical scroll area failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 start_row is invalid - * - 5 end_row is invalid - * - 6 end_row > start_row - * @note start_row <= 0x3F, end_row <= 0x7F, start_row >= end_row - */ -uint8_t ssd1306_set_vertical_scroll_area(ssd1306_handle_t *handle, uint8_t start_row, uint8_t end_row); - -/** - * @brief enable or disable the entire display - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] enable is a bool value - * @return status code - * - 0 success - * - 1 set entire display failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_entire_display(ssd1306_handle_t *handle, ssd1306_entire_display_t enable); - -/** - * @brief set the display mode - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] mode is the display mode - * @return status code - * - 0 success - * - 1 set display mode failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_display_mode(ssd1306_handle_t *handle, ssd1306_display_mode_t mode); - -/** - * @brief set the multiplex ratio - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] multiplex is the multiplex ratio - * @return status code - * - 0 success - * - 1 set multiplex ratio failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 multiplex is too small - * - 5 multiplex is too large - * @note multiplex must be over 0x0E and less than 0x40 - */ -uint8_t ssd1306_set_multiplex_ratio(ssd1306_handle_t *handle, uint8_t multiplex); - -/** - * @brief enable or disable the display - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] on_off is a bool value - * @return status code - * - 0 success - * - 1 set display failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_display(ssd1306_handle_t *handle, ssd1306_display_t on_off); - -/** - * @brief set the page address - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] addr is the page address - * @return status code - * - 0 success - * - 1 set page address failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 addr is invalid - * @note addr <= 0x07 - */ -uint8_t ssd1306_set_page_address(ssd1306_handle_t *handle, uint8_t addr); - -/** - * @brief set the scan direction - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] dir is the scan direction - * @return status code - * - 0 success - * - 1 set scan direction failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_scan_direction(ssd1306_handle_t *handle, ssd1306_scan_direction_t dir); - -/** - * @brief set the display offset - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] offset is the display offset - * @return status code - * - 0 success - * - 1 set display offset failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 offset is invalid - * @note offset <= 0x3F - */ -uint8_t ssd1306_set_display_offset(ssd1306_handle_t *handle, uint8_t offset); - -/** - * @brief set the display clock - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] oscillator_frequency is the oscillator frequency - * @param[in] clock_divide is the clock divide - * @return status code - * - 0 success - * - 1 set display clock failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 oscillator frequency is invalid - * - 5 clock divide is invalid - * @note oscillator_frequency <= 0x0F, clock_divide <= 0x0F - */ -uint8_t ssd1306_set_display_clock(ssd1306_handle_t *handle, uint8_t oscillator_frequency, uint8_t clock_divide); - -/** - * @brief set the display zoom in - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] zoom is the display zoom in - * @return status code - * - 0 success - * - 1 set zoom in failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_zoom_in(ssd1306_handle_t *handle, ssd1306_zoom_in_t zoom); - -/** - * @brief set the pre charge period - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] phase1_period is the phase1 period - * @param[in] phase2_period is the phase2 period - * @return status code - * - 0 success - * - 1 set pre charge period failed - * - 2 handle is NULL - * - 3 handle is not initialized - * - 4 phase1 period is invalid - * - 5 phase2 period is invalid - * @note phase1_period <= 0x0F, phase2_period <= 0x0F - */ -uint8_t ssd1306_set_precharge_period(ssd1306_handle_t *handle, uint8_t phase1_period, uint8_t phase2_period); - -/** - * @brief set the hardware com pins - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] conf is the pin conf - * @param[in] remap is the left right remap - * @return status code - * - 0 success - * - 1 set com pins hardware conf failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_com_pins_hardware_conf(ssd1306_handle_t *handle, ssd1306_pin_conf_t conf, ssd1306_left_right_remap_t remap); - -/** - * @brief set the deselect level - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] level is the deselect level - * @return status code - * - 0 success - * - 1 set deselect level failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_set_deselect_level(ssd1306_handle_t *handle, ssd1306_deselect_level_t level); - -/** - * @} - */ - -/** - * @defgroup ssd1306_extend_driver ssd1306 extend driver function - * @brief ssd1306 extend driver modules - * @ingroup ssd1306_driver - * @{ - */ - -/** - * @brief write the register command - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] *buf points to a data buffer - * @param[in] len is the data length - * @return status code - * - 0 success - * - 1 write failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_write_cmd(ssd1306_handle_t *handle, uint8_t *buf, uint8_t len); - -/** - * @brief write the register data - * @param[in] *handle points to an ssd1306 handle structure - * @param[in] *buf points to a data buffer - * @param[in] len is the data length - * @return status code - * - 0 success - * - 1 write failed - * - 2 handle is NULL - * - 3 handle is not initialized - * @note none - */ -uint8_t ssd1306_write_data(ssd1306_handle_t *handle, uint8_t *buf, uint8_t len); - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/app/src/_board/ssd1306/driver_ssd1306_basic.c b/app/src/_board/ssd1306/driver_ssd1306_basic.c deleted file mode 100644 index ff1fd58..0000000 --- a/app/src/_board/ssd1306/driver_ssd1306_basic.c +++ /dev/null @@ -1,792 +0,0 @@ -/** - * Copyright (c) 2015 - present LibDriver All rights reserved - * - * The MIT License (MIT) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * @file driver_ssd1306_basic.c - * @brief driver ssd1306 basic source file - * @version 2.0.0 - * @author Shifeng Li - * @date 2021-03-30 - * - *

history

- * - *
Date Version Author Description - *
2021/03/30 2.0 Shifeng Li format the code - *
2020/12/10 1.0 Shifeng Li first upload - *
- */ - -#include "driver_ssd1306_basic.h" - -#include - -static ssd1306_handle_t gs_handle; /**< ssd1306 handle */ - -/** - * @brief basic example init - * @param[in] interface is the interface type - * @param[in] addr is the iic device address - * @return status code - * - 0 success - * - 1 init failed - * @note none - */ -uint8_t ssd1306_basic_init(ssd1306_interface_t ifhandler, ssd1306_address_t addr) { - uint8_t res; - - /* link functions */ - DRIVER_SSD1306_LINK_INIT(&gs_handle, ssd1306_handle_t); - DRIVER_SSD1306_LINK_IIC_INIT(&gs_handle, ssd1306_interface_iic_init); - DRIVER_SSD1306_LINK_IIC_DEINIT(&gs_handle, ssd1306_interface_iic_deinit); - DRIVER_SSD1306_LINK_IIC_WRITE(&gs_handle, ssd1306_interface_iic_write); - DRIVER_SSD1306_LINK_SPI_INIT(&gs_handle, ssd1306_interface_spi_init); - DRIVER_SSD1306_LINK_SPI_DEINIT(&gs_handle, ssd1306_interface_spi_deinit); - DRIVER_SSD1306_LINK_SPI_WRITE_COMMAND(&gs_handle, ssd1306_interface_spi_write_cmd); - DRIVER_SSD1306_LINK_SPI_COMMAND_DATA_GPIO_INIT(&gs_handle, ssd1306_interface_spi_cmd_data_gpio_init); - DRIVER_SSD1306_LINK_SPI_COMMAND_DATA_GPIO_DEINIT(&gs_handle, ssd1306_interface_spi_cmd_data_gpio_deinit); - DRIVER_SSD1306_LINK_SPI_COMMAND_DATA_GPIO_WRITE(&gs_handle, ssd1306_interface_spi_cmd_data_gpio_write); - DRIVER_SSD1306_LINK_RESET_GPIO_INIT(&gs_handle, ssd1306_interface_reset_gpio_init); - DRIVER_SSD1306_LINK_RESET_GPIO_DEINIT(&gs_handle, ssd1306_interface_reset_gpio_deinit); - DRIVER_SSD1306_LINK_RESET_GPIO_WRITE(&gs_handle, ssd1306_interface_reset_gpio_write); - DRIVER_SSD1306_LINK_DELAY_MS(&gs_handle, ssd1306_interface_delay_ms); - DRIVER_SSD1306_LINK_DEBUG_PRINT(&gs_handle, ssd1306_interface_debug_print); - - /* set interface */ - res = ssd1306_set_interface(&gs_handle, ifhandler); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set interface failed.\n"); - - return 1; - } - - /* set addr pin */ - res = ssd1306_set_addr_pin(&gs_handle, addr); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set addr failed.\n"); - - return 1; - } - - /* ssd1306 init */ - res = ssd1306_init(&gs_handle); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: init failed.\n"); - - return 1; - } - - /* close display */ - res = ssd1306_set_display(&gs_handle, SSD1306_DISPLAY_OFF); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set display failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set column address range */ - res = ssd1306_set_column_address_range(&gs_handle, SSD1306_BASIC_DEFAULT_COLUMN_ADDRESS_RANGE_START, SSD1306_BASIC_DEFAULT_COLUMN_ADDRESS_RANGE_END); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set column address range failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set page address range */ - res = ssd1306_set_page_address_range(&gs_handle, SSD1306_BASIC_DEFAULT_PAGE_ADDRESS_RANGE_START, SSD1306_BASIC_DEFAULT_PAGE_ADDRESS_RANGE_END); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set page address range failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set low column start address */ - res = ssd1306_set_low_column_start_address(&gs_handle, SSD1306_BASIC_DEFAULT_LOW_COLUMN_START_ADDRESS); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set low column start address failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set high column start address */ - res = ssd1306_set_high_column_start_address(&gs_handle, SSD1306_BASIC_DEFAULT_HIGH_COLUMN_START_ADDRESS); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set high column start address failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set display start line */ - res = ssd1306_set_display_start_line(&gs_handle, SSD1306_BASIC_DEFAULT_DISPLAY_START_LINE); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set display start line failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set fade blinking mode */ - res = ssd1306_set_fade_blinking_mode(&gs_handle, SSD1306_BASIC_DEFAULT_FADE_BLINKING_MODE, SSD1306_BASIC_DEFAULT_FADE_FRAMES); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set fade blinking failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* deactivate scroll */ - res = ssd1306_deactivate_scroll(&gs_handle); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set deactivate scroll failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set zoom in */ - res = ssd1306_set_zoom_in(&gs_handle, SSD1306_BASIC_DEFAULT_ZOOM_IN); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set set zoom in failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set contrast */ - res = ssd1306_set_contrast(&gs_handle, SSD1306_BASIC_DEFAULT_CONTRAST); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set contrast failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set segment remap */ - res = ssd1306_set_segment_remap(&gs_handle, SSD1306_BASIC_DEFAULT_SEGMENT); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set segment remap failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set scan direction */ - res = ssd1306_set_scan_direction(&gs_handle, SSD1306_BASIC_DEFAULT_SCAN_DIRECTION); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set scan direction failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set display mode */ - res = ssd1306_set_display_mode(&gs_handle, SSD1306_BASIC_DEFAULT_DISPLAY_MODE); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set display mode failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set multiplex ratio */ - res = ssd1306_set_multiplex_ratio(&gs_handle, SSD1306_BASIC_DEFAULT_MULTIPLEX_RATIO); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set multiplex ratio failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set display offset */ - res = ssd1306_set_display_offset(&gs_handle, SSD1306_BASIC_DEFAULT_DISPLAY_OFFSET); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set display offset failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set display clock */ - res = ssd1306_set_display_clock(&gs_handle, SSD1306_BASIC_DEFAULT_OSCILLATOR_FREQUENCY, SSD1306_BASIC_DEFAULT_CLOCK_DIVIDE); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set display clock failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set pre charge period */ - res = ssd1306_set_precharge_period(&gs_handle, SSD1306_BASIC_DEFAULT_PHASE1_PERIOD, SSD1306_BASIC_DEFAULT_PHASE2_PERIOD); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set pre charge period failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set hardware pins conf */ - res = ssd1306_set_com_pins_hardware_conf(&gs_handle, SSD1306_BASIC_DEFAULT_PIN_CONF, SSD1306_BASIC_DEFAULT_LEFT_RIGHT_REMAP); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set com pins hardware conf failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set deselect level 0.77 */ - res = ssd1306_set_deselect_level(&gs_handle, SSD1306_BASIC_DEFAULT_DESELECT_LEVEL); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set deselect level failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* set page memory addressing mode */ - res = ssd1306_set_memory_addressing_mode(&gs_handle, SSD1306_MEMORY_ADDRESSING_MODE_PAGE); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set memory addressing level failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* enable charge pump */ - res = ssd1306_set_charge_pump(&gs_handle, SSD1306_CHARGE_PUMP_ENABLE); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set charge pump failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* entire display off */ - res = ssd1306_set_entire_display(&gs_handle, SSD1306_ENTIRE_DISPLAY_OFF); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set entire display failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* enable display */ - res = ssd1306_set_display(&gs_handle, SSD1306_DISPLAY_ON); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: set display failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - /* clear screen */ - res = ssd1306_clear(&gs_handle); - if (res != 0) { - ssd1306_interface_debug_print("ssd1306: clear failed.\n"); - (void)ssd1306_deinit(&gs_handle); - - return 1; - } - - return 0; -} - -/** - * @brief basic example deinit - * @return status code - * - 0 success - * - 1 deinit failed - * @note none - */ -uint8_t ssd1306_basic_deinit(void) { - /* deinit ssd1306 */ - if (ssd1306_deinit(&gs_handle) != 0) { - return 1; - } else { - return 0; - } -} - -/** - * @brief basic example display on - * @return status code - * - 0 success - * - 1 display on failed - * @note none - */ -uint8_t ssd1306_basic_display_on(void) { - uint8_t res; - - /* display on */ - res = ssd1306_set_display(&gs_handle, SSD1306_DISPLAY_ON); - if (res != 0) { - return 1; - } else { - return 0; - } -} - -/** - * @brief basic example display off - * @return status code - * - 0 success - * - 1 display off failed - * @note none - */ -uint8_t ssd1306_basic_display_off(void) { - uint8_t res; - - /* display off */ - res = ssd1306_set_display(&gs_handle, SSD1306_DISPLAY_OFF); - if (res != 0) { - return 1; - } else { - return 0; - } -} - -/** - * @brief basic example clear - * @return status code - * - 0 success - * - 1 clear failed - * @note none - */ -uint8_t ssd1306_basic_clear(void) { - /* clear */ - if (ssd1306_clear(&gs_handle) != 0) { - return 1; - } else { - return 0; - } -} - -/** - * @brief basic example write a point - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] data is the written data - * @return status code - * - 0 success - * - 1 write point failed - * @note none - */ -uint8_t ssd1306_basic_write_point(uint8_t x, uint8_t y, uint8_t data) { - uint8_t res; - - /* write point */ - res = ssd1306_write_point(&gs_handle, x, y, data); - if (res != 0) { - return 1; - } - - return 0; -} -ssd1306_handle_t *ssd1306_handler() { return &gs_handle; } - -/** - * @brief basic example read a point - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[out] *data points to a data buffer - * @return status code - * - 0 success - * - 1 read point failed - * @note none - */ -uint8_t ssd1306_basic_read_point(uint8_t x, uint8_t y, uint8_t *data) { - uint8_t res; - - /* read point in gram */ - res = ssd1306_read_point(&gs_handle, x, y, data); - if (res != 0) { - return 1; - } - - return 0; -} - -/** - * @brief basic example draw a string - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] *str points to a written string address - * @param[in] len is the length of the string - * @param[in] color is the display color - * @param[in] font is the display font size - * @return status code - * - 0 success - * - 1 write string failed - * @note none - */ -uint8_t ssd1306_basic_string(uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t color, ssd1306_font_t font) { - uint8_t res; - - /* write string in gram */ - res = ssd1306_gram_write_string(&gs_handle, x, y, str, len, color, font); - if (res != 0) { - return 1; - } - - /* update gram */ - if (ssd1306_gram_update(&gs_handle) != 0) { - return 1; - } else { - return 0; - } -} - -/** - * @brief basic example fill a rectangle - * @param[in] left is the left coordinate x - * @param[in] top is the top coordinate y - * @param[in] right is the right coordinate x - * @param[in] bottom is the bottom coordinate y - * @param[in] color is the display color - * @return status code - * - 0 success - * - 1 fill rect failed - * @note none - */ -uint8_t ssd1306_basic_rect(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color) { - uint8_t res; - - /* fill rect in gram */ - res = ssd1306_gram_fill_rect(&gs_handle, left, top, right, bottom, color); - if (res != 0) { - return 1; - } - - /* update gram */ - if (ssd1306_gram_update(&gs_handle) != 0) { - return 1; - } else { - return 0; - } -} - -/** - * @brief basic example draw a picture - * @param[in] left is the left coordinate x - * @param[in] top is the top coordinate y - * @param[in] right is the right coordinate x - * @param[in] bottom is the bottom coordinate y - * @param[in] *img points to a image buffer - * @return status code - * - 0 success - * - 1 draw picture failed - * @note none - */ -uint8_t ssd1306_basic_picture(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img) { - uint8_t res; - - /* draw picture in gram */ - res = ssd1306_gram_draw_picture(&gs_handle, left, top, right, bottom, img); - if (res != 0) { - return 1; - } - - /* update gram */ - if (ssd1306_gram_update(&gs_handle) != 0) { - return 1; - } else { - return 0; - } -} -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_clear_gram(void) { - memset(gs_handle.gram, 0, sizeof(gs_handle.gram)); - return 0; -} - -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, const char *str, FontLibrary_t *frontlib) { - const uint8_t *frontbuf = NULL; - FontLibrary_findchar(frontlib, str, &frontbuf); - if (!frontbuf) return 1; - - // ssd1306_gram_write_point - for (uint32_t xoff = 0; xoff < frontlib->widthPixel; xoff++) { - for (uint32_t yoff = 0; yoff < frontlib->heightPixel; yoff++) { - bool pixval = 0; - /** - * |||||| - * VVVVVV - * |||||| - * VVVVVV - * - * x = 3; y = 9; - * byteoff = x + y / frontWidthPixel * frontWidthPixel - * bitoff = y % 8 - */ - - uint8_t byteoff = xoff + yoff / 8 * frontlib->widthPixel; - uint8_t bitoff = yoff % 8; - pixval = (frontbuf[byteoff] >> bitoff) & 0x01; - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, pixval); - } - } - return 0; -} - -uint8_t ssd1306_basic_draw_str(uint8_t xs, uint8_t ys, uint8_t *xchange, uint8_t *ychange, const char *str, FontLibrary_t *frontlib) { - uint8_t x = xs; - uint8_t y = ys; - StrIterator_t iterator; - *xchange = 0; - *ychange = 0; - str_iterator_start(&iterator, frontlib->fontCode, str); - char *nowchr = NULL; - while (true) { - str_iterator_next(&iterator, &nowchr); - if (!nowchr) { - break; - } - ssd1306_basic_draw_one_chr(x, y, nowchr, frontlib); - x += (uint8_t)(frontlib->widthPixel); /* x + font/2 */ - *xchange = *xchange + frontlib->widthPixel; - } - - *ychange = frontlib->heightPixel; - - return 0; -} - -uint8_t ssd1306_basic_draw_battery_level(uint8_t xs, uint8_t ys, uint8_t *xchange, uint8_t *ychange, int level, int width, int high) { - /** - * @brief - * ***** - * ******** - * * * - * * **** * - * * **** * - * ******** - */ - - if (level >= 100) { - level = 100; - } - - uint8_t xoff = 0; - uint8_t yoff = 0; - - int batteryHeaderHigh = 2; - int batteryHeaderWidth = 7; - int batteryBodyHigh = 20; - int batteryBodyWidth = 12; - int border_width = 1; - int blank_width = 1; - - float width_mult = width * 1.0 / batteryBodyWidth; - float high_mult = high * 1.0 / (batteryBodyHigh + batteryHeaderHigh); - - batteryHeaderHigh = batteryHeaderHigh * high_mult; - batteryHeaderWidth = batteryHeaderWidth * width_mult; - batteryBodyHigh = batteryBodyHigh * high_mult; - batteryBodyWidth = batteryBodyWidth * width_mult; - border_width = 1; - blank_width = 1; - - int batteryInterBodyWidth = batteryBodyWidth - blank_width * 2 - border_width * 2; - int batteryInterBodyHigh = batteryBodyHigh - border_width * 2 - blank_width * 2; - /** - * @brief 画头?? - */ - for (int yoff = 0; yoff < batteryHeaderHigh; yoff++) { - for (int xoff = 0; xoff < batteryBodyWidth; xoff++) { - uint16_t battery_start = (batteryBodyWidth - batteryHeaderWidth) / 2; - uint16_t battery_end = battery_start + batteryHeaderWidth; - if (xoff >= battery_start && xoff <= battery_end) { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } else { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 0); - } - } - } - ys += batteryHeaderHigh; - - /** - * @brief 画上边沿 - */ - for (int yoff = 0; yoff < border_width; yoff++) { - for (int xoff = 0; xoff < batteryBodyWidth; xoff++) { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } - } - ys += border_width; - /** - * @brief 画上留白 - */ - for (int yoff = 0; yoff < blank_width; yoff++) { - for (int xoff = 0; xoff < batteryBodyWidth; xoff++) { - // uint16_t start = blank_width; - if (xoff < border_width) { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } else if (xoff >= (batteryInterBodyWidth + border_width * 1 + blank_width * 2)) { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } else { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 0); - } - } - } - ys += blank_width; - - /** - * @brief 画身?? - */ - for (int yoff = 0; yoff < batteryInterBodyHigh; yoff++) { - for (int xoff = 0; xoff < batteryBodyWidth; xoff++) { - // uint16_t start = blank_width; - if (xoff < border_width) { - // right border - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } else if (xoff >= border_width + blank_width && xoff < batteryInterBodyWidth + border_width + blank_width) { - // body - // ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - - uint16_t batterylevel = (100 - level) / 100.0 * batteryInterBodyHigh; - if (yoff >= batterylevel) { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } else { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 0); - } - - } else if (xoff >= batteryInterBodyWidth + border_width * 1 + blank_width * 2) { - // left border - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } else { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 0); - } - } - } - ys += batteryInterBodyHigh; - - /** - * @brief 画上留白 - */ - for (int yoff = 0; yoff < blank_width; yoff++) { - for (int xoff = 0; xoff < batteryBodyWidth; xoff++) { - // uint16_t start = blank_width; - if (xoff < border_width) { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } else if (xoff >= (batteryInterBodyWidth + border_width * 1 + blank_width * 2)) { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } else { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 0); - } - } - } - ys += blank_width; - /** - * @brief 画上边沿 - */ - for (int yoff = 0; yoff < border_width; yoff++) { - for (int xoff = 0; xoff < batteryBodyWidth; xoff++) { - ssd1306_gram_write_point(&gs_handle, xs + xoff, ys + yoff, 1); - } - } - ys += border_width; - - *xchange = batteryBodyWidth; - *ychange = batteryBodyHigh + batteryHeaderHigh; -} - -uint8_t ssd1306_basic_draw_progress(uint8_t xs, uint8_t ys, uint16_t width, uint16_t high, uint16_t markpos, uint16_t progress) { - /** - * @brief - * - * [==================> ] - */ - - /** - * @brief - */ - for (uint16_t i = 0; i < width; i++) { - ssd1306_gram_write_point(&gs_handle, xs + i, ys, 1); - } - ys += 1; - - /** - * @brief - */ - uint16_t progress_width = width * progress / 100.0; - uint16_t markpos_off = width * markpos / 100.0; - for (uint16_t yoff = 0; yoff < high - 2; yoff++) { - for (uint16_t i = 0; i < width; i++) { - if (i == width - 1) { - ssd1306_gram_write_point(&gs_handle, xs + i, ys + yoff, 1); - } else if (i >= markpos_off && i < markpos_off + 1) { - ssd1306_gram_write_point(&gs_handle, xs + i, ys + yoff, 1); - } else { - if (i < progress_width || i == 0) { - ssd1306_gram_write_point(&gs_handle, xs + i, ys + yoff, 1); - } else { - ssd1306_gram_write_point(&gs_handle, xs + i, ys + yoff, 0); - } - } - } - } - - ys += high - 2; - /** - * @brief - */ - for (uint16_t i = 0; i < width; i++) { - ssd1306_gram_write_point(&gs_handle, xs + i, ys, 1); - } - return 0; -} - -uint8_t ssd1306_basic_draw_line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) { - int dx = abs(x2 - x1); - int dy = abs(y2 - y1); - int sx = (x1 < x2) ? 1 : -1; - int sy = (y1 < y2) ? 1 : -1; - int err = dx - dy; - - while (1) { - ssd1306_gram_write_point(&gs_handle, x1, y1, 1); - if (x1 == x2 && y1 == y2) { - break; - } - - int e2 = 2 * err; - if (e2 > -dy) { - err -= dy; - x1 += sx; - } - - if (e2 < dx) { - err += dx; - y1 += sy; - } - } -} diff --git a/app/src/_board/ssd1306/driver_ssd1306_basic.h b/app/src/_board/ssd1306/driver_ssd1306_basic.h deleted file mode 100644 index 2e1d706..0000000 --- a/app/src/_board/ssd1306/driver_ssd1306_basic.h +++ /dev/null @@ -1,226 +0,0 @@ -/** - * Copyright (c) 2015 - present LibDriver All rights reserved - * - * The MIT License (MIT) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * @file driver_ssd1306_basic.h - * @brief driver ssd1306 basic header file - * @version 2.0.0 - * @author Shifeng Li - * @date 2021-03-30 - * - *

history

- * - *
Date Version Author Description - *
2021/03/30 2.0 Shifeng Li format the code - *
2020/12/10 1.0 Shifeng Li first upload - *
- */ - -#ifndef DRIVER_SSD1306_BASIC_H -#define DRIVER_SSD1306_BASIC_H - -#include "driver_ssd1306_interface.h" -#include "fontlib.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ssd1306_example_driver ssd1306 example driver function - * @brief ssd1306 example driver modules - * @ingroup ssd1306_driver - * @{ - */ - -/** - * @brief ssd1306 basic example default definition - */ -#define SSD1306_BASIC_DEFAULT_DESELECT_LEVEL SSD1306_DESELECT_LEVEL_0P77 /**< set deselect level 0.77 */ -#define SSD1306_BASIC_DEFAULT_LEFT_RIGHT_REMAP SSD1306_LEFT_RIGHT_REMAP_DISABLE /**< disable remap */ -#define SSD1306_BASIC_DEFAULT_PIN_CONF SSD1306_PIN_CONF_ALTERNATIVE /**< set alternative */ -#define SSD1306_BASIC_DEFAULT_PHASE1_PERIOD 0x01 /**< set phase 1 */ -#define SSD1306_BASIC_DEFAULT_PHASE2_PERIOD 0x0F /**< set phase F */ -#define SSD1306_BASIC_DEFAULT_OSCILLATOR_FREQUENCY 0x08 /**< set 8 */ -#define SSD1306_BASIC_DEFAULT_CLOCK_DIVIDE 0x00 /**< set clock div 0 */ -#define SSD1306_BASIC_DEFAULT_DISPLAY_OFFSET 0x00 /**< set display offset */ -#define SSD1306_BASIC_DEFAULT_MULTIPLEX_RATIO 0x3F /**< set ratio */ -#define SSD1306_BASIC_DEFAULT_DISPLAY_MODE SSD1306_DISPLAY_MODE_NORMAL /**< set normal mode */ -#define SSD1306_BASIC_DEFAULT_SCAN_DIRECTION SSD1306_SCAN_DIRECTION_COM0_START /**< 字的方向不对修改这里 */ -// #define SSD1306_BASIC_DEFAULT_SCAN_DIRECTION SSD1306_SCAN_DIRECTION_COM0_START /**< 字的方向不对修改这里 */ -#define SSD1306_BASIC_DEFAULT_SEGMENT SSD1306_SEGMENT_COLUMN_ADDRESS_127 /**< 字的方向不对修改这里 */ -// #define SSD1306_BASIC_DEFAULT_SEGMENT SSD1306_SEGMENT_COLUMN_ADDRESS_127 /**< 字的方向不对修改这里 */ -// #define SSD1306_BASIC_DEFAULT_CONTRAST 0xCF /**< set contrast CF */ -#define SSD1306_BASIC_DEFAULT_CONTRAST 0x05 /**< set contrast CF */ -#define SSD1306_BASIC_DEFAULT_ZOOM_IN SSD1306_ZOOM_IN_DISABLE /**< disable zoom in */ -#define SSD1306_BASIC_DEFAULT_FADE_BLINKING_MODE SSD1306_FADE_BLINKING_MODE_DISABLE /**< disable fade */ -#define SSD1306_BASIC_DEFAULT_FADE_FRAMES 0x00 /**< set frame 0 */ -#define SSD1306_BASIC_DEFAULT_DISPLAY_START_LINE 0x00 /**< set start line 0 */ -#define SSD1306_BASIC_DEFAULT_HIGH_COLUMN_START_ADDRESS 0x00 /**< set high start 0 */ -#define SSD1306_BASIC_DEFAULT_LOW_COLUMN_START_ADDRESS 0x00 /**< set low start 0 */ -#define SSD1306_BASIC_DEFAULT_PAGE_ADDRESS_RANGE_START 0x00 /**< set page range start */ -#define SSD1306_BASIC_DEFAULT_PAGE_ADDRESS_RANGE_END 0x07 /**< set page range end */ -#define SSD1306_BASIC_DEFAULT_COLUMN_ADDRESS_RANGE_START 0x00 /**< set range start */ -#define SSD1306_BASIC_DEFAULT_COLUMN_ADDRESS_RANGE_END 0x7F /**< set range end */ - -/** - * @brief basic example init - * @param[in] interface is the interface type - * @param[in] addr is the iic device address - * @return status code - * - 0 success - * - 1 init failed - * @note none - */ -uint8_t ssd1306_basic_init(ssd1306_interface_t ifhandler, ssd1306_address_t addr); - -/** - * @brief basic example deinit - * @return status code - * - 0 success - * - 1 deinit failed - * @note none - */ -uint8_t ssd1306_basic_deinit(void); - -/** - * @brief basic example display on - * @return status code - * - 0 success - * - 1 display on failed - * @note none - */ -uint8_t ssd1306_basic_display_on(void); - -/** - * @brief basic example display off - * @return status code - * - 0 success - * - 1 display off failed - * @note none - */ -uint8_t ssd1306_basic_display_off(void); - -/** - * @brief basic example clear - * @return status code - * - 0 success - * - 1 clear failed - * @note none - */ -uint8_t ssd1306_basic_clear(void); - -/** - * @brief basic example write a point - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] data is the written data - * @return status code - * - 0 success - * - 1 write point failed - * @note none - */ -uint8_t ssd1306_basic_write_point(uint8_t x, uint8_t y, uint8_t data); - -/** - * @brief basic example read a point - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[out] *data points to a data buffer - * @return status code - * - 0 success - * - 1 read point failed - * @note none - */ -uint8_t ssd1306_basic_read_point(uint8_t x, uint8_t y, uint8_t *data); - -/** - * @brief basic example draw a string - * @param[in] x is the coordinate x - * @param[in] y is the coordinate y - * @param[in] *str points to a written string address - * @param[in] len is the length of the string - * @param[in] color is the display color - * @param[in] font is the display font size - * @return status code - * - 0 success - * - 1 write string failed - * @note none - */ -uint8_t ssd1306_basic_string(uint8_t x, uint8_t y, char *str, uint16_t len, uint8_t color, ssd1306_font_t font); -/** - * @brief basic example fill a rectangle - * @param[in] left is the left coordinate x - * @param[in] top is the top coordinate y - * @param[in] right is the right coordinate x - * @param[in] bottom is the bottom coordinate y - * @param[in] color is the display color - * @return status code - * - 0 success - * - 1 fill rect failed - * @note none - */ -uint8_t ssd1306_basic_rect(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t color); - -/** - * @brief basic example draw a picture - * @param[in] left is the left coordinate x - * @param[in] top is the top coordinate y - * @param[in] right is the right coordinate x - * @param[in] bottom is the bottom coordinate y - * @param[in] *img points to a image buffer - * @return status code - * - 0 success - * - 1 draw picture failed - * @note none - */ -uint8_t ssd1306_basic_picture(uint8_t left, uint8_t top, uint8_t right, uint8_t bottom, uint8_t *img); - -/******************************************************************************* - * ADD_BY_ZHAOHE * - *******************************************************************************/ - -uint8_t ssd1306_basic_draw_screen(const char *img); -uint8_t ssd1306_basic_gram_update(); -ssd1306_handle_t *ssd1306_handler(); -uint8_t ssd1306_basic_line(uint8_t x, uint8_t y, uint8_t data); - -uint8_t ssd1306_basic_draw_str(uint8_t xs, uint8_t ys, uint8_t *xchange, uint8_t *ychange, const char *str, FontLibrary_t *frontlib); - -uint8_t ssd1306_basic_draw_battery_level(uint8_t xs, uint8_t ys, uint8_t *xchange, uint8_t *ychange, int level, int width, int high); - -uint8_t ssd1306_basic_draw_progress(uint8_t xs, uint8_t ys, uint16_t width, uint16_t high, uint16_t markpos, uint16_t progress); - -uint8_t ssd1306_basic_draw_line(uint8_t x1, uint8_t y1,uint8_t x2, uint8_t y2); - -uint8_t ssd1306_basic_clear_gram(void); - - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/app/src/_board/ssd1306/driver_ssd1306_font.h b/app/src/_board/ssd1306/driver_ssd1306_font.h deleted file mode 100644 index 1734127..0000000 --- a/app/src/_board/ssd1306/driver_ssd1306_font.h +++ /dev/null @@ -1,350 +0,0 @@ -/** - * Copyright (c) 2015 - present LibDriver All rights reserved - * - * The MIT License (MIT) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * @file driver_ssd1306_font.h - * @brief driver ssd1306 font header file - * @version 2.0.0 - * @author Shifeng Li - * @date 2021-03-30 - * - *

history

- * - *
Date Version Author Description - *
2021/03/30 2.0 Shifeng Li format the code - *
2020/12/10 1.0 Shifeng Li first upload - *
- */ - -#ifndef DRIVER_SSD1306_FONT_H -#define DRIVER_SSD1306_FONT_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -static const uint8_t gsc_ssd1306_ascii_1206[95][12] = -{ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*" ", 0*/ - {0x00, 0x00, 0x00, 0x00, 0x3F, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"!", 1*/ - {0x00, 0x00, 0x30, 0x00, 0x40, 0x00, 0x30, 0x00, 0x40, 0x00, 0x00, 0x00}, /*""", 2*/ - {0x09, 0x00, 0x0B, 0xC0, 0x3D, 0x00, 0x0B, 0xC0, 0x3D, 0x00, 0x09, 0x00}, /*"#", 3*/ - {0x18, 0xC0, 0x24, 0x40, 0x7F, 0xE0, 0x22, 0x40, 0x31, 0x80, 0x00, 0x00}, /*"$", 4*/ - {0x18, 0x00, 0x24, 0xC0, 0x1B, 0x00, 0x0D, 0x80, 0x32, 0x40, 0x01, 0x80}, /*"%", 5*/ - {0x03, 0x80, 0x1C, 0x40, 0x27, 0x40, 0x1C, 0x80, 0x07, 0x40, 0x00, 0x40}, /*"&", 6*/ - {0x10, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"'", 7*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x80, 0x20, 0x40, 0x40, 0x20}, /*"(", 8*/ - {0x00, 0x00, 0x40, 0x20, 0x20, 0x40, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00}, /*")", 9*/ - {0x09, 0x00, 0x06, 0x00, 0x1F, 0x80, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00}, /*"*", 10*/ - {0x04, 0x00, 0x04, 0x00, 0x3F, 0x80, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00}, /*"+", 11*/ - {0x00, 0x10, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*", ", 12*/ - {0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00}, /*"-", 13*/ - {0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*".", 14*/ - {0x00, 0x20, 0x01, 0xC0, 0x06, 0x00, 0x38, 0x00, 0x40, 0x00, 0x00, 0x00}, /*"/", 15*/ - {0x1F, 0x80, 0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 0x1F, 0x80, 0x00, 0x00}, /*"0", 16*/ - {0x00, 0x00, 0x10, 0x40, 0x3F, 0xC0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00}, /*"1", 17*/ - {0x18, 0xC0, 0x21, 0x40, 0x22, 0x40, 0x24, 0x40, 0x18, 0x40, 0x00, 0x00}, /*"2", 18*/ - {0x10, 0x80, 0x20, 0x40, 0x24, 0x40, 0x24, 0x40, 0x1B, 0x80, 0x00, 0x00}, /*"3", 19*/ - {0x02, 0x00, 0x0D, 0x00, 0x11, 0x00, 0x3F, 0xC0, 0x01, 0x40, 0x00, 0x00}, /*"4", 20*/ - {0x3C, 0x80, 0x24, 0x40, 0x24, 0x40, 0x24, 0x40, 0x23, 0x80, 0x00, 0x00}, /*"5", 21*/ - {0x1F, 0x80, 0x24, 0x40, 0x24, 0x40, 0x34, 0x40, 0x03, 0x80, 0x00, 0x00}, /*"6", 22*/ - {0x30, 0x00, 0x20, 0x00, 0x27, 0xC0, 0x38, 0x00, 0x20, 0x00, 0x00, 0x00}, /*"7", 23*/ - {0x1B, 0x80, 0x24, 0x40, 0x24, 0x40, 0x24, 0x40, 0x1B, 0x80, 0x00, 0x00}, /*"8", 24*/ - {0x1C, 0x00, 0x22, 0xC0, 0x22, 0x40, 0x22, 0x40, 0x1F, 0x80, 0x00, 0x00}, /*"9", 25*/ - {0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*":", 26*/ - {0x00, 0x00, 0x00, 0x00, 0x04, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*";", 27*/ - {0x00, 0x00, 0x04, 0x00, 0x0A, 0x00, 0x11, 0x00, 0x20, 0x80, 0x40, 0x40}, /*"<", 28*/ - {0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x00, 0x00}, /*"=", 29*/ - {0x00, 0x00, 0x40, 0x40, 0x20, 0x80, 0x11, 0x00, 0x0A, 0x00, 0x04, 0x00}, /*">", 30*/ - {0x18, 0x00, 0x20, 0x00, 0x23, 0x40, 0x24, 0x00, 0x18, 0x00, 0x00, 0x00}, /*"?", 31*/ - {0x1F, 0x80, 0x20, 0x40, 0x27, 0x40, 0x29, 0x40, 0x1F, 0x40, 0x00, 0x00}, /*"@", 32*/ - {0x00, 0x40, 0x07, 0xC0, 0x39, 0x00, 0x0F, 0x00, 0x01, 0xC0, 0x00, 0x40}, /*"A", 33*/ - {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x24, 0x40, 0x1B, 0x80, 0x00, 0x00}, /*"B", 34*/ - {0x1F, 0x80, 0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 0x30, 0x80, 0x00, 0x00}, /*"C", 35*/ - {0x20, 0x40, 0x3F, 0xC0, 0x20, 0x40, 0x20, 0x40, 0x1F, 0x80, 0x00, 0x00}, /*"D", 36*/ - {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x2E, 0x40, 0x30, 0xC0, 0x00, 0x00}, /*"E", 37*/ - {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x2E, 0x00, 0x30, 0x00, 0x00, 0x00}, /*"F", 38*/ - {0x0F, 0x00, 0x10, 0x80, 0x20, 0x40, 0x22, 0x40, 0x33, 0x80, 0x02, 0x00}, /*"G", 39*/ - {0x20, 0x40, 0x3F, 0xC0, 0x04, 0x00, 0x04, 0x00, 0x3F, 0xC0, 0x20, 0x40}, /*"H", 40*/ - {0x20, 0x40, 0x20, 0x40, 0x3F, 0xC0, 0x20, 0x40, 0x20, 0x40, 0x00, 0x00}, /*"I", 41*/ - {0x00, 0x60, 0x20, 0x20, 0x20, 0x20, 0x3F, 0xC0, 0x20, 0x00, 0x20, 0x00}, /*"J", 42*/ - {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x0B, 0x00, 0x30, 0xC0, 0x20, 0x40}, /*"K", 43*/ - {0x20, 0x40, 0x3F, 0xC0, 0x20, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0xC0}, /*"L", 44*/ - {0x3F, 0xC0, 0x3C, 0x00, 0x03, 0xC0, 0x3C, 0x00, 0x3F, 0xC0, 0x00, 0x00}, /*"M", 45*/ - {0x20, 0x40, 0x3F, 0xC0, 0x0C, 0x40, 0x23, 0x00, 0x3F, 0xC0, 0x20, 0x00}, /*"N", 46*/ - {0x1F, 0x80, 0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 0x1F, 0x80, 0x00, 0x00}, /*"O", 47*/ - {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x24, 0x00, 0x18, 0x00, 0x00, 0x00}, /*"P", 48*/ - {0x1F, 0x80, 0x21, 0x40, 0x21, 0x40, 0x20, 0xE0, 0x1F, 0xA0, 0x00, 0x00}, /*"Q", 49*/ - {0x20, 0x40, 0x3F, 0xC0, 0x24, 0x40, 0x26, 0x00, 0x19, 0xC0, 0x00, 0x40}, /*"R", 50*/ - {0x18, 0xC0, 0x24, 0x40, 0x24, 0x40, 0x22, 0x40, 0x31, 0x80, 0x00, 0x00}, /*"S", 51*/ - {0x30, 0x00, 0x20, 0x40, 0x3F, 0xC0, 0x20, 0x40, 0x30, 0x00, 0x00, 0x00}, /*"T", 52*/ - {0x20, 0x00, 0x3F, 0x80, 0x00, 0x40, 0x00, 0x40, 0x3F, 0x80, 0x20, 0x00}, /*"U", 53*/ - {0x20, 0x00, 0x3E, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x38, 0x00, 0x20, 0x00}, /*"V", 54*/ - {0x38, 0x00, 0x07, 0xC0, 0x3C, 0x00, 0x07, 0xC0, 0x38, 0x00, 0x00, 0x00}, /*"W", 55*/ - {0x20, 0x40, 0x39, 0xC0, 0x06, 0x00, 0x39, 0xC0, 0x20, 0x40, 0x00, 0x00}, /*"X", 56*/ - {0x20, 0x00, 0x38, 0x40, 0x07, 0xC0, 0x38, 0x40, 0x20, 0x00, 0x00, 0x00}, /*"Y", 57*/ - {0x30, 0x40, 0x21, 0xC0, 0x26, 0x40, 0x38, 0x40, 0x20, 0xC0, 0x00, 0x00}, /*"Z", 58*/ - {0x00, 0x00, 0x00, 0x00, 0x7F, 0xE0, 0x40, 0x20, 0x40, 0x20, 0x00, 0x00}, /*"[", 59*/ - {0x00, 0x00, 0x70, 0x00, 0x0C, 0x00, 0x03, 0x80, 0x00, 0x40, 0x00, 0x00}, /*"\", 60*/ - {0x00, 0x00, 0x40, 0x20, 0x40, 0x20, 0x7F, 0xE0, 0x00, 0x00, 0x00, 0x00}, /*"]", 61*/ - {0x00, 0x00, 0x20, 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"^", 62*/ - {0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10}, /*"_", 63*/ - {0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"`", 64*/ - {0x00, 0x00, 0x02, 0x80, 0x05, 0x40, 0x05, 0x40, 0x03, 0xC0, 0x00, 0x40}, /*"a", 65*/ - {0x20, 0x00, 0x3F, 0xC0, 0x04, 0x40, 0x04, 0x40, 0x03, 0x80, 0x00, 0x00}, /*"b", 66*/ - {0x00, 0x00, 0x03, 0x80, 0x04, 0x40, 0x04, 0x40, 0x06, 0x40, 0x00, 0x00}, /*"c", 67*/ - {0x00, 0x00, 0x03, 0x80, 0x04, 0x40, 0x24, 0x40, 0x3F, 0xC0, 0x00, 0x40}, /*"d", 68*/ - {0x00, 0x00, 0x03, 0x80, 0x05, 0x40, 0x05, 0x40, 0x03, 0x40, 0x00, 0x00}, /*"e", 69*/ - {0x00, 0x00, 0x04, 0x40, 0x1F, 0xC0, 0x24, 0x40, 0x24, 0x40, 0x20, 0x00}, /*"f", 70*/ - {0x00, 0x00, 0x02, 0xE0, 0x05, 0x50, 0x05, 0x50, 0x06, 0x50, 0x04, 0x20}, /*"g", 71*/ - {0x20, 0x40, 0x3F, 0xC0, 0x04, 0x40, 0x04, 0x00, 0x03, 0xC0, 0x00, 0x40}, /*"h", 72*/ - {0x00, 0x00, 0x04, 0x40, 0x27, 0xC0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00}, /*"i", 73*/ - {0x00, 0x10, 0x00, 0x10, 0x04, 0x10, 0x27, 0xE0, 0x00, 0x00, 0x00, 0x00}, /*"j", 74*/ - {0x20, 0x40, 0x3F, 0xC0, 0x01, 0x40, 0x07, 0x00, 0x04, 0xC0, 0x04, 0x40}, /*"k", 75*/ - {0x20, 0x40, 0x20, 0x40, 0x3F, 0xC0, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00}, /*"l", 76*/ - {0x07, 0xC0, 0x04, 0x00, 0x07, 0xC0, 0x04, 0x00, 0x03, 0xC0, 0x00, 0x00}, /*"m", 77*/ - {0x04, 0x40, 0x07, 0xC0, 0x04, 0x40, 0x04, 0x00, 0x03, 0xC0, 0x00, 0x40}, /*"n", 78*/ - {0x00, 0x00, 0x03, 0x80, 0x04, 0x40, 0x04, 0x40, 0x03, 0x80, 0x00, 0x00}, /*"o", 79*/ - {0x04, 0x10, 0x07, 0xF0, 0x04, 0x50, 0x04, 0x40, 0x03, 0x80, 0x00, 0x00}, /*"p", 80*/ - {0x00, 0x00, 0x03, 0x80, 0x04, 0x40, 0x04, 0x50, 0x07, 0xF0, 0x00, 0x10}, /*"q", 81*/ - {0x04, 0x40, 0x07, 0xC0, 0x02, 0x40, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00}, /*"r", 82*/ - {0x00, 0x00, 0x06, 0x40, 0x05, 0x40, 0x05, 0x40, 0x04, 0xC0, 0x00, 0x00}, /*"s", 83*/ - {0x00, 0x00, 0x04, 0x00, 0x1F, 0x80, 0x04, 0x40, 0x00, 0x40, 0x00, 0x00}, /*"t", 84*/ - {0x04, 0x00, 0x07, 0x80, 0x00, 0x40, 0x04, 0x40, 0x07, 0xC0, 0x00, 0x40}, /*"u", 85*/ - {0x04, 0x00, 0x07, 0x00, 0x04, 0xC0, 0x01, 0x80, 0x06, 0x00, 0x04, 0x00}, /*"v", 86*/ - {0x06, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x01, 0xC0, 0x06, 0x00, 0x00, 0x00}, /*"w", 87*/ - {0x04, 0x40, 0x06, 0xC0, 0x01, 0x00, 0x06, 0xC0, 0x04, 0x40, 0x00, 0x00}, /*"x", 88*/ - {0x04, 0x10, 0x07, 0x10, 0x04, 0xE0, 0x01, 0x80, 0x06, 0x00, 0x04, 0x00}, /*"y", 89*/ - {0x00, 0x00, 0x04, 0x40, 0x05, 0xC0, 0x06, 0x40, 0x04, 0x40, 0x00, 0x00}, /*"z", 90*/ - {0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x7B, 0xE0, 0x40, 0x20, 0x00, 0x00}, /*"{", 91*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00}, /*"|", 92*/ - {0x00, 0x00, 0x40, 0x20, 0x7B, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"}", 93*/ - {0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, 0x40, 0x00}, /*"~", 94*/ -}; - -static const uint8_t gsc_ssd1306_ascii_1608[95][16] = -{ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*" ", 0*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xCC, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"!", 1*/ - {0x00, 0x00, 0x08, 0x00, 0x30, 0x00, 0x60, 0x00, 0x08, 0x00, 0x30, 0x00, 0x60, 0x00, 0x00, 0x00}, /*""", 2*/ - {0x02, 0x20, 0x03, 0xFC, 0x1E, 0x20, 0x02, 0x20, 0x03, 0xFC, 0x1E, 0x20, 0x02, 0x20, 0x00, 0x00}, /*"#", 3*/ - {0x00, 0x00, 0x0E, 0x18, 0x11, 0x04, 0x3F, 0xFF, 0x10, 0x84, 0x0C, 0x78, 0x00, 0x00, 0x00, 0x00}, /*"$", 4*/ - {0x0F, 0x00, 0x10, 0x84, 0x0F, 0x38, 0x00, 0xC0, 0x07, 0x78, 0x18, 0x84, 0x00, 0x78, 0x00, 0x00}, /*"%", 5*/ - {0x00, 0x78, 0x0F, 0x84, 0x10, 0xC4, 0x11, 0x24, 0x0E, 0x98, 0x00, 0xE4, 0x00, 0x84, 0x00, 0x08}, /*"&", 6*/ - {0x08, 0x00, 0x68, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"'", 7*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xE0, 0x18, 0x18, 0x20, 0x04, 0x40, 0x02, 0x00, 0x00}, /*"(", 8*/ - {0x00, 0x00, 0x40, 0x02, 0x20, 0x04, 0x18, 0x18, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*")", 9*/ - {0x02, 0x40, 0x02, 0x40, 0x01, 0x80, 0x0F, 0xF0, 0x01, 0x80, 0x02, 0x40, 0x02, 0x40, 0x00, 0x00}, /*"*", 10*/ - {0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x0F, 0xF8, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00}, /*"+", 11*/ - {0x00, 0x01, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*", ", 12*/ - {0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80}, /*"-", 13*/ - {0x00, 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*".", 14*/ - {0x00, 0x00, 0x00, 0x06, 0x00, 0x18, 0x00, 0x60, 0x01, 0x80, 0x06, 0x00, 0x18, 0x00, 0x20, 0x00}, /*"/", 15*/ - {0x00, 0x00, 0x07, 0xF0, 0x08, 0x08, 0x10, 0x04, 0x10, 0x04, 0x08, 0x08, 0x07, 0xF0, 0x00, 0x00}, /*"0", 16*/ - {0x00, 0x00, 0x08, 0x04, 0x08, 0x04, 0x1F, 0xFC, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"1", 17*/ - {0x00, 0x00, 0x0E, 0x0C, 0x10, 0x14, 0x10, 0x24, 0x10, 0x44, 0x11, 0x84, 0x0E, 0x0C, 0x00, 0x00}, /*"2", 18*/ - {0x00, 0x00, 0x0C, 0x18, 0x10, 0x04, 0x11, 0x04, 0x11, 0x04, 0x12, 0x88, 0x0C, 0x70, 0x00, 0x00}, /*"3", 19*/ - {0x00, 0x00, 0x00, 0xE0, 0x03, 0x20, 0x04, 0x24, 0x08, 0x24, 0x1F, 0xFC, 0x00, 0x24, 0x00, 0x00}, /*"4", 20*/ - {0x00, 0x00, 0x1F, 0x98, 0x10, 0x84, 0x11, 0x04, 0x11, 0x04, 0x10, 0x88, 0x10, 0x70, 0x00, 0x00}, /*"5", 21*/ - {0x00, 0x00, 0x07, 0xF0, 0x08, 0x88, 0x11, 0x04, 0x11, 0x04, 0x18, 0x88, 0x00, 0x70, 0x00, 0x00}, /*"6", 22*/ - {0x00, 0x00, 0x1C, 0x00, 0x10, 0x00, 0x10, 0xFC, 0x13, 0x00, 0x1C, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"7", 23*/ - {0x00, 0x00, 0x0E, 0x38, 0x11, 0x44, 0x10, 0x84, 0x10, 0x84, 0x11, 0x44, 0x0E, 0x38, 0x00, 0x00}, /*"8", 24*/ - {0x00, 0x00, 0x07, 0x00, 0x08, 0x8C, 0x10, 0x44, 0x10, 0x44, 0x08, 0x88, 0x07, 0xF0, 0x00, 0x00}, /*"9", 25*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0C, 0x03, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*":", 26*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*";", 27*/ - {0x00, 0x00, 0x00, 0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x00, 0x00}, /*"<", 28*/ - {0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x00, 0x00}, /*"=", 29*/ - {0x00, 0x00, 0x10, 0x04, 0x08, 0x08, 0x04, 0x10, 0x02, 0x20, 0x01, 0x40, 0x00, 0x80, 0x00, 0x00}, /*">", 30*/ - {0x00, 0x00, 0x0E, 0x00, 0x12, 0x00, 0x10, 0x0C, 0x10, 0x6C, 0x10, 0x80, 0x0F, 0x00, 0x00, 0x00}, /*"?", 31*/ - {0x03, 0xE0, 0x0C, 0x18, 0x13, 0xE4, 0x14, 0x24, 0x17, 0xC4, 0x08, 0x28, 0x07, 0xD0, 0x00, 0x00}, /*"@", 32*/ - {0x00, 0x04, 0x00, 0x3C, 0x03, 0xC4, 0x1C, 0x40, 0x07, 0x40, 0x00, 0xE4, 0x00, 0x1C, 0x00, 0x04}, /*"A", 33*/ - {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x11, 0x04, 0x11, 0x04, 0x0E, 0x88, 0x00, 0x70, 0x00, 0x00}, /*"B", 34*/ - {0x03, 0xE0, 0x0C, 0x18, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x10, 0x08, 0x1C, 0x10, 0x00, 0x00}, /*"C", 35*/ - {0x10, 0x04, 0x1F, 0xFC, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x08, 0x08, 0x07, 0xF0, 0x00, 0x00}, /*"D", 36*/ - {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x11, 0x04, 0x17, 0xC4, 0x10, 0x04, 0x08, 0x18, 0x00, 0x00}, /*"E", 37*/ - {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x11, 0x00, 0x17, 0xC0, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"F", 38*/ - {0x03, 0xE0, 0x0C, 0x18, 0x10, 0x04, 0x10, 0x04, 0x10, 0x44, 0x1C, 0x78, 0x00, 0x40, 0x00, 0x00}, /*"G", 39*/ - {0x10, 0x04, 0x1F, 0xFC, 0x10, 0x84, 0x00, 0x80, 0x00, 0x80, 0x10, 0x84, 0x1F, 0xFC, 0x10, 0x04}, /*"H", 40*/ - {0x00, 0x00, 0x10, 0x04, 0x10, 0x04, 0x1F, 0xFC, 0x10, 0x04, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"I", 41*/ - {0x00, 0x03, 0x00, 0x01, 0x10, 0x01, 0x10, 0x01, 0x1F, 0xFE, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"J", 42*/ - {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x03, 0x80, 0x14, 0x64, 0x18, 0x1C, 0x10, 0x04, 0x00, 0x00}, /*"K", 43*/ - {0x10, 0x04, 0x1F, 0xFC, 0x10, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x0C, 0x00, 0x00}, /*"L", 44*/ - {0x10, 0x04, 0x1F, 0xFC, 0x1F, 0x00, 0x00, 0xFC, 0x1F, 0x00, 0x1F, 0xFC, 0x10, 0x04, 0x00, 0x00}, /*"M", 45*/ - {0x10, 0x04, 0x1F, 0xFC, 0x0C, 0x04, 0x03, 0x00, 0x00, 0xE0, 0x10, 0x18, 0x1F, 0xFC, 0x10, 0x00}, /*"N", 46*/ - {0x07, 0xF0, 0x08, 0x08, 0x10, 0x04, 0x10, 0x04, 0x10, 0x04, 0x08, 0x08, 0x07, 0xF0, 0x00, 0x00}, /*"O", 47*/ - {0x10, 0x04, 0x1F, 0xFC, 0x10, 0x84, 0x10, 0x80, 0x10, 0x80, 0x10, 0x80, 0x0F, 0x00, 0x00, 0x00}, /*"P", 48*/ - {0x07, 0xF0, 0x08, 0x18, 0x10, 0x24, 0x10, 0x24, 0x10, 0x1C, 0x08, 0x0A, 0x07, 0xF2, 0x00, 0x00}, /*"Q", 49*/ - {0x10, 0x04, 0x1F, 0xFC, 0x11, 0x04, 0x11, 0x00, 0x11, 0xC0, 0x11, 0x30, 0x0E, 0x0C, 0x00, 0x04}, /*"R", 50*/ - {0x00, 0x00, 0x0E, 0x1C, 0x11, 0x04, 0x10, 0x84, 0x10, 0x84, 0x10, 0x44, 0x1C, 0x38, 0x00, 0x00}, /*"S", 51*/ - {0x18, 0x00, 0x10, 0x00, 0x10, 0x04, 0x1F, 0xFC, 0x10, 0x04, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00}, /*"T", 52*/ - {0x10, 0x00, 0x1F, 0xF8, 0x10, 0x04, 0x00, 0x04, 0x00, 0x04, 0x10, 0x04, 0x1F, 0xF8, 0x10, 0x00}, /*"U", 53*/ - {0x10, 0x00, 0x1E, 0x00, 0x11, 0xE0, 0x00, 0x1C, 0x00, 0x70, 0x13, 0x80, 0x1C, 0x00, 0x10, 0x00}, /*"V", 54*/ - {0x1F, 0xC0, 0x10, 0x3C, 0x00, 0xE0, 0x1F, 0x00, 0x00, 0xE0, 0x10, 0x3C, 0x1F, 0xC0, 0x00, 0x00}, /*"W", 55*/ - {0x10, 0x04, 0x18, 0x0C, 0x16, 0x34, 0x01, 0xC0, 0x01, 0xC0, 0x16, 0x34, 0x18, 0x0C, 0x10, 0x04}, /*"X", 56*/ - {0x10, 0x00, 0x1C, 0x00, 0x13, 0x04, 0x00, 0xFC, 0x13, 0x04, 0x1C, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"Y", 57*/ - {0x08, 0x04, 0x10, 0x1C, 0x10, 0x64, 0x10, 0x84, 0x13, 0x04, 0x1C, 0x04, 0x10, 0x18, 0x00, 0x00}, /*"Z", 58*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x00, 0x00}, /*"[", 59*/ - {0x00, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x03, 0x80, 0x00, 0x60, 0x00, 0x1C, 0x00, 0x03, 0x00, 0x00}, /*"\", 60*/ - {0x00, 0x00, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x7F, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"]", 61*/ - {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00}, /*"^", 62*/ - {0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01}, /*"_", 63*/ - {0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"`", 64*/ - {0x00, 0x00, 0x00, 0x98, 0x01, 0x24, 0x01, 0x44, 0x01, 0x44, 0x01, 0x44, 0x00, 0xFC, 0x00, 0x04}, /*"a", 65*/ - {0x10, 0x00, 0x1F, 0xFC, 0x00, 0x88, 0x01, 0x04, 0x01, 0x04, 0x00, 0x88, 0x00, 0x70, 0x00, 0x00}, /*"b", 66*/ - {0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x00, 0x88, 0x00, 0x00}, /*"c", 67*/ - {0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x01, 0x04, 0x01, 0x04, 0x11, 0x08, 0x1F, 0xFC, 0x00, 0x04}, /*"d", 68*/ - {0x00, 0x00, 0x00, 0xF8, 0x01, 0x44, 0x01, 0x44, 0x01, 0x44, 0x01, 0x44, 0x00, 0xC8, 0x00, 0x00}, /*"e", 69*/ - {0x00, 0x00, 0x01, 0x04, 0x01, 0x04, 0x0F, 0xFC, 0x11, 0x04, 0x11, 0x04, 0x11, 0x00, 0x18, 0x00}, /*"f", 70*/ - {0x00, 0x00, 0x00, 0xD6, 0x01, 0x29, 0x01, 0x29, 0x01, 0x29, 0x01, 0xC9, 0x01, 0x06, 0x00, 0x00}, /*"g", 71*/ - {0x10, 0x04, 0x1F, 0xFC, 0x00, 0x84, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x00, 0xFC, 0x00, 0x04}, /*"h", 72*/ - {0x00, 0x00, 0x01, 0x04, 0x19, 0x04, 0x19, 0xFC, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"i", 73*/ - {0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0x01, 0x19, 0x01, 0x19, 0xFE, 0x00, 0x00, 0x00, 0x00}, /*"j", 74*/ - {0x10, 0x04, 0x1F, 0xFC, 0x00, 0x24, 0x00, 0x40, 0x01, 0xB4, 0x01, 0x0C, 0x01, 0x04, 0x00, 0x00}, /*"k", 75*/ - {0x00, 0x00, 0x10, 0x04, 0x10, 0x04, 0x1F, 0xFC, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"l", 76*/ - {0x01, 0x04, 0x01, 0xFC, 0x01, 0x04, 0x01, 0x00, 0x01, 0xFC, 0x01, 0x04, 0x01, 0x00, 0x00, 0xFC}, /*"m", 77*/ - {0x01, 0x04, 0x01, 0xFC, 0x00, 0x84, 0x01, 0x00, 0x01, 0x00, 0x01, 0x04, 0x00, 0xFC, 0x00, 0x04}, /*"n", 78*/ - {0x00, 0x00, 0x00, 0xF8, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x00, 0xF8, 0x00, 0x00}, /*"o", 79*/ - {0x01, 0x01, 0x01, 0xFF, 0x00, 0x85, 0x01, 0x04, 0x01, 0x04, 0x00, 0x88, 0x00, 0x70, 0x00, 0x00}, /*"p", 80*/ - {0x00, 0x00, 0x00, 0x70, 0x00, 0x88, 0x01, 0x04, 0x01, 0x04, 0x01, 0x05, 0x01, 0xFF, 0x00, 0x01}, /*"q", 81*/ - {0x01, 0x04, 0x01, 0x04, 0x01, 0xFC, 0x00, 0x84, 0x01, 0x04, 0x01, 0x00, 0x01, 0x80, 0x00, 0x00}, /*"r", 82*/ - {0x00, 0x00, 0x00, 0xCC, 0x01, 0x24, 0x01, 0x24, 0x01, 0x24, 0x01, 0x24, 0x01, 0x98, 0x00, 0x00}, /*"s", 83*/ - {0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x07, 0xF8, 0x01, 0x04, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00}, /*"t", 84*/ - {0x01, 0x00, 0x01, 0xF8, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x01, 0x08, 0x01, 0xFC, 0x00, 0x04}, /*"u", 85*/ - {0x01, 0x00, 0x01, 0x80, 0x01, 0x70, 0x00, 0x0C, 0x00, 0x10, 0x01, 0x60, 0x01, 0x80, 0x01, 0x00}, /*"v", 86*/ - {0x01, 0xF0, 0x01, 0x0C, 0x00, 0x30, 0x01, 0xC0, 0x00, 0x30, 0x01, 0x0C, 0x01, 0xF0, 0x01, 0x00}, /*"w", 87*/ - {0x00, 0x00, 0x01, 0x04, 0x01, 0x8C, 0x00, 0x74, 0x01, 0x70, 0x01, 0x8C, 0x01, 0x04, 0x00, 0x00}, /*"x", 88*/ - {0x01, 0x01, 0x01, 0x81, 0x01, 0x71, 0x00, 0x0E, 0x00, 0x18, 0x01, 0x60, 0x01, 0x80, 0x01, 0x00}, /*"y", 89*/ - {0x00, 0x00, 0x01, 0x84, 0x01, 0x0C, 0x01, 0x34, 0x01, 0x44, 0x01, 0x84, 0x01, 0x0C, 0x00, 0x00}, /*"z", 90*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x3E, 0xFC, 0x40, 0x02, 0x40, 0x02}, /*"{", 91*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"|", 92*/ - {0x00, 0x00, 0x40, 0x02, 0x40, 0x02, 0x3E, 0xFC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"}", 93*/ - {0x00, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x40, 0x00, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00}, /*"~", 94*/ -}; - -static const uint8_t gsc_ssd1306_ascii_2412[95][36] = -{ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*" ", 0*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x38, 0x0F, 0xFE, 0x38, 0x0F, 0x80, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"!", 1*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x38, 0x00, 0x00, 0x31, 0x00, 0x00, 0x06, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x38, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00}, /*""", 2*/ - {0x00, 0x00, 0x00, 0x00, 0x61, 0x80, 0x00, 0x67, 0xF8, 0x07, 0xF9, 0x80, 0x00, 0x61, 0x80, 0x00, 0x61, 0x80, 0x00, 0x61, 0x80, 0x00, 0x61, 0x80, 0x00, 0x67, 0xF8, 0x07, 0xF9, 0x80, 0x00, 0x61, 0x80, 0x00, 0x00, 0x00}, /*"#", 3*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0xE0, 0x03, 0xE0, 0xF0, 0x06, 0x30, 0x08, 0x04, 0x18, 0x08, 0x1F, 0xFF, 0xFE, 0x04, 0x0E, 0x08, 0x07, 0x87, 0xF0, 0x03, 0x81, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"$", 4*/ - {0x01, 0xF0, 0x00, 0x06, 0x0C, 0x00, 0x04, 0x04, 0x08, 0x06, 0x0C, 0x70, 0x01, 0xF9, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x3B, 0xE0, 0x00, 0xEC, 0x18, 0x07, 0x08, 0x08, 0x04, 0x0C, 0x18, 0x00, 0x03, 0xE0, 0x00, 0x00, 0x00}, /*"%", 5*/ - {0x00, 0x01, 0xE0, 0x00, 0x07, 0xF0, 0x03, 0xF8, 0x18, 0x04, 0x1C, 0x08, 0x04, 0x17, 0x08, 0x07, 0xE1, 0xD0, 0x03, 0xC0, 0xE0, 0x00, 0x23, 0xB0, 0x00, 0x3C, 0x08, 0x00, 0x20, 0x08, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"&", 6*/ - {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x31, 0x00, 0x00, 0x32, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"'", 7*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x01, 0xFF, 0xC0, 0x07, 0x80, 0xF0, 0x0C, 0x00, 0x18, 0x10, 0x00, 0x04, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00}, /*"(", 8*/ - {0x00, 0x00, 0x00, 0x20, 0x00, 0x02, 0x10, 0x00, 0x04, 0x0C, 0x00, 0x18, 0x07, 0x80, 0xF0, 0x01, 0xFF, 0xC0, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*")", 9*/ - {0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x18, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x18, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x66, 0x00, 0x00, 0x66, 0x00, 0x00, 0x42, 0x00}, /*"*", 10*/ - {0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x01, 0xFF, 0xC0, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00}, /*"+", 11*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x31, 0x00, 0x00, 0x32, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*", ", 12*/ - {0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}, /*"-", 13*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x38, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*".", 14*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x70, 0x00, 0x01, 0x80, 0x00, 0x0E, 0x00, 0x00, 0x38, 0x00, 0x00, 0xC0, 0x00, 0x07, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"/", 15*/ - {0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x06, 0x00, 0x18, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x03, 0x80, 0x70, 0x01, 0xFF, 0xE0, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00}, /*"0", 16*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x01, 0x00, 0x08, 0x01, 0x00, 0x08, 0x03, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"1", 17*/ - {0x00, 0x00, 0x00, 0x01, 0xC0, 0x38, 0x02, 0xC0, 0x58, 0x04, 0x00, 0x98, 0x04, 0x01, 0x18, 0x04, 0x02, 0x18, 0x04, 0x04, 0x18, 0x06, 0x1C, 0x18, 0x03, 0xF8, 0x18, 0x01, 0xE0, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"2", 18*/ - {0x00, 0x00, 0x00, 0x01, 0xC0, 0xE0, 0x03, 0xC0, 0xF0, 0x04, 0x00, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x06, 0x18, 0x08, 0x03, 0xF4, 0x18, 0x01, 0xE7, 0xF0, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"3", 19*/ - {0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x11, 0x00, 0x00, 0x61, 0x00, 0x00, 0x81, 0x08, 0x03, 0x01, 0x08, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF8, 0x00, 0x01, 0x08, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00}, /*"4", 20*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x07, 0xFC, 0xD0, 0x06, 0x08, 0x08, 0x06, 0x10, 0x08, 0x06, 0x10, 0x08, 0x06, 0x10, 0x08, 0x06, 0x18, 0x38, 0x06, 0x0F, 0xF0, 0x06, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"5", 21*/ - {0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x84, 0x30, 0x02, 0x08, 0x18, 0x04, 0x10, 0x08, 0x04, 0x10, 0x08, 0x04, 0x10, 0x08, 0x07, 0x18, 0x10, 0x03, 0x0F, 0xF0, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00}, /*"6", 22*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x07, 0x00, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0xF8, 0x06, 0x07, 0xF8, 0x06, 0x18, 0x00, 0x06, 0xE0, 0x00, 0x07, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"7", 23*/ - {0x00, 0x00, 0x00, 0x01, 0xE1, 0xE0, 0x03, 0xF7, 0xF0, 0x06, 0x34, 0x10, 0x04, 0x18, 0x08, 0x04, 0x18, 0x08, 0x04, 0x0C, 0x08, 0x04, 0x0C, 0x08, 0x06, 0x16, 0x18, 0x03, 0xF3, 0xF0, 0x01, 0xC1, 0xE0, 0x00, 0x00, 0x00}, /*"8", 24*/ - {0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x03, 0xFC, 0x30, 0x03, 0x06, 0x38, 0x04, 0x02, 0x08, 0x04, 0x02, 0x08, 0x04, 0x02, 0x08, 0x04, 0x04, 0x10, 0x03, 0x08, 0xF0, 0x01, 0xFF, 0xC0, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00}, /*"9", 25*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x38, 0x00, 0x70, 0x38, 0x00, 0x70, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*":", 26*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x1A, 0x00, 0x30, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*";", 27*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x14, 0x00, 0x00, 0x22, 0x00, 0x00, 0x41, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x40, 0x02, 0x00, 0x20, 0x04, 0x00, 0x10, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"<", 28*/ - {0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00}, /*"=", 29*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x04, 0x00, 0x10, 0x02, 0x00, 0x20, 0x01, 0x00, 0x40, 0x00, 0x80, 0x80, 0x00, 0x41, 0x00, 0x00, 0x22, 0x00, 0x00, 0x14, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}, /*">", 30*/ - {0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x04, 0xC0, 0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0x38, 0x08, 0x0F, 0x38, 0x08, 0x08, 0x38, 0x08, 0x10, 0x00, 0x0C, 0x30, 0x00, 0x07, 0xE0, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x00}, /*"?", 31*/ - {0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x00, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x02, 0x0F, 0x10, 0x06, 0x70, 0x88, 0x04, 0xC0, 0x88, 0x04, 0x83, 0x08, 0x04, 0x7F, 0x88, 0x02, 0xC0, 0x90, 0x03, 0x01, 0x20, 0x00, 0xFE, 0x40}, /*"@", 32*/ - {0x00, 0x00, 0x08, 0x00, 0x00, 0x18, 0x00, 0x01, 0xF8, 0x00, 0x3E, 0x08, 0x01, 0xC2, 0x00, 0x07, 0x02, 0x00, 0x07, 0xE2, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x1F, 0xC8, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08}, /*"A", 33*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x06, 0x18, 0x08, 0x03, 0xF4, 0x18, 0x01, 0xE7, 0xF0, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00}, /*"B", 34*/ - {0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x02, 0x00, 0x18, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x10, 0x06, 0x00, 0x20, 0x07, 0x80, 0xC0, 0x00, 0x00, 0x00}, /*"C", 35*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x18, 0x02, 0x00, 0x10, 0x03, 0x80, 0x70, 0x01, 0xFF, 0xE0, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00}, /*"D", 36*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x08, 0x08, 0x04, 0x3E, 0x08, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x01, 0x00, 0x60, 0x00, 0x00, 0x00}, /*"E", 37*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x04, 0x08, 0x00, 0x04, 0x08, 0x00, 0x04, 0x08, 0x00, 0x04, 0x3E, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00}, /*"F", 38*/ - {0x00, 0x00, 0x00, 0x00, 0x3F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x06, 0x00, 0x18, 0x04, 0x00, 0x08, 0x04, 0x02, 0x08, 0x04, 0x02, 0x08, 0x02, 0x03, 0xF0, 0x07, 0x83, 0xF0, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00}, /*"G", 39*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x04, 0x08, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08}, /*"H", 40*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"I", 41*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0x04, 0x00, 0x01, 0x04, 0x00, 0x01, 0x04, 0x00, 0x03, 0x07, 0xFF, 0xFE, 0x07, 0xFF, 0xFC, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00}, /*"J", 42*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x0C, 0x08, 0x00, 0x18, 0x00, 0x00, 0x3E, 0x00, 0x04, 0xC7, 0x80, 0x05, 0x03, 0xC8, 0x06, 0x00, 0xF8, 0x04, 0x00, 0x38, 0x04, 0x00, 0x18, 0x00, 0x00, 0x08}, /*"K", 43*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00}, /*"L", 44*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0x80, 0x08, 0x07, 0xFC, 0x00, 0x00, 0x7F, 0xC0, 0x00, 0x03, 0xF8, 0x00, 0x07, 0xC0, 0x00, 0x78, 0x00, 0x07, 0x80, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08}, /*"M", 45*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0x00, 0x08, 0x03, 0xC0, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x38, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x07, 0x00, 0x00, 0x01, 0xC0, 0x04, 0x00, 0xF0, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x00}, /*"N", 46*/ - {0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x06, 0x00, 0x18, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x03, 0x00, 0x30, 0x01, 0xFF, 0xE0, 0x00, 0x7F, 0x80, 0x00, 0x00, 0x00}, /*"O", 47*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x04, 0x08, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04, 0x04, 0x00, 0x06, 0x0C, 0x00, 0x03, 0xF8, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x00}, /*"P", 48*/ - {0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0x80, 0x70, 0x06, 0x00, 0x88, 0x04, 0x00, 0x88, 0x04, 0x00, 0xC8, 0x06, 0x00, 0x3C, 0x03, 0x00, 0x3E, 0x01, 0xFF, 0xE6, 0x00, 0x7F, 0x84, 0x00, 0x00, 0x00}, /*"Q", 49*/ - {0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x08, 0x08, 0x04, 0x08, 0x00, 0x04, 0x0C, 0x00, 0x04, 0x0F, 0x00, 0x04, 0x0B, 0xC0, 0x06, 0x10, 0xF0, 0x03, 0xF0, 0x38, 0x01, 0xE0, 0x08, 0x00, 0x00, 0x08}, /*"R", 50*/ - {0x00, 0x00, 0x00, 0x01, 0xE0, 0xF8, 0x03, 0xF0, 0x30, 0x06, 0x30, 0x10, 0x04, 0x18, 0x08, 0x04, 0x18, 0x08, 0x04, 0x0C, 0x08, 0x04, 0x0C, 0x08, 0x02, 0x06, 0x18, 0x02, 0x07, 0xF0, 0x07, 0x81, 0xE0, 0x00, 0x00, 0x00}, /*"S", 51*/ - {0x01, 0x80, 0x00, 0x06, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x07, 0xFF, 0xF8, 0x04, 0x00, 0x08, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0x80, 0x00}, /*"T", 52*/ - {0x04, 0x00, 0x00, 0x07, 0xFF, 0xE0, 0x07, 0xFF, 0xF0, 0x04, 0x00, 0x18, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x04, 0x00, 0x10, 0x07, 0xFF, 0xE0, 0x04, 0x00, 0x00}, /*"U", 53*/ - {0x04, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x07, 0xFE, 0x00, 0x04, 0x1F, 0xE0, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x38, 0x00, 0x01, 0xE0, 0x04, 0x3E, 0x00, 0x07, 0xC0, 0x00, 0x06, 0x00, 0x00, 0x04, 0x00, 0x00}, /*"V", 54*/ - {0x04, 0x00, 0x00, 0x07, 0xE0, 0x00, 0x07, 0xFF, 0xC0, 0x04, 0x1F, 0xF8, 0x00, 0x07, 0xC0, 0x07, 0xF8, 0x00, 0x07, 0xFF, 0x80, 0x04, 0x3F, 0xF8, 0x00, 0x07, 0xC0, 0x04, 0xF8, 0x00, 0x07, 0x00, 0x00, 0x04, 0x00, 0x00}, /*"W", 55*/ - {0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x07, 0xC0, 0x78, 0x05, 0xF1, 0xC8, 0x00, 0x3E, 0x00, 0x00, 0x1F, 0x80, 0x04, 0x63, 0xE8, 0x07, 0x80, 0xF8, 0x06, 0x00, 0x18, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"X", 56*/ - {0x04, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0x80, 0x00, 0x07, 0xE0, 0x08, 0x04, 0x7C, 0x08, 0x00, 0x1F, 0xF8, 0x00, 0x07, 0xF8, 0x00, 0x18, 0x08, 0x04, 0xE0, 0x08, 0x07, 0x00, 0x00, 0x06, 0x00, 0x00, 0x04, 0x00, 0x00}, /*"Y", 57*/ - {0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x06, 0x00, 0x38, 0x04, 0x00, 0xF8, 0x04, 0x03, 0xE8, 0x04, 0x0F, 0x08, 0x04, 0x7C, 0x08, 0x05, 0xF0, 0x08, 0x07, 0xC0, 0x08, 0x07, 0x00, 0x18, 0x04, 0x00, 0x60, 0x00, 0x00, 0x00}, /*"Z", 58*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFE, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00}, /*"[", 59*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x38, 0x00, 0x00, 0x06, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x30, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}, /*"\", 60*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x20, 0x00, 0x02, 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"]", 61*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x10, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00, 0x30, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"^", 62*/ - {0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01}, /*"_", 63*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"`", 64*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x19, 0xF8, 0x00, 0x1B, 0x18, 0x00, 0x22, 0x08, 0x00, 0x26, 0x08, 0x00, 0x24, 0x08, 0x00, 0x24, 0x10, 0x00, 0x3F, 0xF8, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x18}, /*"a", 65*/ - {0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF0, 0x00, 0x18, 0x18, 0x00, 0x10, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x30, 0x18, 0x00, 0x1F, 0xF0, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00}, /*"b", 66*/ - {0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x18, 0x30, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x3C, 0x08, 0x00, 0x1C, 0x10, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"c", 67*/ - {0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x38, 0x18, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x04, 0x10, 0x10, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"d", 68*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x12, 0x30, 0x00, 0x22, 0x18, 0x00, 0x22, 0x08, 0x00, 0x22, 0x08, 0x00, 0x32, 0x08, 0x00, 0x1E, 0x10, 0x00, 0x0E, 0x20, 0x00, 0x00, 0x00}, /*"e", 69*/ - {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x01, 0xFF, 0xF8, 0x03, 0xFF, 0xF8, 0x06, 0x20, 0x08, 0x04, 0x20, 0x08, 0x04, 0x20, 0x08, 0x07, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"f", 70*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x6E, 0x00, 0x1F, 0xF3, 0x00, 0x31, 0xB1, 0x00, 0x20, 0xB1, 0x00, 0x20, 0xB1, 0x00, 0x31, 0x91, 0x00, 0x1F, 0x13, 0x00, 0x2E, 0x1E, 0x00, 0x20, 0x0E, 0x00, 0x30, 0x00}, /*"g", 71*/ - {0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF8, 0x00, 0x10, 0x08, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"h", 72*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x06, 0x3F, 0xF8, 0x06, 0x3F, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"i", 73*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x20, 0x01, 0x00, 0x20, 0x01, 0x00, 0x20, 0x03, 0x06, 0x3F, 0xFE, 0x06, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"j", 74*/ - {0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF8, 0x00, 0x01, 0x88, 0x00, 0x03, 0x00, 0x00, 0x2F, 0xC0, 0x00, 0x38, 0xF8, 0x00, 0x20, 0x38, 0x00, 0x20, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"k", 75*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x04, 0x00, 0x08, 0x07, 0xFF, 0xF8, 0x0F, 0xFF, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"l", 76*/ - {0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x10, 0x08, 0x00, 0x20, 0x00, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x10, 0x08, 0x00, 0x20, 0x00, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x00, 0x08}, /*"m", 77*/ - {0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x10, 0x08, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00}, /*"n", 78*/ - {0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x0F, 0xF0, 0x00, 0x18, 0x30, 0x00, 0x30, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x30, 0x08, 0x00, 0x18, 0x30, 0x00, 0x0F, 0xF0, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00}, /*"o", 79*/ - {0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x3F, 0xFF, 0x00, 0x3F, 0xFF, 0x00, 0x10, 0x11, 0x00, 0x20, 0x09, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x30, 0x38, 0x00, 0x1F, 0xF0, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00}, /*"p", 80*/ - {0x00, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x1F, 0xF0, 0x00, 0x38, 0x18, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x09, 0x00, 0x10, 0x11, 0x00, 0x1F, 0xFF, 0x00, 0x3F, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}, /*"q", 81*/ - {0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x3F, 0xF8, 0x00, 0x3F, 0xF8, 0x00, 0x08, 0x08, 0x00, 0x10, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00}, /*"r", 82*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x78, 0x00, 0x1E, 0x18, 0x00, 0x33, 0x08, 0x00, 0x23, 0x08, 0x00, 0x21, 0x08, 0x00, 0x21, 0x88, 0x00, 0x21, 0x98, 0x00, 0x30, 0xF0, 0x00, 0x38, 0x60, 0x00, 0x00, 0x00}, /*"s", 83*/ - {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0xFF, 0xF0, 0x03, 0xFF, 0xF8, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"t", 84*/ - {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x7F, 0xF8, 0x00, 0x00, 0x18, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x20, 0x10, 0x00, 0x3F, 0xF8, 0x00, 0x7F, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}, /*"u", 85*/ - {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x30, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3F, 0x80, 0x00, 0x23, 0xF0, 0x00, 0x00, 0x78, 0x00, 0x00, 0x70, 0x00, 0x23, 0x80, 0x00, 0x3C, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00}, /*"v", 86*/ - {0x00, 0x20, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x23, 0xF8, 0x00, 0x00, 0xE0, 0x00, 0x27, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x3F, 0xE0, 0x00, 0x21, 0xF8, 0x00, 0x01, 0xE0, 0x00, 0x3E, 0x00, 0x00, 0x20, 0x00}, /*"w", 87*/ - {0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x20, 0x08, 0x00, 0x38, 0x38, 0x00, 0x3E, 0x68, 0x00, 0x27, 0x80, 0x00, 0x03, 0xC8, 0x00, 0x2C, 0xF8, 0x00, 0x38, 0x38, 0x00, 0x20, 0x18, 0x00, 0x20, 0x08, 0x00, 0x00, 0x00}, /*"x", 88*/ - {0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x30, 0x03, 0x00, 0x3C, 0x01, 0x00, 0x3F, 0x83, 0x00, 0x23, 0xEC, 0x00, 0x00, 0x70, 0x00, 0x23, 0x80, 0x00, 0x3C, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00}, /*"y", 89*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x08, 0x00, 0x20, 0x38, 0x00, 0x20, 0xF8, 0x00, 0x23, 0xE8, 0x00, 0x2F, 0x88, 0x00, 0x3E, 0x08, 0x00, 0x38, 0x08, 0x00, 0x20, 0x18, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00}, /*"z", 90*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x14, 0x00, 0x1F, 0xF7, 0xFC, 0x30, 0x00, 0x06, 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"{", 91*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"|", 92*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x02, 0x30, 0x00, 0x06, 0x1F, 0xF7, 0xFC, 0x00, 0x14, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"}", 93*/ - {0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x10, 0x00, 0x00}, /*"~", 94*/ -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/app/src/_board/ssd1306/driver_ssd1306_interface.h b/app/src/_board/ssd1306/driver_ssd1306_interface.h deleted file mode 100644 index 093ed1d..0000000 --- a/app/src/_board/ssd1306/driver_ssd1306_interface.h +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Copyright (c) 2015 - present LibDriver All rights reserved - * - * The MIT License (MIT) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * @file driver_ssd1306_interface.h - * @brief driver ssd1306 interface header file - * @version 2.0.0 - * @author Shifeng Li - * @date 2021-03-30 - * - *

history

- * - *
Date Version Author Description - *
2021/03/30 2.0 Shifeng Li format the code - *
2020/12/10 1.0 Shifeng Li first upload - *
- */ - -#ifndef DRIVER_SSD1306_INTERFACE_H -#define DRIVER_SSD1306_INTERFACE_H - -#include "driver_ssd1306.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -/** - * @defgroup ssd1306_interface_driver ssd1306 interface driver function - * @brief ssd1306 interface driver modules - * @ingroup ssd1306_driver - * @{ - */ - -/** - * @brief interface iic bus init - * @return status code - * - 0 success - * - 1 iic init failed - * @note none - */ -uint8_t ssd1306_interface_iic_init(void); - -/** - * @brief interface iic bus deinit - * @return status code - * - 0 success - * - 1 iic deinit failed - * @note none - */ -uint8_t ssd1306_interface_iic_deinit(void); - -/** - * @brief interface iic bus write - * @param[in] addr is the iic device write address - * @param[in] reg is the iic register address - * @param[in] *buf points to a data buffer - * @param[in] len is the length of the data buffer - * @return status code - * - 0 success - * - 1 write failed - * @note none - */ -uint8_t ssd1306_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len); - -/** - * @brief interface spi bus init - * @return status code - * - 0 success - * - 1 spi init failed - * @note none - */ -uint8_t ssd1306_interface_spi_init(void); - -/** - * @brief interface spi bus deinit - * @return status code - * - 0 success - * - 1 spi deinit failed - * @note none - */ -uint8_t ssd1306_interface_spi_deinit(void); - -/** - * @brief interface spi bus write - * @param[in] *buf points to a data buffer - * @param[in] len is the length of data buffer - * @return status code - * - 0 success - * - 1 write failed - * @note none - */ -uint8_t ssd1306_interface_spi_write_cmd(uint8_t *buf, uint16_t len); - -/** - * @brief interface delay ms - * @param[in] ms - * @note none - */ -void ssd1306_interface_delay_ms(uint32_t ms); - -/** - * @brief interface print format data - * @param[in] fmt is the format data - * @note none - */ -void ssd1306_interface_debug_print(const char *const fmt, ...); - -/** - * @brief interface command && data gpio init - * @return status code - * - 0 success - * - 1 gpio init failed - * @note none - */ -uint8_t ssd1306_interface_spi_cmd_data_gpio_init(void); - -/** - * @brief interface command && data gpio deinit - * @return status code - * - 0 success - * - 1 gpio deinit failed - * @note none - */ -uint8_t ssd1306_interface_spi_cmd_data_gpio_deinit(void); - -/** - * @brief interface command && data gpio write - * @param[in] value is the written value - * @return status code - * - 0 success - * - 1 gpio write failed - * @note none - */ -uint8_t ssd1306_interface_spi_cmd_data_gpio_write(uint8_t value); - -/** - * @brief interface reset gpio init - * @return status code - * - 0 success - * - 1 gpio init failed - * @note none - */ -uint8_t ssd1306_interface_reset_gpio_init(void); - -/** - * @brief interface reset gpio deinit - * @return status code - * - 0 success - * - 1 gpio deinit failed - * @note none - */ -uint8_t ssd1306_interface_reset_gpio_deinit(void); - -/** - * @brief interface reset gpio write - * @param[in] value is the written value - * @return status code - * - 0 success - * - 1 gpio write failed - * @note none - */ -uint8_t ssd1306_interface_reset_gpio_write(uint8_t value); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/app/src/_board/ssd1306/fontlib.c b/app/src/_board/ssd1306/fontlib.c deleted file mode 100644 index b2e6090..0000000 --- a/app/src/_board/ssd1306/fontlib.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "fontlib.h" - -static FontLibrary_t s_fontlibrary[10]; -static uint8_t s_fontlibrarylen = 0; - -uint8_t str_iterator_start(StrIterator_t *iterator, FontCode_t code, const char *chr) { - 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) { - *nowchr = iterator->str + iterator->nowoff; - if (*nowchr[0] == '\0') { - *nowchr = NULL; - return; - } - while (iterator->str[iterator->nowoff] != '\0') { - if ((iterator->str[iterator->nowoff] < 0x80)) { - iterator->nowoff++; - break; - } else { - if (iterator->code == kgbk) { - iterator->nowoff += 2; - } else if (iterator->code == kutf8) { - iterator->nowoff += 3; - } - break; - } - } -} - -void FontLibrary_regsiter(FontLibrary_t *lib) { s_fontlibrary[s_fontlibrarylen++] = *lib; } - -FontLibrary_t *FontLibrary_findlib(FontCode_t fontcode, uint8_t widthPixel, uint8_t heightPixel, bool isAscii) { - for (size_t i = 0; i < s_fontlibrarylen; i++) { - if (s_fontlibrary[i].fontCode == fontcode && // - s_fontlibrary[i].isAscii == isAscii && // - s_fontlibrary[i].widthPixel == widthPixel && // - s_fontlibrary[i].heightPixel == heightPixel) { - return &s_fontlibrary[i]; - } - } - return NULL; -} - -void FontLibrary_findchar(FontLibrary_t *lib, const char *chr, const uint8_t **font) { - *font = NULL; - - uint8_t eachIndexWidth = 1; - if (lib->isAscii) { - eachIndexWidth = 1; - } else { - if (lib->fontCode == kutf8) { - eachIndexWidth = 3; - } else if (lib->fontCode == kgbk) { - eachIndexWidth = 2; - } - } - - if (eachIndexWidth == 1) { - for (int i = 0; i < lib->fontIndexLen; i += 1) { - if (lib->fontIndex[i] == chr[0]) { - *font = &lib->font[i * lib->widthPixel * lib->heightPixel / 8]; - } - } - } else if (eachIndexWidth == 2) { - for (int i = 0; i < lib->fontIndexLen; i += 2) { - if (lib->fontIndex[i] == chr[0] && lib->fontIndex[i + 1] == chr[1]) { - *font = &lib->font[i / 2 * lib->widthPixel * lib->heightPixel / 8]; - } - } - } else if (eachIndexWidth == 3) { - for (int i = 0; i < lib->fontIndexLen; i += 3) { - if (lib->fontIndex[i] == chr[0] && lib->fontIndex[i + 1] == chr[1] && lib->fontIndex[i + 2] == chr[2]) { - *font = &lib->font[i / 3 * lib->widthPixel * lib->heightPixel / 8]; - } - } - } -} - -bool str_is_ascii(const char *chr) { return chr[0] < 0x80; } diff --git a/app/src/_board/ssd1306/fontlib.h b/app/src/_board/ssd1306/fontlib.h deleted file mode 100644 index 14113c6..0000000 --- a/app/src/_board/ssd1306/fontlib.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include -#include -#include -typedef enum { - kutf8, - kgbk, -} FontCode_t; - -typedef enum { - kFontSize08x16, - kFontSize16x16, -} FontSize_t; - -typedef struct { - const uint8_t *font; - - const char *fontIndex; - int fontIndexLen; - - FontCode_t fontCode; - bool isAscii; - - uint8_t widthPixel; - uint8_t heightPixel; -} FontLibrary_t; - -typedef struct { - const char *str; - int nowoff; - FontCode_t code; -} StrIterator_t; - -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(const char *chr); - -void FontLibrary_regsiter(FontLibrary_t *lib); -FontLibrary_t *FontLibrary_findlib(FontCode_t fontcode, uint8_t widthPixel, uint8_t heightPixel, bool isAscii); -void FontLibrary_findchar(FontLibrary_t *lib, const char *chr, const uint8_t **font); diff --git a/app/src/_board/ssd1306/wave_drawer.c b/app/src/_board/ssd1306/wave_drawer.c deleted file mode 100644 index a98fe9f..0000000 --- a/app/src/_board/ssd1306/wave_drawer.c +++ /dev/null @@ -1,92 +0,0 @@ -#include "wave_drawer.h" - -#include "znordic.h" - -static bool m_draw_scan_line = false; - -void wave_drawer_init(wave_drawer_t *dw, uint8_t xs, uint8_t ys, uint16_t width, uint16_t high) { - dw->xs = xs; - dw->ys = ys; - dw->width = width; - dw->high = high; - dw->pointoffset = 0; - - dw->xright_border = xs + width; - dw->xleft_border = xs; - dw->ytop_border = ys; - dw->ybottom_border = ys + high; - - dw->ytop = ys + 1; - dw->ybottom = ys + high - 2; - dw->xleft = xs + 1; - dw->xright = xs + width - 1; - - dw->high = high - 2; - dw->width = width - 1; - dw->is_first_point = true; -} - -void wave_drawer_draw_border(wave_drawer_t *dw) { - for (uint16_t x = dw->xleft_border; x <= dw->xright_border; x++) { - for (uint16_t y = dw->ytop_border; y <= dw->ybottom_border; y++) { - if (x == dw->xleft_border || x == dw->xright_border || y == dw->ytop_border || y == dw->ybottom_border) { - ssd1306_gram_write_point(ssd1306_handler(), x, y, 1); - } else { - ssd1306_gram_write_point(ssd1306_handler(), x, y, 0); - } - } - } -} - -void wave_drawer_draw_next_point(wave_drawer_t *dw, uint8_t y) { - /** - * @brief - * - * ---------------- - * | - * | . ..| .... - * |.. . | - * | - * |--------------- - */ - - uint16_t yreal = y / 100.0 * (dw->high - 4); - uint16_t ypos = dw->ybottom - yreal; - uint16_t xpos = dw->xleft + dw->pointoffset; - - // 清除上一次的点 - for (size_t yoff = 0; yoff < dw->high; yoff++) { - ssd1306_gram_write_point(ssd1306_handler(), xpos + 0, dw->ybottom - yoff, 0); - } - - ssd1306_gram_write_point(ssd1306_handler(), xpos, ypos, 1); - if (xpos > dw->last_xs && !dw->is_first_point) { - // 画当前点和上一次点的连线 - ssd1306_basic_draw_line(xpos - 1, dw->last_ys, xpos, ypos); - } - /** - * @brief 画当前位置标志 - */ - for (size_t yoff = 0; yoff < dw->high; yoff++) { - if (xpos + 1 <= dw->xright) { - if (m_draw_scan_line) { - ssd1306_gram_write_point(ssd1306_handler(), xpos + 1, dw->ybottom - yoff, 1); - } else { - ssd1306_gram_write_point(ssd1306_handler(), xpos + 1, dw->ybottom - yoff, 0); - } - } - for (uint8_t i = 2; i < 2 + 5; i++) { - if (xpos + i <= dw->xright) { - ssd1306_gram_write_point(ssd1306_handler(), xpos + i, dw->ybottom - yoff, 0); - } - } - } - dw->last_xs = xpos; - dw->last_ys = ypos; - - dw->pointoffset++; - if (dw->pointoffset >= dw->width) { - dw->pointoffset = 0; - } - dw->is_first_point = false; -} \ No newline at end of file diff --git a/app/src/_board/ssd1306/wave_drawer.h b/app/src/_board/ssd1306/wave_drawer.h deleted file mode 100644 index e42d3fb..0000000 --- a/app/src/_board/ssd1306/wave_drawer.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "driver_ssd1306.h" -#include "driver_ssd1306_basic.h" - -typedef struct { - uint8_t xs; - uint8_t ys; - - uint8_t last_xs; - uint8_t last_ys; - - uint8_t xright_border; - uint8_t xleft_border; - - uint8_t ytop_border; - uint8_t ybottom_border; - - uint8_t ytop; - uint8_t ybottom; - - uint16_t xleft; - uint16_t xright; - - uint16_t width; - uint16_t high; - - uint16_t pointoffset; - bool is_first_point; -} wave_drawer_t; - -void wave_drawer_init(wave_drawer_t *drawer, uint8_t xs, uint8_t ys, uint16_t width, uint16_t high); -void wave_drawer_draw_border(wave_drawer_t *drawer); -void wave_drawer_draw_next_point(wave_drawer_t *drawer, uint8_t y); diff --git a/app/src/app_basic_service/device_version_info_mgr.c b/app/src/app_basic_service/device_version_info_mgr.c index 1b8d268..466f8b9 100644 --- a/app/src/app_basic_service/device_version_info_mgr.c +++ b/app/src/app_basic_service/device_version_info_mgr.c @@ -8,8 +8,8 @@ void device_info_read_sn(sn_t *sn) { uint32_t lot = NRF_UICR->CUSTOMER[0]; uint32_t id = NRF_UICR->CUSTOMER[1]; static char sn_str[15]; - if (lot == 0 || id == 0 || lot == 0xffffffff || id == 0xffffffff) { - sprintf(sn_str, "%s-%s","iflytop",CATEGORY); + if ((lot == 0 && id == 0) || lot == 0xffffffff || id == 0xffffffff) { + sprintf(sn_str, "%s-%s", "IFLYTOP", "TEST"); } else { sprintf(sn_str, "%s%04d%05d", CATEGORY, lot, id); } diff --git a/app/src/app_service/ecg_service/ecg_service.c b/app/src/app_service/ecg_service/ecg_service.c index eefe3d6..1036254 100644 --- a/app/src/app_service/ecg_service/ecg_service.c +++ b/app/src/app_service/ecg_service/ecg_service.c @@ -199,16 +199,6 @@ void ads129x_read_data(ads129x_capture_data_t* capture_data) { * PUBLIC_FUNC * ***********************************************************************************************************************/ -void ecg_service_init() { // - /** - * @brief - * 在这里初始化一些硬件无关的内存组件 - */ - - ecg_data_mgr_init(); - ecg_algo_init(); -} - void ads1291_ready_pin_irq(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { if (ADS129X_DRDY_GET()) { static ads129x_capture_data_t capture_data; @@ -222,6 +212,16 @@ void ads1291_ready_pin_irq(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) } } +void ecg_service_init() { // + /** + * @brief + * 在这里初始化一些硬件无关的内存组件 + */ + + ecg_data_mgr_init(); + ecg_algo_init(); +} + void ecg_service_load() { /** * @brief 硬件接口初始化 @@ -280,6 +280,9 @@ void ecg_service_load() { regcache.rld_sens = 0x20; regcache.loff_sens = 0x03; ads129x_write_regs(®cache); + ads129x_send_cmd(ADS129X_COMMAND_STANDBY); /* 软件复位,并停止连续读状态 */ + nrf_delay_ms(100); + // ads129x_send_cmd(ADS129X_COMMAND_START); /* 软件复位,并停止连续读状态 */ } void ecg_service_unload() { /** @@ -311,11 +314,6 @@ uint32_t ecg_service_has_captured_time() { return znordic_haspassed_ms(ecg_servi void ecg_service_subic_write_reg(uint8_t addr, uint8_t val) { ads129x_rw_reg(ADS129X_COMMAND_WREG | addr, val); } uint8_t ecg_service_subic_read_reg(uint8_t addr) { return ads129x_rw_reg(ADS129X_COMMAND_RREG | addr, 0); } +int32_t ecg_service_get_display_val() { return ecg_algo_get_display_data(); } -int32_t ecg_service_get_display_val(){ - return ecg_algo_get_display_data(); -} - -int32_t ecg_service_get_heart_rate(){ - return ecg_algo_get_heart_rate(); -} +int32_t ecg_service_get_heart_rate() { return ecg_algo_get_heart_rate(); } diff --git a/app/src/bakservice/ble_cmd_processer/ble_cmd_process_service.c b/app/src/bakservice/ble_cmd_processer/ble_cmd_process_service.c deleted file mode 100644 index ea9e6fd..0000000 --- a/app/src/bakservice/ble_cmd_processer/ble_cmd_process_service.c +++ /dev/null @@ -1,261 +0,0 @@ -#include "ble_cmd_process_service.h" - -#include "aproject_config/config.h" -// -#include "ify_hrs_protocol/heart_rate_sensor_protocol.h" -// -#include "basic_service/device_version_info_mgr.h" -#include "board/board_battery_state.h" -#include "board/board_ecg_sensor.h" -#include "service/storage/storage_service.h" -// -#include "zble_module.h" -#include "zdatachannel_service.h" - -APP_TIMER_DEF(m_record_upload_tmr); // 数据上报定时器 -APP_TIMER_DEF(m_record_upload_finish_packet_report_tmr); // 数据上报完成上报定时器 -static uint8_t txbuf[250]; -static uint8_t reportbuf[250]; -static int m_upload_record_state = 0; -static uint32_t m_upload_data_state_enter_tp = 0; - -static bool m_ble_cmder_is_inited = false; -static uint32_t m_report_data_sumcheckcode = 0; - -static void record_upload_tmr_cb(void* p_context); -static void record_upload_finish_packet_report_tmr_cb(void* p_context); -int ble_stop_upload_record(); -/******************************************************************************* - * 广播控制 * - *******************************************************************************/ -void ble_cmder_start_adv() { - global_state_set_preview_state(false); - zble_module_start_adv(); -} -void ble_cmder_stop_adv() { - zble_module_stop_adv(); - global_state_set_preview_state(false); -} - -/******************************************************************************* - * 模块初始化 * - *******************************************************************************/ -void ble_cmder_init() { - if (!m_ble_cmder_is_inited) { - ZERROR_CHECK(app_timer_create(&m_record_upload_tmr, APP_TIMER_MODE_REPEATED, record_upload_tmr_cb)); - ZERROR_CHECK(app_timer_create(&m_record_upload_finish_packet_report_tmr, APP_TIMER_MODE_SINGLE_SHOT, record_upload_finish_packet_report_tmr_cb)); - } - m_ble_cmder_is_inited = true; -} -void ble_cmder_uninit() {} - -/******************************************************************************* - * 实时上报控制 * - *******************************************************************************/ - -void ble_cmder_try_report_one_sample_data(app_event_t* event) { - heartrate_report_packet_t* reportpacket = (heartrate_report_packet_t*)reportbuf; - reportpacket->cmd = ify_hrs_report_heartrate_data; - reportpacket->frame_index = 0; - reportpacket->frame_type = kifyhrs_pt_report; - reportpacket->sample_data_index = event->val.little_data_block.frameIndex; - - for (int i = 0; i < LITTLE_DATA_BLOCK_FRAME_NUM; i++) { - reportpacket->data[i * 4] = (event->val.little_data_block.data[i] >> 0) & 0xFF; - reportpacket->data[i * 4 + 1] = (event->val.little_data_block.data[i] >> 8) & 0xFF; - reportpacket->data[i * 4 + 2] = (event->val.little_data_block.data[i] >> 16) & 0xFF; - reportpacket->data[i * 4 + 3] = (event->val.little_data_block.data[i] >> 24) & 0xFF; - } - reportpacket->data[LITTLE_DATA_BLOCK_FRAME_NUM * 4] = (event->val.little_data_block.timestamp >> 0) & 0xFF; - reportpacket->data[LITTLE_DATA_BLOCK_FRAME_NUM * 4 + 1] = (event->val.little_data_block.timestamp >> 8) & 0xFF; - reportpacket->data[LITTLE_DATA_BLOCK_FRAME_NUM * 4 + 2] = (event->val.little_data_block.timestamp >> 16) & 0xFF; - reportpacket->data[LITTLE_DATA_BLOCK_FRAME_NUM * 4 + 3] = (event->val.little_data_block.timestamp >> 24) & 0xFF; - - STATIC_ASSERT(sizeof(one_frame_t) == 4); - - // reportpacket->data[2] = (data1 >> 0) & 0xFF; // 第二帧数据 - // reportpacket->data[3] = (data1 >> 8) & 0xFF; // 第二帧数据 - // reportpacket->data[4] = (data2 >> 0) & 0xFF; // 第三帧数据 - // reportpacket->data[5] = (data2 >> 8) & 0xFF; // 第三帧数据 - // reportpacket->data[6] = (data3 >> 0) & 0xFF; // 第四帧数据 - // reportpacket->data[7] = (data3 >> 8) & 0xFF; // 第四帧数据 - // reportpacket->data[8] = (data4 >> 0) & 0xFF; // 第五帧数据 - // reportpacket->data[9] = (data4 >> 8) & 0xFF; // 第五帧数据 - - uint16_t sendlen = sizeof(heartrate_report_packet_t) + LITTLE_DATA_BLOCK_FRAME_NUM * 4 + 4; - zdatachannel_data_send2(reportbuf, sendlen); - return; -} - -void ble_cmder_try_report_sensor_drop_event(uint8_t dropstate0, uint8_t dropstate1) { - sensor_drop_event_report_packet_t* reportpacket = (sensor_drop_event_report_packet_t*)reportbuf; - reportpacket->cmd = ify_hrs_report_sensor_drop_detect; - reportpacket->frame_index = 0; - reportpacket->frame_type = kifyhrs_pt_report; - reportpacket->drop_state0 = dropstate0; - reportpacket->drop_state1 = dropstate1; - - uint16_t sendlen = sizeof(sensor_drop_event_report_packet_t); - zdatachannel_data_send2(reportbuf, sendlen); - return; -} -void ble_cmder_report_upload_finish_event(uint32_t sumcheckcode) { - ify_hrs_packet_t* txheader = (ify_hrs_packet_t*)txbuf; - uint16_t sendlen = sizeof(ify_hrs_packet_t) + 4; - - txheader->cmd = ify_hrs_report_record_upload_end; // 6A - txheader->frame_index = 0; - txheader->frame_type = kifyhrs_pt_report; - - // txheader->data[0] = errorcode; - *(uint32_t*)txheader->data = sumcheckcode; - - zdatachannel_data_send2(txbuf, sendlen); - return; -} - -void ble_cmder_report_sample_finish_event() { - ify_hrs_packet_t* txheader = (ify_hrs_packet_t*)txbuf; - uint16_t sendlen = sizeof(ify_hrs_packet_t); - - txheader->cmd = ify_hrs_report_sample_finish_end; - txheader->frame_index = 0; - txheader->frame_type = kifyhrs_pt_report; - - zdatachannel_data_send2(txbuf, sendlen); - return; -} - -/******************************************************************************* - * 上传数据控制 * - *******************************************************************************/ -static int m_upload_fd; -static uint8_t datacache[256]; -static int m_remaindatalen = 0; -/** - * @brief 数据上报定时器回调 - * - * @param p_context - */ -static void record_upload_finish_packet_report_tmr_cb(void* p_context) { // - ble_cmder_report_upload_finish_event(m_report_data_sumcheckcode); -} - -static void record_upload_tmr_cb(void* p_context) { // - - if (m_upload_record_state == 0) return; - - if (m_upload_record_state == 1) { - if (m_remaindatalen == 0) { - memset(datacache, 0, sizeof(datacache)); - int32_t rdsize = sample_data_mgr_read(m_upload_fd, datacache, sizeof(datacache)); - if (rdsize <= 0) { - ZLOGI("read file end,stop upload"); - m_upload_record_state = 2; - m_upload_data_state_enter_tp = znordic_getpower_on_ms(); - return; - } - m_remaindatalen = rdsize; - } - if (m_remaindatalen == 0) { - return; - } - - int32_t mtusize = zble_module_get_mtu_size(); - mtusize = mtusize < 128 ? mtusize : 128; - - uint8_t* data = datacache + (sizeof(datacache) - m_remaindatalen); - int len = m_remaindatalen > mtusize ? mtusize : m_remaindatalen; - - ZLOGI("upload %d %d %d", len, m_remaindatalen, mtusize); - if (!zdatachannel_is_connected()) { - ZLOGI("ble is disconnected,stop upload"); - ble_stop_upload_record(); - return; - } - - uint32_t suc = zdatachannel_block_data_send2(data, len); - if (suc != NRF_SUCCESS) { - if (suc == NRF_ERROR_INVALID_STATE) { - // 未使能notify - ZLOGI("ble unenable notify,stop upload"); - ble_stop_upload_record(); - return; - } else if (suc == NRF_ERROR_BUSY || suc == NRF_ERROR_RESOURCES) { - // 等待下次发送 - return; - } else { - ZLOGI("ble send error,stop upload %x", suc); - ble_stop_upload_record(); - return; - } - } - for (uint32_t i = 0; i < len; i++) { - m_report_data_sumcheckcode += data[i]; - } - m_remaindatalen -= len; - } else { - if (znordic_haspassed_ms(m_upload_data_state_enter_tp) > 30) { - ble_cmder_report_upload_finish_event(m_report_data_sumcheckcode); - ble_stop_upload_record(); - return; - } - } -} - -int ble_start_upload_record(sample_data_filename_t* recordid) { - // - // 启动 - // - if (ds_now_state() != kdevice_state_home && ds_now_state() != kdevice_state_charging) { - return kifyhrs_ecode_device_busy; - } - - m_upload_fd = sample_data_mgr_open(recordid, kwrflag_read_only); - if (m_upload_fd <= 0) { - return kifyhrs_ecode_no_record_find; - } - - ZERROR_CHECK(app_timer_start(m_record_upload_tmr, APP_TIMER_TICKS(15), NULL)); - m_upload_record_state = 1; - m_remaindatalen = 0; - m_report_data_sumcheckcode = 0; - return 0; -} -int ble_stop_upload_record() { - m_upload_record_state = 0; - app_timer_stop(m_record_upload_tmr); - if (m_upload_fd > 0) { - sample_data_mgr_close(m_upload_fd); - m_upload_fd = 0; - } - return 0; -} -bool ble_is_upload_record() { return m_upload_record_state != 0; } - -/******************************************************************************* - * UTILS * - *******************************************************************************/ -static void send_error_receipt(ify_hrs_packet_t* rxpacket, int32_t errorcode) { - ify_hrs_packet_t* txheader = (ify_hrs_packet_t*)txbuf; - error_receipt_t* receipt = (error_receipt_t*)txheader->data; - uint16_t sendlen = sizeof(ify_hrs_packet_t) + sizeof(error_receipt_t); - - txheader->cmd = rxpacket->cmd; - txheader->frame_index = rxpacket->frame_index; - txheader->frame_type = kifyhrs_pt_error_receipt; - receipt->errorcode = errorcode; - zdatachannel_data_send2(txbuf, sendlen); -} - -static void send_success_receipt(ify_hrs_packet_t* rxpacket, int32_t emptydatasize) { - ify_hrs_packet_t* txheader = (ify_hrs_packet_t*)txbuf; - uint16_t sendlen = sizeof(ify_hrs_packet_t) + emptydatasize; - - txheader->cmd = rxpacket->cmd; - txheader->frame_index = rxpacket->frame_index; - txheader->frame_type = kifyhrs_pt_cmd_receipt; - - zdatachannel_data_send2(txbuf, sendlen); -} - diff --git a/app/src/bakservice/ble_cmd_processer/ble_cmd_process_service.h b/app/src/bakservice/ble_cmd_processer/ble_cmd_process_service.h deleted file mode 100644 index ce20220..0000000 --- a/app/src/bakservice/ble_cmd_processer/ble_cmd_process_service.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "basic_service/device_state.h" - -void ble_cmder_init(); -void ble_cmder_uninit(); - -void ble_cmder_process_rx(uint8_t* rx, int len); -void ble_cmder_start_adv(); -void ble_cmder_stop_adv(); - -void ble_cmder_try_report_one_sample_data(app_event_t* event); -void ble_cmder_try_report_sensor_drop_event(uint8_t dropstate0, uint8_t dropstate1); -void ble_cmder_report_upload_finish_event(uint32_t sumcheckcode); -void ble_cmder_report_sample_finish_event(); -bool ble_is_upload_record(); -int ble_stop_upload_record(); diff --git a/app/src/bakservice/display_mgr/display_manager.c b/app/src/bakservice/display_mgr/display_manager.c deleted file mode 100644 index a886363..0000000 --- a/app/src/bakservice/display_mgr/display_manager.c +++ /dev/null @@ -1,443 +0,0 @@ -#include "display_manager.h" - -#include "../../../screen_res/logo_mono.c" -// -#include - -#include "board/board_battery_state.h" -#include "board/board_ssd1306_interface.h" -#include "aproject_config/config.h" -#include "font.h" -PageState_t g_pageState; - -void dsp_mgr_change_to_page(page_t page) { // - g_pageState.page = page; - g_pageState.last_page = page; - g_pageState.page_change_to_page_time = znordic_getpower_on_s(); - - g_pageState.in_prompt = false; - memset(g_pageState.prompt, 0, sizeof(g_pageState.prompt)); -} - -uint32_t dsp_mgr_get_page_elapsed_time_s(void) { // - return znordic_getpower_on_s() - g_pageState.page_change_to_page_time; -} - -void dsp_mgr_schedule(void) {} - -PageState_t* dsp_mgr_get_state(void) { return NULL; } - -int compute_x_pos_by_center(int16_t x, int16_t width) { return x - width / 2; } -int compute_y_pos_by_center(int16_t y, int16_t height) { return y - height / 2; } - -#define SCREEN_CENTER_X 64 -#define SCREEN_CENTER_Y 32 - -#define CHARGE_BATTERY_WIDTH (12 * 1.2) -#define CHARGE_BATTERY_HEIGHT (22 * 1.2) - -#define MAIN_PAGE_BATTERY_WIDTH (12) // 首页电池宽度 -#define MAIN_PAGE_BATTERY_HEIGHT (22) // 首页电池高度 - -/******************************************************************************* - * 充电页面 * - *******************************************************************************/ -/** - * 显示元素: - * 1.电池电量 - * --------------- - * | _ | - * | | | | - * | | - * --------------- - * - * 动画效果: - * 1. 电池电量变化 - * - */ - -static uint32_t m_nowshowbatterylevel; // 当前显示的电池电量 - -void dsp_mgr_change_to_chargingPage() { - ssd1306_basic_clear(); - uint8_t x = compute_x_pos_by_center(SCREEN_CENTER_X, CHARGE_BATTERY_WIDTH); - uint8_t y = compute_y_pos_by_center(SCREEN_CENTER_Y, CHARGE_BATTERY_HEIGHT); - uint8_t xchange, ychange; - ssd1306_basic_draw_battery_level(x, y, &xchange, &ychange, BoardBattery_get_battery_level(), CHARGE_BATTERY_WIDTH, CHARGE_BATTERY_HEIGHT); - m_nowshowbatterylevel = BoardBattery_get_battery_level(); - ssd1306_basic_gram_update(); - dsp_mgr_change_to_page(kPage_chargingPage); -} - -void chargingPage_set_batteryLevel(int batteryLevel) { - uint8_t x = compute_x_pos_by_center(SCREEN_CENTER_X, CHARGE_BATTERY_WIDTH); - uint8_t y = compute_y_pos_by_center(SCREEN_CENTER_Y, CHARGE_BATTERY_HEIGHT); - uint8_t xchange, ychange; - ssd1306_basic_draw_battery_level(x, y, &xchange, &ychange, batteryLevel, CHARGE_BATTERY_WIDTH, CHARGE_BATTERY_HEIGHT); - ssd1306_basic_gram_update(); -} - -void chargingPage_schedule() { // - static uint32_t last_update_time = 0; - if (znordic_haspassed_ms(last_update_time) < 300) { - return; - } - - last_update_time = znordic_getpower_on_ms(); - m_nowshowbatterylevel += 5; - if (m_nowshowbatterylevel > 100) { - m_nowshowbatterylevel = BoardBattery_get_battery_level(); - } - chargingPage_set_batteryLevel(m_nowshowbatterylevel); -} - -/******************************************************************************* - * 欢迎页面 * - *******************************************************************************/ -void dsp_mgr_change_to_welcome() { - /** - * @brief 切换到欢迎界面 - * 1. 加载屏幕外设 - * 2. 打开屏幕电源 - * 3. 初始化开机页面 - */ - - // ssd1306_basic_string(0, 0, "123456789123456789123", 21, 0, SSD1306_FONT_12); - ssd1306_basic_draw_screen((const char*)gImage_logo_mono); - ssd1306_basic_gram_update(); - dsp_mgr_change_to_page(kPage_welcome); -} - -void welcomePage_schedule() {} - -/******************************************************************************* - * 首页 * - *******************************************************************************/ -static bool m_main_page_colon_state = false; - -void mainPage_show(bool colon_state) { - static ztm_t now; - int16_t batterylevel; - uint8_t xchange, ychange; - uint8_t x, y; - x = compute_x_pos_by_center(SCREEN_CENTER_X, fontclocklib.widthPixel * 5 + MAIN_PAGE_BATTERY_WIDTH); - y = compute_y_pos_by_center(SCREEN_CENTER_Y, fontclocklib.heightPixel + 1); - znordic_rtc_gettime(&now); - batterylevel = BoardBattery_get_battery_level(); - - ssd1306_basic_clear_gram(); - - // ZLOGI("mainPage_show %d %d", colon_state, x, y); - - ssd1306_basic_draw_str(x, y, &xchange, &ychange, fmt("%02d:%02d", now.tm_hour, now.tm_min), &fontclocklib); - x = x + 6 + xchange; - ssd1306_basic_draw_battery_level(x, y, &xchange, &ychange, batterylevel, MAIN_PAGE_BATTERY_WIDTH, MAIN_PAGE_BATTERY_HEIGHT); - ssd1306_basic_gram_update(); - m_main_page_colon_state = colon_state; - dsp_mgr_change_to_page(kPage_main); -} - -void dsp_mgr_change_to_main() { mainPage_show(true); } -void mainPage_updateState() { mainPage_show(!m_main_page_colon_state); } -void mainPage_schedule() { - static uint32_t last_update_time = 0; - if (znordic_haspassed_ms(last_update_time) < 300) { - return; - } - last_update_time = znordic_getpower_on_ms(); - mainPage_updateState(); -} - -/******************************************************************************* - * 保持静止页面 * - *******************************************************************************/ -static int m_prepare_page_progress = 0; -void PreparePage_show(int progress) { - m_prepare_page_progress = progress; - ssd1306_basic_clear_gram(); - uint8_t x = 0; - uint8_t y = 0; - uint8_t xchange, ychange; - - x = compute_x_pos_by_center(SCREEN_CENTER_X, font24x24_zh_lib.widthPixel * 4); - y = compute_y_pos_by_center(SCREEN_CENTER_Y, font24x24_zh_lib.heightPixel); - - ssd1306_basic_draw_str(x, y, &xchange, &ychange, "保持静止", &font24x24_zh_lib); - - if (progress == 0) { - ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "xxxx", &font8x8_xo_lib); - } else if (progress == 1) { - ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "oxxx", &font8x8_xo_lib); - } else if (progress == 2) { - ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "ooxx", &font8x8_xo_lib); - } else if (progress == 3) { - ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "ooox", &font8x8_xo_lib); - } else if (progress == 4) { - ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "oooo", &font8x8_xo_lib); - } - - ssd1306_basic_gram_update(); -} - -void dsp_mgr_change_to_preparePage() { - PreparePage_show(0); - dsp_mgr_change_to_page(kPage_preparePage); -} -void dsp_mgr_preparePage_set_progress(int progress) { PreparePage_show(progress); } -int dsp_mgr_preparePage_get_progress() { return m_prepare_page_progress; } - -void PreparePage_schedule() {} - -/******************************************************************************* - * 采样页面 * - *******************************************************************************/ - -#define SMAPLE_PAGE_START_X 1 -#define SMAPLE_PAGE_START_Y 1 - -typedef struct { - wave_drawer_t wave_drawer; - - int wave_drawser_x; - int wave_drawser_y; - int wave_drawser_hight; - int wave_drawser_width; - - int progress_x; - int progress_y; - - int progress_width; - int progress_hight; - - int heartrate_x; - int heartrate_y; -} sample_page_state_t; -sample_page_state_t m_sample_page_state; -#if 0 -void dsp_mgr_change_to_sampling(int progress_s, int heartrate) { // - sample_page_state_t* sps = &m_sample_page_state; - - sps->wave_drawser_x = SMAPLE_PAGE_START_X; - sps->wave_drawser_y = SMAPLE_PAGE_START_Y; - sps->wave_drawser_hight = 40; - sps->wave_drawser_width = 120; - - sps->progress_x = SMAPLE_PAGE_START_X + 1; - sps->progress_y = SMAPLE_PAGE_START_Y + sps->wave_drawser_hight + 3 + 4; - sps->progress_width = 80; - sps->progress_hight = 8; - - sps->heartrate_x = sps->progress_x + sps->progress_width + 2; - sps->heartrate_y = sps->progress_y - 4; - - int progress = progress_s / SAMPLE_MIN_TIME_S * 25; - - ssd1306_basic_clear_gram(); - - wave_drawer_init(&sps->wave_drawer, sps->wave_drawser_x, sps->wave_drawser_y, sps->wave_drawser_width, sps->wave_drawser_hight); - wave_drawer_draw_border(&sps->wave_drawer); - uint8_t xchange, ychange; - ssd1306_basic_draw_progress(sps->progress_x, sps->progress_y, sps->progress_width, sps->progress_hight, 25, progress); - if (heartrate <= 0) { - ssd1306_basic_draw_str(sps->heartrate_x, sps->heartrate_y, &xchange, &ychange, "<>-- ", &font_asicc16x8_lib); - } else { - ssd1306_basic_draw_str(sps->heartrate_x, sps->heartrate_y, &xchange, &ychange, fmt("<>%3d", heartrate), &font_asicc16x8_lib); - } - ssd1306_basic_gram_update(); - dsp_mgr_change_to_page(kPage_sampling); -} - -void samplePage_update_state(int progress_s, int wave_y, int heartrate, bool update_screen) { // - - sample_page_state_t* sps = &m_sample_page_state; - uint8_t xchange, ychange; - - int progress = progress_s / SAMPLE_MIN_TIME_S * 25; - - if (progress_s / 10 == 0) { - ssd1306_basic_draw_str(sps->progress_x, sps->progress_y - 8, &xchange, &ychange, "xxx", &font8x8_xo_lib); - } else if (progress_s / 10 == 1) { - ssd1306_basic_draw_str(sps->progress_x, sps->progress_y - 8, &xchange, &ychange, "oxx", &font8x8_xo_lib); - } else if (progress_s / 10 == 2) { - ssd1306_basic_draw_str(sps->progress_x, sps->progress_y - 8, &xchange, &ychange, "oox", &font8x8_xo_lib); - } else if (progress_s / 10 == 3) { - ssd1306_basic_draw_str(sps->progress_x, sps->progress_y - 8, &xchange, &ychange, "ooo", &font8x8_xo_lib); - } - - wave_drawer_draw_next_point(&sps->wave_drawer, wave_y); - ssd1306_basic_draw_progress(sps->progress_x, sps->progress_y, sps->progress_width, sps->progress_hight, 25, progress); - if (heartrate <= 0) { - ssd1306_basic_draw_str(sps->heartrate_x, sps->heartrate_y, &xchange, &ychange, "<>-- ", &font_asicc16x8_lib); - } else { - ssd1306_basic_draw_str(sps->heartrate_x, sps->heartrate_y, &xchange, &ychange, fmt("<>%3d", heartrate), &font_asicc16x8_lib); - } - if (update_screen) ssd1306_basic_gram_update(); -} -#endif -void dsp_mgr_change_to_sampling(int progress_s, int heartrate) { // - sample_page_state_t* sps = &m_sample_page_state; - - sps->progress_x = SMAPLE_PAGE_START_X + 10; - sps->progress_y = SMAPLE_PAGE_START_Y + 3; - sps->progress_width = 100; - sps->progress_hight = 8; - - sps->wave_drawser_x = SMAPLE_PAGE_START_X + 5; - sps->wave_drawser_y = SMAPLE_PAGE_START_Y + sps->progress_hight + 5; - sps->wave_drawser_hight = 45; - sps->wave_drawser_width = 85; - - sps->heartrate_x = sps->wave_drawser_x + sps->wave_drawser_width + 1; - sps->heartrate_y = sps->wave_drawser_y + 5; - - int progress = progress_s / SAMPLE_MIN_TIME_S * 25; - uint8_t xchange, ychange; - - ssd1306_basic_clear_gram(); - /** - * @brief - * ================= - * | | 心 - * | wave | - * | | 心率 - */ - ssd1306_basic_draw_progress(sps->progress_x, sps->progress_y, sps->progress_width, sps->progress_hight, 25, progress); - // ssd1306_basic_draw_str(sps->progress_x + sps->progress_width + 2, sps->progress_y, &xchange, &ychange, "x", &font8x8_xo_lib); - - wave_drawer_init(&sps->wave_drawer, sps->wave_drawser_x, sps->wave_drawser_y, sps->wave_drawser_width, sps->wave_drawser_hight); - // wave_drawer_draw_border(&sps->wave_drawer); - - ssd1306_basic_draw_str(sps->heartrate_x + 2, sps->heartrate_y, &xchange, &ychange, "<>", &font_asicc16x8_lib); - ssd1306_basic_draw_str(sps->heartrate_x + 4, sps->heartrate_y + 20, &xchange, &ychange, "-- ", &font_asicc16x8_lib); - ssd1306_basic_gram_update(); - dsp_mgr_change_to_page(kPage_sampling); -} - -void samplePage_update_state(int progress_s, int wave_y, int heartrate, bool updateHeart, bool update_screen) { // - - sample_page_state_t* sps = &m_sample_page_state; - uint8_t xchange, ychange; - static bool heart_logo_state = false; - - int progress = progress_s / SAMPLE_MIN_TIME_S * 25; - - ssd1306_basic_draw_progress(sps->progress_x, sps->progress_y, sps->progress_width, sps->progress_hight, 25, progress); - // if (progress_s / 10 >= 3) { - // ssd1306_basic_draw_str(sps->progress_x + sps->progress_width + 2, sps->progress_y, &xchange, &ychange, "o", &font8x8_xo_lib); - // } else { - // ssd1306_basic_draw_str(sps->progress_x + sps->progress_width + 2, sps->progress_y, &xchange, &ychange, "x", &font8x8_xo_lib); - // } - if (update_screen && updateHeart) { - if (heart_logo_state) { - ssd1306_basic_draw_str(sps->heartrate_x + 2, sps->heartrate_y, &xchange, &ychange, "<>", &font_asicc16x8_lib); - } else { - ssd1306_basic_draw_str(sps->heartrate_x + 2, sps->heartrate_y, &xchange, &ychange, " ", &font_asicc16x8_lib); - } - heart_logo_state = !heart_logo_state; - } - - if (heartrate <= 0) { - ssd1306_basic_draw_str(sps->heartrate_x, sps->heartrate_y + 20, &xchange, &ychange, " ", &font_asicc16x8_lib); - ssd1306_basic_draw_str(sps->heartrate_x + 4, sps->heartrate_y + 20, &xchange, &ychange, "-- ", &font_asicc16x8_lib); - } else { - if (heartrate >= 100) { - ssd1306_basic_draw_str(sps->heartrate_x, sps->heartrate_y + 20, &xchange, &ychange, " ", &font_asicc16x8_lib); - ssd1306_basic_draw_str(sps->heartrate_x, sps->heartrate_y + 20, &xchange, &ychange, fmt("%d", heartrate), &font_asicc16x8_lib); - } else { - ssd1306_basic_draw_str(sps->heartrate_x, sps->heartrate_y + 20, &xchange, &ychange, " ", &font_asicc16x8_lib); - ssd1306_basic_draw_str(sps->heartrate_x + 4, sps->heartrate_y + 20, &xchange, &ychange, fmt("%d", heartrate), &font_asicc16x8_lib); - } - } - wave_drawer_draw_next_point(&sps->wave_drawer, wave_y); - if (update_screen) ssd1306_basic_gram_update(); -} - -void samplePage_schedule() { - static int count = 0; - count++; - int capturetime = hwss_has_captured_time_ms(); - int wave_y = (int)hwss_read_val(); - int heartrate = (int)hwss_read_heart_rate(); - // ZLOGI("samplePage_schedule %d %d %d", capturetime, wave_y, heartrate); - samplePage_update_state(capturetime / 1000, wave_y, hwss_read_heart_rate(), count % 30 == 0, count % 10 == 0); -} - -/******************************************************************************* - * samplingError * - *******************************************************************************/ -void dsp_mgr_change_to_samplingError() { - /** - * @brief - * 不足30秒[X] - */ - ssd1306_basic_clear_gram(); - - uint8_t x; - uint8_t y; - - x = compute_x_pos_by_center(SCREEN_CENTER_X, font24x24_zh_lib.widthPixel * 3 + font12x24_asiic_lib.widthPixel * 2); - y = compute_y_pos_by_center(SCREEN_CENTER_Y, font24x24_zh_lib.heightPixel); - - uint8_t xchange, ychange; - ssd1306_basic_draw_str(x, y, &xchange, &ychange, "不足", &font24x24_zh_lib); - x = x + xchange; - ssd1306_basic_draw_str(x, y, &xchange, &ychange, "30", &font12x24_asiic_lib); - x = x + xchange; - ssd1306_basic_draw_str(x, y, &xchange, &ychange, "秒", &font24x24_zh_lib); - x = x + xchange; - ssd1306_basic_gram_update(); - dsp_mgr_change_to_page(kPage_samplingError); -} - -void dsp_mgr_change_to_sampleSuc() { - /** - * @brief - * 1.进度条 - * 2.提示信息 - */ - ssd1306_basic_clear(); - uint8_t x = 0; - uint8_t y = 0; - - uint8_t xchange, ychange; - x = compute_x_pos_by_center(SCREEN_CENTER_X, font24x24_zh_lib.widthPixel * 4); - y = compute_y_pos_by_center(SCREEN_CENTER_Y, font24x24_zh_lib.heightPixel); - - ssd1306_basic_draw_str(x, y, &xchange, &ychange, "采集完成", &font24x24_zh_lib); - ssd1306_basic_gram_update(); - dsp_mgr_change_to_page(kPage_storagingSuc); -} - -/******************************************************************************* - * SCHEDULE * - *******************************************************************************/ - -APP_TIMER_DEF(m_dsp_mgr_schedule_tmr); -static void dsp_mgr_schedule_tmr_cb(void* p_context) { // - if (g_pageState.page == kPage_chargingPage) { - chargingPage_schedule(); - } else if (g_pageState.page == kPage_welcome) { - welcomePage_schedule(); - } else if (g_pageState.page == kPage_main) { - mainPage_schedule(); - } else if (g_pageState.page == kPage_preparePage) { - PreparePage_schedule(); - } else if (g_pageState.page == kPage_sampling) { - samplePage_schedule(); - } -} - -void dsp_mgr_init(void) { - static bool timer_inited = false; - board_screen_init(); - if (!timer_inited) { - ZERROR_CHECK(app_timer_create(&m_dsp_mgr_schedule_tmr, APP_TIMER_MODE_REPEATED, dsp_mgr_schedule_tmr_cb)); - } - // 此处周期决定采样一个页面显示的宽度 - ZERROR_CHECK(app_timer_start(m_dsp_mgr_schedule_tmr, APP_TIMER_TICKS(12), NULL)); - timer_inited = true; -} -void dsp_mgr_uninit(void) { - app_timer_stop(m_dsp_mgr_schedule_tmr); - board_screen_deinit(); -} diff --git a/app/src/bakservice/display_mgr/display_manager.h b/app/src/bakservice/display_mgr/display_manager.h deleted file mode 100644 index 0553b77..0000000 --- a/app/src/bakservice/display_mgr/display_manager.h +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include "znordic.h" -// -#include "app_timer.h" -#include "diskio_blkdev.h" -#include "ff.h" -#include "nrf_block_dev_sdc.h" -#include "nrf_delay.h" -#include "nrf_drv_pwm.h" -#include "nrf_drv_saadc.h" -#include "nrf_drv_twi.h" -#include "nrf_drv_wdt.h" -#include "nrf_gpio.h" - -/** - * @brief - * 页面流转 - * - * close <--------------------- - * | - * button ---> welcome ---> main ---> preparePage ---> sampling ---> storaging ---> storagingSuc - * ^ ---> samplingError | - * |-------------------------------------------| | - * |-----------------------------------------------------------| - * - */ - -typedef enum { - kPage_poweroff, - kPage_welcome, - kPage_main, - kPage_preparePage, - kPage_sampling, - kPage_samplingError, - kPage_storaging, - kPage_storagingSuc, - kPage_chargingPage, -} page_t; - -typedef struct { - /** - * @brief 页面状态 - */ - page_t page; // 当前页面 - page_t last_page; // 上一个页面 - uint32_t page_change_to_page_time; // 当前页面持续的时间 - - bool in_prompt; // 是否在提示状态 - char prompt[32]; // 提示内容 - - /** - * @brief - */ - -} PageState_t; - -void dsp_mgr_init(void); -void dsp_mgr_uninit(void); -void dsp_mgr_schedule(void); - -PageState_t* dsp_mgr_get_state(void); -uint32_t dsp_mgr_get_page_elapsed_time_s(void); - -void dsp_mgr_change_to_poweroff(); -void dsp_mgr_change_to_welcome(); -void dsp_mgr_change_to_main(); -void dsp_mgr_change_to_chargingPage(); - -// 保持静止页面 -void dsp_mgr_change_to_preparePage(); -void dsp_mgr_preparePage_set_progress(int progress); -int dsp_mgr_preparePage_get_progress(); - -// 采样中页面 -void dsp_mgr_change_to_sampling(int progress_s, int heartrate); - -// 采样出错页面 -void dsp_mgr_change_to_samplingError(); -// 采样成功页面 -void dsp_mgr_change_to_sampleSuc(); \ No newline at end of file diff --git a/app/src/bakservice/display_mgr/font.h b/app/src/bakservice/display_mgr/font.h deleted file mode 100644 index 179ea34..0000000 --- a/app/src/bakservice/display_mgr/font.h +++ /dev/null @@ -1,275 +0,0 @@ -// https://www.23bei.com/tool-965.html - -#include -#if 0 -const uint8_t fontclocklib_code[] = { - 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0xFF, 0xF0, 0x07, 0x80, 0x78, 0x06, // - 0x00, 0x18, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x07, 0x80, 0x78, 0x03, 0xFF, 0xF0, 0x01, 0xFF, // - 0xE0, 0x00, 0x7F, 0x80, // - 0x00, 0x00, 0x00, 0x02, 0x00, 0x10, 0x02, 0x00, 0x10, 0x02, 0x00, 0x10, 0x07, 0xFF, 0xF0, 0x0F, // - 0xFF, 0xF0, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, // - 0x00, 0x00, 0x00, 0x00, // - 0x03, 0x80, 0x70, 0x07, 0x80, 0xF0, 0x0D, 0x81, 0xB0, 0x08, 0x03, 0x30, 0x08, 0x06, 0x30, 0x08, // - 0x0C, 0x30, 0x0C, 0x38, 0x30, 0x0F, 0xF8, 0x30, 0x07, 0xF1, 0xF0, 0x03, 0xC1, 0xF0, 0x00, 0x00, // - 0x00, 0x00, 0x00, 0x00, // - 0x03, 0x81, 0xC0, 0x07, 0x81, 0xE0, 0x0F, 0x81, 0xF0, 0x08, 0x10, 0x10, 0x08, 0x10, 0x10, 0x0C, // - 0x30, 0x10, 0x0F, 0xF8, 0x30, 0x07, 0xEF, 0xF0, 0x03, 0xCF, 0xE0, 0x00, 0x03, 0xC0, 0x00, 0x00, // - 0x00, 0x00, 0x00, 0x00, // - 0x00, 0x06, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x3A, 0x00, 0x00, 0xE2, 0x00, 0x01, 0xC2, 0x10, 0x07, // - 0x02, 0x10, 0x0F, 0xFF, 0xF0, 0x1F, 0xFF, 0xF0, 0x1F, 0xFF, 0xF0, 0x00, 0x02, 0x10, 0x00, 0x02, // - 0x10, 0x00, 0x00, 0x00, // - 0x00, 0x01, 0xC0, 0x0F, 0xF9, 0xE0, 0x0F, 0xF9, 0xB0, 0x0C, 0x30, 0x10, 0x0C, 0x20, 0x10, 0x0C, // - 0x20, 0x10, 0x0C, 0x30, 0x70, 0x0C, 0x3F, 0xF0, 0x0C, 0x1F, 0xE0, 0x0C, 0x0F, 0x80, 0x00, 0x00, // - 0x00, 0x00, 0x00, 0x00, // - 0x00, 0x7F, 0x00, 0x03, 0xFF, 0xC0, 0x07, 0xFF, 0xE0, 0x07, 0x18, 0x70, 0x0C, 0x30, 0x30, 0x08, // - 0x20, 0x10, 0x08, 0x20, 0x10, 0x0E, 0x30, 0x30, 0x0E, 0x3F, 0xE0, 0x06, 0x1F, 0xE0, 0x00, 0x0F, // - 0x80, 0x00, 0x00, 0x00, // - 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x0F, 0x80, 0x00, 0x0E, 0x00, 0x00, 0x0C, 0x01, 0xF0, 0x0C, // - 0x0F, 0xF0, 0x0C, 0x3F, 0xF0, 0x0D, 0xF0, 0x00, 0x0F, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x0C, 0x00, // - 0x00, 0x00, 0x00, 0x00, // - 0x03, 0xC3, 0xC0, 0x07, 0xEF, 0xE0, 0x0F, 0xEF, 0xE0, 0x0C, 0x78, 0x30, 0x08, 0x30, 0x10, 0x08, // - 0x38, 0x10, 0x08, 0x18, 0x10, 0x0C, 0x3C, 0x30, 0x0F, 0xEF, 0xF0, 0x07, 0xE7, 0xE0, 0x03, 0x83, // - 0xC0, 0x00, 0x00, 0x00, // - 0x01, 0xF0, 0x00, 0x07, 0xF8, 0x60, 0x07, 0xFC, 0x70, 0x0E, 0x0C, 0x70, 0x08, 0x04, 0x10, 0x08, // - 0x04, 0x10, 0x08, 0x0C, 0x30, 0x0E, 0x19, 0xE0, 0x07, 0xFF, 0xE0, 0x03, 0xFF, 0x80, 0x00, 0xFE, // - 0x00, 0x00, 0x00, 0x00, // - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x70, 0x00, // - 0xE0, 0x70, 0x00, 0xE0, 0x70, 0x00, 0xE0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - 0x00, 0x00, 0x00, 0x00, // -}; - -static FontLibrary_t fontclocklib = { - .font = fontclocklib_code, - .fontIndex = "0123456789:", - .fontIndexLen = 12, - .fontCode = kgbk, - .isAscii = true, - .widthPixel = 24, - .heightPixel = 24, -}; -#endif - -// DB 00H 00H 07H F0H 0FH F8H 18H 0CH 10H 04H 18H 0CH 0FH F8H 07H F0H;"0",0 -// DB 10H 08H 10H 08H 3FH F8H 3FH F8H 00H 08H 00H 08H 00H 00H 00H 00H;"1",1 -// DB 1CH 18H 3CH 38H 20H 68H 20H C8H 23H 88H 3FH 18H 1CH 18H 00H 00H;"2",2 -// DB 18H 30H 38H 38H 22H 08H 22H 08H 27H 18H 3DH F0H 18H E0H 00H 00H;"3",3 -// DB 01H C0H 07H C0H 0EH 48H 18H 48H 3FH F8H 3FH F8H 00H 48H 00H 00H;"4",4 -// DB 3FH 30H 3FH 38H 23H 08H 22H 08H 23H 18H 21H F0H 20H E0H 00H 00H;"5",5 -// DB 0FH E0H 1FH F0H 33H 18H 22H 08H 33H 18H 31H F0H 00H E0H 00H 00H;"6",6 -// DB 38H 00H 38H 00H 21H F8H 27H F8H 3EH 00H 38H 00H 20H 00H 00H 00H;"7",7 -// DB 1CH 70H 3EH F8H 23H 88H 21H 08H 23H 88H 3EH F8H 1CH 70H 00H 00H;"8",8 -// DB 0EH 00H 1FH 18H 31H 98H 20H 88H 31H 98H 1FH F0H 0FH E0H 00H 00H;"9",9 -// DB 00H 00H 00H 00H 06H 18H 06H 18H 06H 18H 00H 00H 00H 00H 00H 00H;":",10 - -#if 0 -//32*32 -const uint8_t fontclocklib_code[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x40, 0x40, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFE, 0xFF, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0xFF, 0xFE, 0xF0, - 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x06, 0x04, 0x04, 0x06, 0x07, 0x03, 0x01, 0x00, 0x00, /*"0",0*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x06, 0x07, 0x07, 0x07, 0x06, 0x04, 0x04, 0x04, 0x00, 0x00, /*"1",1*/ - 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x1F, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC1, 0xFF, 0x7F, 0x3E, 0x00, - 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x01, 0x00, /*"2",2*/ - 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x80, 0x80, 0x80, 0xC0, 0xE1, 0x7F, 0x3F, 0x1E, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0xFF, 0xFE, 0x78, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x06, 0x04, 0x04, 0x04, 0x04, 0x06, 0x03, 0x03, 0x01, 0x00, 0x00, /*"3",3*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x70, 0x3C, 0x0E, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x10, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x0F, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x08, /*"4",4*/ - 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xC7, 0x60, 0x20, 0x20, 0x20, 0x60, 0xE0, 0xC0, 0x80, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xE1, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x03, 0x03, 0x01, 0x00, 0x00, /*"5",5*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFE, 0x8F, 0x81, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0xC3, 0x83, 0x03, 0x00, - 0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xC3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x06, 0x04, 0x04, 0x04, 0x06, 0x03, 0x03, 0x01, 0x00, /*"6",6*/ - 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x80, 0xE0, 0x78, 0x1E, 0x07, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"7",7*/ - 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x3F, 0x7F, 0xF1, 0xE0, 0xC0, 0x80, 0x80, 0x80, 0xE1, 0x7F, 0x3F, 0x1E, 0x00, - 0x00, 0xF8, 0xFC, 0xFE, 0x07, 0x03, 0x01, 0x01, 0x01, 0x03, 0x07, 0x0F, 0xFE, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x06, 0x04, 0x04, 0x04, 0x04, 0x06, 0x03, 0x03, 0x01, 0x00, 0x00, /*"8",8*/ - 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0xFF, 0xFE, 0xF8, 0x00, - 0x00, 0x00, 0x81, 0x83, 0x87, 0x06, 0x04, 0x04, 0x04, 0x06, 0x83, 0xF3, 0xFF, 0x7F, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x03, 0x07, 0x04, 0x04, 0x04, 0x06, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, /*"9",9*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /*":",10*/ -}; -static FontLibrary_t fontclocklib = { - .font = fontclocklib_code, - .fontIndex = "0123456789:", - .fontIndexLen = 12, - .fontCode = kgbk, - .isAscii = true, - .widthPixel = 16, - .heightPixel = 32, -}; -#endif - -// 24*24 -const uint8_t fontclocklib_code[] = { - - 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x60, 0x20, 0x60, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFE, 0x00, 0x01, 0x07, 0x0F, 0x1E, 0x18, 0x10, 0x18, 0x1E, 0x0F, 0x07, 0x01, /*"0",0*/ - 0x00, 0x00, 0x80, 0x80, 0x80, 0xC0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x1F, 0x1F, 0x1F, 0x10, 0x10, 0x10, 0x00, /*"1",1*/ - 0x00, 0x80, 0xC0, 0x60, 0x20, 0x20, 0x20, 0x60, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x03, 0x03, 0x03, 0x80, 0xC0, 0x60, 0x38, 0x3F, 0x1F, 0x07, 0x00, 0x00, 0x1C, 0x1E, 0x1B, 0x19, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, /*"2",2*/ - 0x00, 0x80, 0xC0, 0xE0, 0x20, 0x20, 0x60, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x10, 0x10, 0x18, 0x3F, 0xEF, 0xE7, 0x80, 0x00, 0x00, 0x07, 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x18, 0x1F, 0x0F, 0x07, 0x00, /*"3",3*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xB8, 0x8E, 0x87, 0x81, 0xFF, 0xFF, 0xFF, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x1F, 0x10, 0x10, /*"4",4*/ - 0x00, 0x00, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x18, 0x08, 0x08, 0x18, 0xF8, 0xF0, 0xE0, 0x00, 0x00, 0x07, 0x0F, 0x1B, 0x10, 0x10, 0x10, 0x1C, 0x1F, 0x0F, 0x03, 0x00, /*"5",5*/ - 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x60, 0x20, 0x20, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x31, 0x18, 0x08, 0x08, 0x18, 0xF8, 0xF0, 0xE0, 0x00, 0x01, 0x07, 0x0F, 0x1C, 0x18, 0x10, 0x10, 0x18, 0x0F, 0x0F, 0x03, /*"6",6*/ - 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0x60, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0xE0, 0xF8, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, /*"7",7*/ - 0x00, 0x80, 0xC0, 0xE0, 0x60, 0x20, 0x20, 0x20, 0x60, 0xE0, 0xC0, 0x80, 0x00, 0x87, 0xEF, 0xEF, 0x3C, 0x18, 0x38, 0x30, 0x78, 0xEF, 0xCF, 0x83, 0x00, 0x07, 0x0F, 0x0F, 0x18, 0x10, 0x10, 0x10, 0x18, 0x1F, 0x0F, 0x07, /*"8",8*/ - 0x00, 0x00, 0xC0, 0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x1F, 0x3F, 0x7F, 0x60, 0x40, 0x40, 0x60, 0x30, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x0C, 0x1C, 0x1C, 0x10, 0x10, 0x18, 0x0F, 0x0F, 0x03, 0x00, /*"9",9*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x1C, 0x00, 0x00, 0x00, /*":",10*/ - -}; -static FontLibrary_t fontclocklib = { - .font = fontclocklib_code, - .fontIndex = "0123456789:", - .fontIndexLen = 12, - .fontCode = kgbk, - .isAscii = true, - .widthPixel = 12, - .heightPixel = 24, -}; - -const uint8_t font8x8_xo_code[] = { - 0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x7E, 0x3C, 0x00, /*实心圆,代表完成*/ - 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, /*空心圆,代表未完成*/ - -}; - -static FontLibrary_t font8x8_xo_lib = { - .font = font8x8_xo_code, - .fontIndex = "ox", - .fontIndexLen = 2, - .fontCode = kgbk, - .isAscii = true, - .widthPixel = 8, - .heightPixel = 8, -}; - -const uint8_t font12x24_asiic_code[] = { - - 0x00, 0x00, 0xC0, 0xE0, 0x70, 0x30, 0x30, 0x60, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFE, 0x00, 0x00, 0x01, 0x07, 0x0E, 0x0C, 0x18, 0x18, 0x0C, 0x0F, 0x07, 0x00, 0x00, /*"0",0*/ - 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, /*"1",1*/ - 0x00, 0x80, 0xE0, 0x60, 0x30, 0x30, 0x30, 0x70, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x80, 0xC0, 0xE0, 0x38, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x08, 0x0E, 0x0F, 0x0B, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, /*"2",2*/ - 0x00, 0x80, 0xC0, 0x60, 0x30, 0x30, 0x30, 0x30, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x18, 0x18, 0x38, 0x7F, 0xE7, 0x80, 0x00, 0x00, 0x03, 0x07, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x0E, 0x07, 0x01, 0x00, /*"3",3*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xF0, 0xB8, 0x8E, 0x87, 0x81, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x0F, 0x01, 0x01, 0x01, /*"4",4*/ - 0x00, 0x00, 0xE0, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x1C, 0x1F, 0x0D, 0x04, 0x04, 0x0C, 0x0C, 0x3C, 0xF8, 0xC0, 0x00, 0x01, 0x07, 0x0E, 0x08, 0x18, 0x18, 0x18, 0x0C, 0x0F, 0x07, 0x00, 0x00, /*"5",5*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0x30, 0x10, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x1E, 0x0F, 0x0D, 0x0C, 0x0C, 0x18, 0xF8, 0xF0, 0x00, 0x00, 0x03, 0x07, 0x0C, 0x18, 0x18, 0x18, 0x18, 0x0C, 0x0F, 0x03, 0x00, /*"6",6*/ - 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xA0, 0xE0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"7",7*/ - 0x00, 0x80, 0xE0, 0x60, 0x30, 0x30, 0x30, 0x20, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0xE3, 0xFF, 0x3C, 0x18, 0x18, 0x18, 0x3C, 0x3F, 0xE7, 0xC0, 0x00, 0x00, 0x07, 0x0F, 0x0C, 0x18, 0x18, 0x18, 0x18, 0x0C, 0x07, 0x03, 0x00, /*"8",8*/ - 0x00, 0xC0, 0xE0, 0x60, 0x30, 0x30, 0x30, 0x60, 0xE0, 0xC0, 0x00, 0x00, 0x02, 0x1F, 0x3D, 0x30, 0x60, 0x60, 0xE0, 0xF0, 0x7F, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1C, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, /*"9",9*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0C, 0x1C, 0xF0, 0xE0, 0xE0, 0x38, 0x1C, 0x04, 0x00, 0x00, 0x00, 0x10, 0x1C, 0x0E, 0x03, 0x01, 0x03, 0x07, 0x0E, 0x18, 0x10, 0x00, /*"x",10*/ - 0x00, 0x30, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x83, 0xEF, 0x7C, 0x7E, 0xE7, 0x81, 0x00, 0x00, 0x00, 0x10, 0x1C, 0x1F, 0x07, 0x01, 0x00, 0x00, 0x01, 0x0F, 0x1E, 0x18, 0x00, /*"X",11*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, /*"[",12*/ - 0x00, 0x0C, 0x0C, 0x0C, 0x0C, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, - /*"]",13*/}; - -static FontLibrary_t font12x24_asiic_lib = { - .font = font12x24_asiic_code, - .fontIndex = "0123456789xX[]", - .fontIndexLen = 15, - .fontCode = kgbk, - .isAscii = true, - .widthPixel = 12, - .heightPixel = 24, -}; - -const uint8_t font24x24_zh_code[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0x38, 0x10, 0x10, 0xF0, 0x90, 0x10, 0x10, 0x10, 0x88, 0xF8, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x0C, 0x06, 0xE7, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x93, - 0x71, 0xFF, 0x39, 0x49, 0x89, 0x08, 0x08, 0x0C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x03, 0x07, 0x06, 0x06, 0x04, 0x04, 0x00, /*"保",0*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFC, 0xFC, 0xC0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC2, 0x63, 0x33, 0xFF, 0x0D, 0x09, 0x08, 0x48, - 0x48, 0x49, 0x48, 0x47, 0x4F, 0xFC, 0x24, 0x24, 0x26, 0x06, 0x04, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x08, 0x38, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x20, 0x60, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"持",1*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0xFC, 0x20, 0xA0, 0x20, 0x00, 0x80, 0x60, 0x3C, 0x2C, 0xA0, 0x70, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x0C, 0x94, 0x75, 0x55, 0x57, 0x15, 0xF4, 0x02, 0x90, - 0x92, 0x92, 0x92, 0xFF, 0x92, 0x8A, 0x49, 0x3F, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0F, 0x02, 0x01, 0x09, 0x18, 0x0F, 0x00, 0x00, 0x00, 0x20, 0x60, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"静",2*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x00, 0x00, - 0xFF, 0x0F, 0x08, 0x08, 0x08, 0x0C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x18, 0x08, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x0C, 0x0F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, /*"止",3*/ - 0x00, 0x00, 0x00, 0x00, 0x40, 0x60, 0x60, 0x60, 0x20, 0x20, 0x20, 0x20, 0xA0, 0xE0, 0x30, 0x30, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x0D, 0xFF, - 0x03, 0x00, 0x00, 0x10, 0x20, 0x60, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, /*"不",4*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xE0, 0x20, 0x20, 0x10, 0x10, 0x10, 0xF8, 0xF8, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x70, 0x61, 0x87, 0x82, 0x06, 0xFE, - 0x12, 0x11, 0x11, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x02, 0x06, 0x0C, 0x0C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x10, 0x00, 0x00, /*"足",5*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0xE0, 0x30, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0xC4, 0x64, 0x1A, 0xFF, 0x12, 0x32, 0x00, 0x18, - 0x0F, 0x00, 0x00, 0x1F, 0x80, 0xE0, 0x3C, 0x08, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x40, 0x20, 0x30, 0x18, 0x0C, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"秒",6*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x20, 0x38, 0xF8, 0x20, 0x20, 0x20, 0x60, 0x9C, 0x24, 0x10, 0x10, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x67, 0x7E, 0x00, - 0x10, 0x8C, 0x9B, 0xB9, 0xE4, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x23, 0x3F, 0x11, 0x13, 0x1D, 0x11, 0x1D, 0x17, 0x10, 0x18, 0x1F, 0x11, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, /*"蓝",7*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x10, 0x10, 0x10, 0x10, 0x10, 0xF0, 0x18, 0x18, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0F, 0x04, 0x84, 0x64, 0x34, 0x1E, - 0x06, 0xFF, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x10, 0x20, 0x70, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"牙",8*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0xF0, 0x70, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x0E, 0x08, 0x08, 0x08, 0x04, 0x04, 0x07, - 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x08, 0x08, 0x18, 0x18, 0x18, 0x10, 0x18, 0x18, 0x18, 0x18, 0x08, 0x08, 0x0C, 0x0E, 0x07, 0x00, 0x00, 0x00, /*"已",9*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x30, 0x10, 0xC0, 0xC0, 0x00, 0x00, 0x40, 0x20, 0x20, 0xA0, 0xF0, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x74, 0x2C, 0x26, 0x01, 0x00, 0x10, 0x50, - 0x48, 0x44, 0xC3, 0xC3, 0x62, 0x24, 0x2C, 0x0C, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x06, 0x02, 0x02, 0x01, 0x10, 0x18, 0x08, 0x08, 0x08, 0x0F, 0x0B, 0x08, 0x08, 0x08, 0x0C, 0x0C, 0x08, 0x00, 0x00, /*"经",10*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xC0, 0x00, 0x00, 0x40, 0x40, 0xC0, 0xE0, 0x5C, 0x2C, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0xF8, 0x08, 0x00, 0x40, 0x48, 0x4E, 0x4B, - 0x44, 0x45, 0xFF, 0x24, 0x24, 0x24, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0C, 0x04, 0x07, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x17, 0x30, 0x30, 0x30, 0x30, 0x30, 0x10, 0x10, 0x00, 0x00, /*"连",11*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x88, 0x98, 0xD0, 0xC0, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x82, 0xC2, 0x62, 0xFF, 0x11, 0x91, 0x80, 0x80, 0x90, - 0x92, 0xF4, 0xB0, 0x98, 0x97, 0x89, 0x48, 0x48, 0x48, 0x40, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x18, 0x3F, 0x0F, 0x00, 0x00, 0x20, 0x20, 0x13, 0x12, 0x0C, 0x06, 0x0F, 0x08, 0x18, 0x30, 0x20, 0x00, 0x00, 0x00, /*"接",12*/ - 0x00, 0x00, 0x00, 0xE0, 0x40, 0x40, 0x80, 0x00, 0xF8, 0x88, 0x40, 0x20, 0x00, 0x80, 0x80, 0x40, 0x40, 0x20, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x40, 0x25, 0x1A, 0xFF, 0x12, 0x12, 0x12, - 0x00, 0xE0, 0x3F, 0x08, 0x04, 0xFC, 0xFC, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x02, 0x02, 0x02, 0x03, 0x02, 0x12, 0x08, 0x06, 0x01, 0x00, 0x00, 0x00, 0x7F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, /*"断",13*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x60, 0x60, 0xE0, 0x20, 0x20, 0x20, 0x20, 0xF0, 0x30, 0x30, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0xE8, 0x3F, 0x08, 0x08, - 0x04, 0x04, 0xFF, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"开",14*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0xF8, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x7F, 0x81, 0x89, 0x49, 0xC8, 0xFF, 0x4C, - 0x44, 0x44, 0x40, 0x3C, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x18, 0x10, 0x10, 0x30, 0x30, 0x30, 0x10, 0x10, 0x1A, 0x1C, 0x00, 0x00, 0x00, /*"电",15*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x78, 0xA8, 0xA8, 0xA8, 0xA8, 0x88, 0xE4, 0x7C, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x14, 0xF4, 0x94, 0x14, 0x52, 0xF2, - 0xAA, 0xAA, 0x8A, 0xFA, 0x3A, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x24, 0x25, 0x25, 0x25, 0x3F, 0x24, 0x24, 0x27, 0x30, 0x30, 0x30, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, /*"量",16*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0xC0, 0xC6, 0xFC, 0xA0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x24, 0xE6, 0xA3, 0xA1, 0x94, 0xAF, - 0x10, 0x11, 0xF3, 0xF6, 0x2C, 0x0C, 0x18, 0x18, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x21, 0x27, 0x24, 0x24, 0x34, 0x12, 0x16, 0x13, 0x10, 0x10, 0x10, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, /*"查",17*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x90, 0x90, 0xF0, 0xB8, 0x88, 0x8C, 0xCC, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0xC8, 0x78, 0xFC, 0xA7, 0xA4, - 0xA4, 0xA4, 0x14, 0x14, 0xF2, 0x22, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, 0x3F, 0x14, 0x14, 0x14, 0x12, 0x10, 0x30, 0x7F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"看",18*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x38, 0x10, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x38, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xC6, 0x65, 0x3C, 0x2C, 0x23, 0x01, 0x80, 0x02, - 0x22, 0x22, 0x22, 0x22, 0x3F, 0x91, 0x91, 0x91, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0C, 0x04, 0x06, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x03, 0x1F, 0x09, 0x09, 0x09, 0x08, 0x08, 0x0F, 0x01, 0x00, 0x00, 0x00, /*"结",19*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30, 0xF0, 0x10, 0x90, 0x90, 0xF0, 0xF0, 0xD0, 0x10, 0x88, 0xF8, 0x78, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x60, 0x21, 0x27, 0xA4, 0x64, 0xFF, - 0x52, 0x92, 0x12, 0x13, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x10, 0x08, 0x04, 0x06, 0x03, 0x01, 0x00, 0x7F, 0x00, 0x00, 0x01, 0x02, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x10, 0x00, 0x00, /*"果",20*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0xD0, 0x90, 0x18, 0x0C, 0x88, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x60, 0x20, 0x20, 0x20, 0x22, 0x22, 0x33, 0x11, - 0xFF, 0x11, 0x11, 0x11, 0x11, 0x10, 0x18, 0x18, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x60, 0x78, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"手",21*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x86, 0xC2, 0x32, 0x0F, 0xFF, 0x21, 0x61, 0x01, 0x01, - 0xFF, 0x01, 0x01, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x3F, 0x0F, 0x00, 0x08, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x07, 0x06, 0x0C, 0x0C, 0x0C, 0x0F, 0x06, 0x00, /*"机",22*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x20, 0x20, 0x50, 0xD0, 0x88, 0x0C, 0x8C, 0x40, 0x70, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x11, 0xD0, 0x70, 0x32, 0xFC, 0x30, - 0x48, 0x88, 0x88, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, 0x30, 0x7F, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x06, 0x0C, 0x0C, 0x04, 0x08, 0x00, 0x00, /*"采",23*/ - 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0xF0, 0x0C, 0x24, 0xA0, 0xA4, 0xEC, 0xE8, 0x90, 0x50, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0xBF, 0x90, 0x90, 0xD2, 0xF2, - 0xCF, 0x4B, 0x4A, 0x49, 0x48, 0x48, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x04, 0x06, 0x03, 0x01, 0x7F, 0x00, 0x01, 0x02, 0x04, 0x0C, 0x18, 0x18, 0x18, 0x10, 0x10, 0x00, 0x00, /*"集",24*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x7C, 0xC0, 0x80, 0x80, 0x88, 0x98, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFE, 0x42, 0x42, 0x22, 0x22, 0xE1, 0x21, - 0x03, 0x1F, 0x70, 0x80, 0xE0, 0x3C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x03, 0x00, 0x04, 0x08, 0x1C, 0x07, 0x00, 0x08, 0x04, 0x02, 0x01, 0x07, 0x0C, 0x18, 0x30, 0x70, 0x78, 0x00, 0x00, /*"成",25*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x81, 0x81, 0xC1, 0x7F, 0x20, 0x20, 0x20, 0x12, - 0x82, 0xE2, 0x3E, 0x07, 0x02, 0x01, 0x01, 0xFF, 0x0F, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x10, 0x10, 0x08, 0x04, 0x03, 0x01, 0x00, 0x04, 0x08, 0x38, 0x1C, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, /*"功",26*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x80, 0x80, 0x80, 0x40, 0x48, 0x58, 0x50, 0x40, 0x20, 0x20, 0xA0, 0xE0, 0xC0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x40, 0x60, 0x24, 0xE4, 0x26, 0x22, - 0xF2, 0x12, 0x10, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x04, 0x06, 0x03, 0x00, 0x00, 0x00, 0x1F, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x3E, 0x10, 0x00, 0x00, /*"完",27*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x78, 0x10, 0x00, 0x80, 0x80, 0x40, 0x40, 0xA0, 0x38, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x18, 0x0C, 0x03, 0xFD, 0x00, 0x00, 0x00, 0xE1, 0xFF, - 0x10, 0x88, 0x0F, 0x3C, 0xE4, 0x84, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1F, 0x00, 0x00, 0x04, 0x0F, 0x03, 0x01, 0x00, 0x04, 0x0C, 0x00, 0x01, 0x06, 0x0C, 0x18, 0x3E, 0x30, 0x00, /*"低",28*/ -}; -static FontLibrary_t font24x24_zh_lib = { - .font = font24x24_zh_code, - .fontIndex = "保持静止不足秒蓝牙已经连接断开电量查看结果手机采集成功完低", - .fontIndexLen = 88, - .fontCode = kgbk, - .isAscii = false, - .widthPixel = 24, - .heightPixel = 24, -}; - -#if 0 -// const unsigned char gImage_heart_16x16[] = { -// /* 0X22,0X01,0X10,0X00,0X10,0X00, */ -// 0X00, 0XF8, 0XFC, 0XFE, 0XFE, 0XFE, 0XFE, 0XFC, 0XFC, 0XFE, 0XFE, 0XFE, 0XFE, 0XFC, 0XF8, 0X00, 0X00, 0X00, 0X03, 0X07, 0X0F, 0X1F, 0X3F, 0X7F, 0X7F, 0X3F, 0X1F, 0X0F, 0X07, 0X03, 0X00, 0X00, -// }; -#endif - -const unsigned char font_asicc_code_16x8[] = { - 0x00, 0xF0, 0x18, 0x08, 0x08, 0x18, 0xE0, 0x00, 0x00, 0x0F, 0x10, 0x20, 0x30, 0x18, 0x0F, 0x00, /*"0",0*/ - 0x00, 0x60, 0x20, 0xF0, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, /*"1",1*/ - 0x00, 0x30, 0x18, 0x08, 0x08, 0xD8, 0x70, 0x00, 0x00, 0x30, 0x38, 0x34, 0x33, 0x31, 0x30, 0x00, /*"2",2*/ - 0x00, 0x30, 0x18, 0x08, 0x88, 0xD8, 0x70, 0x00, 0x00, 0x18, 0x10, 0x20, 0x21, 0x13, 0x0E, 0x00, /*"3",3*/ - 0x00, 0x00, 0x80, 0x60, 0x30, 0xF8, 0x00, 0x00, 0x04, 0x07, 0x05, 0x04, 0x04, 0x3F, 0x04, 0x04, /*"4",4*/ - 0x00, 0xF0, 0x98, 0xC8, 0x88, 0x88, 0x08, 0x00, 0x08, 0x19, 0x30, 0x20, 0x30, 0x19, 0x0F, 0x00, /*"5",5*/ - 0x00, 0x80, 0xC0, 0xF0, 0x98, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x31, 0x20, 0x20, 0x30, 0x1F, 0x06, /*"6",6*/ - 0x00, 0x08, 0x08, 0x08, 0x88, 0xE8, 0x38, 0x00, 0x00, 0x00, 0x30, 0x3E, 0x03, 0x00, 0x00, 0x00, /*"7",7*/ - 0x00, 0xF0, 0x88, 0x88, 0x88, 0xD8, 0x70, 0x00, 0x04, 0x1F, 0x31, 0x21, 0x21, 0x31, 0x1E, 0x00, /*"8",8*/ - 0xE0, 0xF0, 0x08, 0x08, 0x08, 0x98, 0xF0, 0x00, 0x00, 0x01, 0x23, 0x3A, 0x0F, 0x03, 0x00, 0x00, /*"9",9*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, /*"-",10*/ - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x11, 0x00, 0x00, 0x00, /*":",10*/ - - 0X00, 0XF8, 0XFC, 0XFE, 0XFE, 0XFE, 0XFE, 0XFC, 0X00, 0X00, 0X03, 0X07, 0X0F, 0X1F, 0X3F, 0X7F, /*?右半*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*" "*/ -}; - -static FontLibrary_t font_asicc16x8_lib = { - .font = font_asicc_code_16x8, - .fontIndex = "0123456789-:<> ", // <> 这两个符号是心形的左右半边 - .fontIndexLen = 16, - .fontCode = kgbk, - .isAscii = true, - .widthPixel = 8, - .heightPixel = 16, -}; diff --git a/app/src/bakservice/heart_wave_sample_service/heart_ware_sample_data_mgr.c b/app/src/bakservice/heart_wave_sample_service/heart_ware_sample_data_mgr.c deleted file mode 100644 index ecf7ab1..0000000 --- a/app/src/bakservice/heart_wave_sample_service/heart_ware_sample_data_mgr.c +++ /dev/null @@ -1,107 +0,0 @@ -#include "basic_service/app_event.h" -#include "basic_service/app_event_distribute.h" -#include "board/board_ecg_sensor.h" -#include "nrfx_timer.h" - -static uint32_t m_frame_index = 0; // 帧绝对序号 -/*********************************************************************************************************************** - * ab buffer * - ***********************************************************************************************************************/ -#define FRAME_BUFFER_SIZE (256 / sizeof(one_frame_t)) - -static one_frame_t m_capture_buffer_a[FRAME_BUFFER_SIZE]; -static one_frame_t m_capture_buffer_b[FRAME_BUFFER_SIZE]; -static one_frame_t* m_capture_buffer; -static one_frame_t m_capture_buffer_index = 0; - -static void eeprom_cache_buffer_swap() { - if (m_capture_buffer == NULL) { - m_capture_buffer = m_capture_buffer_a; - m_capture_buffer_index = 0; - return; - } - - if (m_capture_buffer == m_capture_buffer_a) { - m_capture_buffer = m_capture_buffer_b; - } else { - m_capture_buffer = m_capture_buffer_a; - } - m_capture_buffer_index = 0; - return; -} - -/*********************************************************************************************************************** - * littlebuffer * - ***********************************************************************************************************************/ -static one_frame_t m_prepare_data_cache[LITTLE_DATA_BLOCK_FRAME_NUM]; -static uint32_t m_prepare_data_cache_index; - -static inline void preview_data_cache_push_data(one_frame_t data) { - if (m_prepare_data_cache_index >= LITTLE_DATA_BLOCK_FRAME_NUM) { - return; - } - m_prepare_data_cache[m_prepare_data_cache_index] = data; - m_prepare_data_cache_index++; -} - -static inline bool preview_data_cache_is_full(void) { - if (m_prepare_data_cache_index >= LITTLE_DATA_BLOCK_FRAME_NUM) { - return true; - } - return false; -} -static inline void preview_data_cache_clear(void) { m_prepare_data_cache_index = 0; } -static inline void preview_data_trigger_event() { - static app_event_t event; - event.eventType = kevent_capture_little_data_block_event; - for (uint32_t i = 0; i < LITTLE_DATA_BLOCK_FRAME_NUM; i++) { - event.val.little_data_block.data[i] = m_prepare_data_cache[i]; - } - event.val.little_data_block.timestamp = znordic_getpower_on_ms(); - event.val.little_data_block.frameIndex = m_frame_index - LITTLE_DATA_BLOCK_FRAME_NUM; - AppEvent_pushEvent(&event); -} - -/*********************************************************************************************************************** - * EXT * - ***********************************************************************************************************************/ - -void hwsd_mgr_push_one_frame(one_frame_t data) { - m_frame_index++; - - /*********************************************************************************************************************** - * EEPROM数据采样存储 * - ***********************************************************************************************************************/ - if (m_capture_buffer == NULL) eeprom_cache_buffer_swap(); - - if (m_capture_buffer_index < FRAME_BUFFER_SIZE) { - m_capture_buffer[m_capture_buffer_index++] = data; - } - - if (m_capture_buffer_index == FRAME_BUFFER_SIZE) { - app_event_t evt; - evt.eventType = kevent_capture_256data_event; - evt.val.capture_data_cache = (uint8_t*)m_capture_buffer; - eeprom_cache_buffer_swap(); - AppEvent_pushEvent(&evt); - } - - /******************************************************************************* - * 实时采样数据事件上报 * - *******************************************************************************/ - /** - * @brief 缓存数据,并触发小数据块事件 - */ - preview_data_cache_push_data(data); - if (preview_data_cache_is_full()) { - preview_data_trigger_event(); - preview_data_cache_clear(); - } -} - -void hwsd_mgr_reset_buffer(){ - m_frame_index = 0; - m_capture_buffer = NULL; - m_capture_buffer_index = 0; - preview_data_cache_clear(); -} diff --git a/app/src/bakservice/heart_wave_sample_service/heart_ware_sample_data_mgr.h b/app/src/bakservice/heart_wave_sample_service/heart_ware_sample_data_mgr.h deleted file mode 100644 index 71c04f3..0000000 --- a/app/src/bakservice/heart_wave_sample_service/heart_ware_sample_data_mgr.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include - -#include "basic_service/app_event.h" -#include "basic_service/app_event_distribute.h" -#include "nrfx_timer.h" - -void hwsd_mgr_push_one_frame(one_frame_t data); -void hwsd_mgr_reset_buffer(); \ No newline at end of file diff --git a/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_data_pre_process.c b/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_data_pre_process.c deleted file mode 100644 index 39d3fbc..0000000 --- a/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_data_pre_process.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "heart_wave_sample_data_pre_process.h" -static one_frame_t m_datacache; -static one_frame_t m_displaydata; - -void hwsd_pre_processer_init() {} -void hwsd_pre_processer_process(one_frame_t framdata) { // - m_datacache = framdata; - m_displaydata = framdata; -} - -one_frame_t hwsd_pre_processer_get_display_data() { return m_displaydata; } -one_frame_t hwsd_pre_processer_get_storage_data() { return m_datacache; } diff --git a/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_data_pre_process.h b/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_data_pre_process.h deleted file mode 100644 index a188a77..0000000 --- a/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_data_pre_process.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include - -#include "basic_service/app_event.h" - -void hwsd_pre_processer_init(); -void hwsd_pre_processer_process(one_frame_t framdata); -one_frame_t hwsd_pre_processer_get_display_data(); -one_frame_t hwsd_pre_processer_get_storage_data(); diff --git a/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_service.c b/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_service.c deleted file mode 100644 index 41b0742..0000000 --- a/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_service.c +++ /dev/null @@ -1,77 +0,0 @@ -#include "heart_wave_sample_service.h" - -#include "basic_service/app_event.h" -#include "basic_service/app_event_distribute.h" -#include "board/ads129x/ads129x.h" -#include "board/app_board.h" -#include "board/board_ecg_sensor.h" -#include "heart_ware_sample_data_mgr.h" -#include "heart_wave_sample_data_pre_process.h" -#include "nrfx_timer.h" - -typedef enum { - kidle, - kprepare, - kcapture, -} capture_state_t; - -static capture_state_t m_prepare_capture_state = kidle; -static uint32_t m_start_capture_tp; - -/** - * @brief 处理ads129x数据,并上报 - * - * @param event - */ -static void on_ads129x_ready_irq(app_board_irq_event_t event) { -#if 1 - static ads129x_capture_data_t capture_data; - ads129x_read_data(&capture_data); - hwsd_mgr_push_one_frame(capture_data.ch1data); -#else - static int32_t data; - data += 1000; - if (data >= 60000) { - data = -60000; - } - hwsd_mgr_push_one_frame(data); -#endif -} - -void hwss_init(void) { // - app_board_reg_irq_listener(kon_irq_ads1291_ready_pin, on_ads129x_ready_irq); -} - -void hwss_start_prepare_capture(void) { - m_start_capture_tp = znordic_getpower_on_s(); - m_prepare_capture_state = kprepare; - hwsd_pre_processer_init(); - hwsd_mgr_reset_buffer(); - - ads129x_start_capture(false); -} -void hwss_start_capture(void) { - m_start_capture_tp = znordic_getpower_on_s(); - m_prepare_capture_state = kcapture; -} -void hwss_stop_capture(void) { - m_prepare_capture_state = kidle; - hwsd_mgr_reset_buffer(); - ads129x_stop_capture(); -} - -float hwss_read_val(void) { - __disable_irq(); - float val = hwsd_pre_processer_get_display_data(); - __enable_irq(); - return val; -} -float hwss_read_heart_rate(void) { // - return 0; -} -int hwss_has_captured_time_ms() { return (znordic_getpower_on_s() - m_start_capture_tp) * 1000; } - -bool hwss_lead_get_state_connected_state() { return true; } - -void hwss_subic_write_reg(uint8_t addr, uint8_t val) { ads129x_write_reg(addr, val); } -uint8_t hwss_subic_read_reg(uint8_t addr) { return ads129x_read_reg(addr); } \ No newline at end of file diff --git a/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_service.h b/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_service.h deleted file mode 100644 index 1e631fb..0000000 --- a/app/src/bakservice/heart_wave_sample_service/heart_wave_sample_service.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include -#include - -// 每256个字节触发一次回调 -typedef void (*heart_wave_sample_service_callback_t)(uint16_t *p_data, uint16_t length); - -void hwss_init(void); - -void hwss_start_capture(void); -void hwss_start_prepare_capture(void); -void hwss_stop_capture(void); -void hwss_subic_write_reg(uint8_t addr, uint8_t val); -uint8_t hwss_subic_read_reg(uint8_t addr); - - - - -float hwss_read_val(void); -float hwss_read_heart_rate(void); -int hwss_has_captured_time_ms(); -bool hwss_lead_get_state_connected_state(); \ No newline at end of file diff --git a/app/src/bakservice/storage/sample_data_manager.c b/app/src/bakservice/storage/sample_data_manager.c deleted file mode 100644 index 6e90080..0000000 --- a/app/src/bakservice/storage/sample_data_manager.c +++ /dev/null @@ -1,92 +0,0 @@ -#include "sample_data_manager.h" - -#include - -#include "zeeprom_fs.h" -#include "znordic.h" -#include "aproject_config/config.h" - -static sample_data_fileinfo_t fileinfocache[MAX_FILE_NUM * 2]; -static uint8_t fileinfocache_count = 0; - -void sample_data_mgr_init() { zeeprom_fs_init(); } -void sample_data_mgr_uninit() { zeeprom_fs_uinit(); } - -sample_data_fileinfo_list_t* sample_data_mgr_get_fileinfo_list() { // - static sample_data_fileinfo_list_t fileinfo_list; - memset(&fileinfo_list, 0, sizeof(fileinfo_list)); - fileinfocache_count = 0; - - // 读取所有记录信息 - zeeprom_header_t* header = zeeprom_fs_get_header(); - - for (uint16_t i = 0; i < ZARRAY_SIZE(header->sectorinfos); i++) { - zeeprom_sector_info_t* sectorinfo = &header->sectorinfos[i]; - if (sectorinfo->usage == 1 && sectorinfo->sector_index_in_file == 0) { - // 读取文件信息 - if (fileinfocache_count >= ZARRAY_SIZE(fileinfocache)) { - ZLOGE("fileinfocache_count >= MAX_FILE_NUM"); - break; - } - - sample_data_fileinfo_t* fileinfo = &fileinfocache[fileinfocache_count]; - fileinfo->fileuuid = sectorinfo->fileuuid; - memcpy(fileinfo->filename, sectorinfo->filename, sizeof(fileinfo->filename)); - fileinfo->size = zeeprom_fs_get_filesize_by_fileuuid(fileinfo->fileuuid); - fileinfo->checksum = zeeprom_fs_get_checksum_by_fileuuid(fileinfo->fileuuid); - - fileinfo_list.fileinfo[fileinfo_list.count] = fileinfo; - fileinfo_list.count++; - fileinfocache_count++; - } - } - // 根据文件uuid排序,uuid最大的排在最前面 - for (uint16_t i = 0; i < fileinfo_list.count; i++) { - for (uint16_t j = i + 1; j < fileinfo_list.count; j++) { - if (fileinfo_list.fileinfo[i]->fileuuid < fileinfo_list.fileinfo[j]->fileuuid) { - sample_data_fileinfo_t* tmp = fileinfo_list.fileinfo[i]; - fileinfo_list.fileinfo[i] = fileinfo_list.fileinfo[j]; - fileinfo_list.fileinfo[j] = tmp; - } - } - } - return &fileinfo_list; -} - -bool sample_data_mgr_storage_is_full() { return zeeprom_fs_get_file_num() >= MAX_FILE_NUM; } -int32_t sample_data_mgr_get_file_num() { return zeeprom_fs_get_file_num(); } - -#if 1 -static const char* filename2str(uint8_t* filename) { - static char filename_str[32]; - sprintf(filename_str, "%02x%02x%02x%02x%02x%02x%02x%02x", filename[0], filename[1], filename[2], filename[3], filename[4], filename[5], filename[6], filename[7]); - return filename_str; -} -#endif - -void sample_data_mgr_dump_fileinfo_list() { - zeeprom_fs_dump_sector_state(); - sample_data_fileinfo_list_t* fileinfo_list = sample_data_mgr_get_fileinfo_list(); - ZLOGI_BLOCK("fileinfo_list->count=%d\n", fileinfo_list->count); - for (uint16_t i = 0; i < fileinfo_list->count; i++) { - sample_data_fileinfo_t* fileinfo = fileinfo_list->fileinfo[i]; - ZLOGI_BLOCK("[%d]: filename=%s, fileuuid=%d, size=%d", i, filename2str(fileinfo->filename), fileinfo->fileuuid, fileinfo->size); - } -} - -int32_t sample_data_mgr_open(sample_data_filename_t* filename, wrflag_t flag) { - /** - * @brief 查看文件数量 - */ - if (flag == kwrflag_write_only) { - if (zeeprom_fs_get_file_num() >= MAX_FILE_NUM) { - zeeprom_fs_delete_the_oldest_file(); - } - } - return zeeprom_fs_open((uint8_t*)filename, flag); -} -int32_t sample_data_mgr_close(int32_t fd) { return zeeprom_fs_close(fd); } -int32_t sample_data_mgr_write(int32_t fd, const uint8_t* data, int32_t size) { return zeeprom_fs_write(fd, data, size); } -int32_t sample_data_mgr_read(int32_t fd, uint8_t* data, int32_t size) { return zeeprom_fs_read(fd, data, size); } -int32_t sample_data_mgr_get_file_size_by_fd(int32_t fd) { return zeeprom_fs_get_filesize_by_fd(fd); } -int32_t sample_data_mgr_delete_file(sample_data_filename_t* filename) { return zeeprom_fs_delete_by_name((uint8_t*)filename); } diff --git a/app/src/bakservice/storage/sample_data_manager.h b/app/src/bakservice/storage/sample_data_manager.h deleted file mode 100644 index 3a70e22..0000000 --- a/app/src/bakservice/storage/sample_data_manager.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once -#include -#include - -#include "aproject_config/config.h" -#include "zeeprom_fs.h" - -void sample_data_mgr_init(); - -typedef struct { - uint8_t year; - uint8_t month; - uint8_t day; - uint8_t hour; - uint8_t min; - uint8_t sec; - uint8_t placeholder[2]; -} sample_data_filename_t; - -typedef struct { - uint8_t filename[8]; - int32_t fileuuid; - int32_t size; - uint32_t checksum; -} sample_data_fileinfo_t; - -typedef struct { - sample_data_fileinfo_t* fileinfo[MAX_FILE_NUM]; - int count; -} sample_data_fileinfo_list_t; - -void sample_data_mgr_init(); -void sample_data_mgr_uninit(); - -sample_data_fileinfo_list_t* sample_data_mgr_get_fileinfo_list(); -bool sample_data_mgr_storage_is_full(); -int32_t sample_data_mgr_get_file_num(); - -int32_t sample_data_mgr_open(sample_data_filename_t* filename, wrflag_t flag); -int32_t sample_data_mgr_close(int32_t fd); - -int32_t sample_data_mgr_write(int32_t fd, const uint8_t* data, int32_t size); -int32_t sample_data_mgr_read(int32_t fd, uint8_t* data, int32_t size); -int32_t sample_data_mgr_get_file_size_by_fd(int32_t fd); - -int32_t sample_data_mgr_delete_file(sample_data_filename_t* filename); diff --git a/app/src/bakservice/storage/storage_service.h b/app/src/bakservice/storage/storage_service.h deleted file mode 100644 index 895d343..0000000 --- a/app/src/bakservice/storage/storage_service.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once -#include "sample_data_manager.h" -#include "zeeprom_fs.h" diff --git a/app/src/bakservice/storage/zeeprom_fs.c b/app/src/bakservice/storage/zeeprom_fs.c deleted file mode 100644 index 1c6594a..0000000 --- a/app/src/bakservice/storage/zeeprom_fs.c +++ /dev/null @@ -1,572 +0,0 @@ -#include "zeeprom_fs.h" - -#include "board/board_eeprom_driver.h" - -static zeeprom_header_t m_eeprom_header; -static bool m_is_init = false; - -static filehandler_t m_filehandler[2]; -static int m_fd_off; - -/******************************************************************************* - * 函数声明 * - *******************************************************************************/ - -static filehandler_t* filehandler_find(int fd); -static filehandler_t* filehandler_alloc(); -static void filehandler_rlease(int fd); - -static int32_t sector_mgr_find_earliest_file_created_index(); -static int32_t sector_mgr_free_sector(int32_t fileuuid); -static zeeprom_sector_info_t* sector_mgr_find_idle_sector(); -static bool sector_mgr_sector_is_open(int32_t fileuuid); -static zeeprom_sector_info_t* sector_mgr_force_find_idle_sector(); -static void sector_mgr_open_sector(int32_t fileuuid); -static void sector_mgr_close_sector(int32_t fileuuid); -// static zeeprom_sector_info_t* sector_mgr_find_fileheader(int32_t fileuuid); -static zeeprom_sector_info_t* sector_mgr_find_end_sector(int32_t fileuuid); -static zeeprom_sector_info_t* sector_mgr_find_sector(int32_t fileuuid, int32_t sector_index_in_file); -static int32_t sector_mgr_file_get_size(int32_t fileuuid); - -static zeeprom_sector_info_t* sector_mgr_find_fileheader_by_filename(uint8_t* fileid); -static int32_t sector_mgr_get_sector_offset(zeeprom_sector_info_t* sector); -static int32_t sector_mgr_get_sector_rom_add(zeeprom_sector_info_t* sector); -static int32_t sector_mgr_file_get_checksum(int32_t fileuuid); - -static void zeeprom_read(int32_t add, uint8_t* data, uint16_t len); -static void zeeprom_write(int32_t add, const uint8_t* data, uint16_t len); -static uint32_t compute_checksum(const uint8_t* data, uint16_t len); - -/******************************************************************************* - * CODE * - *******************************************************************************/ - -static bool m_eeprom_header_inited = false; -int zeeprom_fs_init() { // - board_eeprom_init(); - if (!m_eeprom_header_inited) { - zeeprom_read(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header)); - uint32_t checksum_val = compute_checksum((uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header) - sizeof(m_eeprom_header.sector_info_headers_checksum)); - if (checksum_val != m_eeprom_header.sector_info_headers_checksum) { - memset(&m_eeprom_header, 0, sizeof(m_eeprom_header)); - } - } - m_is_init = true; - m_eeprom_header_inited = true; - return 0; -} -int zeeprom_fs_uinit() { // - // zeeprom_write(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header)); - board_eeprom_uninit(); - m_is_init = false; - return 0; -} - -zeeprom_header_t* zeeprom_fs_get_header() { return &m_eeprom_header; } - -int zeeprom_fs_open(uint8_t* filename, wrflag_t wrflag) { - ZASSERT(m_is_init); - /** - * @brief - * 1. 如果文件已经存在,则打开文件 - * 2. 如果文件不存在, 则创建文件 - * - * 创建文件: - * 1. 找到一个空闲扇区 - * 2. 初始化文件头 - */ - - filehandler_t* fileHander = filehandler_alloc(); - if (!fileHander) { - ZLOGI("fileHander_alloc fail"); - return -1; - } - - if (wrflag == kwrflag_write_only) { - /******************************************************************************* - * 写文件 * - *******************************************************************************/ - zeeprom_sector_info_t* sectorHeaderInfo = NULL; - zeeprom_fs_delete_by_name(filename); - - sectorHeaderInfo = sector_mgr_force_find_idle_sector(); - if (!sectorHeaderInfo) { - ZLOGE("sector_mgr_force_find_idle_sector fail"); - filehandler_rlease(fileHander->fd); - return -1; - } - - memset(sectorHeaderInfo, 0, sizeof(zeeprom_sector_info_t)); - sectorHeaderInfo->usage = 1; - sectorHeaderInfo->opened = 1; - memcpy(sectorHeaderInfo->filename, filename, 8); - sectorHeaderInfo->sector_index_in_file = 0; - sectorHeaderInfo->datalen = 0; - sectorHeaderInfo->sector_data_checksum = 0; - sectorHeaderInfo->fileuuid = m_eeprom_header.fileuuid_cnt++; - fileHander->fileuuid = sectorHeaderInfo->fileuuid; - fileHander->sector_header = sectorHeaderInfo; - fileHander->file_offset = 0; - fileHander->file_size = 0; - fileHander->checksum = 0; - return fileHander->fd; - - } else { - /******************************************************************************* - * 读文件 * - *******************************************************************************/ - zeeprom_sector_info_t* sectorHeaderInfo = sector_mgr_find_fileheader_by_filename(filename); - if (sectorHeaderInfo) { - fileHander->fileuuid = sectorHeaderInfo->fileuuid; - fileHander->file_offset = 0; - fileHander->fd = fileHander->fd; - fileHander->sector_header = sectorHeaderInfo; - fileHander->file_size = sector_mgr_file_get_size(fileHander->fileuuid); - fileHander->checksum = sector_mgr_file_get_checksum(fileHander->fileuuid); - ZLOGI("filesize:%d", fileHander->file_size); - memcpy(fileHander->filename, filename, 8); - memcpy(fileHander->usrdata, sectorHeaderInfo->usrdata, sizeof(sectorHeaderInfo->usrdata)); - sector_mgr_open_sector(fileHander->fileuuid); - return fileHander->fd; - } else { - filehandler_rlease(fileHander->fd); - return -1; - } - } -} - -int zeeprom_fs_write(int fileid, const uint8_t* data, int32_t size) { - ZASSERT(m_is_init); - - filehandler_t* fileHander = NULL; - zeeprom_sector_info_t* header_sinfo = NULL; - zeeprom_sector_info_t* endsector = NULL; - int32_t wadd = 0; - - ZASSERT(size == EEPROM_SECTOR_MIN_WR_SIZE); - - fileHander = filehandler_find(fileid); - if (!fileHander) { - ZLOGE("fileHander_find fail"); - return -1; - } - - header_sinfo = fileHander->sector_header; - if (!header_sinfo) { - ZLOGE("header_sinfo fail"); - return -1; - } - - endsector = sector_mgr_find_end_sector(fileHander->fileuuid); - if (!endsector) { - ZLOGE("sector_mgr_find_end_sector fail"); - return -1; - } - - if (endsector->datalen + size > EEPROM_SECTOR_SIZE) { - ZLOGE("endsector->datalen + size > EEPROM_SECTOR_SIZE"); - return -1; - } - - wadd = sector_mgr_get_sector_rom_add(endsector); - if (wadd < 0) { - ZLOGE("sector_mgr_get_sector_rom_add fail"); - return -1; - } - ZASSERT(wadd % EEPROM_SECTOR_MIN_WR_SIZE == 0); - ZASSERT(wadd >= EEPROM_SECTOR_SIZE); - zeeprom_write(wadd + endsector->datalen, data, size); - - endsector->datalen = endsector->datalen + size; - endsector->sector_data_checksum += compute_checksum(data, size); - fileHander->file_offset += size; - fileHander->file_size += size; - fileHander->checksum += compute_checksum(data, size); - - if (endsector->datalen == EEPROM_SECTOR_SIZE) { - zeeprom_sector_info_t* newsector = sector_mgr_force_find_idle_sector(); - if (!newsector) { - ZLOGE("sector_mgr_force_find_idle_sector fail"); - return -1; - } - - memset(newsector, 0, sizeof(zeeprom_sector_info_t)); - newsector->usage = 1; - newsector->opened = 1; - newsector->sector_data_checksum = 0; - memcpy(newsector->filename, header_sinfo->filename, 8); - newsector->sector_index_in_file = endsector->sector_index_in_file + 1; - newsector->datalen = 0; - newsector->fileuuid = header_sinfo->fileuuid; - } - return size; -} - -int zeeprom_fs_close(int fileid) { - ZASSERT(m_is_init); - - filehandler_t* fileHander = filehandler_find(fileid); - if (!fileHander) { - ZLOGE("zeeprom_fs_close fileHander_find fail"); - return -1; - } - - sector_mgr_close_sector(fileHander->fileuuid); - uint32_t checksum_val = compute_checksum((uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header) - sizeof(m_eeprom_header.sector_info_headers_checksum)); - m_eeprom_header.sector_info_headers_checksum = checksum_val; - // zeeprom_write(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header)); - - filehandler_rlease(fileid); - return 0; -} - -int zeeprom_fs_get_filesize_by_fd(int fd) { - ZASSERT(m_is_init); - filehandler_t* fileHander = filehandler_find(fd); - if (!fileHander) return 0; - return fileHander->file_size; -} - -int zeeprom_fs_read(int fileid, uint8_t* data, int32_t size) { - ZASSERT(m_is_init); - - /** - * @brief - * 找到当前扇区 - */ - ZASSERT(size == EEPROM_SECTOR_MIN_WR_SIZE); - filehandler_t* fileHander = filehandler_find(fileid); - if (!fileHander) return -1; - - if (fileHander->file_offset + size > fileHander->file_size) { - return -1; - } - - zeeprom_sector_info_t* header_sinfo = fileHander->sector_header; - if (!header_sinfo) { - return -1; - } - - int32_t sector_idx = fileHander->file_offset / EEPROM_SECTOR_SIZE; - int32_t sector_off = fileHander->file_offset % EEPROM_SECTOR_SIZE; - - zeeprom_sector_info_t* sector = sector_mgr_find_sector(fileHander->fileuuid, sector_idx); - if (!sector) { - return -1; - } - - int32_t radd = sector_mgr_get_sector_rom_add(sector); - ZASSERT(radd % EEPROM_SECTOR_MIN_WR_SIZE == 0); - radd += sector_off; - - zeeprom_read(radd, data, size); - fileHander->file_offset += size; - return size; -} - -int zeeprom_fs_delete(int32_t fileuuid) { - ZASSERT(m_is_init); - - sector_mgr_free_sector(fileuuid); - return 0; -} -int zeeprom_fs_delete_by_name(uint8_t* filename) { - ZASSERT(m_is_init); - - zeeprom_sector_info_t* sectorHeaderInfo = sector_mgr_find_fileheader_by_filename(filename); - if (sectorHeaderInfo) { - sector_mgr_free_sector(sectorHeaderInfo->fileuuid); - } - return 0; -} - -int zeeprom_fs_get_file_num() { - ZASSERT(m_is_init); - - int count = 0; - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1 && sinfo->sector_index_in_file == 0) { - count++; - } - } - return count; -} -int zeeprom_fs_delete_the_oldest_file() { - ZASSERT(m_is_init); - - int32_t earliest_file_created_index = sector_mgr_find_earliest_file_created_index(); - sector_mgr_free_sector(earliest_file_created_index); - return 0; -} - -int zeeprom_fs_get_filesize_by_fileuuid(int32_t fileuuid) { - ZASSERT(m_is_init); - return sector_mgr_file_get_size(fileuuid); -} - -int zeeprom_fs_get_checksum_by_fileuuid(int32_t fileuuid) { - ZASSERT(m_is_init); - return sector_mgr_file_get_checksum(fileuuid); -} - -static void zeeprom_read(int32_t add, uint8_t* data, uint16_t len) { // - int wrsize = EEPROM_SECTOR_MIN_WR_SIZE; - - int readTimes = len / wrsize; - int readRemain = len % wrsize; - - for (int i = 0; i < readTimes; i++) { - board_eeprom_read(add + i * wrsize, data + i * wrsize, wrsize); - } - if (readRemain > 0) { - board_eeprom_read(add + readTimes * wrsize, data + readTimes * wrsize, readRemain); - } -} -static void zeeprom_write(int32_t add, const uint8_t* data, uint16_t len) { - int wrsize = EEPROM_SECTOR_MIN_WR_SIZE; - - int writeTimes = len / wrsize; - int writeRemain = len % wrsize; - - for (int i = 0; i < writeTimes; i++) { - // int pageoff = add / wrsize + i; - int32_t writeadd = add + i * wrsize; - board_eeprom_write(writeadd, data + i * wrsize, wrsize); - } - if (writeRemain > 0) { - int32_t writeadd = add + writeTimes * wrsize; - board_eeprom_write(writeadd, data + writeTimes * wrsize, writeRemain); - } -} - -static uint32_t compute_checksum(const uint8_t* data, uint16_t len) { - uint32_t sum = 0; - for (int i = 0; i < len; i++) { - sum += data[i]; - } - return sum; -} -/******************************************************************************* - * filehandler * - *******************************************************************************/ -static filehandler_t* filehandler_find(int fd) { - for (int i = 0; i < ZARRAY_SIZE(m_filehandler); i++) { - if (m_filehandler[i].fd == fd) { - return &m_filehandler[i]; - } - } - return NULL; -} -static filehandler_t* filehandler_alloc() { - for (int i = 0; i < ZARRAY_SIZE(m_filehandler); i++) { - if (m_filehandler[i].fd == 0) { - m_filehandler[i].fd = ++m_fd_off; - return &m_filehandler[i]; - } - } - return NULL; -} -static void filehandler_rlease(int fd) { - for (int i = 0; i < ZARRAY_SIZE(m_filehandler); i++) { - if (m_filehandler[i].fd == fd) { - m_filehandler[i].fd = 0; - return; - } - } -} -/******************************************************************************* - * sector_mgr * - *******************************************************************************/ - -// 查找最早创建的文件的file_created_index -static int32_t sector_mgr_find_earliest_file_created_index() { - int32_t earliest_file_created_index = INT32_MAX; - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1) { - if (sinfo->fileuuid < earliest_file_created_index) { - earliest_file_created_index = sinfo->fileuuid; - } - } - } - return earliest_file_created_index; -} -// 删除文件 -static int32_t sector_mgr_free_sector(int32_t fileuuid) { - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) { - sinfo->usage = 0; - } - } - return 0; -} -// -static zeeprom_sector_info_t* sector_mgr_find_idle_sector() { - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 0) { - return sinfo; - } - } - return NULL; -} -static bool sector_mgr_sector_is_open(int32_t fileuuid) { - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) { - return sinfo->opened; - } - } - return false; -} - -static zeeprom_sector_info_t* sector_mgr_force_find_idle_sector() { - /** - * @brief 查找空闲扇区 - */ - zeeprom_sector_info_t* ret_sinfo = sector_mgr_find_idle_sector(); - if (ret_sinfo) return ret_sinfo; - /** - * @brief 查找最早创建的文件 - */ - int32_t earliest_file_created_index = sector_mgr_find_earliest_file_created_index(); - if (sector_mgr_sector_is_open(earliest_file_created_index)) { - return NULL; - } - - /** - * @brief 删除最早创建的文件 - */ - sector_mgr_free_sector(earliest_file_created_index); - - /** - * @brief 重新查找空闲扇区 - */ - ret_sinfo = sector_mgr_find_idle_sector(); - if (ret_sinfo) return ret_sinfo; - - return NULL; -} - -static void sector_mgr_open_sector(int32_t fileuuid) { - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) { - sinfo->opened = true; - } - } -} - -static void sector_mgr_close_sector(int32_t fileuuid) { - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) { - sinfo->opened = false; - } - } -} - -// static zeeprom_sector_info_t* sector_mgr_find_fileheader(int32_t fileuuid) { -// for (int i = 0; i < MAX_SECTOR_NUM; i++) { -// zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; -// if (sinfo->usage == 1 && sinfo->sector_index_in_file == 0 && sinfo->fileuuid == fileuuid) { -// return sinfo; -// } -// } -// return NULL; -// } - -static zeeprom_sector_info_t* sector_mgr_find_sector(int32_t fileuuid, int32_t sector_index_in_file) { - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1 && sinfo->sector_index_in_file == sector_index_in_file && sinfo->fileuuid == fileuuid) { - return sinfo; - } - } - return NULL; -} - -static zeeprom_sector_info_t* sector_mgr_find_end_sector(int32_t fileuuid) { - int32_t maxsectorindex = 0; - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) { - if (sinfo->sector_index_in_file >= maxsectorindex) { - maxsectorindex = sinfo->sector_index_in_file; - } - } - } - return sector_mgr_find_sector(fileuuid, maxsectorindex); -} - -static zeeprom_sector_info_t* sector_mgr_find_fileheader_by_filename(uint8_t* fileid) { - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1 && sinfo->sector_index_in_file == 0 && memcmp(sinfo->filename, fileid, 8) == 0) { - return sinfo; - } - } - return NULL; -} - -static int32_t sector_mgr_get_sector_offset(zeeprom_sector_info_t* sector) { - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo == sector) { - return i; - } - } - return -1; -} - -static int32_t sector_mgr_get_sector_rom_add(zeeprom_sector_info_t* sector) { - int32_t offset = sector_mgr_get_sector_offset(sector); - if (offset < 0) return -1; - return (offset + 1) * EEPROM_SECTOR_SIZE; -} - -static int32_t sector_mgr_file_get_size(int32_t fileuuid) { - int32_t filesize = 0; - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - - if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) { - filesize += sinfo->datalen; - } - } - return filesize; -} - -static int32_t sector_mgr_file_get_checksum(int32_t fileuuid) { - int32_t checksum = 0; - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - - if (sinfo->usage == 1 && sinfo->fileuuid == fileuuid) { - checksum += sinfo->sector_data_checksum; - } - } - return checksum; -} - -static const char* filename2str(uint8_t* filename) { - static char filename_str[32]; - sprintf(filename_str, "%02x%02x%02x%02x%02x%02x%02x%02x", filename[0], filename[1], filename[2], filename[3], filename[4], filename[5], filename[6], filename[7]); - return filename_str; -} - -int zeeprom_fs_dump_sector_state() { - ZLOGI_BLOCK("zeeprom_fs_dump_sector_state\n"); - for (int i = 0; i < MAX_SECTOR_NUM; i++) { - zeeprom_sector_info_t* sinfo = &m_eeprom_header.sectorinfos[i]; - if (sinfo->usage == 1) { - ZLOGI_BLOCK("[%d]: usage=%d opened=%d", i, sinfo->usage, sinfo->opened); - ZLOGI_BLOCK(" fname=%s, index_in_file=%d, datalen=%d, fileuuid=%d", filename2str(sinfo->filename), sinfo->sector_index_in_file, sinfo->datalen, sinfo->fileuuid); - } else { - ZLOGI_BLOCK("[%d]: usage=%d", i, sinfo->usage); - } - } - return 0; -} diff --git a/app/src/bakservice/storage/zeeprom_fs.h b/app/src/bakservice/storage/zeeprom_fs.h deleted file mode 100644 index 642a53f..0000000 --- a/app/src/bakservice/storage/zeeprom_fs.h +++ /dev/null @@ -1,108 +0,0 @@ -#pragma once -#include -/** - * @brief EEPROM简易文件系统代码框架 - * - * 整个存储区域分为两个区 [扇区头][文件数据区] - * - * ----------------- - * | | - * | 扇区头 | 8K * 1 - * | | - * ----------------- - * | | - * | N*数据扇区 | 8K * 31 - * | | - * ----------------- - * - * 扇区头存储 31* zeeprom_sector_info_t个结构体 - * 结构体:zeeprom_sector_info_t * 31 - * uint8_t usage; // 0:空闲 1:已使用 - * uint8_t opened; // 0:未打开 1:已打开 - * uint8_t filename[8]; // 文件名 - * int32_t sector_index_in_file; // 当前扇区中文件数据的起始地址 - * int32_t datalen; // 当前扇区中文件数据的长度 - * uint32_t checksum; // 文件数据的校验和 - * int32_t fileuuid; // 递增,根据这个index判断文件创建的先后顺序,同时也相当于文件唯一标识 - * uint8_t usrdata[20]; // 用户数据 - * - * - * 文件的概念: - * 1.一个文件由一个或多个扇区组成,每个扇区的大小为8K, - * 2.同一个文件依靠fileuuid进行判定 - * 3.如果想要读取文件大小,只需计算相同fileuuid的所有zeeprom_sector_info_t.datalen的和即可。 - * 4.文件顺序依靠sector_index_in_file进行判断 - * 5.文件名保存在sector_index_in_file为0的zeeprom_sector_info_t结构体中 - * - * 扇区头的特殊性: - * 1. 扇区头常驻内存中 - * 2. 如果期望掉电丢弃数据,扇区头不保存导flash中即可 - * - */ - -#define EEPROM_SIZE (256 * 1024) -#define EEPROM_SECTOR_MIN_WR_SIZE (256) -#define EEPROM_SECTOR_SIZE (8 * 1024) -#define MAX_SECTOR_NUM (EEPROM_SIZE / EEPROM_SECTOR_SIZE - 1) -#define EEPROM_FILE_SIZE (EEPROM_SECTOR_SIZE * MAX_SECTOR_NUM) - -// -#pragma pack(1) -typedef struct { - uint8_t usage; - uint8_t opened; - uint8_t filename[8]; // 注意文件名为固定八个字节的二进制数据,不是字符串 - int32_t sector_index_in_file; // 当前扇区中文件数据的起始地址 - int32_t datalen; // 当前扇区中文件数据的长度 - uint32_t sector_data_checksum; // 文件数据的校验和 - int32_t fileuuid; // 递增,根据这个index判断文件创建的先后顺序,同时也相当于文件唯一标识 - uint8_t usrdata[20]; -} zeeprom_sector_info_t; - -typedef struct { - uint8_t filename[8]; - uint8_t usrdata[20]; - - zeeprom_sector_info_t* sector_header; - int32_t file_offset; - int32_t file_size; - uint32_t checksum; - - int fd; - int32_t fileuuid; -} filehandler_t; - -typedef struct { - zeeprom_sector_info_t sectorinfos[MAX_SECTOR_NUM]; - int32_t fileuuid_cnt; // 递增,新创建文件时使用 - uint32_t sector_info_headers_checksum; // 扇区头的校验和 -} zeeprom_header_t; -#pragma pack() - -int zeeprom_fs_init(); -int zeeprom_fs_uinit(); - -typedef enum { - kwrflag_read_only, - kwrflag_write_only, -} wrflag_t; - -zeeprom_header_t* zeeprom_fs_get_header(); - -int zeeprom_fs_open(uint8_t* filename, wrflag_t flag); - -int zeeprom_fs_close(int fd); - -int zeeprom_fs_write(int fd, const uint8_t* data, int32_t size); -int zeeprom_fs_read(int fd, uint8_t* data, int32_t size); - -int zeeprom_fs_get_filesize_by_fd(int fd); - -int zeeprom_fs_get_file_num(); -int zeeprom_fs_delete_the_oldest_file(); -int zeeprom_fs_delete(int32_t fileuuid); -int zeeprom_fs_delete_by_name(uint8_t* filename); - -int zeeprom_fs_dump_sector_state(); -int zeeprom_fs_get_filesize_by_fileuuid(int32_t fileuuid); -int zeeprom_fs_get_checksum_by_fileuuid(int32_t fileuuid); diff --git a/app/src/one_conduction_main.c b/app/src/one_conduction_main.c index e5e4b1d..0c7a0de 100644 --- a/app/src/one_conduction_main.c +++ b/app/src/one_conduction_main.c @@ -3,7 +3,9 @@ #include "app_basic_service/device_version_info_mgr.h" #include "app_basic_service/zapp.h" +#include "app_service/base_hardware/hardware_power_mgr.h" #include "app_service/battery_mgr_service.h" +#include "app_service/ecg_service/ecg_service.h" #include "aproject_config/config.h" #include "ify_hrs_protocol/heart_rate_sensor_protocol.h" #include "zdatachannel_service.h" @@ -45,8 +47,8 @@ static void send_success_receipt(ify_hrs_packet_t* rxpacket, int32_t emptydatasi *******************************************************************************/ void one_conduction_process_rx_packet(uint8_t* rx, int len) { /** - * @brief - * + * @brief + * */ if (len < sizeof(ify_hrs_packet_t)) { @@ -136,7 +138,7 @@ void one_conduction_process_rx_packet(uint8_t* rx, int len) { receipt->drop_state0 = (0); receipt->drop_state1 = 0x00; receipt->device_state0.sampling_state = (zapp_state_machine_now_state() == kdevice_state_sampling); - receipt->device_state0.report_state = 0; + receipt->device_state0.report_state = 0; receipt->device_state0.low_battery = (0 < APP_LOW_BATTERY_WARNING_LIMIT); receipt->device_state0.full_storge = false; @@ -181,4 +183,11 @@ void one_conduction_process_rx_packet(uint8_t* rx, int len) { } } -void one_conduction_main() { ZLOGI("one_conduction_main"); } +void one_conduction_main() { + sn_t sn; + device_info_read_sn(&sn); + ZLOGI("one_conduction_main %s",sn.sn); + ZLOG_FLUSH(); + + zble_module_start_adv(); +} diff --git a/libznordic b/libznordic index 30b9378..34b66f4 160000 --- a/libznordic +++ b/libznordic @@ -1 +1 @@ -Subproject commit 30b93787c0e760b623df1656c3002ed742f1fff8 +Subproject commit 34b66f400e35757e7fc42e0004e88c8d1c090d88 diff --git a/scripter/flash_with_id.bat b/scripter/flash_with_id.bat index a9207ad..d01ae3e 100644 --- a/scripter/flash_with_id.bat +++ b/scripter/flash_with_id.bat @@ -23,6 +23,14 @@ if %errorlevel% neq 0 ( echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE exit /b 1 ) + + +@REM 烧录lot +nrfjprog -f nrf52 --memwr 0x10001080 --val %1 +@REM 烧录ID +nrfjprog -f nrf52 --memwr 0x10001084 --val %2 + + nrfjprog --reset -f NRF52 %复位% if %errorlevel% neq 0 ( echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE @@ -31,10 +39,6 @@ if %errorlevel% neq 0 ( exit /b 1 ) -@REM 烧录lot -nrfjprog -f nrf52 --memwr 0x10001080 --val %1 -@REM 烧录ID -nrfjprog -f nrf52 --memwr 0x10001084 --val %2 echo --------------------------------------------------------------- echo - done