tm1638

Library to support 7-segment display module with TM1638

Author Rob Hamerling, Copyright © 2014..2014, all rights reserved.
Adapted-by
Compiler 2.4q2

Description

Library for a module with TM1638 with
- serial interface
- 8  7-segment displays with dp (decimal point)
- 8  LEDs
- 8  push buttons
.
Data may be displayed anywhere in the 7-segment displays.
The position may be specified with an offset (depending on data type)
.
The tm1638 module uses 3 data wires, which have to be specified by the user.
Before including this library declare the following aliases (mandatory):
.
alias tm1638_dio            is pin_??                    -- pin for data I/O signal
alias tm1638_clk            is pin_??                    -- pin for clock signal
alias tm1638_stb            is pin_??                    -- pin for chip select signal
alias tm1638_dio_direction  is pin_??_direction
.
The pins for tm1638_clk and tm1638_stb must be configured
for digital output by the user program
.
The following constant may be specified as well (optionally):
.
const byte TM1638_WIDTH    =  ?          (number of 7-segment digits, defaults to 8)
.
Initialize the TM1638 with tm1638_init()


Notes

- Supports (= has been tested) only a module with tm1638 chip and
         8 display digits, 8 single color LEDs and 8 buttons.
         Support for modules with duo-leds or TM1640 may be added later.


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions

Private

API details

Global variables/contants

Procedures

  • tm1638_set_leds(byte in leds)

    Title:   Set all LEDs
    Input:   Byte with bit pattern: 0 = off, 1 = on,
    Leftmost led (LED1) is controlled by the least significant bit.
    Returns: nothing
    
    

  • tm1638_display_clear()

    Title:  Clear all display digits (inclusive decimal point)
    Input:  None
    
    

  • tm1638_init()

    Title:   Initialize TM1638 module
    Notes:   - The TM1638 module will be kept in fixed address mode,
    only during init auto-increase mode is used (temporary).
    
    

  • tm1638_display_byte_bin(byte in number)

    Title: Display binary number (byte, 8 bits)
    Input:  - byte with value to be displayed
    
    

Private

Functions

  • tm1638_get_buttons() return byte

    Title:   Get button positions
    Returns: Byte with bit pattern of buttons (0 = off, 1 = on)
    Leftmost button (S1) is represented by the least significant bit.
    
    

Private
  • _tm1638_read_byte() return byte

    Title:    Receive a byte from TM1638
    Returns:  Byte
    Notes:    - STB should have been (re)set according to requirements of caller
     DIO should be configured for input (and be pulled up?)
    
    



Related samples

Here are the list of samples which use this library:

12f157212f1572_tm1638.jal
12f68312f683_tm1638.jal
16f648a16f648a_tm1638.jal
16f72316f723_tm1638.jal
16f7316f73_tm1638.jal
16f87716f877_tm1638.jal
16f877a16f877a_tm1638.jal
16f8816f88_tm1638.jal
18f245018f2450_tm1638.jal
18f252018f2520_tm1638.jal
18f255018f2550_tm1638.jal
18f262018f2620_tm1638.jal
18f45218f452_tm1638.jal
18f455018f4550_tm1638.jal
18f462018f4620_tm1638.jal
18f67j5018f67j50_tm1638.jal