Flipping image on 7 segment

Hi guys. I need some help coding a 7 segment display to invert its image in only baremetal. And also the dot segment on the display should be blinking at all times. I would really appreciate any help I can get. Below you'll find part of the code that I have already written to display the numbers and letters in a normal way.

#define SEGA  B00000001  // Letter a of segment 
#define SEGB  B00000010  // Letter b of segment 
#define SEGC  B00000100  // Letter c of segment 
#define SEGD  B00001000  // Letter d of segment 
#define SEGE  B00010000  // Letter e of segment 
#define SEGF  B00100000  // Letter f of segment 
#define SEGG  B01000000  // Letter g of segment 
#define SEGDP B10000000  // Letter dp of segment 
#define SEGOFF B00000000  // Letter dp of segment 

// define images for the 7Seg display
#define LED_OFF (SEGOFF)  // /* bitmap for the image 
#define LED_ZERO (SEGA|SEGB|SEGC|SEGD|SEGE|SEGF) // bitmap for the image
#define LED_ONE (SEGB|SEGC) // bitmap for the image
#define LED_TWO (SEGA|SEGB|SEGD|SEGE|SEGG)  //bitmap for the image 
#define LED_THREE (SEGA|SEGB|SEGC|SEGD|SEGG) //bitmap for the image
#define LED_FOUR (SEGF|SEGG|SEGB|SEGC) 
#define LED_FIVE (SEGA|SEGF|SEGG|SEGC|SEGD)
#define LED_SIX (SEGA|SEGF|SEGE|SEGD|SEGC|SEGG)
#define LED_SEVEN (SEGB|SEGC|SEGA)
#define LED_EIGHT (SEGA|SEGB|SEGC|SEGD|SEGE|SEGF|SEGG)
#define LED_NINE (SEGA|SEGB|SEGC|SEGD|SEGF|SEGG)
#define LED_A (SEGA|SEGB|SEGC|SEGE|SEGF|SEGG)
#define LED_b (SEGF|SEGE|SEGD|SEGC|SEGG)
#define LED_C (SEGA|SEGF|SEGE|SEGD)
#define LED_d (SEGB|SEGC|SEGD|SEGE|SEGG)
#define LED_E (SEGA|SEGF|SEGE|SEGD|SEGG)
#define LED_F (SEGA|SEGF|S

When is the assignment due? I ask because the "bare metal" requirement is usually an academic exercise.

its due on the 6th of January. I have done the whole code now but I'm just stuck on this final part

I have done the whole code now

Please post the entire sketch, according to the forum guidelines available in the sticky threads at the top of the forum.

Also, I assume that there was some course content relating to the "bare metal" side of things. Are there no resources that you can use from that? Previous assignments, for example?

Can't you just define them inverted? For example,

#define LED_ONE (SEGE|SEGF) // bitmap for the image

instead of

#define LED_ONE (SEGB|SEGC) // bitmap for the image

?

And how are you doing that bare metal decimal point blinking?

a7

Is this for course ENGD2103 by any chance?

Yes how did you know

LOL, another class member posted here this week. Also I love detective work. :)

aarg: Please post the entire sketch, according to the forum guidelines available in the sticky threads at the top of the forum.

Also, I assume that there was some course content relating to the "bare metal" side of things. Are there no resources that you can use from that? Previous assignments, for example?

Can't you just define them inverted? For example,

#define LED_ONE (SEGE|SEGF) // bitmap for the image

instead of

#define LED_ONE (SEGB|SEGC) // bitmap for the image

?

I can do it that way but I think there's a much simpler way to do it

aarg: LOL, another class member posted here this week. Also I love detective work. :)

really ? :grinning: Could you post the link to that post

how is "baremetal" defined? What are the restrictions and why?

I can do it that way but I think there's a much simpler way to do it

Well, if you don't want to change the digit, change the segment.

Just to let you think about the usage of #define

const byte SEGE = 0b00000010;  // former Letter b of segment

const byte SEGB = 0b00010000;  // former Letter e of segment

Slaps forehead.

It is only a single digit seven segment display? I’d do the definition of the symbols to be displayed in an array something like this:

byte fontArray [] = {
0b00111111, // digit 0 segments 
0b00000110, // digit 1 segments 
0b01011011, // digit 2 segments 
// etc
};

The idea is that, to demonstrate your program works correctly, you simply loop through the array displaying every symbol by writing the array element to the chosen port.

The contents of the array depend on how you have wired the seven segments (and decimal point) to the port pins and whether the display is common anode or common cathode. Easiest is if you use the pins of a single port.

You’ll have to use a bit mask to flash the decimal point without overwriting the currently displayed digit, something like: PORTA |= 0b10000000 ; // turn on decimal point (bit 7) PORTA &= ~0b10000000 ; // turn off decimal point (bit 7)

You’ll have to think of a replacement for timing features such as delay(), millis() etc. if you are using a bare metal approach.

You may even have to use your own main() function instead of setup() and loop(), depending on how strict the definition of bare metal is.

ok guys ill try that