Skip to content

Commit

Permalink
Version 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinlyonsrepo committed Dec 30, 2023
1 parent 51afd57 commit 800e5fb
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 39 deletions.
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
# URL: https://github.com/gavinlyonsrepo/TM1638plus_RPI
# Library is installed to /usr/lib and include files are placed at /usr/include.
# Uninstall and clean options provided
# Options
# 1. make = install library
# 2. clean = deletes .o files generated by step 1 from build directory
# 3. make uninstall = uninstalls library

# == Options ==
# 1. make = compile library
# 2. make install = install library to filesystem may need sudo)
# 3. clean = deletes .o files generated by step 1 from build directory
# 4. make uninstall = uninstalls library (may need sudo)
# =============

# Where you want it installed
PREFIX=/usr
Expand All @@ -24,12 +27,11 @@ SRCS = $(wildcard $(SRC)/*.cpp)
OBJS = $(patsubst $(SRC)%.cpp, $(OBJ)/%.o, $(SRCS))

CXX=g++
CCFLAGS= -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Iinclude/
CCFLAGS= -march=native -mtune=native -mcpu=native -Iinclude/
LDFLAGS= -lbcm2835

# make all
# reinstall the library after each recompilation
all: pre-build TM1638plus_RPI install
all: clean pre-build TM1638plus_RPI

pre-build:
@echo
Expand Down
43 changes: 18 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
* [Software](#software)
* [Hardware](#hardware)
* [Notes and Issues](#notes-and-issues)
* [Compilation problems](#compilation-problems)
* [Comms delay](#comms-delay)


## Overview
Expand All @@ -25,11 +23,12 @@
A Raspberry pi library to display data on a 8-digit TM1638 seven segment module.
Dynamic install-able system level Raspberry Pi C++ library.

* Development Tool Chain
1. Raspberry PI 3 model b,
2. C++ , complier g++ (Raspbian 8.3.0-6+rpi1) 8.3.0
3. Raspbian 10 buster OS , armv7l Linux 5.10.103-v7+, 32 bit
4. bcm2835 Library 1.68 (Dependency: used for GPIO control and delays)
* Development Tool chain.
1. Raspberry PI 3 model b
2. C++, g++ (Debian 12.2.0)
3. Raspbian , Debian 12 bookworm OS, , 64 bit.
4. kernel : aarch64 Linux 6.1.0-rpi7-rpi-v8
5. bcm2835 Library 1.73 dependency. Provides low level I2C bus, delays and GPIO control.


## Installation
Expand All @@ -43,15 +42,16 @@ Dynamic install-able system level Raspberry Pi C++ library.
* Run following command to download from github.

```sh
curl -sL https://github.com/gavinlyonsrepo/TM1638plus_RPI/archive/2.0.tar.gz | tar xz
curl -sL https://github.com/gavinlyonsrepo/TM1638plus_RPI/archive/2.1.tar.gz | tar xz
```

4. Run "make" to run the makefile in base folder to install library, it will be
3. Run "make" to run the makefile in base folder to install library, it will be
installed to usr/lib and usr/include

```sh
cd TM1638plus_RPI-2.0
sudo make
cd TM1638plus_RPI-2.1
make
sudo make install
```

## Test
Expand All @@ -78,8 +78,6 @@ Comment out the rest.
Next enter the examples folder and run the makefile in THAT folder,
This makefile builds the examples file using the just installed library.
and creates a test exe file in "bin".
Make run will use "sudo" as the bcm2835
requires root permissions by default [ see here for more details on that](http://www.airspayce.com/mikem/bcm2835/)

```sh
cd examples/
Expand All @@ -101,6 +99,13 @@ This library is a port of my Arduino Library. There at link below you will find

[ Arduino library github Link ](https://github.com/gavinlyonsrepo/TM1638plus)

### Comms delay

Communications optional delay.
It may be necessary to adjust the constant TMCommDelay in the TM1638plus_common.h file. It is Microsecond delay used in communications clocking, it is currently set to 1,
It can be set to 0 or higher. On a different CPU Frequency to one tested, it may be necessary to increase/decrease this.
The user can do this with the Getter method provided. TMCommDelayGet.

## Hardware

Connections to RPI:
Expand Down Expand Up @@ -128,16 +133,4 @@ Pictured at from left to right.

## Notes and Issues

### Compilation problems

Note the tool chain used in overview section, If you have trouble compiling on other
platforms or OS. For example 64-bit OS, user may need to remove or edit
some of the CCFLAGS in root directory Makefile to allow for Compilation, if you see them throwing errors
See [pull request on SSD1306 project](https://github.com/gavinlyonsrepo/SSD1306_OLED_RPI/pull/2) for details.
Will upgrade in future release.

### Comms delay

Communications optional delay.
It may be necessary to adjust the constant _TM_CommDelay in the TM1638plus_common.h file. It is Microsecond delay used in communications clocking, it is currently set to 1,
It can be set to 0 or higher. On a different CPU Frequency to one tested, it may be necessary to increase/decrease this.
12 changes: 9 additions & 3 deletions examples/src/HELLOWORLD_Model1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@
// Constructor object (GPIO STB , GPIO CLOCK , GPIO DIO, )
TM1638plus_Model1 tm(STROBE_TM, CLOCK_TM , DIO_TM);


int main(int argc, char **argv)
{
printf("Test Begin :: Model 1 :: TM1638plus_RPI\r\n");
if(!bcm2835_init()) {return -1;}

printf("TM1638plus_RPI library version number :: %u\r\n", tm.libraryVersionNumberGet());
if(!bcm2835_init())
{
printf("bcm2835 library failed to init, Run as root\r\n");
return -1;
}else
{
printf("bcm2835 library Version Number :%u\r\n", bcm2835_version());
}
tm.displayBegin();
tm.displayText("helowrld");
bcm2835_delay(5000);
Expand Down
10 changes: 9 additions & 1 deletion examples/src/HELLOWORLD_Model2/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ TM1638plus_Model2 tm(STROBE_TM, CLOCK_TM , DIO_TM, swap_nibbles);
int main(int argc, char **argv)
{
printf("Test Begin :: Model 2 :: TM1638plus_RPI\r\n");
if(!bcm2835_init()) {return -1;}
printf("TM1638plus_RPI library version number :: %u\r\n", tm.libraryVersionNumberGet());
if(!bcm2835_init())
{
printf("bcm2835 library failed to init, Run as root\r\n");
return -1;
}else
{
printf("bcm2835 library Version Number :%u\r\n", bcm2835_version());
}

tm.displayBegin();
tm.DisplayStr("helowrld", 0); // Display "helowrld" in 7 segments with 0 decimal points set.
Expand Down
10 changes: 9 additions & 1 deletion examples/src/HELLOWORLD_Model3/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ TM1638plus_Model3 tm(STROBE_TM, CLOCK_TM , DIO_TM);
int main(int argc, char **argv)
{
printf("Test Begin\r\n");
if(!bcm2835_init()) {return -1;}
printf("TM1638plus_RPI library version number :: %u\r\n", tm.libraryVersionNumberGet());
if(!bcm2835_init())
{
printf("bcm2835 library failed to init, Run as root\r\n");
return -1;
}else
{
printf("bcm2835 library Version Number :%u\r\n", bcm2835_version());
}

tm.displayBegin();
tm.displayText("helowrld");
Expand Down
10 changes: 10 additions & 0 deletions extra/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@
* Optimizations + refactoring
* Updated to match original Arduino port, v 2.0.0
* Added "Doxygen" style comments to allow "Doxygen" software to generate an HTML API.

* version 2.0.0 April 2023
* Optimizations + refactoring
* Updated to match original Arduino port, v 2.0.0
* Added "Doxygen" style comments to allow "Doxygen" software to generate an HTML API.

* version 2.1.0 Dec 2023
* Minor Update.
* Changed Makefile so the Library will compile on 64 bit systems without error
* Added Getter and Setters methods fro TMCommDelay
8 changes: 6 additions & 2 deletions include/TM1638plus_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ class TM1638plus_common{
TM1638plus_common(uint8_t strobe, uint8_t clock, uint8_t data);

void reset(void);
void displayBegin();
void displayBegin(void);
void brightness(uint8_t brightness);
uint16_t libraryVersionNumberGet(void);
uint16_t TMCommDelayGet(void);
void TMCommDelayset(uint16_t);

protected:
void sendCommand(uint8_t value);
Expand All @@ -72,7 +75,8 @@ class TM1638plus_common{
const unsigned char * pFontSevenSegptr = SevenSeg; /**< Pointer to the seven segment font data table */

private:
const uint16_t _TMCommDelay = 1; /**< uS delay used in communications , User adjust */
const uint16_t _TMLibVerNum = 210; /**< Library version number 210 = 2.1.0*/
uint16_t _TMCommDelay = 1; /**< uS delay used in communications , User adjust */
const uint8_t _TMDefaultBrightness = 0x02; /**< can be 0x00 to 0x07 , User adjust */

/*! font , map of ASCII values/table to 7-segment, offset to position 32. */
Expand Down
18 changes: 18 additions & 0 deletions src/TM1638plus_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,21 @@ void TM1638plus_common::HighFreqshiftOut(uint8_t dataPin, uint8_t clockPin, uint
}
}

/*!
@brief get the library number
@return The library number 210 = 2.1.0
*/
uint16_t TM1638plus_common::libraryVersionNumberGet(void) {return _TMLibVerNum;}

/*!
@brief get the TM comm delay.
@return The TM comm delay in uS
*/
uint16_t TM1638plus_common::TMCommDelayGet(void){return _TMCommDelay;}

/*!
@brief set the TM comm delay.
@param CommDelay The TM comm delay in uS
*/
void TM1638plus_common::TMCommDelayset(uint16_t CommDelay) {_TMCommDelay = CommDelay;}

0 comments on commit 800e5fb

Please sign in to comment.