Code Monkey home page Code Monkey logo

rpi-tm1638's Introduction

rpi-TM1638

rpi-TM1638 is (yet another) Raspberry Pi library (driver) for (chained) TM1638 boards like the 2$ cheap ones you can buy online.

One of these TM1638 board

It can be used with the LED&KEY (see photo), but also the QYF-TM1638 and JY-LKM1638 (they only differ from the number of switches on the board or the number of leds).

These boards have onboard eight 7-segment displays, 8 LEDs and 8 switches, both controlled by the TM1638 chip. You can control several TM1638 boards, and uses several LEDs, 7-segment displays and switches with only three (Clock, Data and Enable) GPIOs of your Raspberry Pi.

This library proposes:

  • a low level support for the TM1638 chip
  • a higher level support for the LED&KEY TM1638-based board (that can be easily used for the two other boards)

Installation

Just use pip to install the library

pip install rpi-TM1638

or clone the latest version on Github

Example

Suppose you have two TM1638 boards, that share DataIO on GPIO19 and the clock on GPIO13. They have their STB plugged on GPIO 6 and 26. The following program turns on the LEDs #0 (3rd left of the 1st board) and #9 (2nd left of the 2nd board). It displays 12345678 on the first 7-segment display, and 2.3 on the 2nd one. It captures the #2 switch (3rd of the 1st board)

DIO = 19
CLK = 13
STB = 06, 26

TM = TMBoards(DIO, CLK, STB, 0)

TM.leds[3] = True
TM.leds[9] = True

TM.segments[0] = '12345678'
TM.segments[10] = '2.3'

a = TM.switches[2]

Details

The rpi-TM1638 proposes a two-level API:

  • The class TM1638s proposes low-level functions to manipulate the TM chips:
    • turnOn(brightness), turnOff and clearDisplay to turn on/off the displays, clear the displays or set the brightness
    • sendCommand and sendData to talk with the TM chip
    • plus some intern functions (to change the data mode, etc.)
  • The class TMboards (that inherits from TM1638s) proposes somes methods to manipulate the LEDs, 7-segment displays and switches, with some getter/setter on the properties:
    • leds: for the leds
    • segments: for the 7-segment displays
    • switches: for the switches

To use the package, you just need to create a TMboards object or create a class that inherits from TMboards and proposes some high-level properties on top of it.

Two TMboards chained. It works!

rpi-tm1638's People

Contributors

thilaire avatar

Watchers

 avatar

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.