an AVR 7 segment library

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

if someone is interested, i've released an atmega seven segment library.
It runs both on common anode, and common cathode display.
You can find it here:

http://davidegironi.blogspot.it/...

i've used a lookup table to write ascii char to display.
this is the table:

//lookup table ascii char to 7 segment
#define SEGN 0xFF
#define SEGU 0xF7 //unknown way of display this character
static const uint8_t PROGMEM sevsegascii_table[] = {
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	SEGN, SEGN, SEGN, SEGN,
	0xc0, 0xf9, 0xa4, 0xb0, // 0 1 2 3
	0x99, 0x92, 0x82, 0xf8, // 4 5 6 7
	0x80, 0x90, SEGN, SEGN, // 8 9
	SEGN, SEGN, SEGN, SEGN,
	SEGN, 0x88, 0x83, 0xc6, //   A B C
	0xa1, 0x86, 0x8e, 0xc2, // D E F G
	0x8b, 0xcf, 0xe1, SEGU, // H I J _
	0xc7, 0xc8, 0xab, 0xc0, // L M N O
	0x8c, 0x98, 0xaf, 0x92, // P Q R S
	0x87, 0xc1, 0xe3, SEGU, // T U V _
	SEGU, 0x91, 0xa4, SEGN, // _ Y Z
	SEGN, SEGN, SEGN, SEGN,
	SEGN, 0x88, 0x83, 0xc6, //   A B C
	0xa1, 0x86, 0x8e, 0xc2, // D E F G
	0x8b, 0xcf, 0xe1, SEGU, // H I J _
	0xc7, 0xc8, 0xab, 0xc0, // L M N O
	0x8c, 0x98, 0xaf, 0x92, // P Q R S
	0x87, 0xc1, 0xe3, SEGU, // T U V _
	SEGU, 0x91, 0xa4, SEGN, // _ Y Z
	SEGN, SEGN, SEGN, SEGN
};

Attachment(s): 

Last Edited: Sun. Jul 8, 2012 - 08:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Instead of magic numbers, I'd use macros to define what bit is what segment. Makes it more universal.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

May want to post the schematic to see HOW the display needs to be wired up in order to work with your table. :wink:

Or at least which port bits go to which segment.You can see that my table is different to yours for say 0 and 1

;7 Segment look up table. Bits assignment:
;Bit 0=Seg A, Bit 1=Seg B, Bit 2=Seg C, Bit 3=Seg D
;Bit 4=Seg E, Bit 5=Seg F, Bit 6=Seg G
;Decimal point can use Bit 7 by oring Segment data
;with 80H

lk_up_tbl_7_seg:
;0,1
.db	0b00111111,0b00000110

(0x3f and 0x06) also you seem to have the digit order reversed ie 1 0 3 2??

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jayjay1974 wrote:
Instead of magic numbers, I'd use macros to define what bit is what segment. Makes it more universal.

i've searched for some macro, but i can not find one.
can you suggest me one?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just something like this:

#define SEG_A 0x01
#define SEG_B 0x02
.
.
.
static const uint8_t PROGMEM sevsegascii_table[] = { 
SEG_A | SEG_B | SEG_G.
SEG_B | SEG_G,
.
.
.
};
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@js

i've add the schematic in the first post.

as an example, take number 0
which is a,b,c,d,e,f=1 g,dot=0
portb is
dot g f e d c b a
0x 0 0 1 1 1 1 1 1 = 0x3F
my display is common anode, so is
dot g f e d c b a
0x 1 1 0 0 0 0 0 0 = 0xC0 or = 0xFF - 0x3F

if i've made some mistake please correct me,
thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jayjay1974 wrote:
Just something like this:

#define SEG_A 0x01
#define SEG_B 0x02
.
.
.
static const uint8_t PROGMEM sevsegascii_table[] = { 
SEG_A | SEG_B | SEG_G.
SEG_B | SEG_G,
.
.
.
};

my first table was like your post, but later i convert it to hex numbers, which is less readble i know :(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys,

Thank you.

Dear I am using your 7-segment library function from http://davidegironi.blogspot.it/... ... brary.html

but I have to display float values on three 7-segment display.
How to display floating values from 00.0 to 999.

for example:

00.0-00.1-00.2-----00.9-----01.0-01.1-01.2-----01.9
02.0-02.1-----02.9-03.0------09.0----09.9-10.0-10.1-10.2------20.0-----90.0----99.0---99.8-99.9-100-101-102-103-------200---500---800--900---980---999 then roll over to 00.0

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Beware - cross post above. Member imranahmed already has the subject open in this thread: https://www.avrfreaks.net/index.p...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wonder exactly how many times you intend to ask the same question? Do you think you are magically going to get new/different answers just because you ask again?

You were told before that sprintf() will convert a float to some individual digits. You then need to "post process" those a a bit to convert from ASCII to BDC (basically subtract '0' from each digit) and then also deterine where the d.p. is and light up the corresponding d.p. segment on the 7-seg. And that is it. Which bit of this are you having trouble implementing?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Excuse me, but what happens if one uses different ports for displaying a character (I wrote a python script to handle this case and generate some gcc code -untested on real HW : just looked at the generated code and showed it- : I did not look at the multiplexed case, but common anode was derived fom common cathode by inverting bits). This is not a rae case -for LCD, it often happens, too-, as PCB layouts may be made simpler by using different parts of different ports...