ljj3166 发表于 2021-6-6 17:42

【短时天气预报系统】outdoor装置基本设计与实现

本帖最后由 ljj3166 于 2021-6-6 17:50 编辑

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">周末,撸一贴</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">来看看室外端装置的设计</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">基本硬件框架,上灵魂画作</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p><span style="font-size:16px;"><strong><span style="font-family:等线">撸了一板,大概长这个样子</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">其中bq25570的反馈网络设计</span></strong></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">大概意思是</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">bq25570为电容充电,充电截止电压为3.8v</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">充电阈值区间为2.6v-3.6v</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">同时为后级电路提供工作电源,电压为1.8v</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">投板,焊接</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">吐槽一下</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">BME280这颗传感器,采集气压、温度、湿度</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">印象中10块钱左右的价格</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">现在涨到60左右,还基本上没货</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">样品直接被喊到100+</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">实在没办法,花50闷买了微雪的模块</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">拆机再焊上,真囧</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">接下来是outdoor装置中的&ldquo;电池&rdquo;</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">一颗70F的法拉电容</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">锂离子的法拉电容,标称等效电池容量大约在25mAh</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">自放电等参数相当牛鬼,价格也是十分感人,10多闷</span></strong></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">唉,海内半导体产业任重道远啊</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">开机测试一下,模拟一个弱光情况下的太阳能板电压</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">大约0.7v的输入</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">基本上能够达到反馈电阻网络的预设值</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">电容充电电压大约在3.8v,对后级电路供电的电压大约在1.8v</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">这块表读数似乎稍微偏低一些</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">找了个艳阳天,中午时刻测试了一下充电电流</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">充电电流大约在20mA左右</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">基本上,一个晴朗的中午,就能在一个多小时</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">不到两个小时把25mAh的电容充满</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">接下来就是撸码了</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">Outdoor端的内容不多</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">主要是iic与BME280通信,采集气压温度湿度</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">然后通过广播包或者扫描响应包把数据发送出来</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">先看看IIC的通信</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">直接贴代码</span></strong></span></p>

<pre>
<code class="language-cpp">ARM_DRIVER_I2C *i2c;
extern ARM_DRIVER_I2C Driver_I2C0;
void I2C_MasterCallback(uint32_t event);
void I2C_SlaveCallback(uint32_t event);
/* ----------------------------------------------------------------------------
* Function      : void I2C_MasterCallback(uint32_t event)
* ----------------------------------------------------------------------------
* Description   : This function is a master callback. The parameter event
*                 indicates one or more events that occurred during driver
*                 operation.
* Inputs        : event - I2C Events notification mask
* Outputs       : None
* Assumptions   : None
* ------------------------------------------------------------------------- */
void I2C_MasterCallback(uint32_t event) {
        bool direction = (i2c-&gt;GetStatus().direction == 1U);

        /* Check if transfer is done */
        if (event &amp; ARM_I2C_EVENT_TRANSFER_DONE) {
                /* Device is configured as transmitter */
                if (direction == I2C_STATUS_DIRECTION_TX) {
                        /* Delay time for switching modes of operation */
//                        Sys_Delay_ProgramROM((uint32_t) (0.5 * SystemCoreClock) / 1000);

//            /* MasterTransmit finished, start MasterReceive */
//            i2c-&gt;MasterReceive(RTE_I2C0_SLAVE_ADDR_DEFAULT, buff_rx, buff_size, false);
                }
                /* Check if device is configured as receiver */
                else if (direction == I2C_STATUS_DIRECTION_RX) {
                        /* Check the address nack event */
                        if (event &amp; ARM_I2C_EVENT_ADDRESS_NACK) {
//                /* MasterTransmit finished, start MasterReceive */
//                i2c-&gt;MasterReceive(RTE_I2C0_SLAVE_ADDR_DEFAULT, buff_rx, buff_size, false);
                                return;
                        }

                        /* Delay time for switching modes of operation */
//                        Sys_Delay_ProgramROM((uint32_t) (0.5 * SystemCoreClock) / 1000);

                }
        }
        /* Check if transfer error occurred */
        else if ((event &amp; ARM_I2C_EVENT_TRANSFER_INCOMPLETE)
                        || (event &amp; ARM_I2C_EVENT_BUS_ERROR)) {
                /* Abort current transfer */
                i2c-&gt;Control(ARM_I2C_ABORT_TRANSFER, 0);

//        /* Go back to SlaveReceive default mode */
//        i2c-&gt;SlaveReceive(buff_rx, buff_size);
//
//        /* Toggle LED state 10 times for 100 milliseconds to indicate error */
//        ToggleLed(10, 100);
//        PRINTF("TRANSFER INCOMPLETE OR BUS ERROR\n");
        }
}

/* ----------------------------------------------------------------------------
* Function      : void I2C_SlaveCallback(uint32_t event)
* ----------------------------------------------------------------------------
* Description   : This function is a slave callback. The parameter event
*                 indicates one or more events that occurred during driver
*                 operation.
* Inputs        : event - I2C Events notification mask
* Outputs       : None
* Assumptions   : None
* ------------------------------------------------------------------------- */
void I2C_SlaveCallback(uint32_t event) {
        bool direction = (i2c-&gt;GetStatus().direction == 1U);

        /* Check if transfer is done */
        if (event &amp; ARM_I2C_EVENT_TRANSFER_DONE) {
                if (direction == I2C_STATUS_DIRECTION_TX) {
                }
                /* Check if device is configured as receiver */
                else if (direction == I2C_STATUS_DIRECTION_RX) {

                }
        }
        /* Check if transfer error occurred */
        else if ((event &amp; ARM_I2C_EVENT_TRANSFER_INCOMPLETE)
                        || (event &amp; ARM_I2C_EVENT_BUS_ERROR)) {
                /* Abort current transfer */
                i2c-&gt;Control(ARM_I2C_ABORT_TRANSFER, 0);

        }
}
/* ----------------------------------------------------------------------------
* Function      : void I2C_CallBack(uint32_t event)
* ----------------------------------------------------------------------------
* Description   : This function is a callback registered by the function
*                 Initialize. The parameter event indicates one or more events
*                 that occurred during driver operation.
* Inputs        : event - I2C Events notification mask
* Outputs       : None
* Assumptions   : None
* ------------------------------------------------------------------------- */
void I2C_EventCallback(uint32_t event) {
        static volatile uint32_t I2C_Event;
        bool mode = (i2c-&gt;GetStatus().mode == 1U);
        I2C_Event |= event;

        /* Refresh the watchdog */
        Sys_Watchdog_Refresh();

        if (mode == I2C_STATUS_MODE_MASTER) {
                I2C_MasterCallback(event);
        } else if (mode == I2C_STATUS_MODE_SLAVE) {
                I2C_SlaveCallback(event);
        }
}

void iic_init(void) {

        /* Initialize i2c driver structure */
        i2c = &amp;Driver_I2C0;
        /* Initialize i2c, register callback function */
        i2c-&gt;Initialize(I2C_EventCallback);

}

bool iic_write_byte(uint8_t device_address, uint8_t reg_address, uint8_t value) {
        uint8_t data[] = { reg_address, value };
        //return i2c-&gt;MasterTransmit(handle-&gt;device_address, data, 2, false) == 0;
        i2c-&gt;MasterTransmit(device_address, data, 2, false);
        while (i2c-&gt;GetStatus().busy)
                ;
        return true;
}

bool iic_write_buff(uint8_t device_address, uint8_t reg_address, uint8_t *data,
                size_t length) {
        if (length == 0 || length &gt; 4) {
                return false;
        }

        uint8_t transfer;
        transfer = reg_address;

        memcpy(&amp;transfer, data, length);
        i2c-&gt;MasterTransmit(device_address, transfer, length + 1, false);
        while (i2c-&gt;GetStatus().busy)
                ;
        return true;
        //return i2c-&gt;MasterTransmit(handle-&gt;device_address, transfer, length + 1, false) == 0;
}

bool iic_read(uint8_t device_address, uint8_t reg_address, uint8_t *dest,
                size_t length) {
        uint8_t addr = reg_address;
        i2c-&gt;MasterTransmit(device_address, &amp;addr, 1, false);
        while (i2c-&gt;GetStatus().busy)
                ;
        i2c-&gt;MasterReceive(device_address, dest, length, false);
        while (i2c-&gt;GetStatus().busy)
                ;
        return true;
}
</code></pre>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">从官方例程&ldquo;I2c_cmsis_driver&rdquo;扒拉下来的</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">要注意,官方例程在IIC回调中加了master和slaver的角色转换</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">并不是单纯的master示例,夹带了不少私货</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">要注意修改,对初次使用带来不少的问题</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">总体来说,过程还是比较清晰</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">但作为官方例程,还需要整理一下再发布</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">再一个是休眠</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">这个是比较重要的一环</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">阅读文档,可以知道,RSL10分为运行、待机和休眠这几种工作模式</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">其中待机大约在30uA左右</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">休眠又根据内部rom、ram和外设电源保持的情况</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">从几uA到几十nA </span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">休眠的时候,会产生POR</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">除了ACS相关的配置外</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">其他所有的配置都会复位</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">唤醒后从PROM开始运行至main</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">所以干脆唤醒后直接复位,重新配置RSL10,完成一次采集和广播的操作</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">这样会带来几百ms到数s的启动时间(一般消耗在时钟源启动、休眠配置、蓝牙配置)</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">并带来额外的电流消耗</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">但是简单粗暴有效,楼主最喜欢了</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">就这么定了</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">采用RTC唤醒,保持PROM及片上FLASH电源</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">几处关键配置</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"><strong><span style="font-size:24px;"><span style="font-family:等线">配置外部RTC及唤醒周期</span></span></strong></p>

<p>&nbsp;</p>

<pre>
<code class="language-cpp">/* Configure RTC */
        ACS-&gt;RTC_CFG = RTC_CNT_START_VALUE
        ;
        *((volatile uint8_t*) &amp;ACS-&gt;RTC_CTRL) = (uint8_t) (RTC_CLK_SRC |
        RTC_ALARM_ZERO);

        /* Reset and enable RTC */
        ACS_RTC_CTRL-&gt;RESET_ALIAS = RTC_RESET_BITBAND;
        ACS_RTC_CTRL-&gt;ENABLE_ALIAS = RTC_ENABLE_BITBAND;
</code></pre>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:24px;"><strong><span style="font-family:等线"><span lang="EN-US"><span style="font-family:Consolas">CFG</span></span>和<span lang="EN-US"><span style="font-family:Consolas">CTRL</span></span></span></strong></span></p>

<p>&nbsp;</p>

<pre>
<code class="language-cpp">/* Set delay and wake-up sources, use
         *    WAKEUP_DELAY_[ 1 | 2 | 4 | ... | 128],
         *    WAKEUP_DCDC_OVERLOAD_,
         *    WAKEUP_WAKEUP_PAD_,
         *    WAKEUP_DIO*_,
         *    WAKEUP_DIO*_ */
        sleep_mode_flash_env-&gt;wakeup_cfg = WAKEUP_DELAY_32 |
        WAKEUP_WAKEUP_PAD_RISING |
        WAKEUP_DIO3_DISABLE |
        WAKEUP_DIO2_DISABLE |
        WAKEUP_DIO1_DISABLE |
        WAKEUP_DIO0_DISABLE;

        /* Set wake-up control/status registers, use
         *    PADS_RETENTION_,
         *    BOOT_FLASH_APP_REBOOT_,
         *    BOOT_,
         *    WAKEUP_DCDC_OVERLOAD_,
         *    WAKEUP_PAD_EVENT_,
         *    WAKEUP_RTC_ALARM_,
         *    WAKEUP_BB_TIMER_,
         *    WAKEUP_DIO3_EVENT_,
         *    WAKEUP_DIO2_EVENT_,
         *    WAKEUP_DIO1_EVENT_,
         *    WAKEUP_DIO0_EVENT_ */
        sleep_mode_flash_env-&gt;wakeup_ctrl = PADS_RETENTION_ENABLE |
        BOOT_FLASH_APP_REBOOT_DISABLE |
        BOOT_FLASH_XTAL_DEFAULT_TRIM |
        WAKEUP_DCDC_OVERLOAD_CLEAR |
        WAKEUP_PAD_EVENT_CLEAR |
        WAKEUP_RTC_ALARM_CLEAR |
        WAKEUP_BB_TIMER_CLEAR |
        WAKEUP_DIO3_EVENT_CLEAR |
        WAKEUP_DIO2_EVENT_CLEAR |
        WAKEUP_DIO1_EVENT_CLEAR |
        WAKEUP_DIO0_EVENT_CLEAR;
</code></pre>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"><strong><span style="font-size:24px;"><span style="font-family:等线"><span style="color:black">保持的电源</span></span></span></strong></p>

<p>&nbsp;</p>

<pre>
<code class="language-cpp">/* Power-off/retain memory instances */
    SYSCTRL-&gt;MEM_POWER_CFG = sleep_mode_env-&gt;mem_power_cfg |
                             PROM_POWER_ENABLE             |
                             FLASH_POWER_ENABLE;
</code></pre>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">电源模式这里混杂了大量寄存器操作</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">比较不友好,希望后面的固件库能够有重大更新</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">进入休眠大约在0.6uA</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">每3分钟唤醒一次,并疯狂连续广播6s,广播间隔40ms</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">测了一下连续10次采集广播的平均电流</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">大约在12uA左右</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">从这个角度,如果每s进行一次广播</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">再仔细优化一下,可能可以到10uA左右</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">功耗控制得勉强能看,基本堪用吧</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">大概计算一下</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">25mAh的电容,大约可以工作2083小时</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">大约相当于85天</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">如果85天内有一个艳阳天,基本上就能在2小时内完成充电</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">保障下一个85天的使用</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">这颗bq25570的启动电压是0.3v</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">阴天应该也有充电,只是多少的问题,毕竟大部分时间只有nA级的电流</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">如果85天完全极夜,那&hellip;,洗洗睡吧</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">关于BME280的数据广播</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">先是GCC使用printf打印浮点数的问题</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">GCC默认是不支持printf打印浮点数的</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">需要在工程中做配置修改</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">Project<span lang="EN-US" style="font-family:Wingdings">--&gt;</span>properties<span lang="EN-US" style="font-family:Wingdings">--&gt;</span>&hellip;&hellip;</span></strong></span></p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">启用浮点printf</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">然后可以愉快地打印浮点数了</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">浮点数转数组</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">一般情况下使用union结构体</span></strong></span></p>

<pre>
<code class="language-cpp">typedef union
{
   struct
   {
       unsigned char low_byte;
       unsigned char mlow_byte;
       unsigned char mhigh_byte;
       unsigned char high_byte;
    }float_byte;

    float  value;
}FLAOT_UNION;
</code></pre>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">但是实际使用中貌似不行,不知道哪里又被优化掉了</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">后来直接粗暴作业</span></strong></span></p>

<pre>
<code class="language-cpp">unsigned char tmp;
                        tmp = rcvAdvData;
                        tmp = rcvAdvData;
                        tmp = rcvAdvData;
                        tmp = rcvAdvData;
                        tmp = rcvAdvData;
                        tmp = rcvAdvData;
                        tmp = rcvAdvData;
                        tmp = rcvAdvData;
                        double f1 = *(double *)(tmp);
</code></pre>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">解决问题,淋漓</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">蓝牙调试助手能够清晰扫描到相关数据</span></strong></span></p>

<p>&nbsp;</p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">Indoor端也能正确收到广播和扫描响应包</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">并解析出对应的气压温度湿度</span></strong></span></p>

<p style="text-align:justify"></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">到此,基本上解决了项目的主要节点问题</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">接下来就是大量细小的作业和数据测试</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">不知道有没有时间去彻底完成</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">甚至不知道可行性有多大</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">自己选的题目,含泪跪完</span></strong></span></p>

<p style="text-align:justify"><span style="font-size:16px;"><strong><span style="font-family:等线">以上</span></strong></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

dcexpert 发表于 2021-6-7 10:37

<p>法拉电容是亮点,没想到BME280也涨的这么厉害了。</p>

ljj3166 发表于 2021-6-7 16:06

dcexpert 发表于 2021-6-7 10:37
法拉电容是亮点,没想到BME280也涨的这么厉害了。

<p>现在好多器件涨价涨得看不懂了</p>

<p>不知道要淘汰掉多少小作坊</p>

dql2016 发表于 2021-6-7 19:13

<p>好厉害</p>

7905 发表于 2021-6-7 20:21

楼主技术棒棒哒,富含幽默感,“楼主最喜欢了”,“淋漓”

lightxixi 发表于 2021-6-9 15:41

<p>楼主霸气~</p>

w494143467 发表于 2021-6-9 16:47

<p>一看就是经常搞DIY的博主!</p>

freebsder 发表于 2021-6-9 17:44

<p>你那两个丝印图标是哪个汉子帮你画的?</p>

ljj3166 发表于 2021-6-9 22:40

freebsder 发表于 2021-6-9 17:44
你那两个丝印图标是哪个汉子帮你画的?

<p>麻花疼大儿子截的,巨硬mspaint小妾画的</p>

freebsder 发表于 2021-6-11 17:42

ljj3166 发表于 2021-6-9 22:40
麻花疼大儿子截的,巨硬mspaint小妾画的

<p>丑</p>

freebsder 发表于 2021-6-11 17:45

ljj3166 发表于 2021-6-9 22:40
麻花疼大儿子截的,巨硬mspaint小妾画的

<p>我换了个键盘,啪啪啪的特爽,因此我决定多打几个字:</p>

<p>丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑丑</p>

ljj3166 发表于 2021-6-11 18:20

freebsder 发表于 2021-6-11 17:42


<p>@eric_wang报告班长,有人说论坛logo丑</p>

<p>统统拉进黑名单</p>
页: [1]
查看完整版本: 【短时天气预报系统】outdoor装置基本设计与实现