【泰坦触觉 TITAN Core开发套件】定时闹钟功能的实现
<div class='showpostmsg'> 本帖最后由 jinglixixi 于 2025-1-17 15:53 编辑<p>在不清楚开发板硬件设计的情况下,要实现定时闹钟功能的稳妥办法是用外部的开发板进行控制处理,将泰坦触觉开发套件作为振动器件来使用,两种的中间桥梁则为 串口通讯。</p>
<p>这里作为外部控制的是ETEB-6001DPX-V1开发板,它负责RTC计时及显示驱动等功能,显示器件为串行数码管。</p>
<p>数码管与开发板的连接关系为:</p>
<p>CLK----P2.2</p>
<p>DIN----P2.3</p>
<p>CS ----P2.4</p>
<p>输出高低电平的语句定义为:</p>
<p>#define CLK_SetLow GPIO_WritePin(GPIO2, GPIO_PIN_02, RESET)</p>
<p>#define CLK_SetHigh GPIO_WritePin(GPIO2, GPIO_PIN_02, SET)</p>
<p> </p>
<p>#define DIN_SetLow GPIO_WritePin(GPIO2, GPIO_PIN_03, RESET)</p>
<p>#define DIN_SetHigh GPIO_WritePin(GPIO2, GPIO_PIN_03, SET)</p>
<p> </p>
<p>#define CS_SetLow GPIO_WritePin(GPIO2, GPIO_PIN_04, RESET)</p>
<p>#define CS_SetHigh GPIO_WritePin(GPIO2, GPIO_PIN_04, SET)</p>
<p> </p>
<p>为进行串口通讯,使用串口为 UART0,其使用的引脚如图1所示。</p>
<p> </p>
<p>图1 串口使用引脚</p>
<p> </p>
<p>UART0的初识化函数为:</p>
<pre>
<code class="language-cpp">static void UART0_printf_init(void)
{
UART_InitTypeDef init;
init.baudRate = 115200;
init.wordLength = UART_WORDLENGTH_8B;
init.stopBits = UART_STOPBITS_1;
init.parity = UART_PARITY_NONE;
init.mode = UART_MODE_NORMAL;
init.DMAMode = UART_DMA_MULTI_MODE;
init.irqEnableFlag = UART_IT_NONE;
init.hwFlowCtl = UART_HWFLOW_DISABLE;
init.TXFIFOThreshold= UART_TXFIFO_THRESHOLD_0BYTES;
init.RXFIFOThreshold= UART_RXFIFO_THRESHOLD_1BYTES;
UART_Init(UART0, &init);
}
</code></pre>
<p> </p>
<p>使用的RTC初始化函数为:</p>
<pre>
<code class="language-cpp">static void RTC_Calendar_init(void)
{
RTC_InitTypeDef init;
rtcDatetime time;
/* set default RTC parameter */
RTC_StructInit(&init);
/* init RTC peripheral */
RTC_Init(&init);
/* set start calendar time */
time.year = 2025;
time.month =1;
time.day = 16;
time.hour = 7;
time.minute = 4;
time.second = 50;
if(RTC_SetDatetime(&time) != DRV_OK)
{
while(1);
}
/* start count */
RTC_Enable();
}
</code></pre>
<p> </p>
<p>以触觉马达振动实现电子闹钟功能的主程序为:</p>
<pre>
<code class="language-cpp">int main(void)
{
rtcDatetime calendar;
uint8_t tick = 0;
RTC_Calendar_init();
UART0_printf_init();
EVB_LEDInit();
Init_MAX7219();
Write_Max7219(1,1);
Write_Max7219(2,0);
Write_Max7219(3,10);
Write_Max7219(4,0);
Write_Max7219(5,0);
Write_Max7219(6,10);
Write_Max7219(7,0);
Write_Max7219(8,0);
while (1)
{
/* get current date time */
RTC_GetDatetime(&calendar);
if(tick != calendar.second)
{
tick = calendar.second;
Write_Max7219(1,calendar.second%10);
Write_Max7219(2,calendar.second/10);
Write_Max7219(4,calendar.minute%10);
Write_Max7219(5,calendar.minute/10);
Write_Max7219(7,calendar.hour%10);
Write_Max7219(8,calendar.hour/10);
if((calendar.hour==7)&&(calendar.minute==5)&&(calendar.second==0))
{
printf("vibrate 150 0.5 1000 0.5 0.5;");
printf("\nCurrent time is %02d:%02d:%02d\n",calendar.hour, calendar.minute, calendar.second);
}
}
}
}
</code></pre>
<p> </p>
<p>整体的电路连接如图2所示,经程序的编译与调试运行,串口的输出信息如图3所示,即在得到设置时间时,会发出控制触觉马达的振动指令。</p>
<p> </p>
<p>图2 电路连接</p>
<p> </p>
<p> </p>
<p>图3 输出信息</p>
<p> </p>
<p>演示视频:</p>
<p>6b49a9879853429abe7525f2c073adc9<br />
</p>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>在得到设置时间时,可以控制触觉马达的振动指令,实现了</p>
<p>后面争取换个小板子来实现,那才更匹配。</p>
<p>的确是这样</p>
<p>触感马达肯定是要接触的,这样最好可以弄个小电池,然后加上低功耗控制芯片 </p>
秦天qintian0303 发表于 2025-1-21 09:57
触感马达肯定是要接触的,这样最好可以弄个小电池,然后加上低功耗控制芯片
<p>没错,要手镯类的东西,必须配小电池。其实还有另一种方案,就是将控制小型化置入触感马达内部,因为其内部是开心的。再有就是触感马达进一步小型化,甚至在其表面附加一层太阳能电池以补充能耗。</p>
页:
[1]