Code Monkey home page Code Monkey logo

cardkb-i2ckeyboard's Introduction

This is a very basic MakeCode extension for the Grove Keyboard "CardKB" of M5Stack. It's still in the making. This extension will work for the Calliope mini as well for the BBC micro:bit.

Further information can be found here: https://docs.m5stack.com/en/unit/cardkb

Wiring:

On the Calliope mini the wiring is quite simple. Just plug the keyboard to the left A0 Grove-port.

  • It uses the I²C protocol.
  • The I²C-address of the keyboard is 0x5F (95)
  • It works with 3.3 volts, but not with 5

Example

read string

The minimal setup is to read the keyboard in the loop and directly feed it to the showString, to see the letters on the LED-matrix. You can also store values in arrays for words, or send it to the serialport. The output is a string.

basic.forever(function () {
    basic.showString(CardKB.readString())
})

read charcode This outputs the charcode as numbers. This is an example of using the charcode to create strings with the text block. Usually the Keyboard functions for reading charcode or letter should only evoked once and stored in a variable.

let charcode = 0
basic.forever(function () {
    charcode = CardKB.readCharcode()
    basic.showString(String.fromCharCode(charcode))
    if (charcode == -73) {
        basic.showIcon(IconNames.ArrowEast)
    } else if (charcode == -74) {
        basic.showIcon(IconNames.ArrowSouth)
    } else if (charcode == -75) {
        basic.showIcon(IconNames.ArrowNorth)
    } else if (charcode == -76) {
        basic.showIcon(IconNames.ArrowWest)
    }
})

Issues

  • reading the I²C Keyboard doesnt work when evoked multiple times.
  • Return nothing is not possible and didn't even worked with changing the tsconfig.json to "noImplicitReturns": false That is annyoing because the keyboard returns the whole time 0. If there is a if-statement (output != 0) to prevent that the alternating output path still needs to return a value something like "" null or 0 and can't return nothing like in Javascript return;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.