# tm1640

Library to support 7-segment display module with TM1640

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

Description

    Library for a module with TM1640 with
    - serial interface
    - 16  7-segment displays with dp (decimal point)
    .
    Data may be displayed anywhere in the 7-segment displays.
    The position may be specified with an offset (depending on data type)
    .
    The tm1640 module uses 2 data wires, which have to be specified by the user.
    Before including this library declare the following aliases (mandatory):
    .
    alias tm1640_din            is pin_??                    -- pin for data I/O signal
    alias tm1640_clk            is pin_??                    -- pin for clock signal
    which should be set to OUTPUT by the user program
    .
    The following constant may be specified as well (optionally):
    .
    const byte TM1640_WIDTH    =  ?          (number of 7-segment digits, defaults to 16)
    .
    Initialize the TM1640 with tm1640_init()

Notes

    - Supports (= has been tested) with a module with tm1640 chip
             and 16 7-segment display digits

Dependencies

- tm1638_font

## Summary

### Global variables/contants

- `const byte TM1640_DISPLAY_PWM1 = 0b_1000_0000`
- `const byte TM1640_DISPLAY_PWM10 = 0b_1000_0011`
- `const byte TM1640_ADDRESS_SELECT = 0b_1100_0000`
- `const byte TM1640_DISPLAY_PWM13 = 0b_1000_0110`
- `const byte TM1640_DISPLAY_ON = 0b_1000_1000`
- `const byte TM1640_DISPLAY_PWM12 = 0b_1000_0101`
- `const byte TM1640_DOT = 0b_1000_0000`
- `const byte TM1640_DISPLAY_PWM11 = 0b_1000_0100`
- `const byte TM1640_DISPLAY_PWM2 = 0b_1000_0001`
- `const byte TM1640_DISPLAY_PWM4 = 0b_1000_0010`
- `const byte TM1640_MODE_NORMAL = 0b_0100_0000`
- `const byte TM1640_WRITE_DATA = 0b_0100_0000`
- `const byte TM1640_DISPLAY_PWM14 = 0b_1000_0111`
- `const byte TM1640_ADDRESS_FIXED = 0b_0100_0100`
- `const byte TM1640_MODE_TEST = 0b_0100_1000`
- `const byte TM1640_ADDRESS_AUTO = 0b_0100_0000`
- `const byte TM1640_DISPLAY_OFF = 0b_1000_0000`

### Procedures

- `tm1640_init()`
- `tm1640_display_clear()`
- `tm1640_display_word_bin(word in number)`

Private

- `_tm1640_write_byte_raw(byte in data)`
- `_tm1640_write_command(byte in cmd)`

### Functions

## API details

### Global variables/contants

- `const byte TM1640_DISPLAY_PWM1 = 0b_1000_0000`

  No documentation found

- `const byte TM1640_DISPLAY_PWM10 = 0b_1000_0011`

  No documentation found

- `const byte TM1640_ADDRESS_SELECT = 0b_1100_0000`

      base of command byte

- `const byte TM1640_DISPLAY_PWM13 = 0b_1000_0110`

  No documentation found

- `const byte TM1640_DISPLAY_ON = 0b_1000_1000`

  No documentation found

- `const byte TM1640_DISPLAY_PWM12 = 0b_1000_0101`

  No documentation found

- `const byte TM1640_DOT = 0b_1000_0000`

      segment of decimal point

- `const byte TM1640_DISPLAY_PWM11 = 0b_1000_0100`

      PWM dutycycle for LEDs

- `const byte TM1640_DISPLAY_PWM2 = 0b_1000_0001`

  No documentation found

- `const byte TM1640_DISPLAY_PWM4 = 0b_1000_0010`

  No documentation found

- `const byte TM1640_MODE_NORMAL = 0b_0100_0000`

  No documentation found

- `const byte TM1640_WRITE_DATA = 0b_0100_0000`

  No documentation found

- `const byte TM1640_DISPLAY_PWM14 = 0b_1000_0111`

  No documentation found

- `const byte TM1640_ADDRESS_FIXED = 0b_0100_0100`

  No documentation found

- `const byte TM1640_MODE_TEST = 0b_0100_1000`

  No documentation found

- `const byte TM1640_ADDRESS_AUTO = 0b_0100_0000`

  No documentation found

- `const byte TM1640_DISPLAY_OFF = 0b_1000_0000`

  No documentation found

### Procedures

- `tm1640_init()`

      Title:  Initialize TM1640 module
      Notes:

- `tm1640_display_clear()`

      Title:  Clear all display digits (inclusive decimal point)
      Input:  (none)
      Notes:  - Set display into normal mode (disable test mode)
      and set display into fixed address mode at return.

- `tm1640_display_word_bin(word in number)`

      Title: Display binary number (word, 16 bits)
      Input: word with value to be displayed

Private

- `_tm1640_write_byte_raw(byte in data)`

      Title:  Send byte 'raw' to the TM1640 (8 bits bit-banging)
      Input:  byte to be transferred
      Notes:  - tm1640_din should have been reset before calling this procedure
       must be followed by 1 clock cycle after last byte of an operation
       data handling and loop logic ensure that timing constraints
      are not exceeded (tested with 32 MHz oscillator frequency)

- `_tm1640_write_command(byte in cmd)`

      Title:  Send a command (single byte) to the TM1640
      Input:  - Byte with command

### Functions

## Related samples

Here are the list of samples which use this library:

12f1572 | 12f1572_tm1640.jal
12f683 | 12f683_tm1640.jal
16f648a | 16f648a_tm1640.jal
16f723 | 16f723_tm1640.jal
16f73 | 16f73_tm1640.jal
16f877 | 16f877_tm1640.jal
16f877a | 16f877a_tm1640.jal
16f88 | 16f88_tm1640.jal
18f2450 | 18f2450_tm1640.jal
18f2520 | 18f2520_tm1640.jal
18f2550 | 18f2550_tm1640.jal
18f2620 | 18f2620_tm1640.jal
18f452 | 18f452_tm1640.jal
18f4550 | 18f4550_tm1640.jal
18f4620 | 18f4620_tm1640.jal
18f67j50 | 18f67j50_tm1640.jal