TM1637 is great for where there is a need for buttons & LED display & fewer pins on the micro.
I needed to read buttons & display more than 1 value, display long strings, flash some digits etc.
It was not feasible to build upon the existing lib(s) as I needed a more modular code structure.
The library is targeted to OEM display boards(ones we make), OTS 4d & 6d hobby modules are supported.
There are 3 sections to the library, 1. Command lib, 2. Message processor, 3. Hardware driver. Initially it was one big file but separate .h files made it more manageable.
Commands are easy to use & many parameters are default set.
Most settings & config. are also default value, only need to re-set if required to enable flexible/advanced use. Making it easy to get started or for basic use..
As the TM1637 digit registers are write only, there is a display buffer to set & manipulate, then send to disp.
Tested with PIC12F683 all commands & some combined ok. I could display a scrolling string with length up to the compiler length error The demo runs on a PIC16F1829.
This version is alpha & for Test/Comment/Review. There may be remnants of testing still in the code.
If someone has a TM1637 module it would be great to test some other (mega2560 etc...)
Features...
• Display size from 1 to 6 digits.
• Values can display as decimal 0 - 999999 or Hex 0 - FFFFFF (0d16777215).
• Value can be displayed at any digit position.
• More than 1 value can be displayed simultaneously.(eg. 3 hex bytes dot separated)
• Read key buttons.
• Option for digit remap to correct swapped com pins of 6d hobby disp modules.
• Option to remap button number per datasheet (weird sequence).
• Uses a buffer to reflect TM digit registers.
• Additional user buffers enabled.
• Zero blanking on/off (can control number of leading zeros).
• Direct writing a byte to display digit.(bypass buffer)
• Display text with scrolling for long strings.
• Scroll array of raw digit values.
• Flash display, digits or segment.
• Linear bar-graph up to 16 LED's (with fill/no-fill)
• Use sequential or fixed register addressing mode.
• Fixed 2 existing issues in existing libs with ACK (1. both devices driving DIO pin for half clock & 2. NACK disable latched).
I made an ACP file (append it to existing greatcowbasic.acp) that I found useful when I had memory leaks.
There is a vid here: https://youtu.be/Ng-FH4Exrts
It is final from me at this point, review this version.
I am interested if someone can try it & feedback if somethings not working right or "a better way to do this".
I had a bit of luck with the ACK code. I wondered how I was going to test for NACK when later I started to get display anomalies after changing chips & compiler version, thinking that was my issue, then I looked with the scope & saw the problem, I left the logic analyzer connected but it wasn't powered! (PIC has more drive pin current on DIO & TM couldn't assert the ACK properly.)
Anyway this helped test the NACK recovery.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is a report of your constants(symbols). This may give you some insights. The numbers on the right are the file handle numbers that added the symbol.
The attempted reDEFINE is nice, but, not formatted correctly. I see that.
Showing reDEFINE is very useful to know where and what it is being set to.
?F2L84S0I84? - the internal tracker of each line of code. Sometimes you see this in the ASM when the compiler has failed to convert to pseudo code and/or ASM.
F2 File number 2 - at some point we could change to the filename
L84 Line number in the file
S0 - Method number. An index that increments every time the compiler finds a method.
I84 - Line number in the all of the source files.
Sub call depth... not when this report is executed. We would have to report from the Assembler. At that point the optimisation would have happened with the replacement of CALLs with BRAnches etc. So, you could potentially write an analyser to walk the ASM to calc the stack usage.
Last edit: Anobium 2022-08-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I started with the TM1638, I wanted to see scrolling text on 10 LED digits, & display 40bit hex,
but had a 5m flood & another La Nina summer coming... I'm still getting the water out of the tractor hydraulics.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
TM1638.
I ported? the TM1637_OEM_lib to TM1638, was simpler than I assumed
1. Change all Start/Stop to Strobe line Low/Hi.
2. Delete ACK code.
3. Digit address set to even registers. (digit-1)*2
4. a few tweaks & limitations.
That was the easy part, but I could not get it working properly, data message looked good but display was garbled, on/off & bright were working ok.
I made a test program to fill successive 16 registers with bytes & bits with 400ms waits to observe, it looks like the TM1638 board I have is wired stupid.
Each bit of register 0 sets segment "a" of each digit, register 2 sets segment "b" of each digit etc. , successive even address are segments not digits. (odd address registers are not connected) https://youtu.be/FOhTs2_JT_A
The datasheet show it is possible to reverse the Segment_Digit Common to accommodate CC or CA displays but I'm sure it requires a remap subroutine to encode the data <--> address for this. I would rather de-solder & rewire the display for test at this moment. Ordered some different boards so a few weeks...
My board is the one with no discrete LED's "QYF-TM1638"
For reference I tried mmotte's tm1638.h & it is same garble.
No, this is a different device TM1638 lib, submitted the TM1637 lib for review ,
I just updated as you mentioned...
I just tried the TM1638 code. Too many issues to resolve. I will look another time
I assumed you tried to re-code my lib for TM1638 (I should have asked for clarification)
I will start a new discussion topic "TM1638_OEM_ Lib" when I get new info.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Apologies, I was supposed to updated this post a while ago...
Attached zip with latest files for reference. (the latest GCB release will include these)
TM1637 is great for where there is a need for buttons & LED display & fewer pins on the micro.
I needed to read buttons & display more than 1 value, display long strings, flash some digits etc.
It was not feasible to build upon the existing lib(s) as I needed a more modular code structure.
The library is targeted to OEM display boards(ones we make), OTS 4d & 6d hobby modules are supported.
There are 3 sections to the library, 1. Command lib, 2. Message processor, 3. Hardware driver. Initially it was one big file but separate .h files made it more manageable.
Commands are easy to use & many parameters are default set.
Most settings & config. are also default value, only need to re-set if required to enable flexible/advanced use. Making it easy to get started or for basic use..
As the TM1637 digit registers are write only, there is a display buffer to set & manipulate, then send to disp.
Tested with PIC12F683 all commands & some combined ok. I could display a scrolling string with length up to the compiler length error The demo runs on a PIC16F1829.
This version is alpha & for Test/Comment/Review. There may be remnants of testing still in the code.
If someone has a TM1637 module it would be great to test some other (mega2560 etc...)
Features...
• Display size from 1 to 6 digits.
• Values can display as decimal 0 - 999999 or Hex 0 - FFFFFF (0d16777215).
• Value can be displayed at any digit position.
• More than 1 value can be displayed simultaneously.(eg. 3 hex bytes dot separated)
• Read key buttons.
• Option for digit remap to correct swapped com pins of 6d hobby disp modules.
• Option to remap button number per datasheet (weird sequence).
• Uses a buffer to reflect TM digit registers.
• Additional user buffers enabled.
• Zero blanking on/off (can control number of leading zeros).
• Direct writing a byte to display digit.(bypass buffer)
• Display text with scrolling for long strings.
• Scroll array of raw digit values.
• Flash display, digits or segment.
• Linear bar-graph up to 16 LED's (with fill/no-fill)
• Use sequential or fixed register addressing mode.
• Fixed 2 existing issues in existing libs with ACK (1. both devices driving DIO pin for half clock & 2. NACK disable latched).
I made an ACP file (append it to existing greatcowbasic.acp) that I found useful when I had memory leaks.
There is a vid here: https://youtu.be/Ng-FH4Exrts
Will have a help doc soon...
Very nice video.
The functionality looks to be very good.
Do you want me to wait, until a later version, for a code review?
It is final from me at this point, review this version.
I am interested if someone can try it & feedback if somethings not working right or "a better way to do this".
I had a bit of luck with the ACK code. I wondered how I was going to test for NACK when later I started to get display anomalies after changing chips & compiler version, thinking that was my issue, then I looked with the scope & saw the problem, I left the logic analyzer connected but it wasn't powered! (PIC has more drive pin current on DIO & TM couldn't assert the ACK properly.)
Anyway this helped test the NACK recovery.
Code looks good.
Here is a report of your constants(symbols). This may give you some insights. The numbers on the right are the file handle numbers that added the symbol.
You can also get this report of Conditional Statements. This also may confirm your thinking.
This is line number in your source, the statement and comments. The #ENDIF is not shown,.
This debug capability is in the new release of the compiler. All intended to assist developers.
Its nice that the re-define shows in the report?
Defined in include as default, & defined in program as (potentially) new value.
CODE/CurrentValues: TM_DISPLEN 6 1
4 Constant: TM_DISPLEN now '6' tobe '6' ;?F2L84S0I84?
I wonder if sub call depth could be reported in debug (just wishing)
The attempted reDEFINE is nice, but, not formatted correctly. I see that.
Showing reDEFINE is very useful to know where and what it is being set to.
?F2L84S0I84? - the internal tracker of each line of code. Sometimes you see this in the ASM when the compiler has failed to convert to pseudo code and/or ASM.
Sub call depth... not when this report is executed. We would have to report from the Assembler. At that point the optimisation would have happened with the replacement of CALLs with BRAnches etc. So, you could potentially write an analyser to walk the ASM to calc the stack usage.
Last edit: Anobium 2022-08-23
Help reference attached.
Last edit: ToniG 2022-08-23
I have a board with a TM1638 - this has the extra connection for STB.
Will this work ?
Different com protocol.
check this thread
https://sourceforge.net/p/gcbasic/discussion/629990/thread/c527906a12/
Aha... that code is good to put into a release? I did not move it out.. so, the .h is not in the release or your demo.
:-(
I started with the TM1638, I wanted to see scrolling text on 10 LED digits, & display 40bit hex,
but had a 5m flood & another La Nina summer coming... I'm still getting the water out of the tractor hydraulics.
I just tried the TM1638 code. Too many issues to resolve. I will look another time,
TM1638.
I ported? the TM1637_OEM_lib to TM1638, was simpler than I assumed
1. Change all Start/Stop to Strobe line Low/Hi.
2. Delete ACK code.
3. Digit address set to even registers. (digit-1)*2
4. a few tweaks & limitations.
That was the easy part, but I could not get it working properly, data message looked good but display was garbled, on/off & bright were working ok.
I made a test program to fill successive 16 registers with bytes & bits with 400ms waits to observe, it looks like the TM1638 board I have is wired stupid.
Each bit of register 0 sets segment "a" of each digit, register 2 sets segment "b" of each digit etc. , successive even address are segments not digits. (odd address registers are not connected)
https://youtu.be/FOhTs2_JT_A
The datasheet show it is possible to reverse the Segment_Digit Common to accommodate CC or CA displays but I'm sure it requires a remap subroutine to encode the data <--> address for this. I would rather de-solder & rewire the display for test at this moment. Ordered some different boards so a few weeks...
My board is the one with no discrete LED's "QYF-TM1638"
For reference I tried mmotte's tm1638.h & it is same garble.
Last edit: ToniG 2022-08-28
Interesting state of affairs. :-)
I should hold off testing?
No, this is a different device TM1638 lib, submitted the TM1637 lib for review ,
I just updated as you mentioned...
I assumed you tried to re-code my lib for TM1638 (I should have asked for clarification)
I will start a new discussion topic "TM1638_OEM_ Lib" when I get new info.
Yes, I tried the new TM1637 lib - no action on a TM1638 board.
I get action when using mmotte's tm1638.h
That is because the new TM1637 lib is for TM1637 & not a TM1638 board.
TM1637 lib is for TM1637 boards only.
TM1637 - 2 wire I2C like interface CLK DIO
TM1638 - 3 wire SPI like interface STB CLK DIO
Ok, Back to the TM1637 lib submitted for review.
There is a line of code missing in Sub tmSndBuf. - "
TM_lp2 = TMlp2 '< If not remap
"I noticed it when I set Var TM_6dReMap = Off (off = correctly wired displays = not 6digit hobby modules)
oh.. :-) Do you have a new complete file?
Yes, attached.
File compare should show just 1 line change.
Yes, one line. I have loaded into the next release. See https://github.com/GreatCowBASIC/Demonstration_Sources/tree/main/7_Segment_LED_Solutions/7_Segment_TM1637_OEM_Solutions
Don't think its ready for commit to release yet, #includes are still local, option explicit still active, ...
Apologies, I was supposed to updated this post a while ago...
Attached zip with latest files for reference. (the latest GCB release will include these)
@Toni
Can you inspect https://github.com/GreatCowBASIC/Demonstration_Sources/tree/main/7_Segment_LED_Solutions/7_Segment_TM1637_OEM_Solutions
Are there files here that needs to be deleted?