用的STM32F103,驱动程序借助单片机的做了修改,按键程序搞不太明白,所以没办法实现按键数码管+-和移位,求解答
- uint8_t Read_Key()
- {
- uint8_t i=0;
- uint8_t key1=0;
- uint16_t key2=0;
- Write_Cmd(0x42);
- Set(DIO); //this is obligatory, check the data sheet,GPIO
- for(i=0;i<4;i++)
- {
- key1=Read_Byte();
- key2|=(key1<<i);
- }
- key2>>=1;
- for(i=0;i<8;i++)
- {
- if(0x01<<i==key2)return i+1;
- }
- return 0;
- }
- /***********************************************************************************************
- *Function Name: TM1638_SendData
- *Purpose : Write data to the location specified
- *params : i ------the bit code of digtal tube,0 to 7
- str ------the string,the char which was not in tm_data will be replace with "''".
- *return : none
- ***********************************************************************************************/
- void TM1638_SendData(uint8_t i,uint8_t * str){
- int j=0,k=0;
- unsigned char chr;
- for(;i<8;i++)
- {
- k=0;
- for(j=0;j<14;j++)
- {
- if(*str==tm_dat[0][j])
- {
- chr=tm_dat[1][j];
- k=1;
- break;
- }
- }
-
- if(k==0)
- {
- chr=0x00;
- }
-
- if(*(str+1)=='.')
- {
- chr|=0x80;
- Write_Dat(i*2,chr);
- str++;
- }else
- {
- Write_Dat(i*2,chr);
- }
- str++;
- if(*str=='\0')break;
- }
- }
- 这个TM1638_SendData看不懂啊,怎么用?
复制代码
|