I2C Full Keyboard Sample (CardKb)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi, I feel somewhat guilty about calling this a sample,

but knowing that we have access to an I2C Full Keyboard may be good!

これをサンプルと言い張るのは少しずうずうしいかもしれませんが、

I2C で接続できるフルキーボードが安価に入手できるのは良い知らせかも知れません。

In the discussion of Data entry from keyboard to PSOC

I encountered M5Stack Official CardKB Mini Keyboard Unit MEGA328P GROVE I2C USB ISP Programmer for ESP32 Arduino D...

Data entry from keyboard to PSOC のスレで、I2C で接続できるミニキーボードを見つけました。

M5Stack Official CardKB Mini Keyboard Unit MEGA328P GROVE I2C USB ISP Programmer for ESP32 Arduino D...

So I ordered a couple of these and they arrived today.

スイッチサイエンスさんのウェブにあったのでポチッたところ、今日到着しました。

M5Stack用カード型キーボードユニット - スイッチサイエンス

Pins from top to bottom are

============

1 GND

2 5V

3 SDA

4 SCL

============

IMG_4142.JPG

schematic

001-schematic.JPG

pins

002-pins.JPG

main.c

====================

#include "project.h"

#include "stdio.h"

#define CARDKB_I2C_SLAVE_ADDR   0x5F

#define STR_LEN 64

char str[STR_LEN+1] ;

void print(char *str)

{

    UART_PutString(str) ;

}

void printc(char c)

{

    UART_PutChar(c) ;

}

void cls(void)

{

    print("\033c") ; /* reset */

    CyDelay(20) ;

    print("\033[2J") ; /* clear screen */

    CyDelay(20) ;

}

void splash(void)

{

    cls() ;

    print("5LP CardKb Test") ;

    snprintf(str, STR_LEN, "(%s %s)\n", __DATE__, __TIME__) ;

    print(str) ;

}

void init_hardware(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    UART_Start() ;

    splash() ;

   

    I2C_Start() ;

}

uint8_t myI2C_ReadByte(uint8_t reg_addr)

{

    uint8_t status ;

    uint8_t value = 0 ;

   

    I2C_MasterClearStatus();

    status = I2C_MasterSendStart(CARDKB_I2C_SLAVE_ADDR, I2C_WRITE_XFER_MODE) ;

   

    if (I2C_MSTR_NO_ERROR == status) {

        I2C_MasterWriteByte(reg_addr);

        status = I2C_MasterSendRestart(CARDKB_I2C_SLAVE_ADDR, I2C_READ_XFER_MODE); 

    }

   

    if (I2C_MSTR_NO_ERROR == status) {  

        value = I2C_MasterReadByte(I2C_ACK_DATA);

    }

    I2C_MasterSendStop(); 

   

    return(value) ;

}

uint8_t read_cardkb(void)

{

    uint8_t key = 0 ;

    key = myI2C_ReadByte(1) ;

    return( key ) ;

}

int main(void)

{

    uint8_t key ;

   

    init_hardware() ;

 

    for(;;)

    {

        key = read_cardkb() ;

        if (key) {

//            snprintf(str, STR_LEN, "%02X ", key) ;

//            print(str) ;

            printc(key) ;

        }

        CyDelay(10) ;

    }

}

====================

Tera Term log

000-TeraTerm-log.JPG

moto

5 Replies
eeEn_4618901
Level 4
Level 4
5 likes given First like received First like given

Hi Motoo,

Thank you for project

Best Regards.

eeEn_4618901
Level 4
Level 4
5 likes given First like received First like given

Hi Motoo;

if i want to use lcd. What should I do to make the articles I write appear on the LCD?

Best Regards.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Eemuh-san,

Nice to hear from you 😉

Have your "CardKb" arrived?

Anyway, I have seen there are LCD components in PSoC Creator

000-Display_LCD.JPG

And also there are many LCD Displays available like the one I used for PSoC 4

Maze, my first demo binary

So first of all, you need to decide what kind of output you'd like to display

and which "LCD" module you'd like to use.

Having written that, would you create a new question/discussion about LCD display and 5LP,

so that many can notice your question and will help you?

Although I will try to join, I'm sure that there are many experts about this topic (LCD and 5LP) than I.

Best Regards,

17-Mar-2020

Motoo Tanaka

0 Likes

Hi Motoo Tanaka,

CardKb came. I can use it after doing deep cleaning..:)

I want to use character LCD.

I want to write the letters I write side by side and create a word.

I changed the function as follows. On the LCD screen, 1 letter is written and the other letter is pressed. I want to write a word.

void printc(char c)

{

    UART_PutChar(c) ;

sprintf(yaz, "%c",c);

     lcd_Position(1u,0u);

    lcd_PrintString(yaz);

}

0 Likes

Hi Moto,

I opened a new discussion. I would be glad if you can look at it.

LCD keyboard CardKb

Best Regards.